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.

mollie/organizations.go   A
last analyzed

Size/Duplication

Total Lines 120
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
cc 8
eloc 71
dl 0
loc 120
ccs 14
cts 14
cp 1
crap 8
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A mollie.*OrganizationsService.get 0 11 3
A mollie.*OrganizationsService.GetPartnerStatus 0 15 3
A mollie.*OrganizationsService.Get 0 2 1
A mollie.*OrganizationsService.GetCurrent 0 2 1
1
package mollie
2
3
import (
4
	"context"
5
	"encoding/json"
6
	"fmt"
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
	PartnerContractExpiresAt       *time.Time               `json:"partnerContractExpiresAt,omitempty"`
73
	Links                          OrganizationPartnerLinks `json:"_links,omitempty"`
74
}
75
76
// OrganizationsService instance operates over organization resources.
77
type OrganizationsService service
78
79
// Get retrieve an organization by its id.
80 1
func (os *OrganizationsService) Get(ctx context.Context, id string) (res *Response, o *Organization, err error) {
81
	return os.get(ctx, fmt.Sprintf("v2/organizations/%s", id))
82
}
83
84
// GetCurrent retrieve the currently authenticated organization.
85 1
func (os *OrganizationsService) GetCurrent(ctx context.Context) (res *Response, o *Organization, err error) {
86
	return os.get(ctx, "v2/organizations/me")
87
}
88
89
// GetPartnerStatus retrieves details about the partner status
90
// of the currently authenticated organization.
91
//
92
// See: https://docs.mollie.com/reference/get-partner-status
93
func (os *OrganizationsService) GetPartnerStatus(ctx context.Context) (
94
	res *Response,
95
	ops *OrganizationPartnerStatus,
96
	err error,
97 1
) {
98 1
	res, err = os.client.get(ctx, "v2/organizations/me/partner", nil)
99 1
	if err != nil {
100
		return
101
	}
102 1
103 1
	if err = json.Unmarshal(res.content, &ops); err != nil {
104
		return
105
	}
106 1
107
	return
108
}
109
110 1
func (os *OrganizationsService) get(ctx context.Context, uri string) (res *Response, o *Organization, err error) {
111 1
	res, err = os.client.get(ctx, uri, nil)
112 1
	if err != nil {
113
		return
114
	}
115 1
116 1
	if err = json.Unmarshal(res.content, &o); err != nil {
117
		return
118
	}
119 1
120
	return
121
}
122