-
Notifications
You must be signed in to change notification settings - Fork 4
/
model_subscription.go
629 lines (528 loc) · 19.3 KB
/
model_subscription.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
/*
Ory APIs
Documentation for all public and administrative Ory APIs. Administrative APIs can only be accessed with a valid Personal Access Token. Public APIs are mostly used in browsers.
API version: v1.11.7
Contact: support@ory.sh
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package client
import (
"encoding/json"
"time"
"fmt"
)
// checks if the Subscription type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &Subscription{}
// Subscription struct for Subscription
type Subscription struct {
CreatedAt time.Time `json:"created_at"`
// The currency of the subscription. To change this, a new subscription must be created. usd USD eur Euro
Currency string `json:"currency"`
// The currently active interval of the subscription monthly Monthly yearly Yearly
CurrentInterval string `json:"current_interval"`
// The currently active plan of the subscription
CurrentPlan string `json:"current_plan"`
CurrentPlanDetails *PlanDetails `json:"current_plan_details,omitempty"`
// The ID of the stripe customer
CustomerId string `json:"customer_id"`
// The ID of the subscription
Id string `json:"id"`
IntervalChangesTo NullableString `json:"interval_changes_to"`
OngoingStripeCheckoutId NullableString `json:"ongoing_stripe_checkout_id,omitempty"`
// Until when the subscription is payed
PayedUntil time.Time `json:"payed_until"`
PlanChangesAt *time.Time `json:"plan_changes_at,omitempty"`
PlanChangesTo NullableString `json:"plan_changes_to"`
// For `collection_method=charge_automatically` a subscription moves into `incomplete` if the initial payment attempt fails. A subscription in this status can only have metadata and default_source updated. Once the first invoice is paid, the subscription moves into an `active` status. If the first invoice is not paid within 23 hours, the subscription transitions to `incomplete_expired`. This is a terminal status, the open invoice will be voided and no further invoices will be generated. A subscription that is currently in a trial period is `trialing` and moves to `active` when the trial period is over. A subscription can only enter a `paused` status [when a trial ends without a payment method](https://stripe.com/billing/subscriptions/trials#create-free-trials-without-payment). A `paused` subscription doesn't generate invoices and can be resumed after your customer adds their payment method. The `paused` status is different from [pausing collection](https://stripe.com/billing/subscriptions/pause-payment), which still generates invoices and leaves the subscription's status unchanged. If subscription `collection_method=charge_automatically`, it becomes `past_due` when payment is required but cannot be paid (due to failed payment or awaiting additional user actions). Once Stripe has exhausted all payment retry attempts, the subscription will become `canceled` or `unpaid` (depending on your subscriptions settings). If subscription `collection_method=send_invoice` it becomes `past_due` when its invoice is not paid by the due date, and `canceled` or `unpaid` if it is still not paid by an additional deadline after that. Note that when a subscription has a status of `unpaid`, no subsequent invoices will be attempted (invoices will be created, but then immediately automatically closed). After receiving updated payment information from a customer, you may choose to reopen and pay their closed invoices.
Status string `json:"status"`
StripeCheckoutExpiresAt *time.Time `json:"stripe_checkout_expires_at,omitempty"`
UpdatedAt time.Time `json:"updated_at"`
AdditionalProperties map[string]interface{}
}
type _Subscription Subscription
// NewSubscription instantiates a new Subscription 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 NewSubscription(createdAt time.Time, currency string, currentInterval string, currentPlan string, customerId string, id string, intervalChangesTo NullableString, payedUntil time.Time, planChangesTo NullableString, status string, updatedAt time.Time) *Subscription {
this := Subscription{}
this.CreatedAt = createdAt
this.Currency = currency
this.CurrentInterval = currentInterval
this.CurrentPlan = currentPlan
this.CustomerId = customerId
this.Id = id
this.IntervalChangesTo = intervalChangesTo
this.PayedUntil = payedUntil
this.PlanChangesTo = planChangesTo
this.Status = status
this.UpdatedAt = updatedAt
return &this
}
// NewSubscriptionWithDefaults instantiates a new Subscription 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 NewSubscriptionWithDefaults() *Subscription {
this := Subscription{}
return &this
}
// GetCreatedAt returns the CreatedAt field value
func (o *Subscription) GetCreatedAt() time.Time {
if o == nil {
var ret time.Time
return ret
}
return o.CreatedAt
}
// GetCreatedAtOk returns a tuple with the CreatedAt field value
// and a boolean to check if the value has been set.
func (o *Subscription) GetCreatedAtOk() (*time.Time, bool) {
if o == nil {
return nil, false
}
return &o.CreatedAt, true
}
// SetCreatedAt sets field value
func (o *Subscription) SetCreatedAt(v time.Time) {
o.CreatedAt = v
}
// GetCurrency returns the Currency field value
func (o *Subscription) GetCurrency() string {
if o == nil {
var ret string
return ret
}
return o.Currency
}
// GetCurrencyOk returns a tuple with the Currency field value
// and a boolean to check if the value has been set.
func (o *Subscription) GetCurrencyOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Currency, true
}
// SetCurrency sets field value
func (o *Subscription) SetCurrency(v string) {
o.Currency = v
}
// GetCurrentInterval returns the CurrentInterval field value
func (o *Subscription) GetCurrentInterval() string {
if o == nil {
var ret string
return ret
}
return o.CurrentInterval
}
// GetCurrentIntervalOk returns a tuple with the CurrentInterval field value
// and a boolean to check if the value has been set.
func (o *Subscription) GetCurrentIntervalOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.CurrentInterval, true
}
// SetCurrentInterval sets field value
func (o *Subscription) SetCurrentInterval(v string) {
o.CurrentInterval = v
}
// GetCurrentPlan returns the CurrentPlan field value
func (o *Subscription) GetCurrentPlan() string {
if o == nil {
var ret string
return ret
}
return o.CurrentPlan
}
// GetCurrentPlanOk returns a tuple with the CurrentPlan field value
// and a boolean to check if the value has been set.
func (o *Subscription) GetCurrentPlanOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.CurrentPlan, true
}
// SetCurrentPlan sets field value
func (o *Subscription) SetCurrentPlan(v string) {
o.CurrentPlan = v
}
// GetCurrentPlanDetails returns the CurrentPlanDetails field value if set, zero value otherwise.
func (o *Subscription) GetCurrentPlanDetails() PlanDetails {
if o == nil || IsNil(o.CurrentPlanDetails) {
var ret PlanDetails
return ret
}
return *o.CurrentPlanDetails
}
// GetCurrentPlanDetailsOk returns a tuple with the CurrentPlanDetails field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Subscription) GetCurrentPlanDetailsOk() (*PlanDetails, bool) {
if o == nil || IsNil(o.CurrentPlanDetails) {
return nil, false
}
return o.CurrentPlanDetails, true
}
// HasCurrentPlanDetails returns a boolean if a field has been set.
func (o *Subscription) HasCurrentPlanDetails() bool {
if o != nil && !IsNil(o.CurrentPlanDetails) {
return true
}
return false
}
// SetCurrentPlanDetails gets a reference to the given PlanDetails and assigns it to the CurrentPlanDetails field.
func (o *Subscription) SetCurrentPlanDetails(v PlanDetails) {
o.CurrentPlanDetails = &v
}
// GetCustomerId returns the CustomerId field value
func (o *Subscription) GetCustomerId() string {
if o == nil {
var ret string
return ret
}
return o.CustomerId
}
// GetCustomerIdOk returns a tuple with the CustomerId field value
// and a boolean to check if the value has been set.
func (o *Subscription) GetCustomerIdOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.CustomerId, true
}
// SetCustomerId sets field value
func (o *Subscription) SetCustomerId(v string) {
o.CustomerId = v
}
// GetId returns the Id field value
func (o *Subscription) GetId() string {
if o == nil {
var ret string
return ret
}
return o.Id
}
// GetIdOk returns a tuple with the Id field value
// and a boolean to check if the value has been set.
func (o *Subscription) GetIdOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Id, true
}
// SetId sets field value
func (o *Subscription) SetId(v string) {
o.Id = v
}
// GetIntervalChangesTo returns the IntervalChangesTo field value
// If the value is explicit nil, the zero value for string will be returned
func (o *Subscription) GetIntervalChangesTo() string {
if o == nil || o.IntervalChangesTo.Get() == nil {
var ret string
return ret
}
return *o.IntervalChangesTo.Get()
}
// GetIntervalChangesToOk returns a tuple with the IntervalChangesTo field value
// 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 *Subscription) GetIntervalChangesToOk() (*string, bool) {
if o == nil {
return nil, false
}
return o.IntervalChangesTo.Get(), o.IntervalChangesTo.IsSet()
}
// SetIntervalChangesTo sets field value
func (o *Subscription) SetIntervalChangesTo(v string) {
o.IntervalChangesTo.Set(&v)
}
// GetOngoingStripeCheckoutId returns the OngoingStripeCheckoutId field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *Subscription) GetOngoingStripeCheckoutId() string {
if o == nil || IsNil(o.OngoingStripeCheckoutId.Get()) {
var ret string
return ret
}
return *o.OngoingStripeCheckoutId.Get()
}
// GetOngoingStripeCheckoutIdOk returns a tuple with the OngoingStripeCheckoutId 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 *Subscription) GetOngoingStripeCheckoutIdOk() (*string, bool) {
if o == nil {
return nil, false
}
return o.OngoingStripeCheckoutId.Get(), o.OngoingStripeCheckoutId.IsSet()
}
// HasOngoingStripeCheckoutId returns a boolean if a field has been set.
func (o *Subscription) HasOngoingStripeCheckoutId() bool {
if o != nil && o.OngoingStripeCheckoutId.IsSet() {
return true
}
return false
}
// SetOngoingStripeCheckoutId gets a reference to the given NullableString and assigns it to the OngoingStripeCheckoutId field.
func (o *Subscription) SetOngoingStripeCheckoutId(v string) {
o.OngoingStripeCheckoutId.Set(&v)
}
// SetOngoingStripeCheckoutIdNil sets the value for OngoingStripeCheckoutId to be an explicit nil
func (o *Subscription) SetOngoingStripeCheckoutIdNil() {
o.OngoingStripeCheckoutId.Set(nil)
}
// UnsetOngoingStripeCheckoutId ensures that no value is present for OngoingStripeCheckoutId, not even an explicit nil
func (o *Subscription) UnsetOngoingStripeCheckoutId() {
o.OngoingStripeCheckoutId.Unset()
}
// GetPayedUntil returns the PayedUntil field value
func (o *Subscription) GetPayedUntil() time.Time {
if o == nil {
var ret time.Time
return ret
}
return o.PayedUntil
}
// GetPayedUntilOk returns a tuple with the PayedUntil field value
// and a boolean to check if the value has been set.
func (o *Subscription) GetPayedUntilOk() (*time.Time, bool) {
if o == nil {
return nil, false
}
return &o.PayedUntil, true
}
// SetPayedUntil sets field value
func (o *Subscription) SetPayedUntil(v time.Time) {
o.PayedUntil = v
}
// GetPlanChangesAt returns the PlanChangesAt field value if set, zero value otherwise.
func (o *Subscription) GetPlanChangesAt() time.Time {
if o == nil || IsNil(o.PlanChangesAt) {
var ret time.Time
return ret
}
return *o.PlanChangesAt
}
// GetPlanChangesAtOk returns a tuple with the PlanChangesAt field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Subscription) GetPlanChangesAtOk() (*time.Time, bool) {
if o == nil || IsNil(o.PlanChangesAt) {
return nil, false
}
return o.PlanChangesAt, true
}
// HasPlanChangesAt returns a boolean if a field has been set.
func (o *Subscription) HasPlanChangesAt() bool {
if o != nil && !IsNil(o.PlanChangesAt) {
return true
}
return false
}
// SetPlanChangesAt gets a reference to the given time.Time and assigns it to the PlanChangesAt field.
func (o *Subscription) SetPlanChangesAt(v time.Time) {
o.PlanChangesAt = &v
}
// GetPlanChangesTo returns the PlanChangesTo field value
// If the value is explicit nil, the zero value for string will be returned
func (o *Subscription) GetPlanChangesTo() string {
if o == nil || o.PlanChangesTo.Get() == nil {
var ret string
return ret
}
return *o.PlanChangesTo.Get()
}
// GetPlanChangesToOk returns a tuple with the PlanChangesTo field value
// 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 *Subscription) GetPlanChangesToOk() (*string, bool) {
if o == nil {
return nil, false
}
return o.PlanChangesTo.Get(), o.PlanChangesTo.IsSet()
}
// SetPlanChangesTo sets field value
func (o *Subscription) SetPlanChangesTo(v string) {
o.PlanChangesTo.Set(&v)
}
// GetStatus returns the Status field value
func (o *Subscription) GetStatus() string {
if o == nil {
var ret string
return ret
}
return o.Status
}
// GetStatusOk returns a tuple with the Status field value
// and a boolean to check if the value has been set.
func (o *Subscription) GetStatusOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Status, true
}
// SetStatus sets field value
func (o *Subscription) SetStatus(v string) {
o.Status = v
}
// GetStripeCheckoutExpiresAt returns the StripeCheckoutExpiresAt field value if set, zero value otherwise.
func (o *Subscription) GetStripeCheckoutExpiresAt() time.Time {
if o == nil || IsNil(o.StripeCheckoutExpiresAt) {
var ret time.Time
return ret
}
return *o.StripeCheckoutExpiresAt
}
// GetStripeCheckoutExpiresAtOk returns a tuple with the StripeCheckoutExpiresAt field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Subscription) GetStripeCheckoutExpiresAtOk() (*time.Time, bool) {
if o == nil || IsNil(o.StripeCheckoutExpiresAt) {
return nil, false
}
return o.StripeCheckoutExpiresAt, true
}
// HasStripeCheckoutExpiresAt returns a boolean if a field has been set.
func (o *Subscription) HasStripeCheckoutExpiresAt() bool {
if o != nil && !IsNil(o.StripeCheckoutExpiresAt) {
return true
}
return false
}
// SetStripeCheckoutExpiresAt gets a reference to the given time.Time and assigns it to the StripeCheckoutExpiresAt field.
func (o *Subscription) SetStripeCheckoutExpiresAt(v time.Time) {
o.StripeCheckoutExpiresAt = &v
}
// GetUpdatedAt returns the UpdatedAt field value
func (o *Subscription) GetUpdatedAt() time.Time {
if o == nil {
var ret time.Time
return ret
}
return o.UpdatedAt
}
// GetUpdatedAtOk returns a tuple with the UpdatedAt field value
// and a boolean to check if the value has been set.
func (o *Subscription) GetUpdatedAtOk() (*time.Time, bool) {
if o == nil {
return nil, false
}
return &o.UpdatedAt, true
}
// SetUpdatedAt sets field value
func (o *Subscription) SetUpdatedAt(v time.Time) {
o.UpdatedAt = v
}
func (o Subscription) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o Subscription) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
toSerialize["created_at"] = o.CreatedAt
toSerialize["currency"] = o.Currency
toSerialize["current_interval"] = o.CurrentInterval
toSerialize["current_plan"] = o.CurrentPlan
if !IsNil(o.CurrentPlanDetails) {
toSerialize["current_plan_details"] = o.CurrentPlanDetails
}
toSerialize["customer_id"] = o.CustomerId
toSerialize["id"] = o.Id
toSerialize["interval_changes_to"] = o.IntervalChangesTo.Get()
if o.OngoingStripeCheckoutId.IsSet() {
toSerialize["ongoing_stripe_checkout_id"] = o.OngoingStripeCheckoutId.Get()
}
toSerialize["payed_until"] = o.PayedUntil
if !IsNil(o.PlanChangesAt) {
toSerialize["plan_changes_at"] = o.PlanChangesAt
}
toSerialize["plan_changes_to"] = o.PlanChangesTo.Get()
toSerialize["status"] = o.Status
if !IsNil(o.StripeCheckoutExpiresAt) {
toSerialize["stripe_checkout_expires_at"] = o.StripeCheckoutExpiresAt
}
toSerialize["updated_at"] = o.UpdatedAt
for key, value := range o.AdditionalProperties {
toSerialize[key] = value
}
return toSerialize, nil
}
func (o *Subscription) 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{
"created_at",
"currency",
"current_interval",
"current_plan",
"customer_id",
"id",
"interval_changes_to",
"payed_until",
"plan_changes_to",
"status",
"updated_at",
}
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)
}
}
varSubscription := _Subscription{}
err = json.Unmarshal(data, &varSubscription)
if err != nil {
return err
}
*o = Subscription(varSubscription)
additionalProperties := make(map[string]interface{})
if err = json.Unmarshal(data, &additionalProperties); err == nil {
delete(additionalProperties, "created_at")
delete(additionalProperties, "currency")
delete(additionalProperties, "current_interval")
delete(additionalProperties, "current_plan")
delete(additionalProperties, "current_plan_details")
delete(additionalProperties, "customer_id")
delete(additionalProperties, "id")
delete(additionalProperties, "interval_changes_to")
delete(additionalProperties, "ongoing_stripe_checkout_id")
delete(additionalProperties, "payed_until")
delete(additionalProperties, "plan_changes_at")
delete(additionalProperties, "plan_changes_to")
delete(additionalProperties, "status")
delete(additionalProperties, "stripe_checkout_expires_at")
delete(additionalProperties, "updated_at")
o.AdditionalProperties = additionalProperties
}
return err
}
type NullableSubscription struct {
value *Subscription
isSet bool
}
func (v NullableSubscription) Get() *Subscription {
return v.value
}
func (v *NullableSubscription) Set(val *Subscription) {
v.value = val
v.isSet = true
}
func (v NullableSubscription) IsSet() bool {
return v.isSet
}
func (v *NullableSubscription) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableSubscription(val *Subscription) *NullableSubscription {
return &NullableSubscription{value: val, isSet: true}
}
func (v NullableSubscription) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableSubscription) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}