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 (#278)
by Victor Hugo
01:25
created

mollie/terminals.go   A

Size/Duplication

Total Lines 87
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
cc 6
eloc 52
dl 0
loc 87
ccs 12
cts 12
cp 1
crap 6
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A mollie.*TerminalsService.List 0 15 3
A mollie.*TerminalsService.Get 0 11 3
1
package mollie
2
3
import (
4
	"context"
5
	"encoding/json"
6
	"fmt"
7
	"time"
8
)
9
10
// TerminalsService operates over terminals resource.
11
type TerminalsService service
12
13
// TerminalStatus is the status of the terminal, which is a read-only value determined by Mollie.
14
type TerminalStatus string
15
16
// Possible terminal statuses.
17
const (
18
	TerminalPending  TerminalStatus = "pending"
19
	TerminalActive   TerminalStatus = "active"
20
	TerminalInactive TerminalStatus = "inactive"
21
)
22
23
// Terminal symbolizes a physical device to receive payments.
24
type Terminal struct {
25
	ID           string          `json:"id,omitempty"`
26
	Resource     string          `json:"resource,omitempty"`
27
	ProfileID    string          `json:"profileID,omitempty"`
28
	Status       TerminalStatus  `json:"status,omitempty"`
29
	Brand        string          `json:"brand,omitempty"`
30
	Model        string          `json:"model,omitempty"`
31
	SerialNumber string          `json:"serialNumber,omitempty"`
32
	Currency     string          `json:"currency,omitempty"`
33
	Description  string          `json:"description,omitempty"`
34
	CreatedAt    *time.Time      `json:"createdAt,omitempty"`
35
	UpdatedAt    *time.Time      `json:"updatedAt,omitempty"`
36
	Links        PaginationLinks `json:"_links,omitempty"`
37
}
38
39
// Get terminal retrieves a single terminal object by its terminal ID.
40
func (ts *TerminalsService) Get(ctx context.Context, id string) (res *Response, t *Terminal, err error) {
41 1
	res, err = ts.client.get(ctx, fmt.Sprintf("v2/terminals/%s", id), nil)
42 1
	if err != nil {
43 1
		return
44
	}
45
46 1
	if err = json.Unmarshal(res.content, &t); err != nil {
47 1
		return
48
	}
49
50 1
	return
51
}
52
53
// TerminalListOptions holds query string parameters valid for terminals lists.
54
//
55
// ProfileID and TestMode are valid only when using access tokens.
56
type TerminalListOptions struct {
57
	From      string `url:"from,omitempty"`
58
	Limit     int    `url:"limit,omitempty"`
59
	ProfileID string `url:"profileID,omitempty"`
60
	TestMode  bool   `url:"testMode,omitempty"`
61
}
62
63
// TerminalList describes the response for terminals list endpoints.
64
type TerminalList struct {
65
	Count    int `json:"count,omitempty"`
66
	Embedded struct {
67
		Terminals []*Terminal `json:"terminals,omitempty"`
68
	} `json:"_embedded,omitempty"`
69
	Links PaginationLinks `json:"_links,omitempty"`
70
}
71
72
// List retrieves a list of terminals symbolizing the physical devices to receive payments.
73
func (ts *TerminalsService) List(ctx context.Context, options *TerminalListOptions) (
74
	res *Response,
75
	tl *TerminalList,
76
	err error,
77
) {
78 1
	res, err = ts.client.get(ctx, "v2/terminals", options)
79 1
	if err != nil {
80 1
		return
81
	}
82
83 1
	if err = json.Unmarshal(res.content, &tl); err != nil {
84 1
		return
85
	}
86
87 1
	return
88
}
89