-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmodel_create_promo_code_request.go
More file actions
426 lines (353 loc) · 13 KB
/
Copy pathmodel_create_promo_code_request.go
File metadata and controls
426 lines (353 loc) · 13 KB
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
/*
OpenPay API
super charge your subscription management.
API version: 1.2.1
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package getopenpay
import (
"encoding/json"
"time"
"fmt"
)
// checks if the CreatePromoCodeRequest type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &CreatePromoCodeRequest{}
// CreatePromoCodeRequest struct for CreatePromoCodeRequest
type CreatePromoCodeRequest struct {
// The customer-facing code. This code must be unique across all active promotion codes for a specific customer. Case insensitive.
Code string `json:"code"`
// The unique id of coupon for this promotion code.
CouponId string `json:"coupon_id"`
// List of customer that this promotion code can be used by. If not set, the promotion code can be used by all customers.
CustomerIds []string `json:"customer_ids,omitempty"`
ExpiresAt NullableTime `json:"expires_at,omitempty"`
MaxRedemptions NullableInt32 `json:"max_redemptions,omitempty"`
MaxRedemptionsPerCustomer NullableInt32 `json:"max_redemptions_per_customer,omitempty"`
Restrictions NullablePromoRestrictions `json:"restrictions,omitempty"`
AdditionalProperties map[string]interface{}
}
type _CreatePromoCodeRequest CreatePromoCodeRequest
// NewCreatePromoCodeRequest instantiates a new CreatePromoCodeRequest object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewCreatePromoCodeRequest(code string, couponId string) *CreatePromoCodeRequest {
this := CreatePromoCodeRequest{}
this.Code = code
this.CouponId = couponId
return &this
}
// NewCreatePromoCodeRequestWithDefaults instantiates a new CreatePromoCodeRequest object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewCreatePromoCodeRequestWithDefaults() *CreatePromoCodeRequest {
this := CreatePromoCodeRequest{}
return &this
}
// GetCode returns the Code field value
func (o *CreatePromoCodeRequest) GetCode() string {
if o == nil {
var ret string
return ret
}
return o.Code
}
// GetCodeOk returns a tuple with the Code field value
// and a boolean to check if the value has been set.
func (o *CreatePromoCodeRequest) GetCodeOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Code, true
}
// SetCode sets field value
func (o *CreatePromoCodeRequest) SetCode(v string) {
o.Code = v
}
// GetCouponId returns the CouponId field value
func (o *CreatePromoCodeRequest) GetCouponId() string {
if o == nil {
var ret string
return ret
}
return o.CouponId
}
// GetCouponIdOk returns a tuple with the CouponId field value
// and a boolean to check if the value has been set.
func (o *CreatePromoCodeRequest) GetCouponIdOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.CouponId, true
}
// SetCouponId sets field value
func (o *CreatePromoCodeRequest) SetCouponId(v string) {
o.CouponId = v
}
// GetCustomerIds returns the CustomerIds field value if set, zero value otherwise.
func (o *CreatePromoCodeRequest) GetCustomerIds() []string {
if o == nil || IsNil(o.CustomerIds) {
var ret []string
return ret
}
return o.CustomerIds
}
// GetCustomerIdsOk returns a tuple with the CustomerIds field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *CreatePromoCodeRequest) GetCustomerIdsOk() ([]string, bool) {
if o == nil || IsNil(o.CustomerIds) {
return nil, false
}
return o.CustomerIds, true
}
// HasCustomerIds returns a boolean if a field has been set.
func (o *CreatePromoCodeRequest) HasCustomerIds() bool {
if o != nil && !IsNil(o.CustomerIds) {
return true
}
return false
}
// SetCustomerIds gets a reference to the given []string and assigns it to the CustomerIds field.
func (o *CreatePromoCodeRequest) SetCustomerIds(v []string) {
o.CustomerIds = v
}
// GetExpiresAt returns the ExpiresAt field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *CreatePromoCodeRequest) GetExpiresAt() time.Time {
if o == nil || IsNil(o.ExpiresAt.Get()) {
var ret time.Time
return ret
}
return *o.ExpiresAt.Get()
}
// GetExpiresAtOk returns a tuple with the ExpiresAt field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *CreatePromoCodeRequest) GetExpiresAtOk() (*time.Time, bool) {
if o == nil {
return nil, false
}
return o.ExpiresAt.Get(), o.ExpiresAt.IsSet()
}
// HasExpiresAt returns a boolean if a field has been set.
func (o *CreatePromoCodeRequest) HasExpiresAt() bool {
if o != nil && o.ExpiresAt.IsSet() {
return true
}
return false
}
// SetExpiresAt gets a reference to the given NullableTime and assigns it to the ExpiresAt field.
func (o *CreatePromoCodeRequest) SetExpiresAt(v time.Time) {
o.ExpiresAt.Set(&v)
}
// SetExpiresAtNil sets the value for ExpiresAt to be an explicit nil
func (o *CreatePromoCodeRequest) SetExpiresAtNil() {
o.ExpiresAt.Set(nil)
}
// UnsetExpiresAt ensures that no value is present for ExpiresAt, not even an explicit nil
func (o *CreatePromoCodeRequest) UnsetExpiresAt() {
o.ExpiresAt.Unset()
}
// GetMaxRedemptions returns the MaxRedemptions field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *CreatePromoCodeRequest) GetMaxRedemptions() int32 {
if o == nil || IsNil(o.MaxRedemptions.Get()) {
var ret int32
return ret
}
return *o.MaxRedemptions.Get()
}
// GetMaxRedemptionsOk returns a tuple with the MaxRedemptions field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *CreatePromoCodeRequest) GetMaxRedemptionsOk() (*int32, bool) {
if o == nil {
return nil, false
}
return o.MaxRedemptions.Get(), o.MaxRedemptions.IsSet()
}
// HasMaxRedemptions returns a boolean if a field has been set.
func (o *CreatePromoCodeRequest) HasMaxRedemptions() bool {
if o != nil && o.MaxRedemptions.IsSet() {
return true
}
return false
}
// SetMaxRedemptions gets a reference to the given NullableInt32 and assigns it to the MaxRedemptions field.
func (o *CreatePromoCodeRequest) SetMaxRedemptions(v int32) {
o.MaxRedemptions.Set(&v)
}
// SetMaxRedemptionsNil sets the value for MaxRedemptions to be an explicit nil
func (o *CreatePromoCodeRequest) SetMaxRedemptionsNil() {
o.MaxRedemptions.Set(nil)
}
// UnsetMaxRedemptions ensures that no value is present for MaxRedemptions, not even an explicit nil
func (o *CreatePromoCodeRequest) UnsetMaxRedemptions() {
o.MaxRedemptions.Unset()
}
// GetMaxRedemptionsPerCustomer returns the MaxRedemptionsPerCustomer field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *CreatePromoCodeRequest) GetMaxRedemptionsPerCustomer() int32 {
if o == nil || IsNil(o.MaxRedemptionsPerCustomer.Get()) {
var ret int32
return ret
}
return *o.MaxRedemptionsPerCustomer.Get()
}
// GetMaxRedemptionsPerCustomerOk returns a tuple with the MaxRedemptionsPerCustomer field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *CreatePromoCodeRequest) GetMaxRedemptionsPerCustomerOk() (*int32, bool) {
if o == nil {
return nil, false
}
return o.MaxRedemptionsPerCustomer.Get(), o.MaxRedemptionsPerCustomer.IsSet()
}
// HasMaxRedemptionsPerCustomer returns a boolean if a field has been set.
func (o *CreatePromoCodeRequest) HasMaxRedemptionsPerCustomer() bool {
if o != nil && o.MaxRedemptionsPerCustomer.IsSet() {
return true
}
return false
}
// SetMaxRedemptionsPerCustomer gets a reference to the given NullableInt32 and assigns it to the MaxRedemptionsPerCustomer field.
func (o *CreatePromoCodeRequest) SetMaxRedemptionsPerCustomer(v int32) {
o.MaxRedemptionsPerCustomer.Set(&v)
}
// SetMaxRedemptionsPerCustomerNil sets the value for MaxRedemptionsPerCustomer to be an explicit nil
func (o *CreatePromoCodeRequest) SetMaxRedemptionsPerCustomerNil() {
o.MaxRedemptionsPerCustomer.Set(nil)
}
// UnsetMaxRedemptionsPerCustomer ensures that no value is present for MaxRedemptionsPerCustomer, not even an explicit nil
func (o *CreatePromoCodeRequest) UnsetMaxRedemptionsPerCustomer() {
o.MaxRedemptionsPerCustomer.Unset()
}
// GetRestrictions returns the Restrictions field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *CreatePromoCodeRequest) GetRestrictions() PromoRestrictions {
if o == nil || IsNil(o.Restrictions.Get()) {
var ret PromoRestrictions
return ret
}
return *o.Restrictions.Get()
}
// GetRestrictionsOk returns a tuple with the Restrictions field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *CreatePromoCodeRequest) GetRestrictionsOk() (*PromoRestrictions, bool) {
if o == nil {
return nil, false
}
return o.Restrictions.Get(), o.Restrictions.IsSet()
}
// HasRestrictions returns a boolean if a field has been set.
func (o *CreatePromoCodeRequest) HasRestrictions() bool {
if o != nil && o.Restrictions.IsSet() {
return true
}
return false
}
// SetRestrictions gets a reference to the given NullablePromoRestrictions and assigns it to the Restrictions field.
func (o *CreatePromoCodeRequest) SetRestrictions(v PromoRestrictions) {
o.Restrictions.Set(&v)
}
// SetRestrictionsNil sets the value for Restrictions to be an explicit nil
func (o *CreatePromoCodeRequest) SetRestrictionsNil() {
o.Restrictions.Set(nil)
}
// UnsetRestrictions ensures that no value is present for Restrictions, not even an explicit nil
func (o *CreatePromoCodeRequest) UnsetRestrictions() {
o.Restrictions.Unset()
}
func (o CreatePromoCodeRequest) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o CreatePromoCodeRequest) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
toSerialize["code"] = o.Code
toSerialize["coupon_id"] = o.CouponId
if !IsNil(o.CustomerIds) {
toSerialize["customer_ids"] = o.CustomerIds
}
if o.ExpiresAt.IsSet() {
toSerialize["expires_at"] = o.ExpiresAt.Get()
}
if o.MaxRedemptions.IsSet() {
toSerialize["max_redemptions"] = o.MaxRedemptions.Get()
}
if o.MaxRedemptionsPerCustomer.IsSet() {
toSerialize["max_redemptions_per_customer"] = o.MaxRedemptionsPerCustomer.Get()
}
if o.Restrictions.IsSet() {
toSerialize["restrictions"] = o.Restrictions.Get()
}
for key, value := range o.AdditionalProperties {
toSerialize[key] = value
}
return toSerialize, nil
}
func (o *CreatePromoCodeRequest) UnmarshalJSON(data []byte) (err error) {
// This validates that all required properties are included in the JSON object
// by unmarshalling the object into a generic map with string keys and checking
// that every required field exists as a key in the generic map.
requiredProperties := []string{
"code",
"coupon_id",
}
allProperties := make(map[string]interface{})
err = json.Unmarshal(data, &allProperties)
if err != nil {
return err;
}
for _, requiredProperty := range(requiredProperties) {
if _, exists := allProperties[requiredProperty]; !exists {
return fmt.Errorf("no value given for required property %v", requiredProperty)
}
}
varCreatePromoCodeRequest := _CreatePromoCodeRequest{}
err = json.Unmarshal(data, &varCreatePromoCodeRequest)
if err != nil {
return err
}
*o = CreatePromoCodeRequest(varCreatePromoCodeRequest)
additionalProperties := make(map[string]interface{})
if err = json.Unmarshal(data, &additionalProperties); err == nil {
delete(additionalProperties, "code")
delete(additionalProperties, "coupon_id")
delete(additionalProperties, "customer_ids")
delete(additionalProperties, "expires_at")
delete(additionalProperties, "max_redemptions")
delete(additionalProperties, "max_redemptions_per_customer")
delete(additionalProperties, "restrictions")
o.AdditionalProperties = additionalProperties
}
return err
}
type NullableCreatePromoCodeRequest struct {
value *CreatePromoCodeRequest
isSet bool
}
func (v NullableCreatePromoCodeRequest) Get() *CreatePromoCodeRequest {
return v.value
}
func (v *NullableCreatePromoCodeRequest) Set(val *CreatePromoCodeRequest) {
v.value = val
v.isSet = true
}
func (v NullableCreatePromoCodeRequest) IsSet() bool {
return v.isSet
}
func (v *NullableCreatePromoCodeRequest) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableCreatePromoCodeRequest(val *CreatePromoCodeRequest) *NullableCreatePromoCodeRequest {
return &NullableCreatePromoCodeRequest{value: val, isSet: true}
}
func (v NullableCreatePromoCodeRequest) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableCreatePromoCodeRequest) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}