forked from labd/commercetools-go-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types_project.go
386 lines (346 loc) · 11.4 KB
/
types_project.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
// Automatically generated, do not edit
package commercetools
import (
"encoding/json"
"errors"
"time"
)
// ProjectUpdateAction uses action as discriminator attribute
type ProjectUpdateAction interface{}
func mapDiscriminatorProjectUpdateAction(input interface{}) (ProjectUpdateAction, 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 "changeCountries":
new := ProjectChangeCountriesAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "changeCountryTaxRateFallbackEnabled":
new := ProjectChangeCountryTaxRateFallbackEnabledAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "changeCurrencies":
new := ProjectChangeCurrenciesAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "changeLanguages":
new := ProjectChangeLanguagesAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "changeMessagesConfiguration":
new := ProjectChangeMessagesConfigurationAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "changeMessagesEnabled":
new := ProjectChangeMessagesEnabledAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "changeName":
new := ProjectChangeNameAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "setExternalOAuth":
new := ProjectSetExternalOAuthAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "setShippingRateInputType":
new := ProjectSetShippingRateInputTypeAction{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
if new.ShippingRateInputType != nil {
new.ShippingRateInputType, err = mapDiscriminatorShippingRateInputType(new.ShippingRateInputType)
if err != nil {
return nil, err
}
}
return new, nil
}
return nil, nil
}
// ShippingRateInputType uses type as discriminator attribute
type ShippingRateInputType interface{}
func mapDiscriminatorShippingRateInputType(input interface{}) (ShippingRateInputType, 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 "CartClassification":
new := CartClassificationType{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "CartScore":
new := CartScoreType{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
case "CartValue":
new := CartValueType{}
err := decodeStruct(input, &new)
if err != nil {
return nil, err
}
return new, nil
}
return nil, nil
}
// CartClassificationType implements the interface ShippingRateInputType
type CartClassificationType struct {
Values []CustomFieldLocalizedEnumValue `json:"values"`
}
// MarshalJSON override to set the discriminator value
func (obj CartClassificationType) MarshalJSON() ([]byte, error) {
type Alias CartClassificationType
return json.Marshal(struct {
Type string `json:"type"`
*Alias
}{Type: "CartClassification", Alias: (*Alias)(&obj)})
}
// CartScoreType implements the interface ShippingRateInputType
type CartScoreType struct{}
// MarshalJSON override to set the discriminator value
func (obj CartScoreType) MarshalJSON() ([]byte, error) {
type Alias CartScoreType
return json.Marshal(struct {
Type string `json:"type"`
*Alias
}{Type: "CartScore", Alias: (*Alias)(&obj)})
}
// CartValueType implements the interface ShippingRateInputType
type CartValueType struct{}
// MarshalJSON override to set the discriminator value
func (obj CartValueType) MarshalJSON() ([]byte, error) {
type Alias CartValueType
return json.Marshal(struct {
Type string `json:"type"`
*Alias
}{Type: "CartValue", Alias: (*Alias)(&obj)})
}
// CartsConfiguration is a standalone struct
type CartsConfiguration struct {
CountryTaxRateFallbackEnabled bool `json:"countryTaxRateFallbackEnabled"`
}
// ExternalOAuth is a standalone struct
type ExternalOAuth struct {
URL string `json:"url"`
AuthorizationHeader string `json:"authorizationHeader"`
}
// Project is a standalone struct
type Project struct {
Version int `json:"version"`
TrialUntil string `json:"trialUntil,omitempty"`
ShippingRateInputType ShippingRateInputType `json:"shippingRateInputType,omitempty"`
Name string `json:"name"`
Messages *MessageConfiguration `json:"messages"`
Languages []Locale `json:"languages"`
Key string `json:"key"`
ExternalOAuth *ExternalOAuth `json:"externalOAuth,omitempty"`
Currencies []CurrencyCode `json:"currencies"`
CreatedAt time.Time `json:"createdAt"`
Countries []CountryCode `json:"countries"`
Carts *CartsConfiguration `json:"carts"`
}
// UnmarshalJSON override to deserialize correct attribute types based
// on the discriminator value
func (obj *Project) UnmarshalJSON(data []byte) error {
type Alias Project
if err := json.Unmarshal(data, (*Alias)(obj)); err != nil {
return err
}
if obj.ShippingRateInputType != nil {
var err error
obj.ShippingRateInputType, err = mapDiscriminatorShippingRateInputType(obj.ShippingRateInputType)
if err != nil {
return err
}
}
return nil
}
// ProjectChangeCountriesAction implements the interface ProjectUpdateAction
type ProjectChangeCountriesAction struct {
Countries []CountryCode `json:"countries"`
}
// MarshalJSON override to set the discriminator value
func (obj ProjectChangeCountriesAction) MarshalJSON() ([]byte, error) {
type Alias ProjectChangeCountriesAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "changeCountries", Alias: (*Alias)(&obj)})
}
// ProjectChangeCountryTaxRateFallbackEnabledAction implements the interface ProjectUpdateAction
type ProjectChangeCountryTaxRateFallbackEnabledAction struct {
CountryTaxRateFallbackEnabled bool `json:"countryTaxRateFallbackEnabled"`
}
// MarshalJSON override to set the discriminator value
func (obj ProjectChangeCountryTaxRateFallbackEnabledAction) MarshalJSON() ([]byte, error) {
type Alias ProjectChangeCountryTaxRateFallbackEnabledAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "changeCountryTaxRateFallbackEnabled", Alias: (*Alias)(&obj)})
}
// ProjectChangeCurrenciesAction implements the interface ProjectUpdateAction
type ProjectChangeCurrenciesAction struct {
Currencies []CurrencyCode `json:"currencies"`
}
// MarshalJSON override to set the discriminator value
func (obj ProjectChangeCurrenciesAction) MarshalJSON() ([]byte, error) {
type Alias ProjectChangeCurrenciesAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "changeCurrencies", Alias: (*Alias)(&obj)})
}
// ProjectChangeLanguagesAction implements the interface ProjectUpdateAction
type ProjectChangeLanguagesAction struct {
Languages []Locale `json:"languages"`
}
// MarshalJSON override to set the discriminator value
func (obj ProjectChangeLanguagesAction) MarshalJSON() ([]byte, error) {
type Alias ProjectChangeLanguagesAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "changeLanguages", Alias: (*Alias)(&obj)})
}
// ProjectChangeMessagesConfigurationAction implements the interface ProjectUpdateAction
type ProjectChangeMessagesConfigurationAction struct {
MessagesConfiguration *MessageConfigurationDraft `json:"messagesConfiguration"`
}
// MarshalJSON override to set the discriminator value
func (obj ProjectChangeMessagesConfigurationAction) MarshalJSON() ([]byte, error) {
type Alias ProjectChangeMessagesConfigurationAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "changeMessagesConfiguration", Alias: (*Alias)(&obj)})
}
// ProjectChangeMessagesEnabledAction implements the interface ProjectUpdateAction
type ProjectChangeMessagesEnabledAction struct {
MessagesEnabled bool `json:"messagesEnabled"`
}
// MarshalJSON override to set the discriminator value
func (obj ProjectChangeMessagesEnabledAction) MarshalJSON() ([]byte, error) {
type Alias ProjectChangeMessagesEnabledAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "changeMessagesEnabled", Alias: (*Alias)(&obj)})
}
// ProjectChangeNameAction implements the interface ProjectUpdateAction
type ProjectChangeNameAction struct {
Name string `json:"name"`
}
// MarshalJSON override to set the discriminator value
func (obj ProjectChangeNameAction) MarshalJSON() ([]byte, error) {
type Alias ProjectChangeNameAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "changeName", Alias: (*Alias)(&obj)})
}
// ProjectSetExternalOAuthAction implements the interface ProjectUpdateAction
type ProjectSetExternalOAuthAction struct {
ExternalOAuth *ExternalOAuth `json:"externalOAuth,omitempty"`
}
// MarshalJSON override to set the discriminator value
func (obj ProjectSetExternalOAuthAction) MarshalJSON() ([]byte, error) {
type Alias ProjectSetExternalOAuthAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "setExternalOAuth", Alias: (*Alias)(&obj)})
}
// ProjectSetShippingRateInputTypeAction implements the interface ProjectUpdateAction
type ProjectSetShippingRateInputTypeAction struct {
ShippingRateInputType ShippingRateInputType `json:"shippingRateInputType,omitempty"`
}
// MarshalJSON override to set the discriminator value
func (obj ProjectSetShippingRateInputTypeAction) MarshalJSON() ([]byte, error) {
type Alias ProjectSetShippingRateInputTypeAction
return json.Marshal(struct {
Action string `json:"action"`
*Alias
}{Action: "setShippingRateInputType", Alias: (*Alias)(&obj)})
}
// UnmarshalJSON override to deserialize correct attribute types based
// on the discriminator value
func (obj *ProjectSetShippingRateInputTypeAction) UnmarshalJSON(data []byte) error {
type Alias ProjectSetShippingRateInputTypeAction
if err := json.Unmarshal(data, (*Alias)(obj)); err != nil {
return err
}
if obj.ShippingRateInputType != nil {
var err error
obj.ShippingRateInputType, err = mapDiscriminatorShippingRateInputType(obj.ShippingRateInputType)
if err != nil {
return err
}
}
return nil
}
// ProjectUpdate is a standalone struct
type ProjectUpdate struct {
Version int `json:"version"`
Actions []ProjectUpdateAction `json:"actions"`
}
// UnmarshalJSON override to deserialize correct attribute types based
// on the discriminator value
func (obj *ProjectUpdate) UnmarshalJSON(data []byte) error {
type Alias ProjectUpdate
if err := json.Unmarshal(data, (*Alias)(obj)); err != nil {
return err
}
for i := range obj.Actions {
var err error
obj.Actions[i], err = mapDiscriminatorProjectUpdateAction(obj.Actions[i])
if err != nil {
return err
}
}
return nil
}