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/terminals.go   A
last analyzed

Size/Duplication

Total Lines 91
Duplicated Lines 0 %

Test Coverage

Coverage 92.86%

Importance

Changes 0
Metric Value
cc 8
eloc 54
dl 0
loc 91
ccs 13
cts 14
cp 0.9286
crap 8.0231
rs 10
c 0
b 0
f 0

2 Methods

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