forked from labd/commercetools-go-sdk
/
types_category.go
610 lines (552 loc) · 18.7 KB
/
types_category.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
// Automatically generated, do not edit
package commercetools
import (
"encoding/json"
"errors"
"time"
)
// CategoryUpdateAction uses action as discriminator attribute
type CategoryUpdateAction interface{}
func mapDiscriminatorCategoryUpdateAction(input interface{}) (CategoryUpdateAction, 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 "addAsset":
new := CategoryAddAssetAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "changeAssetName":
new := CategoryChangeAssetNameAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "changeAssetOrder":
new := CategoryChangeAssetOrderAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "changeName":
new := CategoryChangeNameAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "changeOrderHint":
new := CategoryChangeOrderHintAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "changeParent":
new := CategoryChangeParentAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "changeSlug":
new := CategoryChangeSlugAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "removeAsset":
new := CategoryRemoveAssetAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "setAssetCustomField":
new := CategorySetAssetCustomFieldAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "setAssetCustomType":
new := CategorySetAssetCustomTypeAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "setAssetDescription":
new := CategorySetAssetDescriptionAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "setAssetKey":
new := CategorySetAssetKeyAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "setAssetSources":
new := CategorySetAssetSourcesAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "setAssetTags":
new := CategorySetAssetTagsAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "setCustomField":
new := CategorySetCustomFieldAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "setCustomType":
new := CategorySetCustomTypeAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "setDescription":
new := CategorySetDescriptionAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "setExternalId":
new := CategorySetExternalIDAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "setKey":
new := CategorySetKeyAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "setMetaDescription":
new := CategorySetMetaDescriptionAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "setMetaKeywords":
new := CategorySetMetaKeywordsAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "setMetaTitle":
new := CategorySetMetaTitleAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
}
return nil, nil
}
// Category is of type BaseResource
type Category struct {
Version int `json:"version"`
Slug *LocalizedString `json:"slug"`
Parent *CategoryReference `json:"parent,omitempty"`
OrderHint string `json:"orderHint"`
Name *LocalizedString `json:"name"`
MetaTitle *LocalizedString `json:"metaTitle,omitempty"`
MetaKeywords *LocalizedString `json:"metaKeywords,omitempty"`
MetaDescription *LocalizedString `json:"metaDescription,omitempty"`
LastModifiedBy *LastModifiedBy `json:"lastModifiedBy,omitempty"`
LastModifiedAt time.Time `json:"lastModifiedAt"`
Key string `json:"key,omitempty"`
ID string `json:"id"`
ExternalID string `json:"externalId,omitempty"`
Description *LocalizedString `json:"description,omitempty"`
Custom *CustomFields `json:"custom,omitempty"`
CreatedBy *CreatedBy `json:"createdBy,omitempty"`
CreatedAt time.Time `json:"createdAt"`
Assets []Asset `json:"assets,omitempty"`
Ancestors []CategoryReference `json:"ancestors"`
}
// CategoryAddAssetAction implements the interface CategoryUpdateAction
type CategoryAddAssetAction struct {
Position float64 `json:"position,omitempty"`
Asset *AssetDraft `json:"asset"`
}
// MarshalJSON override to set the discriminator value
func (obj CategoryAddAssetAction) MarshalJSON() ([]byte, error) {
type Alias CategoryAddAssetAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "addAsset", Alias: (*Alias)(&obj)})
}
// CategoryChangeAssetNameAction implements the interface CategoryUpdateAction
type CategoryChangeAssetNameAction struct {
Name *LocalizedString `json:"name"`
AssetKey string `json:"assetKey,omitempty"`
AssetID string `json:"assetId,omitempty"`
}
// MarshalJSON override to set the discriminator value
func (obj CategoryChangeAssetNameAction) MarshalJSON() ([]byte, error) {
type Alias CategoryChangeAssetNameAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "changeAssetName", Alias: (*Alias)(&obj)})
}
// CategoryChangeAssetOrderAction implements the interface CategoryUpdateAction
type CategoryChangeAssetOrderAction struct {
AssetOrder []string `json:"assetOrder"`
}
// MarshalJSON override to set the discriminator value
func (obj CategoryChangeAssetOrderAction) MarshalJSON() ([]byte, error) {
type Alias CategoryChangeAssetOrderAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "changeAssetOrder", Alias: (*Alias)(&obj)})
}
// CategoryChangeNameAction implements the interface CategoryUpdateAction
type CategoryChangeNameAction struct {
Name *LocalizedString `json:"name"`
}
// MarshalJSON override to set the discriminator value
func (obj CategoryChangeNameAction) MarshalJSON() ([]byte, error) {
type Alias CategoryChangeNameAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "changeName", Alias: (*Alias)(&obj)})
}
// CategoryChangeOrderHintAction implements the interface CategoryUpdateAction
type CategoryChangeOrderHintAction struct {
OrderHint string `json:"orderHint"`
}
// MarshalJSON override to set the discriminator value
func (obj CategoryChangeOrderHintAction) MarshalJSON() ([]byte, error) {
type Alias CategoryChangeOrderHintAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "changeOrderHint", Alias: (*Alias)(&obj)})
}
// CategoryChangeParentAction implements the interface CategoryUpdateAction
type CategoryChangeParentAction struct {
Parent *CategoryResourceIdentifier `json:"parent"`
}
// MarshalJSON override to set the discriminator value
func (obj CategoryChangeParentAction) MarshalJSON() ([]byte, error) {
type Alias CategoryChangeParentAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "changeParent", Alias: (*Alias)(&obj)})
}
// CategoryChangeSlugAction implements the interface CategoryUpdateAction
type CategoryChangeSlugAction struct {
Slug *LocalizedString `json:"slug"`
}
// MarshalJSON override to set the discriminator value
func (obj CategoryChangeSlugAction) MarshalJSON() ([]byte, error) {
type Alias CategoryChangeSlugAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "changeSlug", Alias: (*Alias)(&obj)})
}
// CategoryDraft is a standalone struct
type CategoryDraft struct {
Slug *LocalizedString `json:"slug"`
Parent *CategoryResourceIdentifier `json:"parent,omitempty"`
OrderHint string `json:"orderHint,omitempty"`
Name *LocalizedString `json:"name"`
MetaTitle *LocalizedString `json:"metaTitle,omitempty"`
MetaKeywords *LocalizedString `json:"metaKeywords,omitempty"`
MetaDescription *LocalizedString `json:"metaDescription,omitempty"`
Key string `json:"key,omitempty"`
ExternalID string `json:"externalId,omitempty"`
Description *LocalizedString `json:"description,omitempty"`
Custom *CustomFieldsDraft `json:"custom,omitempty"`
Assets []AssetDraft `json:"assets,omitempty"`
}
// CategoryPagedQueryResponse is a standalone struct
type CategoryPagedQueryResponse struct {
Total int `json:"total,omitempty"`
Results []Category `json:"results"`
Offset int `json:"offset"`
Limit int `json:"limit"`
Count int `json:"count"`
}
// CategoryReference implements the interface Reference
type CategoryReference struct {
ID string `json:"id"`
Obj *Category `json:"obj,omitempty"`
}
// MarshalJSON override to set the discriminator value
func (obj CategoryReference) MarshalJSON() ([]byte, error) {
type Alias CategoryReference
return json.Marshal(struct {
TypeID string `json:"typeId"`
*Alias
}{TypeID: "category", Alias: (*Alias)(&obj)})
}
// CategoryRemoveAssetAction implements the interface CategoryUpdateAction
type CategoryRemoveAssetAction struct {
AssetKey string `json:"assetKey,omitempty"`
AssetID string `json:"assetId,omitempty"`
}
// MarshalJSON override to set the discriminator value
func (obj CategoryRemoveAssetAction) MarshalJSON() ([]byte, error) {
type Alias CategoryRemoveAssetAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "removeAsset", Alias: (*Alias)(&obj)})
}
// CategoryResourceIdentifier implements the interface ResourceIdentifier
type CategoryResourceIdentifier struct {
Key string `json:"key,omitempty"`
ID string `json:"id,omitempty"`
}
// MarshalJSON override to set the discriminator value
func (obj CategoryResourceIdentifier) MarshalJSON() ([]byte, error) {
type Alias CategoryResourceIdentifier
return json.Marshal(struct {
TypeID string `json:"typeId"`
*Alias
}{TypeID: "category", Alias: (*Alias)(&obj)})
}
// CategorySetAssetCustomFieldAction implements the interface CategoryUpdateAction
type CategorySetAssetCustomFieldAction struct {
Value interface{} `json:"value,omitempty"`
Name string `json:"name"`
AssetKey string `json:"assetKey,omitempty"`
AssetID string `json:"assetId,omitempty"`
}
// MarshalJSON override to set the discriminator value
func (obj CategorySetAssetCustomFieldAction) MarshalJSON() ([]byte, error) {
type Alias CategorySetAssetCustomFieldAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "setAssetCustomField", Alias: (*Alias)(&obj)})
}
// CategorySetAssetCustomTypeAction implements the interface CategoryUpdateAction
type CategorySetAssetCustomTypeAction struct {
Type *TypeResourceIdentifier `json:"type,omitempty"`
Fields interface{} `json:"fields,omitempty"`
AssetKey string `json:"assetKey,omitempty"`
AssetID string `json:"assetId,omitempty"`
}
// MarshalJSON override to set the discriminator value
func (obj CategorySetAssetCustomTypeAction) MarshalJSON() ([]byte, error) {
type Alias CategorySetAssetCustomTypeAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "setAssetCustomType", Alias: (*Alias)(&obj)})
}
// CategorySetAssetDescriptionAction implements the interface CategoryUpdateAction
type CategorySetAssetDescriptionAction struct {
Description *LocalizedString `json:"description,omitempty"`
AssetKey string `json:"assetKey,omitempty"`
AssetID string `json:"assetId,omitempty"`
}
// MarshalJSON override to set the discriminator value
func (obj CategorySetAssetDescriptionAction) MarshalJSON() ([]byte, error) {
type Alias CategorySetAssetDescriptionAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "setAssetDescription", Alias: (*Alias)(&obj)})
}
// CategorySetAssetKeyAction implements the interface CategoryUpdateAction
type CategorySetAssetKeyAction struct {
AssetKey string `json:"assetKey,omitempty"`
AssetID string `json:"assetId"`
}
// MarshalJSON override to set the discriminator value
func (obj CategorySetAssetKeyAction) MarshalJSON() ([]byte, error) {
type Alias CategorySetAssetKeyAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "setAssetKey", Alias: (*Alias)(&obj)})
}
// CategorySetAssetSourcesAction implements the interface CategoryUpdateAction
type CategorySetAssetSourcesAction struct {
Sources []AssetSource `json:"sources"`
AssetKey string `json:"assetKey,omitempty"`
AssetID string `json:"assetId,omitempty"`
}
// MarshalJSON override to set the discriminator value
func (obj CategorySetAssetSourcesAction) MarshalJSON() ([]byte, error) {
type Alias CategorySetAssetSourcesAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "setAssetSources", Alias: (*Alias)(&obj)})
}
// CategorySetAssetTagsAction implements the interface CategoryUpdateAction
type CategorySetAssetTagsAction struct {
Tags []string `json:"tags,omitempty"`
AssetKey string `json:"assetKey,omitempty"`
AssetID string `json:"assetId,omitempty"`
}
// MarshalJSON override to set the discriminator value
func (obj CategorySetAssetTagsAction) MarshalJSON() ([]byte, error) {
type Alias CategorySetAssetTagsAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "setAssetTags", Alias: (*Alias)(&obj)})
}
// CategorySetCustomFieldAction implements the interface CategoryUpdateAction
type CategorySetCustomFieldAction struct {
Value interface{} `json:"value,omitempty"`
Name string `json:"name"`
}
// MarshalJSON override to set the discriminator value
func (obj CategorySetCustomFieldAction) MarshalJSON() ([]byte, error) {
type Alias CategorySetCustomFieldAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "setCustomField", Alias: (*Alias)(&obj)})
}
// CategorySetCustomTypeAction implements the interface CategoryUpdateAction
type CategorySetCustomTypeAction struct {
Type *TypeResourceIdentifier `json:"type,omitempty"`
Fields *FieldContainer `json:"fields,omitempty"`
}
// MarshalJSON override to set the discriminator value
func (obj CategorySetCustomTypeAction) MarshalJSON() ([]byte, error) {
type Alias CategorySetCustomTypeAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "setCustomType", Alias: (*Alias)(&obj)})
}
// CategorySetDescriptionAction implements the interface CategoryUpdateAction
type CategorySetDescriptionAction struct {
Description *LocalizedString `json:"description,omitempty"`
}
// MarshalJSON override to set the discriminator value
func (obj CategorySetDescriptionAction) MarshalJSON() ([]byte, error) {
type Alias CategorySetDescriptionAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "setDescription", Alias: (*Alias)(&obj)})
}
// CategorySetExternalIDAction implements the interface CategoryUpdateAction
type CategorySetExternalIDAction struct {
ExternalID string `json:"externalId,omitempty"`
}
// MarshalJSON override to set the discriminator value
func (obj CategorySetExternalIDAction) MarshalJSON() ([]byte, error) {
type Alias CategorySetExternalIDAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "setExternalId", Alias: (*Alias)(&obj)})
}
// CategorySetKeyAction implements the interface CategoryUpdateAction
type CategorySetKeyAction struct {
Key string `json:"key,omitempty"`
}
// MarshalJSON override to set the discriminator value
func (obj CategorySetKeyAction) MarshalJSON() ([]byte, error) {
type Alias CategorySetKeyAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "setKey", Alias: (*Alias)(&obj)})
}
// CategorySetMetaDescriptionAction implements the interface CategoryUpdateAction
type CategorySetMetaDescriptionAction struct {
MetaDescription *LocalizedString `json:"metaDescription,omitempty"`
}
// MarshalJSON override to set the discriminator value
func (obj CategorySetMetaDescriptionAction) MarshalJSON() ([]byte, error) {
type Alias CategorySetMetaDescriptionAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "setMetaDescription", Alias: (*Alias)(&obj)})
}
// CategorySetMetaKeywordsAction implements the interface CategoryUpdateAction
type CategorySetMetaKeywordsAction struct {
MetaKeywords *LocalizedString `json:"metaKeywords,omitempty"`
}
// MarshalJSON override to set the discriminator value
func (obj CategorySetMetaKeywordsAction) MarshalJSON() ([]byte, error) {
type Alias CategorySetMetaKeywordsAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "setMetaKeywords", Alias: (*Alias)(&obj)})
}
// CategorySetMetaTitleAction implements the interface CategoryUpdateAction
type CategorySetMetaTitleAction struct {
MetaTitle *LocalizedString `json:"metaTitle,omitempty"`
}
// MarshalJSON override to set the discriminator value
func (obj CategorySetMetaTitleAction) MarshalJSON() ([]byte, error) {
type Alias CategorySetMetaTitleAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "setMetaTitle", Alias: (*Alias)(&obj)})
}
// CategoryUpdate is a standalone struct
type CategoryUpdate struct {
Version int `json:"version"`
Actions []CategoryUpdateAction `json:"actions"`
}
// UnmarshalJSON override to deserialize correct attribute types based
// on the discriminator value
func (obj *CategoryUpdate) UnmarshalJSON(data []byte) error {
type Alias CategoryUpdate
if err := json.Unmarshal(data, (*Alias)(obj)); err != nil {
return err
}
for i := range obj.Actions {
var err error
obj.Actions[i], err = mapDiscriminatorCategoryUpdateAction(obj.Actions[i])
if err != nil {
return err
}
}
return nil
}