forked from labd/commercetools-go-sdk
/
types_product_selection.go
832 lines (758 loc) · 31.3 KB
/
types_product_selection.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
package platform
// Generated file, please do not change!!!
import (
"encoding/json"
"errors"
"time"
)
type AssignedProductReference struct {
// Reference to a Product that is assigned to the Product Selection.
Product ProductReference `json:"product"`
// The Variants of the Product that are included from the Product Selection.
//
// This field may exist only in Product Selections with `Individual` [ProductSelectionMode](ctp:api:type:ProductSelectionMode).
// In absence of this field, all Variants are deemed to be included.
VariantSelection ProductVariantSelection `json:"variantSelection,omitempty"`
// The Variants of the Product that are excluded from the Product Selection.
//
// This field may exist only in Product Selections with `IndividualExclusion` [ProductSelectionMode](ctp:api:type:ProductSelectionMode).
// In absence of this field, all Variants are deemed to be excluded.
VariantExclusion *ProductVariantExclusion `json:"variantExclusion,omitempty"`
}
// UnmarshalJSON override to deserialize correct attribute types based
// on the discriminator value
func (obj *AssignedProductReference) UnmarshalJSON(data []byte) error {
type Alias AssignedProductReference
if err := json.Unmarshal(data, (*Alias)(obj)); err != nil {
return err
}
if obj.VariantSelection != nil {
var err error
obj.VariantSelection, err = mapDiscriminatorProductVariantSelection(obj.VariantSelection)
if err != nil {
return err
}
}
return nil
}
type AssignedProductSelection struct {
// Reference to the Product Selection that this assignment is part of.
ProductSelection ProductSelectionReference `json:"productSelection"`
// Defines which Variants of the Product will be included in the Product Selection.
//
// This field is only available for assignments to a Product Selection with `Individual` [ProductSelectionMode](ctp:api:type:ProductSelectionMode).
VariantSelection ProductVariantSelection `json:"variantSelection,omitempty"`
// Defines which Variants of the Product will be excluded from the Product Selection.
//
// This field is only available for assignments to a Product Selection with `IndividualExclusion` [ProductSelectionMode](ctp:api:type:ProductSelectionMode).
VariantExclusion *ProductVariantExclusion `json:"variantExclusion,omitempty"`
// Date and time (UTC) this assignment was initially created.
CreatedAt time.Time `json:"createdAt"`
}
// UnmarshalJSON override to deserialize correct attribute types based
// on the discriminator value
func (obj *AssignedProductSelection) UnmarshalJSON(data []byte) error {
type Alias AssignedProductSelection
if err := json.Unmarshal(data, (*Alias)(obj)); err != nil {
return err
}
if obj.VariantSelection != nil {
var err error
obj.VariantSelection, err = mapDiscriminatorProductVariantSelection(obj.VariantSelection)
if err != nil {
return err
}
}
return nil
}
/**
* [PagedQueryResult](/general-concepts#pagedqueryresult) containing an array of [AssignedProductSelection](ctp:api:type:AssignedProductSelection).
*
*/
type AssignedProductSelectionPagedQueryResponse struct {
// Number of [results requested](/../api/general-concepts#limit).
Limit int `json:"limit"`
// Number of [elements skipped](/../api/general-concepts#offset).
Offset int `json:"offset"`
// Actual number of results returned.
Count int `json:"count"`
// Total number of results matching the query.
// This number is an estimation that is not [strongly consistent](/general-concepts#strong-consistency).
// Unlike other endpoints, the Product Selection endpoint does not return this field by default.
// To get `total`, pass the query parameter `withTotal` set to `true`.
// When the results are filtered with a [Query Predicate](/predicates/query), `total` is subject to a [limit](/limits#queries).
Total *int `json:"total,omitempty"`
// References to ProductSelection that are assigned to the Product.
Results []AssignedProductSelection `json:"results"`
}
type ProductSelection struct {
// Unique identifier of the ProductSelection.
ID string `json:"id"`
// Current version of the ProductSelection.
Version int `json:"version"`
// Date and time (UTC) the ProductSelection was initially created.
CreatedAt time.Time `json:"createdAt"`
// Date and time (UTC) the ProductSelection was last updated.
LastModifiedAt time.Time `json:"lastModifiedAt"`
// Present on resources updated after 1/02/2019 except for [events not tracked](/../api/client-logging#events-tracked).
LastModifiedBy *LastModifiedBy `json:"lastModifiedBy,omitempty"`
// Present on resources created after 1/02/2019 except for [events not tracked](/../api/client-logging#events-tracked).
CreatedBy *CreatedBy `json:"createdBy,omitempty"`
// User-defined unique identifier of the ProductSelection.
Key *string `json:"key,omitempty"`
// Name of the ProductSelection.
Name LocalizedString `json:"name"`
// Number of Products that are currently assigned to this ProductSelection.
ProductCount int `json:"productCount"`
// Specifies in which way the Products are assigned to the ProductSelection.
// Currently, the only way of doing this is to specify each Product individually, either by [including or excluding](ctp:api:type:ProductSelectionMode) them explicitly.
Type *ProductSelectionTypeEnum `json:"type,omitempty"`
// Specifies in which way the Products are assigned to the ProductSelection.
// Currently, the only way of doing this is to specify each Product individually, either by [including or excluding](ctp:api:type:ProductSelectionMode) them explicitly.
Mode ProductSelectionMode `json:"mode"`
// Custom Fields of the ProductSelection.
Custom *CustomFields `json:"custom,omitempty"`
}
/**
*
* Given the mode of Product Selection, this assignment refers to, it may contain:
*
* - `variantSelection` field for a Product Selection with `Individual` [ProductSelectionMode](ctp:api:type:ProductSelectionMode).
* - `variantExclusion` field for a Product Selection with `IndividualExclusion` [ProductSelectionMode](ctp:api:type:ProductSelectionMode) ([BETA](/../offering/api-contract#public-beta)).
*/
type ProductSelectionAssignment struct {
// Reference to a Product that is assigned to the ProductSelection.
Product ProductReference `json:"product"`
// Reference to the Product Selection that this assignment is part of.
ProductSelection ProductSelectionReference `json:"productSelection"`
// Define which Variants of the added Product will be included in the Product Selection.
//
// This field is only available for assignments to a Product Selection with `Individual` [ProductSelectionMode](ctp:api:type:ProductSelectionMode).
// The list of SKUs will be updated automatically on any change of those performed on the respective Product itself.
VariantSelection ProductVariantSelection `json:"variantSelection,omitempty"`
// Defines which Variants of the Product will be excluded from the Product Selection.
//
// This field is only available for assignments to a Product Selection with `IndividualExclusion` [ProductSelectionMode](ctp:api:type:ProductSelectionMode).
// The list of SKUs will be updated automatically on any change of those performed on the respective Product itself.
VariantExclusion *ProductVariantExclusion `json:"variantExclusion,omitempty"`
}
// UnmarshalJSON override to deserialize correct attribute types based
// on the discriminator value
func (obj *ProductSelectionAssignment) UnmarshalJSON(data []byte) error {
type Alias ProductSelectionAssignment
if err := json.Unmarshal(data, (*Alias)(obj)); err != nil {
return err
}
if obj.VariantSelection != nil {
var err error
obj.VariantSelection, err = mapDiscriminatorProductVariantSelection(obj.VariantSelection)
if err != nil {
return err
}
}
return nil
}
type ProductSelectionDraft struct {
// User-defined unique identifier for the ProductSelection.
Key *string `json:"key,omitempty"`
// Name of the ProductSelection. Not checked for uniqueness, but distinct names are recommended.
Name LocalizedString `json:"name"`
// Custom Fields of this ProductSelection.
Custom *CustomFieldsDraft `json:"custom,omitempty"`
// Type of the Product Selection.
Type *ProductSelectionTypeEnum `json:"type,omitempty"`
// Mode of the Product Selection.
Mode *ProductSelectionMode `json:"mode,omitempty"`
}
/**
* Product Selections can have the following modes:
*
*/
type ProductSelectionMode string
const (
ProductSelectionModeIndividual ProductSelectionMode = "Individual"
ProductSelectionModeIndividualExclusion ProductSelectionMode = "IndividualExclusion"
)
/**
* [PagedQueryResult](/general-concepts#pagedqueryresult) containing an array of [ProductSelection](ctp:api:type:ProductSelection).
*
*/
type ProductSelectionPagedQueryResponse struct {
// Number of [results requested](/../api/general-concepts#limit).
Limit int `json:"limit"`
// Number of [elements skipped](/../api/general-concepts#offset).
Offset int `json:"offset"`
// Actual number of results returned.
Count int `json:"count"`
// Total number of results matching the query.
// This number is an estimation that is not [strongly consistent](/general-concepts#strong-consistency).
// Unlike other endpoints, the Product Selection endpoint does not return this field by default.
// To get `total`, pass the query parameter `withTotal` set to `true`.
// When the results are filtered with a [Query Predicate](/predicates/query), `total` is subject to a [limit](/limits#queries).
Total *int `json:"total,omitempty"`
// [ProductSelections](ctp:api:type:ProductSelection) matching the query.
Results []ProductSelection `json:"results"`
}
/**
* [PagedQueryResult](/general-concepts#pagedqueryresult) containing an array of [AssignedProductReference](ctp:api:type:AssignedProductReference).
*
*/
type ProductSelectionProductPagedQueryResponse struct {
// Number of [results requested](/../api/general-concepts#limit).
Limit int `json:"limit"`
// Number of [elements skipped](/../api/general-concepts#offset).
Offset int `json:"offset"`
// Actual number of results returned.
Count int `json:"count"`
// Total number of results matching the query.
// This number is an estimation that is not [strongly consistent](/general-concepts#strong-consistency).
// Unlike other endpoints, the Product Selection endpoint does not return this field by default.
// To get `total`, pass the query parameter `withTotal` set to `true`.
// When the results are filtered with a [Query Predicate](/predicates/query), `total` is subject to a [limit](/limits#queries).
Total *int `json:"total,omitempty"`
// References to Products that are assigned to the ProductSelection.
Results []AssignedProductReference `json:"results"`
}
/**
* [Reference](ctp:api:type:Reference) to a [ProductSelection](ctp:api:type:ProductSelection).
*
*/
type ProductSelectionReference struct {
// Unique identifier of the referenced [ProductSelection](ctp:api:type:ProductSelection).
ID string `json:"id"`
// Contains the representation of the expanded ProductSelection. Only present in responses to requests with [Reference Expansion](/../api/general-concepts#reference-expansion) for ProductSelections.
Obj *ProductSelection `json:"obj,omitempty"`
}
// MarshalJSON override to set the discriminator value or remove
// optional nil slices
func (obj ProductSelectionReference) MarshalJSON() ([]byte, error) {
type Alias ProductSelectionReference
return json.Marshal(struct {
Action string `json:"typeId"`
*Alias
}{Action: "product-selection", Alias: (*Alias)(&obj)})
}
/**
* [ResourceIdentifier](ctp:api:type:ResourceIdentifier) to a [ProductSelection](ctp:api:type:ProductSelection).
*
*/
type ProductSelectionResourceIdentifier struct {
// Unique identifier of the referenced [ProductSelection](ctp:api:type:ProductSelection). Either `id` or `key` is required.
ID *string `json:"id,omitempty"`
// User-defined unique identifier of the referenced [ProductSelection](ctp:api:type:ProductSelection). Either `id` or `key` is required.
Key *string `json:"key,omitempty"`
}
// MarshalJSON override to set the discriminator value or remove
// optional nil slices
func (obj ProductSelectionResourceIdentifier) MarshalJSON() ([]byte, error) {
type Alias ProductSelectionResourceIdentifier
return json.Marshal(struct {
Action string `json:"typeId"`
*Alias
}{Action: "product-selection", Alias: (*Alias)(&obj)})
}
type ProductSelectionType interface{}
func mapDiscriminatorProductSelectionType(input interface{}) (ProductSelectionType, 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 "individualExclusion":
obj := IndividualExclusionProductSelectionType{}
if err := decodeStruct(input, &obj); err != nil {
return nil, err
}
return obj, nil
case "individual":
obj := IndividualProductSelectionType{}
if err := decodeStruct(input, &obj); err != nil {
return nil, err
}
return obj, nil
}
return nil, nil
}
type IndividualExclusionProductSelectionType struct {
// The name of the ProductSelection which is recommended to be unique.
Name LocalizedString `json:"name"`
}
// MarshalJSON override to set the discriminator value or remove
// optional nil slices
func (obj IndividualExclusionProductSelectionType) MarshalJSON() ([]byte, error) {
type Alias IndividualExclusionProductSelectionType
return json.Marshal(struct {
Action string `json:"type"`
*Alias
}{Action: "individualExclusion", Alias: (*Alias)(&obj)})
}
type IndividualProductSelectionType struct {
// The name of the ProductSelection which is recommended to be unique.
Name LocalizedString `json:"name"`
}
// MarshalJSON override to set the discriminator value or remove
// optional nil slices
func (obj IndividualProductSelectionType) MarshalJSON() ([]byte, error) {
type Alias IndividualProductSelectionType
return json.Marshal(struct {
Action string `json:"type"`
*Alias
}{Action: "individual", Alias: (*Alias)(&obj)})
}
/**
* The following types of Product Selections are supported:
*
*/
type ProductSelectionTypeEnum string
const (
ProductSelectionTypeEnumIndividual ProductSelectionTypeEnum = "individual"
ProductSelectionTypeEnumIndividualExclusion ProductSelectionTypeEnum = "individualExclusion"
)
type ProductSelectionUpdate struct {
Version int `json:"version"`
Actions []ProductSelectionUpdateAction `json:"actions"`
}
// UnmarshalJSON override to deserialize correct attribute types based
// on the discriminator value
func (obj *ProductSelectionUpdate) UnmarshalJSON(data []byte) error {
type Alias ProductSelectionUpdate
if err := json.Unmarshal(data, (*Alias)(obj)); err != nil {
return err
}
for i := range obj.Actions {
var err error
obj.Actions[i], err = mapDiscriminatorProductSelectionUpdateAction(obj.Actions[i])
if err != nil {
return err
}
}
return nil
}
type ProductSelectionUpdateAction interface{}
func mapDiscriminatorProductSelectionUpdateAction(input interface{}) (ProductSelectionUpdateAction, 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 "addProduct":
obj := ProductSelectionAddProductAction{}
if err := decodeStruct(input, &obj); err != nil {
return nil, err
}
if obj.VariantSelection != nil {
var err error
obj.VariantSelection, err = mapDiscriminatorProductVariantSelection(obj.VariantSelection)
if err != nil {
return nil, err
}
}
return obj, nil
case "changeName":
obj := ProductSelectionChangeNameAction{}
if err := decodeStruct(input, &obj); err != nil {
return nil, err
}
return obj, nil
case "excludeProduct":
obj := ProductSelectionExcludeProductAction{}
if err := decodeStruct(input, &obj); err != nil {
return nil, err
}
return obj, nil
case "removeProduct":
obj := ProductSelectionRemoveProductAction{}
if err := decodeStruct(input, &obj); err != nil {
return nil, err
}
return obj, nil
case "setCustomField":
obj := ProductSelectionSetCustomFieldAction{}
if err := decodeStruct(input, &obj); err != nil {
return nil, err
}
return obj, nil
case "setCustomType":
obj := ProductSelectionSetCustomTypeAction{}
if err := decodeStruct(input, &obj); err != nil {
return nil, err
}
return obj, nil
case "setKey":
obj := ProductSelectionSetKeyAction{}
if err := decodeStruct(input, &obj); err != nil {
return nil, err
}
return obj, nil
case "setVariantExclusion":
obj := ProductSelectionSetVariantExclusionAction{}
if err := decodeStruct(input, &obj); err != nil {
return nil, err
}
return obj, nil
case "setVariantSelection":
obj := ProductSelectionSetVariantSelectionAction{}
if err := decodeStruct(input, &obj); err != nil {
return nil, err
}
if obj.VariantSelection != nil {
var err error
obj.VariantSelection, err = mapDiscriminatorProductVariantSelection(obj.VariantSelection)
if err != nil {
return nil, err
}
}
return obj, nil
}
return nil, nil
}
/**
* Only Product Variants with the explicitly listed SKUs are part of a Product Selection with `IndividualExclusion` [ProductSelectionMode](ctp:api:type:ProductSelectionMode).
*
*/
type ProductVariantExclusion struct {
// Non-empty array of SKUs representing Product Variants to be included in the Product Selection with `IndividualExclusion` [ProductSelectionMode](ctp:api:type:ProductSelectionMode).
Skus []string `json:"skus"`
}
/**
* Polymorphic base type for Product Variant Selections. The actual type is determined by the `type` field.
*
*/
type ProductVariantSelection interface{}
func mapDiscriminatorProductVariantSelection(input interface{}) (ProductVariantSelection, 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 "exclusion":
obj := ProductVariantSelectionExclusion{}
if err := decodeStruct(input, &obj); err != nil {
return nil, err
}
return obj, nil
case "includeAllExcept":
obj := ProductVariantSelectionIncludeAllExcept{}
if err := decodeStruct(input, &obj); err != nil {
return nil, err
}
return obj, nil
case "includeOnly":
obj := ProductVariantSelectionIncludeOnly{}
if err := decodeStruct(input, &obj); err != nil {
return nil, err
}
return obj, nil
case "inclusion":
obj := ProductVariantSelectionInclusion{}
if err := decodeStruct(input, &obj); err != nil {
return nil, err
}
return obj, nil
}
return nil, nil
}
/**
* All Product Variants except the explicitly stated SKUs are part of the Product Selection.
*
*/
type ProductVariantSelectionExclusion struct {
// Non-empty array of SKUs representing Product Variants to be excluded from the Product Selection.
Skus []string `json:"skus"`
}
// MarshalJSON override to set the discriminator value or remove
// optional nil slices
func (obj ProductVariantSelectionExclusion) MarshalJSON() ([]byte, error) {
type Alias ProductVariantSelectionExclusion
return json.Marshal(struct {
Action string `json:"type"`
*Alias
}{Action: "exclusion", Alias: (*Alias)(&obj)})
}
/**
* All Product Variants except the explicitly stated SKUs are part of the Product Selection.
*
*/
type ProductVariantSelectionIncludeAllExcept struct {
// Non-empty array of SKUs representing Product Variants to be excluded from the Product Selection.
Skus []string `json:"skus"`
}
// MarshalJSON override to set the discriminator value or remove
// optional nil slices
func (obj ProductVariantSelectionIncludeAllExcept) MarshalJSON() ([]byte, error) {
type Alias ProductVariantSelectionIncludeAllExcept
return json.Marshal(struct {
Action string `json:"type"`
*Alias
}{Action: "includeAllExcept", Alias: (*Alias)(&obj)})
}
/**
* Only Product Variants with explicitly stated SKUs are part of the Product Selection.
*
*/
type ProductVariantSelectionIncludeOnly struct {
// Non-empty array of SKUs representing Product Variants to be included into the Product Selection.
Skus []string `json:"skus"`
}
// MarshalJSON override to set the discriminator value or remove
// optional nil slices
func (obj ProductVariantSelectionIncludeOnly) MarshalJSON() ([]byte, error) {
type Alias ProductVariantSelectionIncludeOnly
return json.Marshal(struct {
Action string `json:"type"`
*Alias
}{Action: "includeOnly", Alias: (*Alias)(&obj)})
}
/**
* Only Product Variants with explicitly stated SKUs are part of the Product Selection.
*
*/
type ProductVariantSelectionInclusion struct {
// Non-empty array of SKUs representing Product Variants to be included into the Product Selection.
Skus []string `json:"skus"`
}
// MarshalJSON override to set the discriminator value or remove
// optional nil slices
func (obj ProductVariantSelectionInclusion) MarshalJSON() ([]byte, error) {
type Alias ProductVariantSelectionInclusion
return json.Marshal(struct {
Action string `json:"type"`
*Alias
}{Action: "inclusion", Alias: (*Alias)(&obj)})
}
type ProductVariantSelectionTypeEnum string
const (
ProductVariantSelectionTypeEnumInclusion ProductVariantSelectionTypeEnum = "inclusion"
ProductVariantSelectionTypeEnumExclusion ProductVariantSelectionTypeEnum = "exclusion"
ProductVariantSelectionTypeEnumIncludeOnly ProductVariantSelectionTypeEnum = "includeOnly"
ProductVariantSelectionTypeEnumIncludeAllExcept ProductVariantSelectionTypeEnum = "includeAllExcept"
)
/**
* [PagedQueryResult](/general-concepts#pagedqueryresult) containing an array of [ProductSelectionAssignment](ctp:api:type:ProductSelectionAssignment).
*
*/
type ProductsInStorePagedQueryResponse struct {
// Number of [results requested](/../api/general-concepts#limit).
Limit int `json:"limit"`
// Number of [elements skipped](/../api/general-concepts#offset).
Offset int `json:"offset"`
// Actual number of results returned.
Count int `json:"count"`
// Total number of results matching the query.
// This number is an estimation that is not [strongly consistent](/general-concepts#strong-consistency).
// Unlike other endpoints, the Product Selection endpoint does not return this field by default.
// To get `total`, pass the query parameter `withTotal` set to `true`.
// When the results are filtered with a [Query Predicate](/predicates/query), `total` is subject to a [limit](/limits#queries).
Total *int `json:"total,omitempty"`
// ProductSelectionAssignments matching the query.
Results []ProductSelectionAssignment `json:"results"`
}
/**
* Adds a Product to the Product Selection.
*
* If the specified Product is already assigned to the Product Selection, but the existing Product Selection has a different Product Variant Selection, a [ProductPresentWithDifferentVariantSelection](ctp:api:type:ProductPresentWithDifferentVariantSelectionError) error is returned.
*
*/
type ProductSelectionAddProductAction struct {
// ResourceIdentifier of the Product
Product ProductResourceIdentifier `json:"product"`
// Defines which Variants of the Product will be included in the Product Selection.
// If not supplied all Variants are deemed to be included.
VariantSelection ProductVariantSelection `json:"variantSelection,omitempty"`
}
// UnmarshalJSON override to deserialize correct attribute types based
// on the discriminator value
func (obj *ProductSelectionAddProductAction) UnmarshalJSON(data []byte) error {
type Alias ProductSelectionAddProductAction
if err := json.Unmarshal(data, (*Alias)(obj)); err != nil {
return err
}
if obj.VariantSelection != nil {
var err error
obj.VariantSelection, err = mapDiscriminatorProductVariantSelection(obj.VariantSelection)
if err != nil {
return err
}
}
return nil
}
// MarshalJSON override to set the discriminator value or remove
// optional nil slices
func (obj ProductSelectionAddProductAction) MarshalJSON() ([]byte, error) {
type Alias ProductSelectionAddProductAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "addProduct", Alias: (*Alias)(&obj)})
}
type ProductSelectionChangeNameAction struct {
// The new name to be set for the ProductSelection.
Name LocalizedString `json:"name"`
}
// MarshalJSON override to set the discriminator value or remove
// optional nil slices
func (obj ProductSelectionChangeNameAction) MarshalJSON() ([]byte, error) {
type Alias ProductSelectionChangeNameAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "changeName", Alias: (*Alias)(&obj)})
}
/**
* Excludes a Product from a Product Selection with `IndividualExclusion` [ProductSelectionMode](ctp:api:type:ProductSelectionMode).
*
* If the specified Product is already assigned to the Product Selection, but the existing Product Selection has a different Product Variant Exclusion, a [ProductPresentWithDifferentVariantSelection](ctp:api:type:ProductPresentWithDifferentVariantSelectionError) error is returned.
*
*/
type ProductSelectionExcludeProductAction struct {
// ResourceIdentifier of the Product
Product ProductResourceIdentifier `json:"product"`
// Defines which Variants of the Product will be excluded from the Product Selection.
// If not supplied all Variants are deemed to be excluded.
VariantExclusion *ProductVariantExclusion `json:"variantExclusion,omitempty"`
}
// MarshalJSON override to set the discriminator value or remove
// optional nil slices
func (obj ProductSelectionExcludeProductAction) MarshalJSON() ([]byte, error) {
type Alias ProductSelectionExcludeProductAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "excludeProduct", Alias: (*Alias)(&obj)})
}
type ProductSelectionRemoveProductAction struct {
// ResourceIdentifier of the Product
Product ProductResourceIdentifier `json:"product"`
}
// MarshalJSON override to set the discriminator value or remove
// optional nil slices
func (obj ProductSelectionRemoveProductAction) MarshalJSON() ([]byte, error) {
type Alias ProductSelectionRemoveProductAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "removeProduct", Alias: (*Alias)(&obj)})
}
type ProductSelectionSetCustomFieldAction struct {
// Name of the [Custom Field](/../api/projects/custom-fields).
Name string `json:"name"`
// If `value` is absent or `null`, this field will be removed if it exists.
// Removing a field that does not exist returns an [InvalidOperation](ctp:api:type:InvalidOperationError) error.
// If `value` is provided, it is set for the field defined by `name`.
Value interface{} `json:"value,omitempty"`
}
// MarshalJSON override to set the discriminator value or remove
// optional nil slices
func (obj ProductSelectionSetCustomFieldAction) MarshalJSON() ([]byte, error) {
type Alias ProductSelectionSetCustomFieldAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "setCustomField", Alias: (*Alias)(&obj)})
}
type ProductSelectionSetCustomTypeAction struct {
// Defines the [Type](ctp:api:type:Type) that extends the ProductSelection with [Custom Fields](/../api/projects/custom-fields).
// If absent, any existing Type and Custom Fields are removed from the ProductSelection.
Type *TypeResourceIdentifier `json:"type,omitempty"`
// Sets the [Custom Fields](/../api/projects/custom-fields) fields for the ProductSelection.
Fields *FieldContainer `json:"fields,omitempty"`
}
// MarshalJSON override to set the discriminator value or remove
// optional nil slices
func (obj ProductSelectionSetCustomTypeAction) MarshalJSON() ([]byte, error) {
type Alias ProductSelectionSetCustomTypeAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "setCustomType", Alias: (*Alias)(&obj)})
}
type ProductSelectionSetKeyAction struct {
// If `key` is absent or `null`, the existing key, if any, will be removed.
Key *string `json:"key,omitempty"`
}
// MarshalJSON override to set the discriminator value or remove
// optional nil slices
func (obj ProductSelectionSetKeyAction) MarshalJSON() ([]byte, error) {
type Alias ProductSelectionSetKeyAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "setKey", Alias: (*Alias)(&obj)})
}
/**
* Updates the Product Variant Exclusion of an existing [Product Selection Assignment](ctp:api:type:ProductSelectionAssignment).
* A [ProductVariantExclusion](ctp:api:type:ProductVariantExclusion) can only be set if the [Product](ctp:api:type:Product) has already been excluded from the [Product Selection](ctp:api:type:ProductSelection) with `IndividualExclusion` [ProductSelectionMode](ctp:api:type:ProductSelectionMode).
*
* If the specified Product is not assigned to the Product Selection, a [ProductAssignmentMissing](ctp:api:type:ProductAssignmentMissingError) error is returned.
*
*/
type ProductSelectionSetVariantExclusionAction struct {
// ResourceIdentifier of the Product
Product ProductResourceIdentifier `json:"product"`
// Determines which Variants of the previously excluded Product are to be included in the Product Selection with `IndividualExclusion` [ProductSelectionMode](ctp:api:type:ProductSelectionMode).
// Leave it empty to unset an existing Variant Exclusion.
VariantExclusion *ProductVariantExclusion `json:"variantExclusion,omitempty"`
}
// MarshalJSON override to set the discriminator value or remove
// optional nil slices
func (obj ProductSelectionSetVariantExclusionAction) MarshalJSON() ([]byte, error) {
type Alias ProductSelectionSetVariantExclusionAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "setVariantExclusion", Alias: (*Alias)(&obj)})
}
/**
* Updates the Product Variant Selection of an existing [Product Selection Assignment](ctp:api:type:ProductSelectionAssignment).
* A [ProductVariantSelection](ctp:api:type:ProductVariantSelection) can only be set if the [Product](ctp:api:type:Product) has already been included in the Product Selection with `Individual` [ProductSelectionMode](ctp:api:type:ProductSelectionMode).
*
* If the specified Product is not assigned to the Product Selection, a [ProductAssignmentMissing](ctp:api:type:ProductAssignmentMissingError) error is returned.
*
*/
type ProductSelectionSetVariantSelectionAction struct {
// ResourceIdentifier of the Product
Product ProductResourceIdentifier `json:"product"`
// Determines which Variants of the previously added Product are to be included in, or excluded from, the Product Selection.
// Leave it empty to unset an existing Variant Selection.
VariantSelection ProductVariantSelection `json:"variantSelection,omitempty"`
}
// UnmarshalJSON override to deserialize correct attribute types based
// on the discriminator value
func (obj *ProductSelectionSetVariantSelectionAction) UnmarshalJSON(data []byte) error {
type Alias ProductSelectionSetVariantSelectionAction
if err := json.Unmarshal(data, (*Alias)(obj)); err != nil {
return err
}
if obj.VariantSelection != nil {
var err error
obj.VariantSelection, err = mapDiscriminatorProductVariantSelection(obj.VariantSelection)
if err != nil {
return err
}
}
return nil
}
// MarshalJSON override to set the discriminator value or remove
// optional nil slices
func (obj ProductSelectionSetVariantSelectionAction) MarshalJSON() ([]byte, error) {
type Alias ProductSelectionSetVariantSelectionAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "setVariantSelection", Alias: (*Alias)(&obj)})
}