-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsubscriptions.go
1926 lines (1711 loc) · 59.4 KB
/
subscriptions.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
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// This file was auto-generated by Fern from our API Definition.
package square
import (
json "encoding/json"
fmt "fmt"
internal "github.com/square/square-go-sdk/internal"
)
type BulkSwapPlanRequest struct {
// The ID of the new subscription plan variation.
//
// This field is required.
NewPlanVariationID string `json:"new_plan_variation_id" url:"-"`
// The ID of the plan variation whose subscriptions should be swapped. Active subscriptions
// using this plan variation will be subscribed to the new plan variation on their next billing
// day.
OldPlanVariationID string `json:"old_plan_variation_id" url:"-"`
// The ID of the location to associate with the swapped subscriptions.
LocationID string `json:"location_id" url:"-"`
}
type ChangeBillingAnchorDateRequest struct {
// The ID of the subscription to update the billing anchor date.
SubscriptionID string `json:"-" url:"-"`
// The anchor day for the billing cycle.
MonthlyBillingAnchorDate *int `json:"monthly_billing_anchor_date,omitempty" url:"-"`
// The `YYYY-MM-DD`-formatted date when the scheduled `BILLING_ANCHOR_CHANGE` action takes
// place on the subscription.
//
// When this date is unspecified or falls within the current billing cycle, the billing anchor date
// is changed immediately.
EffectiveDate *string `json:"effective_date,omitempty" url:"-"`
}
type SubscriptionsDeleteActionRequest struct {
// The ID of the subscription the targeted action is to act upon.
SubscriptionID string `json:"-" url:"-"`
// The ID of the targeted action to be deleted.
ActionID string `json:"-" url:"-"`
}
type SwapPlanRequest struct {
// The ID of the subscription to swap the subscription plan for.
SubscriptionID string `json:"-" url:"-"`
// The ID of the new subscription plan variation.
//
// This field is required.
NewPlanVariationID *string `json:"new_plan_variation_id,omitempty" url:"-"`
// A list of PhaseInputs, to pass phase-specific information used in the swap.
Phases []*PhaseInput `json:"phases,omitempty" url:"-"`
}
type SubscriptionsCancelRequest struct {
// The ID of the subscription to cancel.
SubscriptionID string `json:"-" url:"-"`
}
type CreateSubscriptionRequest struct {
// A unique string that identifies this `CreateSubscription` request.
// If you do not provide a unique string (or provide an empty string as the value),
// the endpoint treats each request as independent.
//
// For more information, see [Idempotency keys](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency).
IdempotencyKey *string `json:"idempotency_key,omitempty" url:"-"`
// The ID of the location the subscription is associated with.
LocationID string `json:"location_id" url:"-"`
// The ID of the [subscription plan variation](https://developer.squareup.com/docs/subscriptions-api/plans-and-variations#plan-variations) created using the Catalog API.
PlanVariationID *string `json:"plan_variation_id,omitempty" url:"-"`
// The ID of the [customer](entity:Customer) subscribing to the subscription plan variation.
CustomerID string `json:"customer_id" url:"-"`
// The `YYYY-MM-DD`-formatted date to start the subscription.
// If it is unspecified, the subscription starts immediately.
StartDate *string `json:"start_date,omitempty" url:"-"`
// The `YYYY-MM-DD`-formatted date when the newly created subscription is scheduled for cancellation.
//
// This date overrides the cancellation date set in the plan variation configuration.
// If the cancellation date is earlier than the end date of a subscription cycle, the subscription stops
// at the canceled date and the subscriber is sent a prorated invoice at the beginning of the canceled cycle.
//
// When the subscription plan of the newly created subscription has a fixed number of cycles and the `canceled_date`
// occurs before the subscription plan expires, the specified `canceled_date` sets the date when the subscription
// stops through the end of the last cycle.
CanceledDate *string `json:"canceled_date,omitempty" url:"-"`
// The tax to add when billing the subscription.
// The percentage is expressed in decimal form, using a `'.'` as the decimal
// separator and without a `'%'` sign. For example, a value of 7.5
// corresponds to 7.5%.
TaxPercentage *string `json:"tax_percentage,omitempty" url:"-"`
// A custom price which overrides the cost of a subscription plan variation with `STATIC` pricing.
// This field does not affect itemized subscriptions with `RELATIVE` pricing. Instead,
// you should edit the Subscription's [order template](https://developer.squareup.com/docs/subscriptions-api/manage-subscriptions#phases-and-order-templates).
PriceOverrideMoney *Money `json:"price_override_money,omitempty" url:"-"`
// The ID of the [subscriber's](entity:Customer) [card](entity:Card) to charge.
// If it is not specified, the subscriber receives an invoice via email with a link to pay for their subscription.
CardID *string `json:"card_id,omitempty" url:"-"`
// The timezone that is used in date calculations for the subscription. If unset, defaults to
// the location timezone. If a timezone is not configured for the location, defaults to "America/New_York".
// Format: the IANA Timezone Database identifier for the location timezone. For
// a list of time zones, see [List of tz database time zones](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).
Timezone *string `json:"timezone,omitempty" url:"-"`
// The origination details of the subscription.
Source *SubscriptionSource `json:"source,omitempty" url:"-"`
// The day-of-the-month to change the billing date to.
MonthlyBillingAnchorDate *int `json:"monthly_billing_anchor_date,omitempty" url:"-"`
// array of phases for this subscription
Phases []*Phase `json:"phases,omitempty" url:"-"`
}
type SubscriptionsGetRequest struct {
// The ID of the subscription to retrieve.
SubscriptionID string `json:"-" url:"-"`
// A query parameter to specify related information to be included in the response.
//
// The supported query parameter values are:
//
// - `actions`: to include scheduled actions on the targeted subscription.
Include *string `json:"-" url:"include,omitempty"`
}
type SubscriptionsListEventsRequest struct {
// The ID of the subscription to retrieve the events for.
SubscriptionID string `json:"-" url:"-"`
// When the total number of resulting subscription events exceeds the limit of a paged response,
// specify the cursor returned from a preceding response here to fetch the next set of results.
// If the cursor is unset, the response contains the last page of the results.
//
// For more information, see [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination).
Cursor *string `json:"-" url:"cursor,omitempty"`
// The upper limit on the number of subscription events to return
// in a paged response.
Limit *int `json:"-" url:"limit,omitempty"`
}
type PauseSubscriptionRequest struct {
// The ID of the subscription to pause.
SubscriptionID string `json:"-" url:"-"`
// The `YYYY-MM-DD`-formatted date when the scheduled `PAUSE` action takes place on the subscription.
//
// When this date is unspecified or falls within the current billing cycle, the subscription is paused
// on the starting date of the next billing cycle.
PauseEffectiveDate *string `json:"pause_effective_date,omitempty" url:"-"`
// The number of billing cycles the subscription will be paused before it is reactivated.
//
// When this is set, a `RESUME` action is also scheduled to take place on the subscription at
// the end of the specified pause cycle duration. In this case, neither `resume_effective_date`
// nor `resume_change_timing` may be specified.
PauseCycleDuration *int64 `json:"pause_cycle_duration,omitempty" url:"-"`
// The date when the subscription is reactivated by a scheduled `RESUME` action.
// This date must be at least one billing cycle ahead of `pause_effective_date`.
ResumeEffectiveDate *string `json:"resume_effective_date,omitempty" url:"-"`
// The timing whether the subscription is reactivated immediately or at the end of the billing cycle, relative to
// `resume_effective_date`.
// See [ChangeTiming](#type-changetiming) for possible values
ResumeChangeTiming *ChangeTiming `json:"resume_change_timing,omitempty" url:"-"`
// The user-provided reason to pause the subscription.
PauseReason *string `json:"pause_reason,omitempty" url:"-"`
}
type ResumeSubscriptionRequest struct {
// The ID of the subscription to resume.
SubscriptionID string `json:"-" url:"-"`
// The `YYYY-MM-DD`-formatted date when the subscription reactivated.
ResumeEffectiveDate *string `json:"resume_effective_date,omitempty" url:"-"`
// The timing to resume a subscription, relative to the specified
// `resume_effective_date` attribute value.
// See [ChangeTiming](#type-changetiming) for possible values
ResumeChangeTiming *ChangeTiming `json:"resume_change_timing,omitempty" url:"-"`
}
type SearchSubscriptionsRequest struct {
// When the total number of resulting subscriptions exceeds the limit of a paged response,
// specify the cursor returned from a preceding response here to fetch the next set of results.
// If the cursor is unset, the response contains the last page of the results.
//
// For more information, see [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination).
Cursor *string `json:"cursor,omitempty" url:"-"`
// The upper limit on the number of subscriptions to return
// in a paged response.
Limit *int `json:"limit,omitempty" url:"-"`
// A subscription query consisting of specified filtering conditions.
//
// If this `query` field is unspecified, the `SearchSubscriptions` call will return all subscriptions.
Query *SearchSubscriptionsQuery `json:"query,omitempty" url:"-"`
// An option to include related information in the response.
//
// The supported values are:
//
// - `actions`: to include scheduled actions on the targeted subscriptions.
Include []string `json:"include,omitempty" url:"-"`
}
// Defines output parameters in a response of the
// [BulkSwapPlan](api-endpoint:Subscriptions-BulkSwapPlan) endpoint.
type BulkSwapPlanResponse struct {
// Errors encountered during the request.
Errors []*Error `json:"errors,omitempty" url:"errors,omitempty"`
// The number of affected subscriptions.
AffectedSubscriptions *int `json:"affected_subscriptions,omitempty" url:"affected_subscriptions,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (b *BulkSwapPlanResponse) GetErrors() []*Error {
if b == nil {
return nil
}
return b.Errors
}
func (b *BulkSwapPlanResponse) GetAffectedSubscriptions() *int {
if b == nil {
return nil
}
return b.AffectedSubscriptions
}
func (b *BulkSwapPlanResponse) GetExtraProperties() map[string]interface{} {
return b.extraProperties
}
func (b *BulkSwapPlanResponse) UnmarshalJSON(data []byte) error {
type unmarshaler BulkSwapPlanResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*b = BulkSwapPlanResponse(value)
extraProperties, err := internal.ExtractExtraProperties(data, *b)
if err != nil {
return err
}
b.extraProperties = extraProperties
b.rawJSON = json.RawMessage(data)
return nil
}
func (b *BulkSwapPlanResponse) String() string {
if len(b.rawJSON) > 0 {
if value, err := internal.StringifyJSON(b.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(b); err == nil {
return value
}
return fmt.Sprintf("%#v", b)
}
// Defines output parameters in a response from the
// [CancelSubscription](api-endpoint:Subscriptions-CancelSubscription) endpoint.
type CancelSubscriptionResponse struct {
// Errors encountered during the request.
Errors []*Error `json:"errors,omitempty" url:"errors,omitempty"`
// The specified subscription scheduled for cancellation according to the action created by the request.
Subscription *Subscription `json:"subscription,omitempty" url:"subscription,omitempty"`
// A list of a single `CANCEL` action scheduled for the subscription.
Actions []*SubscriptionAction `json:"actions,omitempty" url:"actions,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (c *CancelSubscriptionResponse) GetErrors() []*Error {
if c == nil {
return nil
}
return c.Errors
}
func (c *CancelSubscriptionResponse) GetSubscription() *Subscription {
if c == nil {
return nil
}
return c.Subscription
}
func (c *CancelSubscriptionResponse) GetActions() []*SubscriptionAction {
if c == nil {
return nil
}
return c.Actions
}
func (c *CancelSubscriptionResponse) GetExtraProperties() map[string]interface{} {
return c.extraProperties
}
func (c *CancelSubscriptionResponse) UnmarshalJSON(data []byte) error {
type unmarshaler CancelSubscriptionResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*c = CancelSubscriptionResponse(value)
extraProperties, err := internal.ExtractExtraProperties(data, *c)
if err != nil {
return err
}
c.extraProperties = extraProperties
c.rawJSON = json.RawMessage(data)
return nil
}
func (c *CancelSubscriptionResponse) String() string {
if len(c.rawJSON) > 0 {
if value, err := internal.StringifyJSON(c.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(c); err == nil {
return value
}
return fmt.Sprintf("%#v", c)
}
// Defines output parameters in a request to the
// [ChangeBillingAnchorDate](api-endpoint:Subscriptions-ChangeBillingAnchorDate) endpoint.
type ChangeBillingAnchorDateResponse struct {
// Errors encountered during the request.
Errors []*Error `json:"errors,omitempty" url:"errors,omitempty"`
// The specified subscription for updating billing anchor date.
Subscription *Subscription `json:"subscription,omitempty" url:"subscription,omitempty"`
// A list of a single billing anchor date change for the subscription.
Actions []*SubscriptionAction `json:"actions,omitempty" url:"actions,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (c *ChangeBillingAnchorDateResponse) GetErrors() []*Error {
if c == nil {
return nil
}
return c.Errors
}
func (c *ChangeBillingAnchorDateResponse) GetSubscription() *Subscription {
if c == nil {
return nil
}
return c.Subscription
}
func (c *ChangeBillingAnchorDateResponse) GetActions() []*SubscriptionAction {
if c == nil {
return nil
}
return c.Actions
}
func (c *ChangeBillingAnchorDateResponse) GetExtraProperties() map[string]interface{} {
return c.extraProperties
}
func (c *ChangeBillingAnchorDateResponse) UnmarshalJSON(data []byte) error {
type unmarshaler ChangeBillingAnchorDateResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*c = ChangeBillingAnchorDateResponse(value)
extraProperties, err := internal.ExtractExtraProperties(data, *c)
if err != nil {
return err
}
c.extraProperties = extraProperties
c.rawJSON = json.RawMessage(data)
return nil
}
func (c *ChangeBillingAnchorDateResponse) String() string {
if len(c.rawJSON) > 0 {
if value, err := internal.StringifyJSON(c.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(c); err == nil {
return value
}
return fmt.Sprintf("%#v", c)
}
// Supported timings when a pending change, as an action, takes place to a subscription.
type ChangeTiming string
const (
ChangeTimingImmediate ChangeTiming = "IMMEDIATE"
ChangeTimingEndOfBillingCycle ChangeTiming = "END_OF_BILLING_CYCLE"
)
func NewChangeTimingFromString(s string) (ChangeTiming, error) {
switch s {
case "IMMEDIATE":
return ChangeTimingImmediate, nil
case "END_OF_BILLING_CYCLE":
return ChangeTimingEndOfBillingCycle, nil
}
var t ChangeTiming
return "", fmt.Errorf("%s is not a valid %T", s, t)
}
func (c ChangeTiming) Ptr() *ChangeTiming {
return &c
}
// Defines output parameters in a response from the
// [CreateSubscription](api-endpoint:Subscriptions-CreateSubscription) endpoint.
type CreateSubscriptionResponse struct {
// Errors encountered during the request.
Errors []*Error `json:"errors,omitempty" url:"errors,omitempty"`
// The newly created subscription.
//
// For more information, see
// [Subscription object](https://developer.squareup.com/docs/subscriptions-api/manage-subscriptions#subscription-object).
Subscription *Subscription `json:"subscription,omitempty" url:"subscription,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (c *CreateSubscriptionResponse) GetErrors() []*Error {
if c == nil {
return nil
}
return c.Errors
}
func (c *CreateSubscriptionResponse) GetSubscription() *Subscription {
if c == nil {
return nil
}
return c.Subscription
}
func (c *CreateSubscriptionResponse) GetExtraProperties() map[string]interface{} {
return c.extraProperties
}
func (c *CreateSubscriptionResponse) UnmarshalJSON(data []byte) error {
type unmarshaler CreateSubscriptionResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*c = CreateSubscriptionResponse(value)
extraProperties, err := internal.ExtractExtraProperties(data, *c)
if err != nil {
return err
}
c.extraProperties = extraProperties
c.rawJSON = json.RawMessage(data)
return nil
}
func (c *CreateSubscriptionResponse) String() string {
if len(c.rawJSON) > 0 {
if value, err := internal.StringifyJSON(c.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(c); err == nil {
return value
}
return fmt.Sprintf("%#v", c)
}
// Defines output parameters in a response of the [DeleteSubscriptionAction](api-endpoint:Subscriptions-DeleteSubscriptionAction)
// endpoint.
type DeleteSubscriptionActionResponse struct {
// Errors encountered during the request.
Errors []*Error `json:"errors,omitempty" url:"errors,omitempty"`
// The subscription that has the specified action deleted.
Subscription *Subscription `json:"subscription,omitempty" url:"subscription,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (d *DeleteSubscriptionActionResponse) GetErrors() []*Error {
if d == nil {
return nil
}
return d.Errors
}
func (d *DeleteSubscriptionActionResponse) GetSubscription() *Subscription {
if d == nil {
return nil
}
return d.Subscription
}
func (d *DeleteSubscriptionActionResponse) GetExtraProperties() map[string]interface{} {
return d.extraProperties
}
func (d *DeleteSubscriptionActionResponse) UnmarshalJSON(data []byte) error {
type unmarshaler DeleteSubscriptionActionResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*d = DeleteSubscriptionActionResponse(value)
extraProperties, err := internal.ExtractExtraProperties(data, *d)
if err != nil {
return err
}
d.extraProperties = extraProperties
d.rawJSON = json.RawMessage(data)
return nil
}
func (d *DeleteSubscriptionActionResponse) String() string {
if len(d.rawJSON) > 0 {
if value, err := internal.StringifyJSON(d.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(d); err == nil {
return value
}
return fmt.Sprintf("%#v", d)
}
// Defines output parameters in a response from the
// [RetrieveSubscription](api-endpoint:Subscriptions-RetrieveSubscription) endpoint.
type GetSubscriptionResponse struct {
// Errors encountered during the request.
Errors []*Error `json:"errors,omitempty" url:"errors,omitempty"`
// The subscription retrieved.
Subscription *Subscription `json:"subscription,omitempty" url:"subscription,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (g *GetSubscriptionResponse) GetErrors() []*Error {
if g == nil {
return nil
}
return g.Errors
}
func (g *GetSubscriptionResponse) GetSubscription() *Subscription {
if g == nil {
return nil
}
return g.Subscription
}
func (g *GetSubscriptionResponse) GetExtraProperties() map[string]interface{} {
return g.extraProperties
}
func (g *GetSubscriptionResponse) UnmarshalJSON(data []byte) error {
type unmarshaler GetSubscriptionResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*g = GetSubscriptionResponse(value)
extraProperties, err := internal.ExtractExtraProperties(data, *g)
if err != nil {
return err
}
g.extraProperties = extraProperties
g.rawJSON = json.RawMessage(data)
return nil
}
func (g *GetSubscriptionResponse) String() string {
if len(g.rawJSON) > 0 {
if value, err := internal.StringifyJSON(g.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(g); err == nil {
return value
}
return fmt.Sprintf("%#v", g)
}
// Defines output parameters in a response from the
// [ListSubscriptionEvents](api-endpoint:Subscriptions-ListSubscriptionEvents).
type ListSubscriptionEventsResponse struct {
// Errors encountered during the request.
Errors []*Error `json:"errors,omitempty" url:"errors,omitempty"`
// The retrieved subscription events.
SubscriptionEvents []*SubscriptionEvent `json:"subscription_events,omitempty" url:"subscription_events,omitempty"`
// When the total number of resulting subscription events exceeds the limit of a paged response,
// the response includes a cursor for you to use in a subsequent request to fetch the next set of events.
// If the cursor is unset, the response contains the last page of the results.
//
// For more information, see [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination).
Cursor *string `json:"cursor,omitempty" url:"cursor,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (l *ListSubscriptionEventsResponse) GetErrors() []*Error {
if l == nil {
return nil
}
return l.Errors
}
func (l *ListSubscriptionEventsResponse) GetSubscriptionEvents() []*SubscriptionEvent {
if l == nil {
return nil
}
return l.SubscriptionEvents
}
func (l *ListSubscriptionEventsResponse) GetCursor() *string {
if l == nil {
return nil
}
return l.Cursor
}
func (l *ListSubscriptionEventsResponse) GetExtraProperties() map[string]interface{} {
return l.extraProperties
}
func (l *ListSubscriptionEventsResponse) UnmarshalJSON(data []byte) error {
type unmarshaler ListSubscriptionEventsResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*l = ListSubscriptionEventsResponse(value)
extraProperties, err := internal.ExtractExtraProperties(data, *l)
if err != nil {
return err
}
l.extraProperties = extraProperties
l.rawJSON = json.RawMessage(data)
return nil
}
func (l *ListSubscriptionEventsResponse) String() string {
if len(l.rawJSON) > 0 {
if value, err := internal.StringifyJSON(l.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(l); err == nil {
return value
}
return fmt.Sprintf("%#v", l)
}
// Defines output parameters in a response from the
// [PauseSubscription](api-endpoint:Subscriptions-PauseSubscription) endpoint.
type PauseSubscriptionResponse struct {
// Errors encountered during the request.
Errors []*Error `json:"errors,omitempty" url:"errors,omitempty"`
// The subscription to be paused by the scheduled `PAUSE` action.
Subscription *Subscription `json:"subscription,omitempty" url:"subscription,omitempty"`
// The list of a `PAUSE` action and a possible `RESUME` action created by the request.
Actions []*SubscriptionAction `json:"actions,omitempty" url:"actions,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (p *PauseSubscriptionResponse) GetErrors() []*Error {
if p == nil {
return nil
}
return p.Errors
}
func (p *PauseSubscriptionResponse) GetSubscription() *Subscription {
if p == nil {
return nil
}
return p.Subscription
}
func (p *PauseSubscriptionResponse) GetActions() []*SubscriptionAction {
if p == nil {
return nil
}
return p.Actions
}
func (p *PauseSubscriptionResponse) GetExtraProperties() map[string]interface{} {
return p.extraProperties
}
func (p *PauseSubscriptionResponse) UnmarshalJSON(data []byte) error {
type unmarshaler PauseSubscriptionResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*p = PauseSubscriptionResponse(value)
extraProperties, err := internal.ExtractExtraProperties(data, *p)
if err != nil {
return err
}
p.extraProperties = extraProperties
p.rawJSON = json.RawMessage(data)
return nil
}
func (p *PauseSubscriptionResponse) String() string {
if len(p.rawJSON) > 0 {
if value, err := internal.StringifyJSON(p.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(p); err == nil {
return value
}
return fmt.Sprintf("%#v", p)
}
// Represents a phase, which can override subscription phases as defined by plan_id
type Phase struct {
// id of subscription phase
UID *string `json:"uid,omitempty" url:"uid,omitempty"`
// index of phase in total subscription plan
Ordinal *int64 `json:"ordinal,omitempty" url:"ordinal,omitempty"`
// id of order to be used in billing
OrderTemplateID *string `json:"order_template_id,omitempty" url:"order_template_id,omitempty"`
// the uid from the plan's phase in catalog
PlanPhaseUID *string `json:"plan_phase_uid,omitempty" url:"plan_phase_uid,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (p *Phase) GetUID() *string {
if p == nil {
return nil
}
return p.UID
}
func (p *Phase) GetOrdinal() *int64 {
if p == nil {
return nil
}
return p.Ordinal
}
func (p *Phase) GetOrderTemplateID() *string {
if p == nil {
return nil
}
return p.OrderTemplateID
}
func (p *Phase) GetPlanPhaseUID() *string {
if p == nil {
return nil
}
return p.PlanPhaseUID
}
func (p *Phase) GetExtraProperties() map[string]interface{} {
return p.extraProperties
}
func (p *Phase) UnmarshalJSON(data []byte) error {
type unmarshaler Phase
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*p = Phase(value)
extraProperties, err := internal.ExtractExtraProperties(data, *p)
if err != nil {
return err
}
p.extraProperties = extraProperties
p.rawJSON = json.RawMessage(data)
return nil
}
func (p *Phase) String() string {
if len(p.rawJSON) > 0 {
if value, err := internal.StringifyJSON(p.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(p); err == nil {
return value
}
return fmt.Sprintf("%#v", p)
}
// Represents the arguments used to construct a new phase.
type PhaseInput struct {
// index of phase in total subscription plan
Ordinal int64 `json:"ordinal" url:"ordinal"`
// id of order to be used in billing
OrderTemplateID *string `json:"order_template_id,omitempty" url:"order_template_id,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (p *PhaseInput) GetOrdinal() int64 {
if p == nil {
return 0
}
return p.Ordinal
}
func (p *PhaseInput) GetOrderTemplateID() *string {
if p == nil {
return nil
}
return p.OrderTemplateID
}
func (p *PhaseInput) GetExtraProperties() map[string]interface{} {
return p.extraProperties
}
func (p *PhaseInput) UnmarshalJSON(data []byte) error {
type unmarshaler PhaseInput
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*p = PhaseInput(value)
extraProperties, err := internal.ExtractExtraProperties(data, *p)
if err != nil {
return err
}
p.extraProperties = extraProperties
p.rawJSON = json.RawMessage(data)
return nil
}
func (p *PhaseInput) String() string {
if len(p.rawJSON) > 0 {
if value, err := internal.StringifyJSON(p.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(p); err == nil {
return value
}
return fmt.Sprintf("%#v", p)
}
// Defines output parameters in a response from the
// [ResumeSubscription](api-endpoint:Subscriptions-ResumeSubscription) endpoint.
type ResumeSubscriptionResponse struct {
// Errors encountered during the request.
Errors []*Error `json:"errors,omitempty" url:"errors,omitempty"`
// The resumed subscription.
Subscription *Subscription `json:"subscription,omitempty" url:"subscription,omitempty"`
// A list of `RESUME` actions created by the request and scheduled for the subscription.
Actions []*SubscriptionAction `json:"actions,omitempty" url:"actions,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (r *ResumeSubscriptionResponse) GetErrors() []*Error {
if r == nil {
return nil
}
return r.Errors
}
func (r *ResumeSubscriptionResponse) GetSubscription() *Subscription {
if r == nil {
return nil
}
return r.Subscription
}
func (r *ResumeSubscriptionResponse) GetActions() []*SubscriptionAction {
if r == nil {
return nil
}
return r.Actions
}
func (r *ResumeSubscriptionResponse) GetExtraProperties() map[string]interface{} {
return r.extraProperties
}
func (r *ResumeSubscriptionResponse) UnmarshalJSON(data []byte) error {
type unmarshaler ResumeSubscriptionResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*r = ResumeSubscriptionResponse(value)
extraProperties, err := internal.ExtractExtraProperties(data, *r)
if err != nil {
return err
}
r.extraProperties = extraProperties
r.rawJSON = json.RawMessage(data)
return nil
}
func (r *ResumeSubscriptionResponse) String() string {
if len(r.rawJSON) > 0 {
if value, err := internal.StringifyJSON(r.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(r); err == nil {
return value
}
return fmt.Sprintf("%#v", r)
}
// Represents a set of query expressions (filters) to narrow the scope of targeted subscriptions returned by
// the [SearchSubscriptions](api-endpoint:Subscriptions-SearchSubscriptions) endpoint.
type SearchSubscriptionsFilter struct {
// A filter to select subscriptions based on the subscribing customer IDs.
CustomerIDs []string `json:"customer_ids,omitempty" url:"customer_ids,omitempty"`
// A filter to select subscriptions based on the location.
LocationIDs []string `json:"location_ids,omitempty" url:"location_ids,omitempty"`
// A filter to select subscriptions based on the source application.
SourceNames []string `json:"source_names,omitempty" url:"source_names,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (s *SearchSubscriptionsFilter) GetCustomerIDs() []string {
if s == nil {
return nil
}
return s.CustomerIDs
}
func (s *SearchSubscriptionsFilter) GetLocationIDs() []string {
if s == nil {
return nil
}
return s.LocationIDs
}
func (s *SearchSubscriptionsFilter) GetSourceNames() []string {
if s == nil {
return nil
}
return s.SourceNames
}
func (s *SearchSubscriptionsFilter) GetExtraProperties() map[string]interface{} {
return s.extraProperties
}
func (s *SearchSubscriptionsFilter) UnmarshalJSON(data []byte) error {
type unmarshaler SearchSubscriptionsFilter
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*s = SearchSubscriptionsFilter(value)
extraProperties, err := internal.ExtractExtraProperties(data, *s)
if err != nil {
return err
}
s.extraProperties = extraProperties
s.rawJSON = json.RawMessage(data)
return nil
}
func (s *SearchSubscriptionsFilter) String() string {
if len(s.rawJSON) > 0 {
if value, err := internal.StringifyJSON(s.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(s); err == nil {
return value
}
return fmt.Sprintf("%#v", s)
}
// Represents a query, consisting of specified query expressions, used to search for subscriptions.
type SearchSubscriptionsQuery struct {
// A list of query expressions.
Filter *SearchSubscriptionsFilter `json:"filter,omitempty" url:"filter,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (s *SearchSubscriptionsQuery) GetFilter() *SearchSubscriptionsFilter {
if s == nil {