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 (#56)
by
unknown
01:39
created

mollie.*ShortDate.MarshalJSON   A

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
dl 0
loc 2
ccs 1
cts 1
cp 1
crap 1
rs 10
c 0
b 0
f 0
nop 0
1
package mollie
2
3
import (
4
	"encoding/json"
5
	"strings"
6
	"time"
7
)
8
9
// Amount represents a currency and value pair.
10
type Amount struct {
11
	Currency string `json:"currency,omitempty"`
12
	Value    string `json:"value,omitempty"`
13
}
14
15
// Address provides a human friendly representation of a geographical space.
16
//
17
// When providing an address object as parameter to a request, the following conditions must be met:
18
//
19
// If any of the fields is provided, all fields have to be provided with exception of the region field.
20
// If only the region field is given, one should provide all the other fields as per the previous condition.
21
// For certain PayPal payments the region field is required.
22
type Address struct {
23
	StreetAndNumber  string `json:"streetAndNumber,omitempty"`
24
	StreetAdditional string `json:"streetAdditional,omitempty"`
25
	PostalCode       string `json:"postalCode,omitempty"`
26
	City             string `json:"city,omitempty"`
27
	Region           string `json:"region,omitempty"`
28
	Country          string `json:"country,omitempty"`
29
}
30
31
// ShortDate is a string representing a date in YYYY-MM-DD format.
32
type ShortDate struct {
33
	time.Time
34
}
35
36
// MarshalJSON overrides the default marshal action
37
// for the Date struct. Returns date as YYYY-MM-DD formatted string.
38
func (d *ShortDate) MarshalJSON() ([]byte, error) {
39 1
       return json.Marshal(d.Time.Format("2006-01-02"))
40
}
41
42
// UnmarshalJSON overrides the default unmarshal action
43
// for the Date struct, as we need links to be pointers to the time.Time struct.
44
func (d *ShortDate) UnmarshalJSON(b []byte) error {
45 1
	s := string(b)
46 1
	s = strings.Trim(s, "\"")
47 1
	t, err := time.Parse("2006-01-02", s)
48 1
	if err != nil {
49 1
		return err
50
	}
51 1
	d.Time = t
52 1
	return nil
53
}
54
55
// Locale represents a country and language in ISO-15897 format.
56
type Locale string
57
58
// Mollie supported locales
59
const (
60
	English       Locale = "en_US"
61
	Dutch         Locale = "nl_NL"
62
	DutchBelgium  Locale = "nl_BE"
63
	French        Locale = "fr_FR"
64
	FrenchBelgium Locale = "fr_BE"
65
	German        Locale = "de_DE"
66
	GermanAustria Locale = "de_AT"
67
	GermanSwiss   Locale = "de_CH"
68
	Spanish       Locale = "es_ES"
69
	Catalan       Locale = "ca_ES"
70
	Portuguese    Locale = "pt_PT"
71
	Italian       Locale = "it_IT"
72
	Norwegian     Locale = "nb_NO"
73
	Swedish       Locale = "sv_SE"
74
	Finish        Locale = "fi_FI"
75
	Danish        Locale = "da_DK"
76
	Icelandic     Locale = "is_IS"
77
	Hungarian     Locale = "hu_HU"
78
	Polish        Locale = "pl_PL"
79
	Latvian       Locale = "lv_LV"
80
	Lithuanian    Locale = "lt_LT"
81
)
82
83
// PhoneNumber represents a phone number in the E.164 format.
84
type PhoneNumber string
85
86
// QRCode object represents an image of a QR code.
87
type QRCode struct {
88
	Height int    `json:"height,omitempty"`
89
	Width  int    `json:"width,omitempty"`
90
	Src    string `json:"src,omitempty"`
91
}
92
93
// URL in Mollie are commonly represented as objects with an href and type field.
94
type URL struct {
95
	Href string `json:"href,omitempty"`
96
	Type string `json:"type,omitempty"`
97
}
98
99
// PaginationLinks describes the hal component of paginated responses.
100
type PaginationLinks struct {
101
	Self     *URL `json:"self,omitempty"`
102
	Previous *URL `json:"previous,omitempty"`
103
	Next     *URL `json:"next,omitempty"`
104
	Docs     *URL `json:"documentation,omitempty"`
105
}
106
107
// CategoryCode specifies an industry or category
108
type CategoryCode uint
109
110
// Available category codes
111
const (
112
	BookMagazinesAndNewspapers      CategoryCode = 5192
113
	GeneralMerchandise              CategoryCode = 5399
114
	FoodAndDrinks                   CategoryCode = 5499
115
	AutomotiveProducts              CategoryCode = 5533
116
	ChildrenProducts                CategoryCode = 5641
117
	ClothingAndShoes                CategoryCode = 5651
118
	ElectronicsComputersAndSoftware CategoryCode = 5732
119
	HostingOrVpnServices            CategoryCode = 5734
120
	Entertainment                   CategoryCode = 5735
121
	CreditsOrVouchersOrGiftCards    CategoryCode = 5815
122
	Alcohol                         CategoryCode = 5921
123
	JewelryAndAccessories           CategoryCode = 5944
124
	HealthAndBeautyProducts         CategoryCode = 5977
125
	FinancialServices               CategoryCode = 6012
126
	Consultancy                     CategoryCode = 7299
127
	TravelRentalAndTransportation   CategoryCode = 7999
128
	AdvisingOrCoachingOrTraining    CategoryCode = 8299
129
	CharityAndDonations             CategoryCode = 8398
130
	PoliticalParties                CategoryCode = 8699
131
	Others                          CategoryCode = 0
132
)
133
134
// Mode contains information about the creation environment.
135
type Mode string
136
137
// Valid modes
138
const (
139
	LiveMode Mode = "live"
140
	TestMode Mode = "test"
141
)
142
143
// EmbedValue describes the valid value of embed query string.
144
type EmbedValue string
145
146
// Valid Embed query string value.
147
const (
148
	EmbedPayment     EmbedValue = "payment"
149
	EmbedRefund      EmbedValue = "refund"
150
	EmbedShipments   EmbedValue = "shipments"
151
	EmbedChangebacks EmbedValue = "chanrgebacks"
152
)
153
154
// Rate describes service rates, further divided into fixed and percentage costs.
155
type Rate struct {
156
	Fixed    Amount `json:"fixed,omitempty"`
157
	Variable string `json:"variable,omitempty"`
158
}
159