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 ( 255a0b...e2059e )
by Victor Hugo
01:20 queued 10s
created

mollie/organizations.go   A

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
cc 8
eloc 49
dl 0
loc 73
ccs 20
cts 20
cp 1
crap 8
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A mollie.*OrganizationsService.Get 0 15 4
A mollie.*OrganizationsService.GetCurrent 0 15 4
1
package mollie
2
3
import (
4
	"encoding/json"
5
	"fmt"
6
	"net/http"
7
)
8
9
// Organization describes an organization detail
10
type Organization struct {
11
	Resource           string             `json:"resource,omitempty"`
12
	ID                 string             `json:"id,omitempty"`
13
	Name               string             `json:"name,omitempty"`
14
	Email              string             `json:"email,omitempty"`
15
	Locale             string             `json:"locale,omitempty"`
16
	Address            *Address           `json:"address,omitempty"`
17
	RegistrationNumber string             `json:"registrationNumber,omitempty"`
18
	VatNumber          string             `json:"vatNumber,omitempty"`
19
	VatRegulation      string             `json:"vatRegulation,omitempty"`
20
	Links              *OrganizationLinks `json:"_links,omitempty"`
21
}
22
23
// OrganizationLinks describes all the possible links to be returned with
24
// a organization object.
25
type OrganizationLinks struct {
26
	Self          URL `json:"self,omitempty"`
27
	Chargebacks   URL `json:"chargebacks,omitempty"`
28
	Customers     URL `json:"customers,omitempty"`
29
	Invoices      URL `json:"invoices,omitempty"`
30
	Payments      URL `json:"payments,omitempty"`
31
	Profiles      URL `json:"profiles,omitempty"`
32
	Refunds       URL `json:"refunds,omitempty"`
33
	Settlements   URL `json:"settlements,omitempty"`
34
	Documentation URL `json:"documentation,omitempty"`
35
}
36
37
// OrganizationsService instance operates over organization resources
38
type OrganizationsService service
39
40
// Get retrieve an organization by its id.
41
func (os *OrganizationsService) Get(id string) (o *Organization, err error) {
42 1
	getURL := fmt.Sprintf("v2/organizations/%s", id)
43
44 1
	req, err := os.client.NewAPIRequest(http.MethodGet, getURL, nil)
45 1
	if err != nil {
46 1
		return
47
	}
48 1
	res, err := os.client.Do(req)
49 1
	if err != nil {
50 1
		return
51
	}
52 1
	if err = json.Unmarshal(res.content, &o); err != nil {
53 1
		return
54
	}
55 1
	return
56
}
57
58
// GetCurrent retrieve the currently authenticated organization
59
func (os *OrganizationsService) GetCurrent() (o *Organization, err error) {
60 1
	getURL := "v2/organizations/me"
61
62 1
	req, err := os.client.NewAPIRequest(http.MethodGet, getURL, nil)
63 1
	if err != nil {
64 1
		return
65
	}
66 1
	res, err := os.client.Do(req)
67 1
	if err != nil {
68 1
		return
69
	}
70 1
	if err = json.Unmarshal(res.content, &o); err != nil {
71 1
		return
72
	}
73 1
	return
74
}
75