1
|
|
|
package mollie |
2
|
|
|
|
3
|
|
|
import ( |
4
|
|
|
"strings" |
5
|
|
|
"time" |
6
|
|
|
) |
7
|
|
|
|
8
|
|
|
// Amount represents a currency and value pair. |
9
|
|
|
type Amount struct { |
10
|
|
|
Currency string `json:"currency,omitempty"` |
11
|
|
|
Value string `json:"value,omitempty"` |
12
|
|
|
} |
13
|
|
|
|
14
|
|
|
// Address provides a human friendly representation of a geographical space. |
15
|
|
|
// |
16
|
|
|
// When providing an address object as parameter to a request, the following conditions must be met: |
17
|
|
|
// |
18
|
|
|
// -If any of the fields is provided, all fields have to be provided with exception of the region field. |
19
|
|
|
// -If only the region field is given, one should provide all the other fields as per the previous condition. |
20
|
|
|
// -For certain PayPal payments the region field is required. |
21
|
|
|
type Address struct { |
22
|
|
|
StreetAndNumber string `json:"streetAndNumber,omitempty"` |
23
|
|
|
StreetAdditional string `json:"streetAdditional,omitempty"` |
24
|
|
|
PostalCode string `json:"postalCode,omitempty"` |
25
|
|
|
City string `json:"city,omitempty"` |
26
|
|
|
Region string `json:"region,omitempty"` |
27
|
|
|
Country string `json:"country,omitempty"` |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
// ShortDate is a string representing a date in YYYY-MM-DD format. |
31
|
|
|
type ShortDate struct { |
32
|
|
|
time.Time |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
// UnmarshalJSON overrides the default unmarshal action |
36
|
|
|
// for the Date struct, as we need links to be pointers |
37
|
|
|
// to the time.Time struct. |
38
|
|
|
func (d *ShortDate) UnmarshalJSON(b []byte) error { |
39
|
1 |
|
s := string(b) |
40
|
1 |
|
s = strings.Trim(s, "\"") |
41
|
1 |
|
t, err := time.Parse("2006-01-02", s) |
42
|
1 |
|
if err != nil { |
43
|
1 |
|
return err |
44
|
|
|
} |
45
|
1 |
|
d.Time = t |
46
|
1 |
|
return nil |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
// Locale represents a country and language in ISO-15897 format. |
50
|
|
|
type Locale string |
51
|
|
|
|
52
|
|
|
// Mollie supported locales |
53
|
|
|
const ( |
54
|
|
|
English Locale = "en_US" |
55
|
|
|
Dutch Locale = "nl_NL" |
56
|
|
|
DutchBelgium Locale = "nl_BE" |
57
|
|
|
French Locale = "fr_FR" |
58
|
|
|
FrenchBelgium Locale = "fr_BE" |
59
|
|
|
German Locale = "de_DE" |
60
|
|
|
GermanAustria Locale = "de_AT" |
61
|
|
|
GermanSwiss Locale = "de_CH" |
62
|
|
|
Spanish Locale = "es_ES" |
63
|
|
|
Catalan Locale = "ca_ES" |
64
|
|
|
Portuguese Locale = "pt_PT" |
65
|
|
|
Italian Locale = "it_IT" |
66
|
|
|
Norwegian Locale = "nb_NO" |
67
|
|
|
Swedish Locale = "sv_SE" |
68
|
|
|
Finish Locale = "fi_FI" |
69
|
|
|
Danish Locale = "da_DK" |
70
|
|
|
Icelandic Locale = "is_IS" |
71
|
|
|
Hungarian Locale = "hu_HU" |
72
|
|
|
Polish Locale = "pl_PL" |
73
|
|
|
Latvian Locale = "lv_LV" |
74
|
|
|
Lithuanian Locale = "lt_LT" |
75
|
|
|
) |
76
|
|
|
|
77
|
|
|
// PhoneNumber represents a phone number in the E.164 format. |
78
|
|
|
type PhoneNumber string |
79
|
|
|
|
80
|
|
|
// QR code object represents an image of a QR code. |
81
|
|
|
type QRCode struct { |
82
|
|
|
Height int `json:"height,omitempty"` |
83
|
|
|
Width int `json:"width,omitempty"` |
84
|
|
|
Src string `json:"src,omitempty"` |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
// URLs in Mollie are commonly represented as objects with an href and type field. |
88
|
|
|
type URL struct { |
89
|
|
|
Href string `json:"href,omitempty"` |
90
|
|
|
Type string `json:"type,omitempty"` |
91
|
|
|
} |
92
|
|
|
|