forked from labd/commercetools-go-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types_common.go
905 lines (844 loc) · 26.2 KB
/
types_common.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
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
// Automatically generated, do not edit
package commercetools
import (
"encoding/json"
"errors"
"time"
)
// MoneyType is an enum type
type MoneyType string
// Enum values for MoneyType
const (
MoneyTypeCentPrecision MoneyType = "centPrecision"
MoneyTypeHighPrecision MoneyType = "highPrecision"
)
// ReferenceTypeID is an enum type
type ReferenceTypeID string
// Enum values for ReferenceTypeID
const (
ReferenceTypeIDCart ReferenceTypeID = "cart"
ReferenceTypeIDCartDiscount ReferenceTypeID = "cart-discount"
ReferenceTypeIDCategory ReferenceTypeID = "category"
ReferenceTypeIDChannel ReferenceTypeID = "channel"
ReferenceTypeIDCustomer ReferenceTypeID = "customer"
ReferenceTypeIDCustomerGroup ReferenceTypeID = "customer-group"
ReferenceTypeIDDiscountCode ReferenceTypeID = "discount-code"
ReferenceTypeIDKeyValueDocument ReferenceTypeID = "key-value-document"
ReferenceTypeIDPayment ReferenceTypeID = "payment"
ReferenceTypeIDProduct ReferenceTypeID = "product"
ReferenceTypeIDProductType ReferenceTypeID = "product-type"
ReferenceTypeIDProductDiscount ReferenceTypeID = "product-discount"
ReferenceTypeIDOrder ReferenceTypeID = "order"
ReferenceTypeIDReview ReferenceTypeID = "review"
ReferenceTypeIDShoppingList ReferenceTypeID = "shopping-list"
ReferenceTypeIDShippingMethod ReferenceTypeID = "shipping-method"
ReferenceTypeIDState ReferenceTypeID = "state"
ReferenceTypeIDStore ReferenceTypeID = "store"
ReferenceTypeIDTaxCategory ReferenceTypeID = "tax-category"
ReferenceTypeIDType ReferenceTypeID = "type"
ReferenceTypeIDZone ReferenceTypeID = "zone"
ReferenceTypeIDInventoryEntry ReferenceTypeID = "inventory-entry"
ReferenceTypeIDOrderEdit ReferenceTypeID = "order-edit"
)
// CountryCode is of type string
type CountryCode string
// CurrencyCode is of type string
type CurrencyCode string
// Locale is of type string
type Locale string
// LocalizedString is a map
type LocalizedString map[string]string
// GeoJSON uses type as discriminator attribute
type GeoJSON interface{}
func mapDiscriminatorGeoJSON(input interface{}) (GeoJSON, error) {
var discriminator string
if data, ok := input.(map[string]interface{}); ok {
discriminator, ok = data["type"].(string)
if !ok {
return nil, errors.New("Error processing discriminator field 'type'")
}
} else {
return nil, errors.New("Invalid data")
}
switch discriminator {
case "Point":
new := GeoJSONPoint{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
}
return nil, nil
}
// KeyReference uses typeId as discriminator attribute
type KeyReference interface{}
func mapDiscriminatorKeyReference(input interface{}) (KeyReference, error) {
var discriminator string
if data, ok := input.(map[string]interface{}); ok {
discriminator, ok = data["typeId"].(string)
if !ok {
return nil, errors.New("Error processing discriminator field 'typeId'")
}
} else {
return nil, errors.New("Invalid data")
}
switch discriminator {
case "store":
new := StoreKeyReference{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
}
return nil, nil
}
// Reference uses typeId as discriminator attribute
type Reference interface{}
func mapDiscriminatorReference(input interface{}) (Reference, error) {
var discriminator string
if data, ok := input.(map[string]interface{}); ok {
discriminator, ok = data["typeId"].(string)
if !ok {
return nil, errors.New("Error processing discriminator field 'typeId'")
}
} else {
return nil, errors.New("Invalid data")
}
switch discriminator {
case "cart-discount":
new := CartDiscountReference{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "cart":
new := CartReference{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "category":
new := CategoryReference{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "channel":
new := ChannelReference{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "key-value-document":
new := CustomObjectReference{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "customer-group":
new := CustomerGroupReference{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "customer":
new := CustomerReference{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "discount-code":
new := DiscountCodeReference{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "inventory-entry":
new := InventoryEntryReference{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "order-edit":
new := OrderEditReference{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "order":
new := OrderReference{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "payment":
new := PaymentReference{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "product-discount":
new := ProductDiscountReference{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "product":
new := ProductReference{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "product-type":
new := ProductTypeReference{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "review":
new := ReviewReference{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "shipping-method":
new := ShippingMethodReference{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "shopping-list":
new := ShoppingListReference{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "state":
new := StateReference{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "store":
new := StoreReference{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "tax-category":
new := TaxCategoryReference{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "type":
new := TypeReference{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "zone":
new := ZoneReference{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
}
return nil, nil
}
// ResourceIdentifier uses typeId as discriminator attribute
type ResourceIdentifier interface{}
func mapDiscriminatorResourceIdentifier(input interface{}) (ResourceIdentifier, error) {
var discriminator string
if data, ok := input.(map[string]interface{}); ok {
discriminator, ok = data["typeId"].(string)
if !ok {
return nil, errors.New("Error processing discriminator field 'typeId'")
}
} else {
return nil, errors.New("Invalid data")
}
switch discriminator {
case "cart-discount":
new := CartDiscountResourceIdentifier{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "cart":
new := CartResourceIdentifier{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "category":
new := CategoryResourceIdentifier{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "channel":
new := ChannelResourceIdentifier{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "customer-group":
new := CustomerGroupResourceIdentifier{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "customer":
new := CustomerResourceIdentifier{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "discount-code":
new := DiscountCodeResourceIdentifier{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "inventory-entry":
new := InventoryEntryResourceIdentifier{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "order-edit":
new := OrderEditResourceIdentifier{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "order":
new := OrderResourceIdentifier{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "payment":
new := PaymentResourceIdentifier{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "product-discount":
new := ProductDiscountResourceIdentifier{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "product":
new := ProductResourceIdentifier{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "product-type":
new := ProductTypeResourceIdentifier{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "review":
new := ReviewResourceIdentifier{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "shipping-method":
new := ShippingMethodResourceIdentifier{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "shopping-list":
new := ShoppingListResourceIdentifier{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "state":
new := StateResourceIdentifier{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "store":
new := StoreResourceIdentifier{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "tax-category":
new := TaxCategoryResourceIdentifier{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "type":
new := TypeResourceIdentifier{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "zone":
new := ZoneResourceIdentifier{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
}
return nil, nil
}
// TypedMoney uses type as discriminator attribute
type TypedMoney interface{}
func mapDiscriminatorTypedMoney(input interface{}) (TypedMoney, error) {
var discriminator string
if data, ok := input.(map[string]interface{}); ok {
discriminator, ok = data["type"].(string)
if !ok {
return nil, errors.New("Error processing discriminator field 'type'")
}
} else {
return nil, errors.New("Invalid data")
}
switch discriminator {
case "centPrecision":
new := CentPrecisionMoney{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "highPrecision":
new := HighPrecisionMoney{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
}
return nil, nil
}
// TypedMoneyDraft uses type as discriminator attribute
type TypedMoneyDraft interface{}
func mapDiscriminatorTypedMoneyDraft(input interface{}) (TypedMoneyDraft, error) {
var discriminator string
if data, ok := input.(map[string]interface{}); ok {
discriminator, ok = data["type"].(string)
if !ok {
return nil, errors.New("Error processing discriminator field 'type'")
}
} else {
return nil, errors.New("Invalid data")
}
switch discriminator {
case "centPrecision":
new := CentPrecisionMoneyDraft{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "highPrecision":
new := HighPrecisionMoneyDraft{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
}
return nil, nil
}
// Address is a standalone struct
type Address struct {
Title string `json:"title,omitempty"`
StreetNumber string `json:"streetNumber,omitempty"`
StreetName string `json:"streetName,omitempty"`
State string `json:"state,omitempty"`
Salutation string `json:"salutation,omitempty"`
Region string `json:"region,omitempty"`
PostalCode string `json:"postalCode,omitempty"`
Phone string `json:"phone,omitempty"`
POBox string `json:"pOBox,omitempty"`
Mobile string `json:"mobile,omitempty"`
LastName string `json:"lastName,omitempty"`
Key string `json:"key,omitempty"`
ID string `json:"id,omitempty"`
FirstName string `json:"firstName,omitempty"`
Fax string `json:"fax,omitempty"`
ExternalID string `json:"externalId,omitempty"`
Email string `json:"email,omitempty"`
Department string `json:"department,omitempty"`
Country CountryCode `json:"country"`
Company string `json:"company,omitempty"`
City string `json:"city,omitempty"`
Building string `json:"building,omitempty"`
Apartment string `json:"apartment,omitempty"`
AdditionalStreetInfo string `json:"additionalStreetInfo,omitempty"`
AdditionalAddressInfo string `json:"additionalAddressInfo,omitempty"`
Custom *CustomFields `json:"custom,omitempty"`
}
// Address is a standalone struct
type AddressDraft struct {
Title string `json:"title,omitempty"`
StreetNumber string `json:"streetNumber,omitempty"`
StreetName string `json:"streetName,omitempty"`
State string `json:"state,omitempty"`
Salutation string `json:"salutation,omitempty"`
Region string `json:"region,omitempty"`
PostalCode string `json:"postalCode,omitempty"`
Phone string `json:"phone,omitempty"`
POBox string `json:"pOBox,omitempty"`
Mobile string `json:"mobile,omitempty"`
LastName string `json:"lastName,omitempty"`
Key string `json:"key,omitempty"`
ID string `json:"id,omitempty"`
FirstName string `json:"firstName,omitempty"`
Fax string `json:"fax,omitempty"`
ExternalID string `json:"externalId,omitempty"`
Email string `json:"email,omitempty"`
Department string `json:"department,omitempty"`
Country CountryCode `json:"country"`
Company string `json:"company,omitempty"`
City string `json:"city,omitempty"`
Building string `json:"building,omitempty"`
Apartment string `json:"apartment,omitempty"`
AdditionalStreetInfo string `json:"additionalStreetInfo,omitempty"`
AdditionalAddressInfo string `json:"additionalAddressInfo,omitempty"`
Custom *CustomFieldsDraft `json:"custom,omitempty"`
}
// Asset is a standalone struct
type Asset struct {
Tags []string `json:"tags,omitempty"`
Sources []AssetSource `json:"sources"`
Name *LocalizedString `json:"name"`
Key string `json:"key,omitempty"`
ID string `json:"id"`
Description *LocalizedString `json:"description,omitempty"`
Custom *CustomFields `json:"custom,omitempty"`
}
// AssetDimensions is a standalone struct
type AssetDimensions struct {
W float64 `json:"w"`
H float64 `json:"h"`
}
// AssetDraft is a standalone struct
type AssetDraft struct {
Tags []string `json:"tags,omitempty"`
Sources []AssetSource `json:"sources"`
Name *LocalizedString `json:"name"`
Key string `json:"key,omitempty"`
Description *LocalizedString `json:"description,omitempty"`
Custom *CustomFieldsDraft `json:"custom,omitempty"`
}
// AssetSource is a standalone struct
type AssetSource struct {
URI string `json:"uri"`
Key string `json:"key,omitempty"`
Dimensions *AssetDimensions `json:"dimensions,omitempty"`
ContentType string `json:"contentType,omitempty"`
}
// BaseResource is a standalone struct
type BaseResource struct {
Version int `json:"version"`
LastModifiedAt time.Time `json:"lastModifiedAt"`
ID string `json:"id"`
CreatedAt time.Time `json:"createdAt"`
}
// CentPrecisionMoney implements the interface TypedMoney
type CentPrecisionMoney struct {
FractionDigits float64 `json:"fractionDigits"`
CurrencyCode CurrencyCode `json:"currencyCode"`
CentAmount int `json:"centAmount"`
}
// MarshalJSON override to set the discriminator value
func (obj CentPrecisionMoney) MarshalJSON() ([]byte, error) {
type Alias CentPrecisionMoney
return json.Marshal(struct {
Type string `json:"type"`
*Alias
}{Type: "centPrecision", Alias: (*Alias)(&obj)})
}
// CentPrecisionMoneyDraft implements the interface TypedMoneyDraft
type CentPrecisionMoneyDraft struct {
CurrencyCode CurrencyCode `json:"currencyCode"`
CentAmount int `json:"centAmount"`
}
// MarshalJSON override to set the discriminator value
func (obj CentPrecisionMoneyDraft) MarshalJSON() ([]byte, error) {
type Alias CentPrecisionMoneyDraft
return json.Marshal(struct {
Type string `json:"type"`
*Alias
}{Type: "centPrecision", Alias: (*Alias)(&obj)})
}
// ClientLogging is a standalone struct
type ClientLogging struct {
ExternalUserID string `json:"externalUserId,omitempty"`
Customer *CustomerReference `json:"customer,omitempty"`
ClientID string `json:"clientId,omitempty"`
AnonymousID string `json:"anonymousId,omitempty"`
}
// CreatedBy is of type ClientLogging
type CreatedBy struct {
ExternalUserID string `json:"externalUserId,omitempty"`
Customer *CustomerReference `json:"customer,omitempty"`
ClientID string `json:"clientId,omitempty"`
AnonymousID string `json:"anonymousId,omitempty"`
}
// DiscountedPrice is a standalone struct
type DiscountedPrice struct {
Value *Money `json:"value"`
Discount *ProductDiscountReference `json:"discount"`
}
// GeoJSONPoint implements the interface GeoJSON
type GeoJSONPoint struct {
Coordinates []float64 `json:"coordinates"`
}
// MarshalJSON override to set the discriminator value
func (obj GeoJSONPoint) MarshalJSON() ([]byte, error) {
type Alias GeoJSONPoint
return json.Marshal(struct {
Type string `json:"type"`
*Alias
}{Type: "Point", Alias: (*Alias)(&obj)})
}
// HighPrecisionMoney implements the interface TypedMoney
type HighPrecisionMoney struct {
FractionDigits float64 `json:"fractionDigits"`
CurrencyCode CurrencyCode `json:"currencyCode"`
CentAmount int `json:"centAmount"`
PreciseAmount int `json:"preciseAmount"`
}
// MarshalJSON override to set the discriminator value
func (obj HighPrecisionMoney) MarshalJSON() ([]byte, error) {
type Alias HighPrecisionMoney
return json.Marshal(struct {
Type string `json:"type"`
*Alias
}{Type: "highPrecision", Alias: (*Alias)(&obj)})
}
// HighPrecisionMoneyDraft implements the interface TypedMoneyDraft
type HighPrecisionMoneyDraft struct {
CurrencyCode CurrencyCode `json:"currencyCode"`
CentAmount int `json:"centAmount"`
PreciseAmount int `json:"preciseAmount"`
}
// MarshalJSON override to set the discriminator value
func (obj HighPrecisionMoneyDraft) MarshalJSON() ([]byte, error) {
type Alias HighPrecisionMoneyDraft
return json.Marshal(struct {
Type string `json:"type"`
*Alias
}{Type: "highPrecision", Alias: (*Alias)(&obj)})
}
// Image is a standalone struct
type Image struct {
URL string `json:"url"`
Label string `json:"label,omitempty"`
Dimensions *ImageDimensions `json:"dimensions"`
}
// ImageDimensions is a standalone struct
type ImageDimensions struct {
W float64 `json:"w"`
H float64 `json:"h"`
}
// LastModifiedBy is of type ClientLogging
type LastModifiedBy struct {
ExternalUserID string `json:"externalUserId,omitempty"`
Customer *CustomerReference `json:"customer,omitempty"`
ClientID string `json:"clientId,omitempty"`
AnonymousID string `json:"anonymousId,omitempty"`
}
// Money is a standalone struct
type Money struct {
CurrencyCode CurrencyCode `json:"currencyCode"`
CentAmount int `json:"centAmount"`
}
// PagedQueryResponse is a standalone struct
type PagedQueryResponse struct {
Total int `json:"total,omitempty"`
Results []BaseResource `json:"results"`
Offset int `json:"offset"`
Meta interface{} `json:"meta,omitempty"`
Limit int `json:"limit"`
Facets *FacetResults `json:"facets,omitempty"`
Count int `json:"count"`
}
// Price is a standalone struct
type Price struct {
Value TypedMoney `json:"value"`
ValidUntil *time.Time `json:"validUntil,omitempty"`
ValidFrom *time.Time `json:"validFrom,omitempty"`
Tiers []PriceTier `json:"tiers,omitempty"`
ID string `json:"id"`
Discounted *DiscountedPrice `json:"discounted,omitempty"`
CustomerGroup *CustomerGroupReference `json:"customerGroup,omitempty"`
Custom *CustomFields `json:"custom,omitempty"`
Country CountryCode `json:"country,omitempty"`
Channel *ChannelReference `json:"channel,omitempty"`
}
// UnmarshalJSON override to deserialize correct attribute types based
// on the discriminator value
func (obj *Price) UnmarshalJSON(data []byte) error {
type Alias Price
if err := json.Unmarshal(data, (*Alias)(obj)); err != nil {
return err
}
if obj.Value != nil {
var err error
obj.Value, err = mapDiscriminatorTypedMoney(obj.Value)
if err != nil {
return err
}
}
return nil
}
// PriceDraft is a standalone struct
type PriceDraft struct {
Value *Money `json:"value"`
ValidUntil *time.Time `json:"validUntil,omitempty"`
ValidFrom *time.Time `json:"validFrom,omitempty"`
Tiers []PriceTierDraft `json:"tiers,omitempty"`
Discounted *DiscountedPrice `json:"discounted,omitempty"`
CustomerGroup *CustomerGroupResourceIdentifier `json:"customerGroup,omitempty"`
Custom *CustomFieldsDraft `json:"custom,omitempty"`
Country CountryCode `json:"country,omitempty"`
Channel *ChannelResourceIdentifier `json:"channel,omitempty"`
}
// PriceTier is a standalone struct
type PriceTier struct {
Value TypedMoney `json:"value"`
MinimumQuantity int `json:"minimumQuantity"`
}
// UnmarshalJSON override to deserialize correct attribute types based
// on the discriminator value
func (obj *PriceTier) UnmarshalJSON(data []byte) error {
type Alias PriceTier
if err := json.Unmarshal(data, (*Alias)(obj)); err != nil {
return err
}
if obj.Value != nil {
var err error
obj.Value, err = mapDiscriminatorTypedMoney(obj.Value)
if err != nil {
return err
}
}
return nil
}
// PriceTierDraft is a standalone struct
type PriceTierDraft struct {
Value *Money `json:"value"`
MinimumQuantity int `json:"minimumQuantity"`
}
// QueryPrice is a standalone struct
type QueryPrice struct {
Value *Money `json:"value"`
ValidUntil *time.Time `json:"validUntil,omitempty"`
ValidFrom *time.Time `json:"validFrom,omitempty"`
Tiers []PriceTierDraft `json:"tiers,omitempty"`
ID string `json:"id"`
Discounted *DiscountedPrice `json:"discounted,omitempty"`
CustomerGroup *CustomerGroupReference `json:"customerGroup,omitempty"`
Custom *CustomFields `json:"custom,omitempty"`
Country CountryCode `json:"country,omitempty"`
Channel *ChannelReference `json:"channel,omitempty"`
}
// ScopedPrice is a standalone struct
type ScopedPrice struct {
Value TypedMoney `json:"value"`
ValidUntil *time.Time `json:"validUntil,omitempty"`
ValidFrom *time.Time `json:"validFrom,omitempty"`
ID string `json:"id"`
Discounted *DiscountedPrice `json:"discounted,omitempty"`
CustomerGroup *CustomerGroupReference `json:"customerGroup,omitempty"`
Custom *CustomFields `json:"custom,omitempty"`
CurrentValue TypedMoney `json:"currentValue"`
Country CountryCode `json:"country,omitempty"`
Channel *ChannelReference `json:"channel,omitempty"`
}
// UnmarshalJSON override to deserialize correct attribute types based
// on the discriminator value
func (obj *ScopedPrice) UnmarshalJSON(data []byte) error {
type Alias ScopedPrice
if err := json.Unmarshal(data, (*Alias)(obj)); err != nil {
return err
}
if obj.CurrentValue != nil {
var err error
obj.CurrentValue, err = mapDiscriminatorTypedMoney(obj.CurrentValue)
if err != nil {
return err
}
}
if obj.Value != nil {
var err error
obj.Value, err = mapDiscriminatorTypedMoney(obj.Value)
if err != nil {
return err
}
}
return nil
}
// Update is a standalone struct
type Update struct {
Version int `json:"version"`
Actions []UpdateAction `json:"actions"`
}
// UpdateAction is a standalone struct
type UpdateAction struct {
Action string `json:"action"`
}