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 ( 4b3735...704f57 )
by Victor Hugo
01:07 queued 12s
created

mollie.*OrganizationsService.GetPartnerStatus   A

Complexity

Conditions 4

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 4

Importance

Changes 0
Metric Value
cc 4
eloc 10
dl 0
loc 16
ccs 9
cts 9
cp 1
crap 4
rs 9.9
c 0
b 0
f 0
nop 0
1
package mollie
2
3
import (
4
	"encoding/json"
5
	"fmt"
6
	"net/http"
7
	"time"
8
)
9
10
// Organization describes an organization detail
11
type Organization struct {
12
	Resource           string            `json:"resource,omitempty"`
13
	ID                 string            `json:"id,omitempty"`
14
	Name               string            `json:"name,omitempty"`
15
	Email              string            `json:"email,omitempty"`
16
	Locale             string            `json:"locale,omitempty"`
17
	Address            *Address          `json:"address,omitempty"`
18
	RegistrationNumber string            `json:"registrationNumber,omitempty"`
19
	VatNumber          string            `json:"vatNumber,omitempty"`
20
	VatRegulation      string            `json:"vatRegulation,omitempty"`
21
	Links              OrganizationLinks `json:"_links,omitempty"`
22
}
23
24
// OrganizationLinks describes all the possible links to be returned with
25
// a organization object.
26
type OrganizationLinks struct {
27
	Self          *URL `json:"self,omitempty"`
28
	Chargebacks   *URL `json:"chargebacks,omitempty"`
29
	Customers     *URL `json:"customers,omitempty"`
30
	Dashboard     *URL `json:"dashboard,omitempty"`
31
	Invoices      *URL `json:"invoices,omitempty"`
32
	Payments      *URL `json:"payments,omitempty"`
33
	Profiles      *URL `json:"profiles,omitempty"`
34
	Refunds       *URL `json:"refunds,omitempty"`
35
	Settlements   *URL `json:"settlements,omitempty"`
36
	Documentation *URL `json:"documentation,omitempty"`
37
}
38
39
// PartnerType alias for organization partner types.
40
type PartnerType string
41
42
// Available partner types.
43
const (
44
	PartnerTypeOauth      PartnerType = "oauth"
45
	PartnerTypeSignUpLink PartnerType = "signuplink"
46
	PartnerTypeUserAgent  PartnerType = "useragent"
47
)
48
49
// UserAgentToken are time limited valid access tokens.
50
type UserAgentToken struct {
51
	Token    string
52
	StartsAt *time.Time
53
	EndsAt   *time.Time
54
}
55
56
// OrganizationPartnerLinks is an object with several URL objects
57
// relevant to the partner resource.
58
type OrganizationPartnerLinks struct {
59
	Self          *URL `json:"self,omitempty"`
60
	Documentation *URL `json:"documentation,omitempty"`
61
	SignUpLink    *URL `json:"signuplink,omitempty"`
62
}
63
64
// OrganizationPartnerStatus response descriptor.
65
type OrganizationPartnerStatus struct {
66
	IsCommissionPartner            bool                     `json:"isCommissionPartner,omitempty"`
67
	PartnerContractUpdateAvailable bool                     `json:"partnerContractUpdate_available,omitempty"`
68
	Resource                       string                   `json:"resource,omitempty"`
69
	PartnerType                    PartnerType              `json:"partnerType,omitempty"`
70
	UserAgentTokens                []*UserAgentToken        `json:"userAgentTokens,omitempty"`
71
	PartnerContractSignedAt        *time.Time               `json:"partnerContractSignedAt,omitempty"`
72
	Links                          OrganizationPartnerLinks `json:"_links,omitempty"`
73
}
74
75
// OrganizationsService instance operates over organization resources
76
type OrganizationsService service
77
78
// Get retrieve an organization by its id.
79
func (os *OrganizationsService) Get(id string) (o *Organization, err error) {
80 1
	return os.get(fmt.Sprintf("v2/organizations/%s", id))
81
}
82
83
// GetCurrent retrieve the currently authenticated organization
84
func (os *OrganizationsService) GetCurrent() (o *Organization, err error) {
85 1
	return os.get("v2/organizations/me")
86
}
87
88
// GetPartnerStatus retrieves details about the partner status
89
// of the currently authenticated organization.
90
//
91
// See: https://docs.mollie.com/reference/v2/organizations-api/get-partner
92
func (os *OrganizationsService) GetPartnerStatus() (ops *OrganizationPartnerStatus, err error) {
93 1
	req, err := os.client.NewAPIRequest(http.MethodGet, "v2/organizations/me/partner", nil)
94 1
	if err != nil {
95 1
		return
96
	}
97
98 1
	res, err := os.client.Do(req)
99 1
	if err != nil {
100 1
		return
101
	}
102
103 1
	if err = json.Unmarshal(res.content, &ops); err != nil {
104 1
		return
105
	}
106
107 1
	return
108
}
109
110
func (os *OrganizationsService) get(uri string) (o *Organization, err error) {
111 1
	req, err := os.client.NewAPIRequest(http.MethodGet, uri, nil)
112 1
	if err != nil {
113 1
		return
114
	}
115 1
	res, err := os.client.Do(req)
116 1
	if err != nil {
117 1
		return
118
	}
119 1
	if err = json.Unmarshal(res.content, &o); err != nil {
120 1
		return
121
	}
122 1
	return
123
}
124