forked from labd/commercetools-go-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types_store.go
296 lines (264 loc) · 8.98 KB
/
types_store.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
// Automatically generated, do not edit
package commercetools
import (
"encoding/json"
"errors"
"time"
)
// StoreUpdateAction uses action as discriminator attribute
type StoreUpdateAction interface{}
func mapDiscriminatorStoreUpdateAction(input interface{}) (StoreUpdateAction, 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 "setLanguages":
new := StoreSetLanguagesAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "setName":
new := StoreSetNameAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "addDistributionChannel":
new := StoresAddDistributionChannelsAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "addSupplyChannel":
new := StoresAddSupplyChannelsAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "removeDistributionChannel":
new := StoresRemoveDistributionChannelsAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "removeSupplyChannel":
new := StoresRemoveSupplyChannelsAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "setDistributionChannels":
new := StoresSetDistributionChannelsAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "setSupplyChannels":
new := StoresSetSupplyChannelsAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
}
return nil, nil
}
// Store is of type BaseResource
type Store struct {
Version int `json:"version"`
SupplyChannels []ChannelReference `json:"supplyChannels,omitempty"`
Name *LocalizedString `json:"name,omitempty"`
LastModifiedBy *LastModifiedBy `json:"lastModifiedBy,omitempty"`
LastModifiedAt time.Time `json:"lastModifiedAt"`
Languages []string `json:"languages,omitempty"`
Key string `json:"key"`
ID string `json:"id"`
DistributionChannels []ChannelReference `json:"distributionChannels"`
CreatedBy *CreatedBy `json:"createdBy,omitempty"`
CreatedAt time.Time `json:"createdAt"`
}
// StoreDraft is a standalone struct
type StoreDraft struct {
SupplyChannels []ChannelResourceIdentifier `json:"supplyChannels,omitempty"`
Name *LocalizedString `json:"name"`
Languages []string `json:"languages,omitempty"`
Key string `json:"key"`
DistributionChannels []ChannelResourceIdentifier `json:"distributionChannels,omitempty"`
}
// StoreKeyReference implements the interface KeyReference
type StoreKeyReference struct {
Key string `json:"key"`
}
// MarshalJSON override to set the discriminator value
func (obj StoreKeyReference) MarshalJSON() ([]byte, error) {
type Alias StoreKeyReference
return json.Marshal(struct {
TypeID string `json:"typeId"`
*Alias
}{TypeID: "store", Alias: (*Alias)(&obj)})
}
// StorePagedQueryResponse is a standalone struct
type StorePagedQueryResponse struct {
Total int `json:"total,omitempty"`
Results []Store `json:"results"`
Offset int `json:"offset"`
Limit int `json:"limit"`
Count int `json:"count"`
}
// StoreReference implements the interface Reference
type StoreReference struct {
ID string `json:"id"`
Obj *Store `json:"obj,omitempty"`
}
// MarshalJSON override to set the discriminator value
func (obj StoreReference) MarshalJSON() ([]byte, error) {
type Alias StoreReference
return json.Marshal(struct {
TypeID string `json:"typeId"`
*Alias
}{TypeID: "store", Alias: (*Alias)(&obj)})
}
// StoreResourceIdentifier implements the interface ResourceIdentifier
type StoreResourceIdentifier struct {
Key string `json:"key,omitempty"`
ID string `json:"id,omitempty"`
}
// MarshalJSON override to set the discriminator value
func (obj StoreResourceIdentifier) MarshalJSON() ([]byte, error) {
type Alias StoreResourceIdentifier
return json.Marshal(struct {
TypeID string `json:"typeId"`
*Alias
}{TypeID: "store", Alias: (*Alias)(&obj)})
}
// StoreSetLanguagesAction implements the interface StoreUpdateAction
type StoreSetLanguagesAction struct {
Languages []string `json:"languages,omitempty"`
}
// MarshalJSON override to set the discriminator value
func (obj StoreSetLanguagesAction) MarshalJSON() ([]byte, error) {
type Alias StoreSetLanguagesAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "setLanguages", Alias: (*Alias)(&obj)})
}
// StoreSetNameAction implements the interface StoreUpdateAction
type StoreSetNameAction struct {
Name *LocalizedString `json:"name,omitempty"`
}
// MarshalJSON override to set the discriminator value
func (obj StoreSetNameAction) MarshalJSON() ([]byte, error) {
type Alias StoreSetNameAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "setName", Alias: (*Alias)(&obj)})
}
// StoreUpdate is a standalone struct
type StoreUpdate struct {
Version int `json:"version"`
Actions []StoreUpdateAction `json:"actions"`
}
// UnmarshalJSON override to deserialize correct attribute types based
// on the discriminator value
func (obj *StoreUpdate) UnmarshalJSON(data []byte) error {
type Alias StoreUpdate
if err := json.Unmarshal(data, (*Alias)(obj)); err != nil {
return err
}
for i := range obj.Actions {
var err error
obj.Actions[i], err = mapDiscriminatorStoreUpdateAction(obj.Actions[i])
if err != nil {
return err
}
}
return nil
}
// StoresAddDistributionChannelsAction implements the interface StoreUpdateAction
type StoresAddDistributionChannelsAction struct {
DistributionChannel *ChannelResourceIdentifier `json:"distributionChannel"`
}
// MarshalJSON override to set the discriminator value
func (obj StoresAddDistributionChannelsAction) MarshalJSON() ([]byte, error) {
type Alias StoresAddDistributionChannelsAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "addDistributionChannel", Alias: (*Alias)(&obj)})
}
// StoresAddSupplyChannelsAction implements the interface StoreUpdateAction
type StoresAddSupplyChannelsAction struct {
SupplyChannel *ChannelResourceIdentifier `json:"supplyChannel"`
}
// MarshalJSON override to set the discriminator value
func (obj StoresAddSupplyChannelsAction) MarshalJSON() ([]byte, error) {
type Alias StoresAddSupplyChannelsAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "addSupplyChannel", Alias: (*Alias)(&obj)})
}
// StoresRemoveDistributionChannelsAction implements the interface StoreUpdateAction
type StoresRemoveDistributionChannelsAction struct {
DistributionChannel *ChannelResourceIdentifier `json:"distributionChannel"`
}
// MarshalJSON override to set the discriminator value
func (obj StoresRemoveDistributionChannelsAction) MarshalJSON() ([]byte, error) {
type Alias StoresRemoveDistributionChannelsAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "removeDistributionChannel", Alias: (*Alias)(&obj)})
}
// StoresRemoveSupplyChannelsAction implements the interface StoreUpdateAction
type StoresRemoveSupplyChannelsAction struct {
SupplyChannel *ChannelResourceIdentifier `json:"supplyChannel"`
}
// MarshalJSON override to set the discriminator value
func (obj StoresRemoveSupplyChannelsAction) MarshalJSON() ([]byte, error) {
type Alias StoresRemoveSupplyChannelsAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "removeSupplyChannel", Alias: (*Alias)(&obj)})
}
// StoresSetDistributionChannelsAction implements the interface StoreUpdateAction
type StoresSetDistributionChannelsAction struct {
DistributionChannels []ChannelResourceIdentifier `json:"distributionChannels,omitempty"`
}
// MarshalJSON override to set the discriminator value
func (obj StoresSetDistributionChannelsAction) MarshalJSON() ([]byte, error) {
type Alias StoresSetDistributionChannelsAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "setDistributionChannels", Alias: (*Alias)(&obj)})
}
// StoresSetSupplyChannelsAction implements the interface StoreUpdateAction
type StoresSetSupplyChannelsAction struct {
SupplyChannels []ChannelResourceIdentifier `json:"supplyChannels,omitempty"`
}
// MarshalJSON override to set the discriminator value
func (obj StoresSetSupplyChannelsAction) MarshalJSON() ([]byte, error) {
type Alias StoresSetSupplyChannelsAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "setSupplyChannels", Alias: (*Alias)(&obj)})
}