-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
374 lines (349 loc) · 20.3 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
package speedhive
import (
"encoding/json"
"strings"
"time"
)
type SportCategoryValue string
const (
SportCategoryValue_Motorized SportCategoryValue = "Motorized"
SportCategoryValue_Active SportCategoryValue = "Active"
)
type SportValue string
const (
SportValue_Unknown SportValue = "Unknown"
SportValue_Karting SportValue = "Karting"
SportValue_MX SportValue = "MX"
SportValue_Car SportValue = "Car"
SportValue_Bike SportValue = "Bike"
SportValue_RC SportValue = "RC"
SportValue_Cycling SportValue = "Cycling"
SportValue_IceSkating SportValue = "IceSkating"
SportValue_Running SportValue = "Running"
SportValue_ModelBoatRacing SportValue = "ModelBoatRacing"
SportValue_InlineSkating SportValue = "InlineSkating"
SportValue_StockCar SportValue = "StockCar"
SportValue_Swimming SportValue = "Swimming"
SportValue_Other SportValue = "Other"
)
type CountryValue string
const (
CountryValue_PuertoRico CountryValue = "PR"
CountryValue_Palestine CountryValue = "PS"
CountryValue_Palau CountryValue = "PW"
CountryValue_Portugal CountryValue = "PT"
CountryValue_Pakistan CountryValue = "PK"
CountryValue_Philippines CountryValue = "PH"
CountryValue_Pitcairn CountryValue = "PN"
CountryValue_Poland CountryValue = "PL"
CountryValue_SaintPierreAndMiquelon CountryValue = "PM"
CountryValue_Panama CountryValue = "PA"
CountryValue_FrenchPolynesia CountryValue = "PF"
CountryValue_PapuaNewGuinea CountryValue = "PG"
CountryValue_Peru CountryValue = "PE"
CountryValue_Andorra CountryValue = "AD"
CountryValue_AntiguaAndBarbuda CountryValue = "AG"
CountryValue_UnitedArabEmirates CountryValue = "AE"
CountryValue_Afghanistan CountryValue = "AF"
CountryValue_Qatar CountryValue = "QA"
CountryValue_Paraguay CountryValue = "PY"
CountryValue_Nepal CountryValue = "NP"
CountryValue_Norway CountryValue = "NO"
CountryValue_Niue CountryValue = "NU"
CountryValue_Nauru CountryValue = "NR"
CountryValue_Nicaragua CountryValue = "NI"
CountryValue_NorfolkIsland CountryValue = "NF"
CountryValue_Nigeria CountryValue = "NG"
CountryValue_Netherlands CountryValue = "NL"
CountryValue_Namibia CountryValue = "NA"
CountryValue_Niger CountryValue = "NE"
CountryValue_NewCaledonia CountryValue = "NC"
CountryValue_Malawi CountryValue = "MW"
CountryValue_Mexico CountryValue = "MX"
CountryValue_Mauritius CountryValue = "MU"
CountryValue_Maldives CountryValue = "MV"
CountryValue_Malaysia CountryValue = "MY"
CountryValue_Mozambique CountryValue = "MZ"
CountryValue_Oman CountryValue = "OM"
CountryValue_NewZealand CountryValue = "NZ"
CountryValue_Tuvalu CountryValue = "TV"
CountryValue_Taiwan CountryValue = "TW"
CountryValue_TrinidadAndTobago CountryValue = "TT"
CountryValue_Germany CountryValue = "DE"
CountryValue_Djibouti CountryValue = "DJ"
CountryValue_Tanzania CountryValue = "TZ"
CountryValue_Denmark CountryValue = "DK"
CountryValue_Tunisia CountryValue = "TN"
CountryValue_Tonga CountryValue = "TO"
CountryValue_TimorLeste CountryValue = "TL"
CountryValue_Turkmenistan CountryValue = "TM"
CountryValue_Turkey CountryValue = "TR"
CountryValue_Cuba CountryValue = "CU"
CountryValue_FrenchSouthernTerritories CountryValue = "TF"
CountryValue_CapeVerde CountryValue = "CV"
CountryValue_Togo CountryValue = "TG"
CountryValue_Chad CountryValue = "TD"
CountryValue_Cyprus CountryValue = "CY"
CountryValue_Tajikistan CountryValue = "TJ"
CountryValue_CzechRepublic CountryValue = "CZ"
CountryValue_Tokelau CountryValue = "TK"
CountryValue_Curacao CountryValue = "CW"
CountryValue_Thailand CountryValue = "TH"
CountryValue_ChristmasIsland CountryValue = "CX"
CountryValue_Cameroon CountryValue = "CM"
CountryValue_China CountryValue = "CN"
CountryValue_CookIslands CountryValue = "CK"
CountryValue_Chile CountryValue = "CL"
CountryValue_CostaRica CountryValue = "CR"
CountryValue_TurksAndCaicosIslands CountryValue = "TC"
CountryValue_Colombia CountryValue = "CO"
CountryValue_Egypt CountryValue = "EG"
CountryValue_WesternSahara CountryValue = "EH"
CountryValue_Estonia CountryValue = "EE"
CountryValue_Uruguay CountryValue = "UY"
CountryValue_Uzbekistan CountryValue = "UZ"
CountryValue_UnitedStatesMinorOutlyingIslands CountryValue = "UM"
CountryValue_Ecuador CountryValue = "EC"
CountryValue_UnitedStates CountryValue = "US"
CountryValue_Uganda CountryValue = "UG"
CountryValue_Algeria CountryValue = "DZ"
CountryValue_DominicanRepublic CountryValue = "DO"
CountryValue_Dominica CountryValue = "DM"
CountryValue_Ukraine CountryValue = "UA"
CountryValue_Bangladesh CountryValue = "BD"
CountryValue_Belgium CountryValue = "BE"
CountryValue_RussianFederation CountryValue = "RU"
CountryValue_Barbados CountryValue = "BB"
CountryValue_Serbia CountryValue = "RS"
CountryValue_Bahrain CountryValue = "BH"
CountryValue_Burundi CountryValue = "BI"
CountryValue_BurkinaFaso CountryValue = "BF"
CountryValue_Bulgaria CountryValue = "BG"
CountryValue_Rwanda CountryValue = "RW"
CountryValue_Azerbaijan CountryValue = "AZ"
CountryValue_BosniaAndHerzegovina CountryValue = "BA"
CountryValue_Romania CountryValue = "RO"
CountryValue_AmericanSamoa CountryValue = "AS"
CountryValue_Austria CountryValue = "AT"
CountryValue_Reunion CountryValue = "RE"
CountryValue_Antarctica CountryValue = "AQ"
CountryValue_Argentina CountryValue = "AR"
CountryValue_Aruba CountryValue = "AW"
CountryValue_AlandIslands CountryValue = "AX"
CountryValue_Australia CountryValue = "AU"
CountryValue_Albania CountryValue = "AL"
CountryValue_Anguilla CountryValue = "AI"
CountryValue_Angola CountryValue = "AO"
CountryValue_Armenia CountryValue = "AM"
CountryValue_NetherlandsAntilles CountryValue = "AN"
CountryValue_CentralAfricanRepublic CountryValue = "CF"
CountryValue_ElSalvador CountryValue = "SV"
CountryValue_CocosIslands CountryValue = "CC"
CountryValue_SouthSudan CountryValue = "SS"
CountryValue_CongoDR CountryValue = "CD"
CountryValue_SaoTomeAndPrincipe CountryValue = "ST"
CountryValue_CoteDIvoire CountryValue = "CI"
CountryValue_SyrianArabRepublic CountryValue = "SY"
CountryValue_Swaziland CountryValue = "SZ"
CountryValue_Congo CountryValue = "CG"
CountryValue_Switzerland CountryValue = "CH"
CountryValue_SintMaarten CountryValue = "SX"
CountryValue_SanMarino CountryValue = "SM"
CountryValue_Senegal CountryValue = "SN"
CountryValue_Belize CountryValue = "BZ"
CountryValue_Slovakia CountryValue = "SK"
CountryValue_SierraLeone CountryValue = "SL"
CountryValue_Canada CountryValue = "CA"
CountryValue_Suriname CountryValue = "SR"
CountryValue_Somalia CountryValue = "SO"
CountryValue_Bhutan CountryValue = "BT"
CountryValue_Sweden CountryValue = "SE"
CountryValue_Brazil CountryValue = "BR"
CountryValue_Seychelles CountryValue = "SC"
CountryValue_Bahamas CountryValue = "BS"
CountryValue_Sudan CountryValue = "SD"
CountryValue_Slovenia CountryValue = "SI"
CountryValue_Belarus CountryValue = "BY"
CountryValue_SvalbardAndJanMayen CountryValue = "SJ"
CountryValue_BouvetIsland CountryValue = "BV"
CountryValue_Singapore CountryValue = "SG"
CountryValue_Botswana CountryValue = "BW"
CountryValue_SaintHelena CountryValue = "SH"
CountryValue_SaintBarthelemy CountryValue = "BL"
CountryValue_Bermuda CountryValue = "BM"
CountryValue_Benin CountryValue = "BJ"
CountryValue_SaudiArabia CountryValue = "SA"
CountryValue_Bonaire CountryValue = "BQ"
CountryValue_SolomonIslands CountryValue = "SB"
CountryValue_BruneiDarussalam CountryValue = "BN"
CountryValue_Bolivia CountryValue = "BO"
CountryValue_HongKong CountryValue = "HK"
CountryValue_Honduras CountryValue = "HN"
CountryValue_HeardIslandAndMcdonaldIslands CountryValue = "HM"
CountryValue_Guyana CountryValue = "GY"
CountryValue_GuineaBissau CountryValue = "GW"
CountryValue_EquatorialGuinea CountryValue = "GQ"
CountryValue_Greece CountryValue = "GR"
CountryValue_Guadeloupe CountryValue = "GP"
CountryValue_Guam CountryValue = "GU"
CountryValue_SouthGeorgiaAndTheSouthSandwichIslands CountryValue = "GS"
CountryValue_Guatemala CountryValue = "GT"
CountryValue_Israel CountryValue = "IL"
CountryValue_BritishIndianOceanTerritory CountryValue = "IO"
CountryValue_SouthAfrica CountryValue = "ZA"
CountryValue_IsleOfMan CountryValue = "IM"
CountryValue_India CountryValue = "IN"
CountryValue_CanaryIslands CountryValue = "IC"
CountryValue_Indonesia CountryValue = "ID"
CountryValue_Mayotte CountryValue = "YT"
CountryValue_Ireland CountryValue = "IE"
CountryValue_Croatia CountryValue = "HR"
CountryValue_Haiti CountryValue = "HT"
CountryValue_Yemen CountryValue = "YE"
CountryValue_Hungary CountryValue = "HU"
CountryValue_Finland CountryValue = "FI"
CountryValue_Micronesia CountryValue = "FM"
CountryValue_Fiji CountryValue = "FJ"
CountryValue_FalklandIslands CountryValue = "FK"
CountryValue_Vietnam CountryValue = "VN"
CountryValue_Vanuatu CountryValue = "VU"
CountryValue_VirginIslandsUS CountryValue = "VI"
CountryValue_VirginIslandsBritish CountryValue = "VG"
CountryValue_HolySee CountryValue = "VA"
CountryValue_Spain CountryValue = "ES"
CountryValue_Ethiopia CountryValue = "ET"
CountryValue_Venezuela CountryValue = "VE"
CountryValue_Eritrea CountryValue = "ER"
CountryValue_SaintVincentAndTheGrenadines CountryValue = "VC"
CountryValue_Gibraltar CountryValue = "GI"
CountryValue_Guernsey CountryValue = "GG"
CountryValue_Ghana CountryValue = "GH"
CountryValue_Gambia CountryValue = "GM"
CountryValue_Guinea CountryValue = "GN"
CountryValue_Greenland CountryValue = "GL"
CountryValue_Gabon CountryValue = "GA"
CountryValue_UnitedKingdom CountryValue = "GB"
CountryValue_Georgia CountryValue = "GE"
CountryValue_FrenchGuiana CountryValue = "GF"
CountryValue_Samoa CountryValue = "WS"
CountryValue_Grenada CountryValue = "GD"
CountryValue_FaroeIslands CountryValue = "FO"
CountryValue_WallisAndFutuna CountryValue = "WF"
CountryValue_France CountryValue = "FR"
CountryValue_Liberia CountryValue = "LR"
CountryValue_Lesotho CountryValue = "LS"
CountryValue_SriLanka CountryValue = "LK"
CountryValue_Liechtenstein CountryValue = "LI"
CountryValue_Lebanon CountryValue = "LB"
CountryValue_SaintLucia CountryValue = "LC"
CountryValue_LaoPDR CountryValue = "LA"
CountryValue_CaymanIslands CountryValue = "KY"
CountryValue_Kazakhstan CountryValue = "KZ"
CountryValue_Kuwait CountryValue = "KW"
CountryValue_Macao CountryValue = "MO"
CountryValue_NorthernMarianaIslands CountryValue = "MP"
CountryValue_Myanmar CountryValue = "MM"
CountryValue_Mongolia CountryValue = "MN"
CountryValue_Montserrat CountryValue = "MS"
CountryValue_Malta CountryValue = "MT"
CountryValue_Martinique CountryValue = "MQ"
CountryValue_Mauritania CountryValue = "MR"
CountryValue_Madagascar CountryValue = "MG"
CountryValue_MarshallIslands CountryValue = "MH"
CountryValue_Montenegro CountryValue = "ME"
CountryValue_SaintMartin CountryValue = "MF"
CountryValue_Macedonia CountryValue = "MK"
CountryValue_Mali CountryValue = "ML"
CountryValue_Monaco CountryValue = "MC"
CountryValue_Moldova CountryValue = "MD"
CountryValue_Morocco CountryValue = "MA"
CountryValue_Latvia CountryValue = "LV"
CountryValue_Lithuania CountryValue = "LT"
CountryValue_Luxembourg CountryValue = "LU"
CountryValue_Libya CountryValue = "LY"
CountryValue_Jamaica CountryValue = "JM"
CountryValue_Japan CountryValue = "JP"
CountryValue_Jordan CountryValue = "JO"
CountryValue_Jersey CountryValue = "JE"
CountryValue_Zimbabwe CountryValue = "ZW"
CountryValue_Zambia CountryValue = "ZM"
CountryValue_Iceland CountryValue = "IS"
CountryValue_Italy CountryValue = "IT"
CountryValue_Iraq CountryValue = "IQ"
CountryValue_Iran CountryValue = "IR"
CountryValue_Comoros CountryValue = "KM"
CountryValue_SaintKittsAndNevis CountryValue = "KN"
CountryValue_KoreaRepublicOf CountryValue = "KR"
CountryValue_KoreaDPR CountryValue = "KP"
CountryValue_Kenya CountryValue = "KE"
CountryValue_Kiribati CountryValue = "KI"
CountryValue_Kyrgyzstan CountryValue = "KG"
CountryValue_Cambodia CountryValue = "KH"
)
type OrderValue string
const (
OrderValue_Ascending OrderValue = "asc"
OrderValue_Descending OrderValue = "desc"
)
type Duration time.Duration
func (d *Duration) UnmarshalJSON(b []byte) error {
var value string
if err := json.Unmarshal(b, &value); err != nil {
return err
}
t := time.Duration(0)
// Posibilities are:
// 1. 1:23:45.678
// 2. 23:45.678
// 3. 45.678
// 4. 0.678
// And the negative versions of the above
negative := false
if strings.HasPrefix(value, "-") {
negative = true
value = value[1:]
}
parts := strings.Split(value, ":")
switch len(parts) {
case 1:
t, _ = time.ParseDuration(value + "s")
case 2:
t, _ = time.ParseDuration(parts[0] + "m" + parts[1] + "s")
case 3:
t, _ = time.ParseDuration(parts[0] + "h" + parts[1] + "m" + parts[2] + "s")
}
if negative {
t *= -1
}
*d = Duration(t)
return nil
}
type Time time.Time
func (t *Time) UnmarshalJSON(b []byte) error {
var value string
if err := json.Unmarshal(b, &value); err != nil {
return err
}
if value == "" {
return nil
}
// Time may be in the formats:
// - 2006-01-02
// - 2006-01-02T15:04:05
// - 2006-01-02T15:04:05+07:00
var err error
var tm time.Time
if strings.Contains(value, "T") {
tm, err = time.Parse(time.RFC3339, value)
if err != nil {
tm, err = time.Parse("2006-01-02T15:04:05", value)
}
} else {
tm, err = time.Parse("2006-01-02", value)
}
if err != nil {
return err
}
*t = Time(tm)
return nil
}