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 119
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
cc 8
eloc 70
dl 0
loc 119
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 2 1
A mollie.*OrganizationsService.GetCurrent 0 2 1
A mollie.*OrganizationsService.get 0 11 3
A mollie.*OrganizationsService.GetPartnerStatus 0 15 3
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
	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(ctx context.Context, id string) (res *Response, o *Organization, err error) {
80 1
	return os.get(ctx, fmt.Sprintf("v2/organizations/%s", id))
81
}
82
83
// GetCurrent retrieve the currently authenticated organization.
84
func (os *OrganizationsService) GetCurrent(ctx context.Context) (res *Response, o *Organization, err error) {
85 1
	return os.get(ctx, "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(ctx context.Context) (
93
	res *Response,
94
	ops *OrganizationPartnerStatus,
95
	err error,
96
) {
97 1
	res, err = os.client.get(ctx, "v2/organizations/me/partner", nil)
98 1
	if err != nil {
99 1
		return
100
	}
101
102 1
	if err = json.Unmarshal(res.content, &ops); err != nil {
103 1
		return
104
	}
105
106 1
	return
107
}
108
109
func (os *OrganizationsService) get(ctx context.Context, uri string) (res *Response, o *Organization, err error) {
110 1
	res, err = os.client.get(ctx, uri, nil)
111 1
	if err != nil {
112 1
		return
113
	}
114
115 1
	if err = json.Unmarshal(res.content, &o); err != nil {
116 1
		return
117
	}
118
119 1
	return
120
}
121