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
Push — master ( f83009...037081 )
by Victor Hugo
01:17 queued 12s
created

mollie.*ClientLinksService.CreateClientLink   A

Complexity

Conditions 3

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 10
dl 0
loc 15
ccs 6
cts 6
cp 1
crap 3
rs 9.9
c 0
b 0
f 0
nop 2
1
package mollie
2
3
import (
4
	"context"
5
	"encoding/json"
6
	"fmt"
7
8
	"github.com/google/go-querystring/query"
9
)
10
11
// ClientLinksService interacts with the Client Links API to create
12
// new organizations for your customers.
13
type ClientLinksService service
14
15
// ClientDetails contains information to link a new organization to an
16
// OAuth application.
17
type ClientDetails struct {
18
	Owner              Owner    `json:"owner,omitempty"`
19
	Name               string   `json:"name,omitempty"`
20
	Address            *Address `json:"address,omitempty"`
21
	RegistrationNumber string   `json:"registrationNumber,omitempty"`
22
	VATNumber          string   `json:"vatNumber,omitempty"`
23
}
24
25
// ClientLinkLinks describes all the possible links to be returned with
26
// a client links response object.
27
type ClientLinkLinks struct {
28
	ClientLink    *URL `json:"clientLink,omitempty"`
29
	Documentation *URL `json:"documentation,omitempty"`
30
}
31
32
// ClientLink object with redirect target.
33
type ClientLink struct {
34
	ID       string          `json:"id,omitempty"`
35
	Resource string          `json:"resource,omitempty"`
36
	Links    ClientLinkLinks `json:"_links,omitempty"`
37
}
38
39
// CreateClientLink based on the provided ClientDetails.
40
//
41
// See: https://docs.mollie.com/reference/v2/client-links-api/create-client-link
42
func (cls *ClientLinksService) CreateClientLink(ctx context.Context, cd *ClientDetails) (
43
	res *Response,
44
	cl *ClientLink,
45
	err error,
46
) {
47 1
	res, err = cls.client.post(ctx, "v2/client-links", cd, nil)
48 1
	if err != nil {
49 1
		return
50
	}
51
52 1
	if err = json.Unmarshal(res.content, &cl); err != nil {
53 1
		return
54
	}
55
56 1
	return
57
}
58
59
// ApprovalPromptAction represents possible actions to be performed
60
// once the client link is created and redirected to the dashboard.
61
type ApprovalPromptAction string
62
63
// Possible approval prompt actions.
64
const (
65
	ForceApproval ApprovalPromptAction = "force"
66
	AutoApproval  ApprovalPromptAction = "auto"
67
)
68
69
// ClientLinkFinalizeOptions subset of the parameters allowed for the Authorize endpoint.
70
type ClientLinkFinalizeOptions struct {
71
	ClientID       string `url:"clientID,omitempty"`
72
	State          string `url:"state,omitempty"`
73
	Scope          string `url:"scope,omitempty"`
74
	ApprovalPrompt string `url:"approvalPrompt,omitempty"`
75
}
76
77
func (cls *ClientLinksService) CreateFinalizeClientLink(
78
	ctx context.Context,
79
	clientLink string,
80
	options *ClientLinkFinalizeOptions,
81
) (
82
	clientLinkURI string,
83
) {
84 1
	if options != nil {
85 1
		v, _ := query.Values(options)
86 1
		clientLinkURI = fmt.Sprintf("%s?%s", clientLink, v.Encode())
87
	}
88
89 1
	return
90
}
91