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 ( 77a83f...72de0e )
by Victor Hugo
01:00 queued 11s
created

mollie.*OnboardingService.SubmitOnboardingData   A

Complexity

Conditions 3

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 8
dl 0
loc 12
c 0
b 0
f 0
ccs 7
cts 7
cp 1
crap 3
rs 10
nop 1
1
package mollie
2
3
import (
4
	"encoding/json"
5
	"net/http"
6
	"time"
7
)
8
9
const onboardingTarget = "v2/onboarding/me"
10
11
// OnboardingStatus describes status of the organization’s onboarding process.
12
type OnboardingStatus string
13
14
// Possible status values.
15
const (
16
	NeedsDataOnboardingStatus OnboardingStatus = "needs-data"
17
	InReviewOnboardingStatus  OnboardingStatus = "in-review"
18
	CompletedOnboardingStatus OnboardingStatus = "completed"
19
)
20
21
// OnboardingService operates over the onboarding API.
22
type OnboardingService service
23
24
// OnboardingLinks contains URL objects relevant to the onboarding status.
25
type OnboardingLinks struct {
26
	Self          *URL `json:"self,omitempty"`
27
	Dashboard     *URL `json:"dashboard,omitempty"`
28
	Organization  *URL `json:"organization,omitempty"`
29
	Documentation *URL `json:"documentation,omitempty"`
30
}
31
32
// Onboarding data for an organization.
33
type Onboarding struct {
34
	Resource              string           `json:"reference,omitempty"`
35
	Name                  string           `json:"name,omitempty"`
36
	SignedUpAt            *time.Time       `json:"signedUpAt,omitempty"`
37
	Status                OnboardingStatus `json:"status,omitempty"`
38
	CanReceivePayments    bool             `json:"canReceivePayments,omitempty"`
39
	CanReveiceSettlements bool             `json:"canReceiveSettlements,omitempty"`
40
	Links                 OnboardingLinks  `json:"_links,omitempty"`
41
}
42
43
// GetOnboardingStatus gets the status of onboarding of the authenticated organization.
44
//
45
// See: https://docs.mollie.com/reference/v2/onboarding-api/get-onboarding-status
46
func (os *OnboardingService) GetOnboardingStatus() (o *Onboarding, err error) {
47 1
	req, err := os.client.NewAPIRequest(http.MethodGet, onboardingTarget, nil)
48 1
	if err != nil {
49 1
		return
50
	}
51
52 1
	res, err := os.client.Do(req)
53 1
	if err != nil {
54 1
		return
55
	}
56
57 1
	if err = json.Unmarshal(res.content, &o); err != nil {
58 1
		return
59
	}
60
61 1
	return
62
}
63
64
// OnboardingData request possible values.
65
//
66
// Please note that even though all parameters are optional,
67
// at least one of them needs to be provided in the request.
68
//
69
// Information that the merchant has entered in their dashboard will not be overwritten.
70
type OnboardingData struct {
71
	Organization struct {
72
		Name               string   `json:"name,omitempty"`
73
		Address            *Address `json:"address,omitempty"`
74
		RegistrationNumber string   `json:"registrationNumber,omitempty"`
75
		VatNumber          string   `json:"vatNumber,omitempty"`
76
		VatRegulation      string   `json:"vatRegulation,omitempty"`
77
	} `json:"organization,omitempty"`
78
	Profile struct {
79
		Name         string       `json:"name,omitempty"`
80
		URL          string       `json:"url,omitempty"`
81
		Email        string       `json:"email,omitempty"`
82
		Description  string       `json:"description,omitempty"`
83
		Phone        string       `json:"phone,omitempty"`
84
		CategoryCode CategoryCode `json:"categoryCode,omitempty"`
85
	} `json:"profile,omitempty"`
86
}
87
88
// SubmitOnboardingData sends data that will be prefilled in the merchant’s onboarding.
89
// Please note that the data you submit will only be processed when the onboarding status is needs-data.
90
//
91
// See: https://docs.mollie.com/reference/v2/onboarding-api/submit-onboarding-data
92
func (os *OnboardingService) SubmitOnboardingData(d *OnboardingData) (err error) {
93 1
	req, err := os.client.NewAPIRequest(http.MethodPost, onboardingTarget, d)
94 1
	if err != nil {
95 1
		return
96
	}
97
98 1
	_, err = os.client.Do(req)
99 1
	if err != nil {
100 1
		return
101
	}
102
103 1
	return
104
}
105