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
Pull Request — master (#46)
by Victor Hugo
01:28
created

mollie.*OrganizationsService.get   A

Complexity

Conditions 4

Size

Total Lines 13
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 13
ccs 9
cts 9
cp 1
crap 4
rs 9.9
c 0
b 0
f 0
nop 1
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
	return os.get(fmt.Sprintf("v2/organizations/%s", id))
43
}
44
45
// GetCurrent retrieve the currently authenticated organization
46
func (os *OrganizationsService) GetCurrent() (o *Organization, err error) {
47 1
	return os.get("v2/organizations/me")
48
}
49
50
func (os *OrganizationsService) get(uri string) (o *Organization, err error) {
51 1
	req, err := os.client.NewAPIRequest(http.MethodGet, uri, nil)
52 1
	if err != nil {
53 1
		return
54
	}
55 1
	res, err := os.client.Do(req)
56 1
	if err != nil {
57 1
		return
58
	}
59 1
	if err = json.Unmarshal(res.content, &o); err != nil {
60 1
		return
61
	}
62 1
	return
63
}
64