GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Pull Request — master (#170)
by Victor Hugo
01:29
created

mollie.*PaymentLinksService.Create   A

Complexity

Conditions 3

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 7
dl 0
loc 11
ccs 6
cts 6
cp 1
crap 3
rs 10
c 0
b 0
f 0
nop 3
1
package mollie
2
3
import (
4
	"context"
5
	"encoding/json"
6
	"fmt"
7
	"time"
8
)
9
10
// PaymentLink is a resource that can be shared with your customers
11
// and will redirect them to them the payment page where they can
12
// complete the payment.
13
//
14
// See: https://docs.mollie.com/reference/v2/payment-links-api/get-payment-link
15
type PaymentLink struct {
16
	ID          string           `json:"id,omitempty"`
17
	Resource    string           `json:"resource,omitempty"`
18
	Description string           `json:"description,omitempty"`
19
	ProfileID   string           `json:"profileId,omitempty"`
20
	RedirectURL string           `json:"redirectUrl,omitempty"`
21
	WebhookURL  string           `json:"webhookUrl,omitempty"`
22
	Mode        Mode             `json:"mode,omitempty"`
23
	Amount      Amount           `json:"amount,omitempty"`
24
	CreatedAt   *time.Time       `json:"createdAt,omitempty"`
25
	PaidAt      *time.Time       `json:"paidAt,omitempty"`
26
	UpdatedAt   *time.Time       `json:"updatedAt,omitempty"`
27
	ExpiresAt   *time.Time       `json:"expiresAt,omitempty"`
28
	Links       PaymentLinkLinks `json:"_links,omitempty"`
29
}
30
31
// PaymentLinkLinks describes all the possible links returned with
32
// a payment link struct.
33
//
34
// See: https://docs.mollie.com/reference/v2/payment-links-api/get-payment-link
35
type PaymentLinkLinks struct {
36
	Self          *URL `json:"self,omitempty"`
37
	Documentation *URL `json:"documentation,omitempty"`
38
	PaymentLink   *URL `json:"paymentLink,omitempty"`
39
	Next          *URL `json:"next,omitempty"`
40
	Previous      *URL `json:"previous,omitempty"`
41
}
42
43
// PaymentLinkOptions represents query string parameters to modify
44
// the payment links requests.
45
type PaymentLinkOptions struct {
46
	ProfileID string `url:"profileId,omitempty"`
47
	From      string `url:"from,omitempty"`
48
	Limit     int    `url:"limit,omitempty"`
49
}
50
51
// PaymentLinksList retrieves a list of payment links for the active
52
// profile or account token owner.
53
type PaymentLinksList struct {
54
	Count    int              `json:"count,omitempty"`
55
	Links    PaymentLinkLinks `json:"_links,omitempty"`
56
	Embedded struct {
57
		PaymentLinks []*PaymentLink `json:"payment_links,omitempty"`
58
	} `json:"_embedded,omitempty"`
59
}
60
61
// PaymentLinksService operates over the payment link resource.
62
type PaymentLinksService service
63
64
// Get retrieves a single payment link object by its id/token.
65
//
66
// See: https://docs.mollie.com/reference/v2/payment-links-api/get-payment-link
67
func (pls *PaymentLinksService) Get(ctx context.Context, id string) (res *Response, pl *PaymentLink, err error) {
68 1
	res, err = pls.client.get(ctx, fmt.Sprintf("v2/payment-links/%s", id), nil)
69 1
	if err != nil {
70 1
		return
71
	}
72
73 1
	if err = json.Unmarshal(res.content, &pl); err != nil {
74 1
		return
75
	}
76
77 1
	return
78
}
79
80
// Create generates payment links that by default, unlike regular payments, do not expire.
81
//
82
// See: https://docs.mollie.com/reference/v2/payment-links-api/create-payment-link
83
func (pls *PaymentLinksService) Create(ctx context.Context, p PaymentLink, opts *PaymentLinkOptions) (res *Response, np *PaymentLink, err error) {
84 1
	res, err = pls.client.post(ctx, "v2/payment-links", p, opts)
85 1
	if err != nil {
86 1
		return
87
	}
88
89 1
	if err = json.Unmarshal(res.content, &np); err != nil {
90 1
		return
91
	}
92
93 1
	return
94
}
95
96
// List retrieves all payments links created with the current website profile,
97
// ordered from newest to oldest.
98
//
99
// See: https://docs.mollie.com/reference/v2/payment-links-api/list-payment-links
100
func (pls *PaymentLinksService) List(ctx context.Context, opts *PaymentLinkOptions) (res *Response, pl *PaymentLinksList, err error) {
101 1
	res, err = pls.client.get(ctx, "v2/payment-links", opts)
102 1
	if err != nil {
103 1
		return
104
	}
105
106 1
	if err = json.Unmarshal(res.content, &pl); err != nil {
107 1
		return
108
	}
109
110 1
	return
111
}
112