forked from labd/commercetools-go-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types_cart.go
1969 lines (1772 loc) · 65.3 KB
/
types_cart.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
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Automatically generated, do not edit
package commercetools
import (
"encoding/json"
"errors"
"time"
)
// CartOrigin is an enum type
type CartOrigin string
// Enum values for CartOrigin
const (
CartOriginCustomer CartOrigin = "Customer"
CartOriginMerchant CartOrigin = "Merchant"
)
// CartState is an enum type
type CartState string
// Enum values for CartState
const (
CartStateActive CartState = "Active"
CartStateMerged CartState = "Merged"
CartStateOrdered CartState = "Ordered"
)
// DiscountCodeState is an enum type
type DiscountCodeState string
// Enum values for DiscountCodeState
const (
DiscountCodeStateNotActive DiscountCodeState = "NotActive"
DiscountCodeStateDoesNotMatchCart DiscountCodeState = "DoesNotMatchCart"
DiscountCodeStateMatchesCart DiscountCodeState = "MatchesCart"
DiscountCodeStateMaxApplicationReached DiscountCodeState = "MaxApplicationReached"
DiscountCodeStateApplicationStoppedByPreviousDiscount DiscountCodeState = "ApplicationStoppedByPreviousDiscount"
DiscountCodeStateNotValid DiscountCodeState = "NotValid"
)
// InventoryMode is an enum type
type InventoryMode string
// Enum values for InventoryMode
const (
InventoryModeTrackOnly InventoryMode = "TrackOnly"
InventoryModeReserveOnOrder InventoryMode = "ReserveOnOrder"
InventoryModeNone InventoryMode = "None"
)
// LineItemMode is an enum type
type LineItemMode string
// Enum values for LineItemMode
const (
LineItemModeStandard LineItemMode = "Standard"
LineItemModeGiftLineItem LineItemMode = "GiftLineItem"
)
// LineItemPriceMode is an enum type
type LineItemPriceMode string
// Enum values for LineItemPriceMode
const (
LineItemPriceModePlatform LineItemPriceMode = "Platform"
LineItemPriceModeExternalTotal LineItemPriceMode = "ExternalTotal"
LineItemPriceModeExternalPrice LineItemPriceMode = "ExternalPrice"
)
// ProductPublishScope is an enum type
type ProductPublishScope string
// Enum values for ProductPublishScope
const (
ProductPublishScopeAll ProductPublishScope = "All"
ProductPublishScopePrices ProductPublishScope = "Prices"
)
// RoundingMode is an enum type
type RoundingMode string
// Enum values for RoundingMode
const (
RoundingModeHalfEven RoundingMode = "HalfEven"
RoundingModeHalfUp RoundingMode = "HalfUp"
RoundingModeHalfDown RoundingMode = "HalfDown"
)
// ShippingMethodState is an enum type
type ShippingMethodState string
// Enum values for ShippingMethodState
const (
ShippingMethodStateDoesNotMatchCart ShippingMethodState = "DoesNotMatchCart"
ShippingMethodStateMatchesCart ShippingMethodState = "MatchesCart"
)
// TaxCalculationMode is an enum type
type TaxCalculationMode string
// Enum values for TaxCalculationMode
const (
TaxCalculationModeLineItemLevel TaxCalculationMode = "LineItemLevel"
TaxCalculationModeUnitPriceLevel TaxCalculationMode = "UnitPriceLevel"
)
// TaxMode is an enum type
type TaxMode string
// Enum values for TaxMode
const (
TaxModePlatform TaxMode = "Platform"
TaxModeExternal TaxMode = "External"
TaxModeExternalAmount TaxMode = "ExternalAmount"
TaxModeDisabled TaxMode = "Disabled"
)
// CartUpdateAction uses action as discriminator attribute
type CartUpdateAction interface{}
func mapDiscriminatorCartUpdateAction(input interface{}) (CartUpdateAction, error) {
var discriminator string
if data, ok := input.(map[string]interface{}); ok {
discriminator, ok = data["action"].(string)
if !ok {
return nil, errors.New("Error processing discriminator field 'action'")
}
} else {
return nil, errors.New("Invalid data")
}
switch discriminator {
case "addCustomLineItem":
new := CartAddCustomLineItemAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "addDiscountCode":
new := CartAddDiscountCodeAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "addItemShippingAddress":
new := CartAddItemShippingAddressAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "addLineItem":
new := CartAddLineItemAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "addPayment":
new := CartAddPaymentAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "addShoppingList":
new := CartAddShoppingListAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "applyDeltaToCustomLineItemShippingDetailsTargets":
new := CartApplyDeltaToCustomLineItemShippingDetailsTargetsAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "applyDeltaToLineItemShippingDetailsTargets":
new := CartApplyDeltaToLineItemShippingDetailsTargetsAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "changeCustomLineItemMoney":
new := CartChangeCustomLineItemMoneyAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "changeCustomLineItemQuantity":
new := CartChangeCustomLineItemQuantityAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "changeLineItemQuantity":
new := CartChangeLineItemQuantityAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "changeTaxCalculationMode":
new := CartChangeTaxCalculationModeAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "changeTaxMode":
new := CartChangeTaxModeAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "changeTaxRoundingMode":
new := CartChangeTaxRoundingModeAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "recalculate":
new := CartRecalculateAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "removeCustomLineItem":
new := CartRemoveCustomLineItemAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "removeDiscountCode":
new := CartRemoveDiscountCodeAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "removeItemShippingAddress":
new := CartRemoveItemShippingAddressAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "removeLineItem":
new := CartRemoveLineItemAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "removePayment":
new := CartRemovePaymentAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "setAnonymousId":
new := CartSetAnonymousIDAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "setBillingAddress":
new := CartSetBillingAddressAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "setCartTotalTax":
new := CartSetCartTotalTaxAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "setCountry":
new := CartSetCountryAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "setCustomField":
new := CartSetCustomFieldAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "setCustomLineItemCustomField":
new := CartSetCustomLineItemCustomFieldAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "setCustomLineItemCustomType":
new := CartSetCustomLineItemCustomTypeAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "setCustomLineItemShippingDetails":
new := CartSetCustomLineItemShippingDetailsAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "setCustomLineItemTaxAmount":
new := CartSetCustomLineItemTaxAmountAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "setCustomLineItemTaxRate":
new := CartSetCustomLineItemTaxRateAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "setCustomShippingMethod":
new := CartSetCustomShippingMethodAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "setCustomType":
new := CartSetCustomTypeAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "setCustomerEmail":
new := CartSetCustomerEmailAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "setCustomerGroup":
new := CartSetCustomerGroupAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "setCustomerId":
new := CartSetCustomerIDAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "setDeleteDaysAfterLastModification":
new := CartSetDeleteDaysAfterLastModificationAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "setLineItemCustomField":
new := CartSetLineItemCustomFieldAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "setLineItemCustomType":
new := CartSetLineItemCustomTypeAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "setLineItemDistributionChannel":
new := CartSetLineItemDistributionChannelAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "setLineItemPrice":
new := CartSetLineItemPriceAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "setLineItemShippingDetails":
new := CartSetLineItemShippingDetailsAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "setLineItemTaxAmount":
new := CartSetLineItemTaxAmountAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "setLineItemTaxRate":
new := CartSetLineItemTaxRateAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "setLineItemTotalPrice":
new := CartSetLineItemTotalPriceAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "setLocale":
new := CartSetLocaleAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "setShippingAddress":
new := CartSetShippingAddressAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "setShippingMethod":
new := CartSetShippingMethodAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "setShippingMethodTaxAmount":
new := CartSetShippingMethodTaxAmountAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "setShippingMethodTaxRate":
new := CartSetShippingMethodTaxRateAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "setShippingRateInput":
new := CartSetShippingRateInputAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
if new.ShippingRateInput != nil {
new.ShippingRateInput, err = mapDiscriminatorShippingRateInputDraft(new.ShippingRateInput)
if err != nil {
return nil, err
}
}
return new, nil
case "updateItemShippingAddress":
new := CartUpdateItemShippingAddressAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
}
return nil, nil
}
// ShippingRateInput uses type as discriminator attribute
type ShippingRateInput interface{}
func mapDiscriminatorShippingRateInput(input interface{}) (ShippingRateInput, 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 "Classification":
new := ClassificationShippingRateInput{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "Score":
new := ScoreShippingRateInput{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
}
return nil, nil
}
// ShippingRateInputDraft uses type as discriminator attribute
type ShippingRateInputDraft interface{}
func mapDiscriminatorShippingRateInputDraft(input interface{}) (ShippingRateInputDraft, 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 "Classification":
new := ClassificationShippingRateInputDraft{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "Score":
new := ScoreShippingRateInputDraft{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
}
return nil, nil
}
// Cart is of type BaseResource
type Cart struct {
Version int `json:"version"`
TotalPrice TypedMoney `json:"totalPrice"`
TaxedPrice *TaxedPrice `json:"taxedPrice,omitempty"`
TaxRoundingMode RoundingMode `json:"taxRoundingMode"`
TaxMode TaxMode `json:"taxMode"`
TaxCalculationMode TaxCalculationMode `json:"taxCalculationMode"`
Store *StoreKeyReference `json:"store,omitempty"`
ShippingRateInput ShippingRateInput `json:"shippingRateInput,omitempty"`
ShippingInfo *ShippingInfo `json:"shippingInfo,omitempty"`
ShippingAddress *Address `json:"shippingAddress,omitempty"`
RefusedGifts []CartDiscountReference `json:"refusedGifts"`
PaymentInfo *PaymentInfo `json:"paymentInfo,omitempty"`
Origin CartOrigin `json:"origin"`
Locale string `json:"locale,omitempty"`
LineItems []LineItem `json:"lineItems"`
LastModifiedBy *LastModifiedBy `json:"lastModifiedBy,omitempty"`
LastModifiedAt time.Time `json:"lastModifiedAt"`
ItemShippingAddresses []Address `json:"itemShippingAddresses,omitempty"`
InventoryMode InventoryMode `json:"inventoryMode,omitempty"`
ID string `json:"id"`
DiscountCodes []DiscountCodeInfo `json:"discountCodes,omitempty"`
DeleteDaysAfterLastModification int `json:"deleteDaysAfterLastModification,omitempty"`
CustomerID string `json:"customerId,omitempty"`
CustomerGroup *CustomerGroupReference `json:"customerGroup,omitempty"`
CustomerEmail string `json:"customerEmail,omitempty"`
CustomLineItems []CustomLineItem `json:"customLineItems"`
Custom *CustomFields `json:"custom,omitempty"`
CreatedBy *CreatedBy `json:"createdBy,omitempty"`
CreatedAt time.Time `json:"createdAt"`
Country CountryCode `json:"country,omitempty"`
CartState CartState `json:"cartState"`
BillingAddress *Address `json:"billingAddress,omitempty"`
AnonymousID string `json:"anonymousId,omitempty"`
}
// UnmarshalJSON override to deserialize correct attribute types based
// on the discriminator value
func (obj *Cart) UnmarshalJSON(data []byte) error {
type Alias Cart
if err := json.Unmarshal(data, (*Alias)(obj)); err != nil {
return err
}
if obj.ShippingRateInput != nil {
var err error
obj.ShippingRateInput, err = mapDiscriminatorShippingRateInput(obj.ShippingRateInput)
if err != nil {
return err
}
}
if obj.TotalPrice != nil {
var err error
obj.TotalPrice, err = mapDiscriminatorTypedMoney(obj.TotalPrice)
if err != nil {
return err
}
}
return nil
}
// CartAddCustomLineItemAction implements the interface CartUpdateAction
type CartAddCustomLineItemAction struct {
TaxCategory *TaxCategoryResourceIdentifier `json:"taxCategory,omitempty"`
Slug string `json:"slug"`
Quantity int `json:"quantity"`
Name *LocalizedString `json:"name"`
Money *Money `json:"money"`
ExternalTaxRate *ExternalTaxRateDraft `json:"externalTaxRate,omitempty"`
Custom *CustomFieldsDraft `json:"custom,omitempty"`
}
// MarshalJSON override to set the discriminator value
func (obj CartAddCustomLineItemAction) MarshalJSON() ([]byte, error) {
type Alias CartAddCustomLineItemAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "addCustomLineItem", Alias: (*Alias)(&obj)})
}
// CartAddDiscountCodeAction implements the interface CartUpdateAction
type CartAddDiscountCodeAction struct {
Code string `json:"code"`
}
// MarshalJSON override to set the discriminator value
func (obj CartAddDiscountCodeAction) MarshalJSON() ([]byte, error) {
type Alias CartAddDiscountCodeAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "addDiscountCode", Alias: (*Alias)(&obj)})
}
// CartAddItemShippingAddressAction implements the interface CartUpdateAction
type CartAddItemShippingAddressAction struct {
Address *Address `json:"address"`
}
// MarshalJSON override to set the discriminator value
func (obj CartAddItemShippingAddressAction) MarshalJSON() ([]byte, error) {
type Alias CartAddItemShippingAddressAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "addItemShippingAddress", Alias: (*Alias)(&obj)})
}
// CartAddLineItemAction implements the interface CartUpdateAction
type CartAddLineItemAction struct {
VariantID int `json:"variantId,omitempty"`
SupplyChannel *ChannelResourceIdentifier `json:"supplyChannel,omitempty"`
SKU string `json:"sku,omitempty"`
ShippingDetails *ItemShippingDetailsDraft `json:"shippingDetails,omitempty"`
Quantity int `json:"quantity,omitempty"`
ProductID string `json:"productId,omitempty"`
ExternalTotalPrice *ExternalLineItemTotalPrice `json:"externalTotalPrice,omitempty"`
ExternalTaxRate *ExternalTaxRateDraft `json:"externalTaxRate,omitempty"`
ExternalPrice *Money `json:"externalPrice,omitempty"`
DistributionChannel *ChannelResourceIdentifier `json:"distributionChannel,omitempty"`
Custom *CustomFieldsDraft `json:"custom,omitempty"`
}
// MarshalJSON override to set the discriminator value
func (obj CartAddLineItemAction) MarshalJSON() ([]byte, error) {
type Alias CartAddLineItemAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "addLineItem", Alias: (*Alias)(&obj)})
}
// CartAddPaymentAction implements the interface CartUpdateAction
type CartAddPaymentAction struct {
Payment *PaymentResourceIdentifier `json:"payment"`
}
// MarshalJSON override to set the discriminator value
func (obj CartAddPaymentAction) MarshalJSON() ([]byte, error) {
type Alias CartAddPaymentAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "addPayment", Alias: (*Alias)(&obj)})
}
// CartAddShoppingListAction implements the interface CartUpdateAction
type CartAddShoppingListAction struct {
SupplyChannel *ChannelResourceIdentifier `json:"supplyChannel,omitempty"`
ShoppingList *ShoppingListResourceIdentifier `json:"shoppingList"`
DistributionChannel *ChannelResourceIdentifier `json:"distributionChannel,omitempty"`
}
// MarshalJSON override to set the discriminator value
func (obj CartAddShoppingListAction) MarshalJSON() ([]byte, error) {
type Alias CartAddShoppingListAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "addShoppingList", Alias: (*Alias)(&obj)})
}
// CartApplyDeltaToCustomLineItemShippingDetailsTargetsAction implements the interface CartUpdateAction
type CartApplyDeltaToCustomLineItemShippingDetailsTargetsAction struct {
TargetsDelta []ItemShippingTarget `json:"targetsDelta"`
CustomLineItemID string `json:"customLineItemId"`
}
// MarshalJSON override to set the discriminator value
func (obj CartApplyDeltaToCustomLineItemShippingDetailsTargetsAction) MarshalJSON() ([]byte, error) {
type Alias CartApplyDeltaToCustomLineItemShippingDetailsTargetsAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "applyDeltaToCustomLineItemShippingDetailsTargets", Alias: (*Alias)(&obj)})
}
// CartApplyDeltaToLineItemShippingDetailsTargetsAction implements the interface CartUpdateAction
type CartApplyDeltaToLineItemShippingDetailsTargetsAction struct {
TargetsDelta []ItemShippingTarget `json:"targetsDelta"`
LineItemID string `json:"lineItemId"`
}
// MarshalJSON override to set the discriminator value
func (obj CartApplyDeltaToLineItemShippingDetailsTargetsAction) MarshalJSON() ([]byte, error) {
type Alias CartApplyDeltaToLineItemShippingDetailsTargetsAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "applyDeltaToLineItemShippingDetailsTargets", Alias: (*Alias)(&obj)})
}
// CartChangeCustomLineItemMoneyAction implements the interface CartUpdateAction
type CartChangeCustomLineItemMoneyAction struct {
Money *Money `json:"money"`
CustomLineItemID string `json:"customLineItemId"`
}
// MarshalJSON override to set the discriminator value
func (obj CartChangeCustomLineItemMoneyAction) MarshalJSON() ([]byte, error) {
type Alias CartChangeCustomLineItemMoneyAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "changeCustomLineItemMoney", Alias: (*Alias)(&obj)})
}
// CartChangeCustomLineItemQuantityAction implements the interface CartUpdateAction
type CartChangeCustomLineItemQuantityAction struct {
Quantity int `json:"quantity"`
CustomLineItemID string `json:"customLineItemId"`
}
// MarshalJSON override to set the discriminator value
func (obj CartChangeCustomLineItemQuantityAction) MarshalJSON() ([]byte, error) {
type Alias CartChangeCustomLineItemQuantityAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "changeCustomLineItemQuantity", Alias: (*Alias)(&obj)})
}
// CartChangeLineItemQuantityAction implements the interface CartUpdateAction
type CartChangeLineItemQuantityAction struct {
Quantity int `json:"quantity"`
LineItemID string `json:"lineItemId"`
ExternalTotalPrice *ExternalLineItemTotalPrice `json:"externalTotalPrice,omitempty"`
ExternalPrice *Money `json:"externalPrice,omitempty"`
}
// MarshalJSON override to set the discriminator value
func (obj CartChangeLineItemQuantityAction) MarshalJSON() ([]byte, error) {
type Alias CartChangeLineItemQuantityAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "changeLineItemQuantity", Alias: (*Alias)(&obj)})
}
// CartChangeTaxCalculationModeAction implements the interface CartUpdateAction
type CartChangeTaxCalculationModeAction struct {
TaxCalculationMode TaxCalculationMode `json:"taxCalculationMode"`
}
// MarshalJSON override to set the discriminator value
func (obj CartChangeTaxCalculationModeAction) MarshalJSON() ([]byte, error) {
type Alias CartChangeTaxCalculationModeAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "changeTaxCalculationMode", Alias: (*Alias)(&obj)})
}
// CartChangeTaxModeAction implements the interface CartUpdateAction
type CartChangeTaxModeAction struct {
TaxMode TaxMode `json:"taxMode"`
}
// MarshalJSON override to set the discriminator value
func (obj CartChangeTaxModeAction) MarshalJSON() ([]byte, error) {
type Alias CartChangeTaxModeAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "changeTaxMode", Alias: (*Alias)(&obj)})
}
// CartChangeTaxRoundingModeAction implements the interface CartUpdateAction
type CartChangeTaxRoundingModeAction struct {
TaxRoundingMode RoundingMode `json:"taxRoundingMode"`
}
// MarshalJSON override to set the discriminator value
func (obj CartChangeTaxRoundingModeAction) MarshalJSON() ([]byte, error) {
type Alias CartChangeTaxRoundingModeAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "changeTaxRoundingMode", Alias: (*Alias)(&obj)})
}
// CartDraft is a standalone struct
type CartDraft struct {
TaxRoundingMode RoundingMode `json:"taxRoundingMode,omitempty"`
TaxMode TaxMode `json:"taxMode,omitempty"`
TaxCalculationMode TaxCalculationMode `json:"taxCalculationMode,omitempty"`
Store *StoreResourceIdentifier `json:"store,omitempty"`
ShippingRateInput ShippingRateInputDraft `json:"shippingRateInput,omitempty"`
ShippingMethod *ShippingMethodResourceIdentifier `json:"shippingMethod,omitempty"`
ShippingAddress *Address `json:"shippingAddress,omitempty"`
Origin CartOrigin `json:"origin,omitempty"`
Locale string `json:"locale,omitempty"`
LineItems []LineItemDraft `json:"lineItems,omitempty"`
ItemShippingAddresses []Address `json:"itemShippingAddresses,omitempty"`
InventoryMode InventoryMode `json:"inventoryMode,omitempty"`
ExternalTaxRateForShippingMethod *ExternalTaxRateDraft `json:"externalTaxRateForShippingMethod,omitempty"`
DiscountCodes []string `json:"discountCodes,omitempty"`
DeleteDaysAfterLastModification int `json:"deleteDaysAfterLastModification,omitempty"`
CustomerID string `json:"customerId,omitempty"`
CustomerGroup *CustomerGroupResourceIdentifier `json:"customerGroup,omitempty"`
CustomerEmail string `json:"customerEmail,omitempty"`
CustomLineItems []CustomLineItemDraft `json:"customLineItems,omitempty"`
Custom *CustomFieldsDraft `json:"custom,omitempty"`
Currency CurrencyCode `json:"currency"`
Country string `json:"country,omitempty"`
BillingAddress *Address `json:"billingAddress,omitempty"`
AnonymousID string `json:"anonymousId,omitempty"`
}
// UnmarshalJSON override to deserialize correct attribute types based
// on the discriminator value
func (obj *CartDraft) UnmarshalJSON(data []byte) error {
type Alias CartDraft
if err := json.Unmarshal(data, (*Alias)(obj)); err != nil {
return err
}
if obj.ShippingRateInput != nil {
var err error
obj.ShippingRateInput, err = mapDiscriminatorShippingRateInputDraft(obj.ShippingRateInput)
if err != nil {
return err
}
}
return nil
}
// CartPagedQueryResponse is a standalone struct
type CartPagedQueryResponse struct {
Total int `json:"total,omitempty"`
Results []Cart `json:"results"`
Offset int `json:"offset"`
Limit int `json:"limit"`
Count int `json:"count"`
}
// CartRecalculateAction implements the interface CartUpdateAction
type CartRecalculateAction struct {
UpdateProductData bool `json:"updateProductData"`
}
// MarshalJSON override to set the discriminator value
func (obj CartRecalculateAction) MarshalJSON() ([]byte, error) {
type Alias CartRecalculateAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "recalculate", Alias: (*Alias)(&obj)})
}
// CartReference implements the interface Reference
type CartReference struct {
ID string `json:"id"`
Obj *Cart `json:"obj,omitempty"`
}
// MarshalJSON override to set the discriminator value
func (obj CartReference) MarshalJSON() ([]byte, error) {
type Alias CartReference
return json.Marshal(struct {
TypeID string `json:"typeId"`
*Alias
}{TypeID: "cart", Alias: (*Alias)(&obj)})
}
// CartRemoveCustomLineItemAction implements the interface CartUpdateAction
type CartRemoveCustomLineItemAction struct {
CustomLineItemID string `json:"customLineItemId"`
}
// MarshalJSON override to set the discriminator value
func (obj CartRemoveCustomLineItemAction) MarshalJSON() ([]byte, error) {
type Alias CartRemoveCustomLineItemAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "removeCustomLineItem", Alias: (*Alias)(&obj)})
}
// CartRemoveDiscountCodeAction implements the interface CartUpdateAction
type CartRemoveDiscountCodeAction struct {
DiscountCode *DiscountCodeReference `json:"discountCode"`
}
// MarshalJSON override to set the discriminator value
func (obj CartRemoveDiscountCodeAction) MarshalJSON() ([]byte, error) {
type Alias CartRemoveDiscountCodeAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "removeDiscountCode", Alias: (*Alias)(&obj)})
}
// CartRemoveItemShippingAddressAction implements the interface CartUpdateAction
type CartRemoveItemShippingAddressAction struct {
AddressKey string `json:"addressKey"`
}
// MarshalJSON override to set the discriminator value
func (obj CartRemoveItemShippingAddressAction) MarshalJSON() ([]byte, error) {
type Alias CartRemoveItemShippingAddressAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "removeItemShippingAddress", Alias: (*Alias)(&obj)})
}
// CartRemoveLineItemAction implements the interface CartUpdateAction
type CartRemoveLineItemAction struct {
ShippingDetailsToRemove *ItemShippingDetailsDraft `json:"shippingDetailsToRemove,omitempty"`
Quantity int `json:"quantity,omitempty"`
LineItemID string `json:"lineItemId"`
ExternalTotalPrice *ExternalLineItemTotalPrice `json:"externalTotalPrice,omitempty"`
ExternalPrice *Money `json:"externalPrice,omitempty"`
}
// MarshalJSON override to set the discriminator value
func (obj CartRemoveLineItemAction) MarshalJSON() ([]byte, error) {
type Alias CartRemoveLineItemAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "removeLineItem", Alias: (*Alias)(&obj)})
}
// CartRemovePaymentAction implements the interface CartUpdateAction
type CartRemovePaymentAction struct {
Payment *PaymentResourceIdentifier `json:"payment"`
}
// MarshalJSON override to set the discriminator value
func (obj CartRemovePaymentAction) MarshalJSON() ([]byte, error) {
type Alias CartRemovePaymentAction
return json.Marshal(struct {