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 ( 7c96ad...f304ca )
by Victor Hugo
01:07 queued 12s
created

mollie.*ShortDate.MarshalJSON   A

Complexity

Conditions 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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