From 64aa4ef7cdd70261ce0fff2578160a8d73e345f1 Mon Sep 17 00:00:00 2001 From: DX Codefresh Date: Wed, 3 Aug 2022 15:35:33 +0000 Subject: [PATCH] Generated Latest Changes for v2021-02-25 --- openapi/api.yaml | 127 ++++++++++++++++++++++++- payment_method.go | 3 + plan.go | 8 ++ plan_create.go | 8 ++ plan_pricing.go | 2 +- plan_pricing_create.go | 2 +- plan_ramp_interval.go | 122 ++++++++++++++++++++++++ plan_ramp_interval_create.go | 16 ++++ plan_ramp_pricing.go | 122 ++++++++++++++++++++++++ plan_ramp_pricing_create.go | 16 ++++ plan_update.go | 5 +- scripts/clean | 6 ++ subscription.go | 3 + subscription_change.go | 3 + subscription_change_create.go | 3 + subscription_create.go | 3 + subscription_purchase.go | 3 + subscription_ramp_interval.go | 16 ++++ subscription_ramp_interval_response.go | 125 ++++++++++++++++++++++++ 19 files changed, 589 insertions(+), 4 deletions(-) create mode 100644 plan_ramp_interval.go create mode 100644 plan_ramp_interval_create.go create mode 100644 plan_ramp_pricing.go create mode 100644 plan_ramp_pricing_create.go create mode 100644 subscription_ramp_interval.go create mode 100644 subscription_ramp_interval_response.go diff --git a/openapi/api.yaml b/openapi/api.yaml index b0cc256..78c9803 100644 --- a/openapi/api.yaml +++ b/openapi/api.yaml @@ -17535,7 +17535,7 @@ components: title: Field value description: Any values that resemble a credit card number or security code (CVV/CVC) will be rejected. - maxLength: 100 + maxLength: 255 required: - name - value @@ -18959,6 +18959,14 @@ components: renew its term at renewal. If `auto_renew` is `false`, then a subscription will expire at the end of its term. `auto_renew` can be overridden on the subscription record itself. + pricing_model: + title: Pricing Model + "$ref": "#/components/schemas/PricingModelTypeEnum" + ramp_intervals: + type: array + title: Ramp Intervals + items: + "$ref": "#/components/schemas/PlanRampInterval" revenue_schedule_type: title: Revenue schedule type "$ref": "#/components/schemas/RevenueScheduleTypeEnum" @@ -19121,6 +19129,14 @@ components: renew its term at renewal. If `auto_renew` is `false`, then a subscription will expire at the end of its term. `auto_renew` can be overridden on the subscription record itself. + pricing_model: + title: Pricing Model + "$ref": "#/components/schemas/PricingModelTypeEnum" + ramp_intervals: + type: array + title: Ramp Intervals + items: + "$ref": "#/components/schemas/PlanRampInterval" revenue_schedule_type: title: Revenue schedule type "$ref": "#/components/schemas/RevenueScheduleTypeEnum" @@ -19242,6 +19258,7 @@ components: type: number format: float title: Unit price + description: This field should not be sent when the pricing model is 'ramp'. minimum: 0 maximum: 1000000 tax_inclusive: @@ -19250,6 +19267,19 @@ components: default: false description: This field is deprecated. Please do not use it. deprecated: true + PlanRampInterval: + type: object + title: Plan Ramp Interval + properties: + starting_billing_cycle: + type: integer + description: Represents the first billing cycle of a ramp. + default: 1 + currencies: + type: array + description: Represents the price for the ramp interval. + items: + "$ref": "#/components/schemas/PlanRampPricing" PlanUpdate: type: object properties: @@ -19316,6 +19346,11 @@ components: renew its term at renewal. If `auto_renew` is `false`, then a subscription will expire at the end of its term. `auto_renew` can be overridden on the subscription record itself. + ramp_intervals: + type: array + title: Ramp Intervals + items: + "$ref": "#/components/schemas/PlanRampInterval" revenue_schedule_type: title: Revenue schedule type "$ref": "#/components/schemas/RevenueScheduleTypeEnum" @@ -19362,6 +19397,7 @@ components: currencies: type: array title: Pricing + description: Optional when the pricing model is 'ramp'. items: "$ref": "#/components/schemas/PlanPricing" minItems: 1 @@ -19441,6 +19477,24 @@ components: If `unit_amount_decimal` is provided, `unit_amount` cannot be provided. required: - currency + PlanRampPricing: + type: object + properties: + currency: + type: string + title: Currency + description: 3-letter ISO 4217 currency code. + maxLength: 3 + unit_amount: + type: number + format: float + title: Unit price + description: Represents the price for the Ramp Interval. + minimum: 0 + maximum: 1000000 + required: + - currency + - unit_amount Pricing: type: object properties: @@ -20044,6 +20098,13 @@ components: default: true title: Auto renew description: Whether the subscription renews at the end of its term. + ramp_intervals: + type: array + title: Ramp Intervals + description: The ramp intervals representing the pricing schedule for the + subscription. + items: + "$ref": "#/components/schemas/SubscriptionRampIntervalResponse" paused_at: type: string format: date-time @@ -20546,6 +20607,13 @@ components: readOnly: true billing_info: "$ref": "#/components/schemas/SubscriptionChangeBillingInfo" + ramp_intervals: + type: array + title: Ramp Intervals + description: The ramp intervals representing the pricing schedule for the + subscription. + items: + "$ref": "#/components/schemas/SubscriptionRampIntervalResponse" SubscriptionChangeBillingInfo: type: object description: Accept nested attributes for three_d_secure_action_result_token_id @@ -20671,6 +20739,12 @@ components: "$ref": "#/components/schemas/GatewayTransactionTypeEnum" billing_info: "$ref": "#/components/schemas/SubscriptionChangeBillingInfoCreate" + ramp_intervals: + type: array + title: Ramp Intervals + description: The new set of ramp intervals for the subscription. + items: + "$ref": "#/components/schemas/SubscriptionRampInterval" SubscriptionChangeShippingCreate: type: object title: Shipping details that will be changed on a subscription @@ -20825,6 +20899,12 @@ components: default: true title: Auto renew description: Whether the subscription renews at the end of its term. + ramp_intervals: + type: array + title: Ramp Intervals + description: The new set of ramp intervals for the subscription. + items: + "$ref": "#/components/schemas/SubscriptionRampInterval" revenue_schedule_type: title: Revenue schedule type "$ref": "#/components/schemas/RevenueScheduleTypeEnum" @@ -20964,6 +21044,12 @@ components: revenue_schedule_type: title: Revenue schedule type "$ref": "#/components/schemas/RevenueScheduleTypeEnum" + ramp_intervals: + type: array + title: Ramp Intervals + description: The new set of ramp intervals for the subscription. + items: + "$ref": "#/components/schemas/SubscriptionRampInterval" required: - plan_code SubscriptionUpdate: @@ -21145,6 +21231,30 @@ components: format: float title: Assigns the subscription's shipping cost. If this is greater than zero then a `method_id` or `method_code` is required. + SubscriptionRampInterval: + type: object + title: Subscription Ramp Interval + properties: + starting_billing_cycle: + type: integer + description: Represents how many billing cycles are included in a ramp interval. + default: 1 + unit_amount: + type: integer + description: Represents the price for the ramp interval. + SubscriptionRampIntervalResponse: + type: object + title: Subscription Ramp Interval + properties: + starting_billing_cycle: + type: integer + description: Represents how many billing cycles are included in a ramp interval. + remaining_billing_cycles: + type: integer + description: Represents how many billing cycles are left in a ramp interval. + unit_amount: + type: integer + description: Represents the price for the ramp interval. TaxInfo: type: object title: Tax info @@ -21998,6 +22108,10 @@ components: routing_number_bank: type: string description: The bank name of this routing number. + username: + type: string + description: Username of the associated payment method. Currently only associated + with Venmo. Error: type: object properties: @@ -22327,6 +22441,16 @@ components: - api_only - read_only - write + PricingModelTypeEnum: + type: string + enum: + - fixed + - ramp + default: fixed + description: | + A fixed pricing model has the same price for each billing period. + A ramp pricing model defines a set of Ramp Intervals, where a subscription changes price on + a specified cadence of billing periods. The price change could be an increase or decrease. RevenueScheduleTypeEnum: type: string enum: @@ -22594,6 +22718,7 @@ components: - paypal_billing_agreement - roku - sepadirectdebit + - venmo - wire_transfer - braintree_v_zero CardTypeEnum: diff --git a/payment_method.go b/payment_method.go index b6ae0dd..12fbb4b 100644 --- a/payment_method.go +++ b/payment_method.go @@ -55,6 +55,9 @@ type PaymentMethod struct { // The bank name of this routing number. RoutingNumberBank string `json:"routing_number_bank,omitempty"` + + // Username of the associated payment method. Currently only associated with Venmo. + Username string `json:"username,omitempty"` } // GetResponse returns the ResponseMetadata that generated this resource diff --git a/plan.go b/plan.go index 354abd7..89ebc66 100644 --- a/plan.go +++ b/plan.go @@ -52,6 +52,14 @@ type Plan struct { // Subscriptions will automatically inherit this value once they are active. If `auto_renew` is `true`, then a subscription will automatically renew its term at renewal. If `auto_renew` is `false`, then a subscription will expire at the end of its term. `auto_renew` can be overridden on the subscription record itself. AutoRenew bool `json:"auto_renew,omitempty"` + // A fixed pricing model has the same price for each billing period. + // A ramp pricing model defines a set of Ramp Intervals, where a subscription changes price on + // a specified cadence of billing periods. The price change could be an increase or decrease. + PricingModel string `json:"pricing_model,omitempty"` + + // Ramp Intervals + RampIntervals []PlanRampInterval `json:"ramp_intervals,omitempty"` + // Revenue schedule type RevenueScheduleType string `json:"revenue_schedule_type,omitempty"` diff --git a/plan_create.go b/plan_create.go index 271c929..889acce 100644 --- a/plan_create.go +++ b/plan_create.go @@ -41,6 +41,14 @@ type PlanCreate struct { // Subscriptions will automatically inherit this value once they are active. If `auto_renew` is `true`, then a subscription will automatically renew its term at renewal. If `auto_renew` is `false`, then a subscription will expire at the end of its term. `auto_renew` can be overridden on the subscription record itself. AutoRenew *bool `json:"auto_renew,omitempty"` + // A fixed pricing model has the same price for each billing period. + // A ramp pricing model defines a set of Ramp Intervals, where a subscription changes price on + // a specified cadence of billing periods. The price change could be an increase or decrease. + PricingModel *string `json:"pricing_model,omitempty"` + + // Ramp Intervals + RampIntervals []PlanRampIntervalCreate `json:"ramp_intervals,omitempty"` + // Revenue schedule type RevenueScheduleType *string `json:"revenue_schedule_type,omitempty"` diff --git a/plan_pricing.go b/plan_pricing.go index c5b5fec..56b4e28 100644 --- a/plan_pricing.go +++ b/plan_pricing.go @@ -18,7 +18,7 @@ type PlanPricing struct { // Amount of one-time setup fee automatically charged at the beginning of a subscription billing cycle. For subscription plans with a trial, the setup fee will be charged at the time of signup. Setup fees do not increase with the quantity of a subscription plan. SetupFee float64 `json:"setup_fee,omitempty"` - // Unit price + // This field should not be sent when the pricing model is 'ramp'. UnitAmount float64 `json:"unit_amount,omitempty"` // This field is deprecated. Please do not use it. diff --git a/plan_pricing_create.go b/plan_pricing_create.go index 175a62a..6875bd2 100644 --- a/plan_pricing_create.go +++ b/plan_pricing_create.go @@ -14,7 +14,7 @@ type PlanPricingCreate struct { // Amount of one-time setup fee automatically charged at the beginning of a subscription billing cycle. For subscription plans with a trial, the setup fee will be charged at the time of signup. Setup fees do not increase with the quantity of a subscription plan. SetupFee *float64 `json:"setup_fee,omitempty"` - // Unit price + // This field should not be sent when the pricing model is 'ramp'. UnitAmount *float64 `json:"unit_amount,omitempty"` // This field is deprecated. Please do not use it. diff --git a/plan_ramp_interval.go b/plan_ramp_interval.go new file mode 100644 index 0000000..cdd683b --- /dev/null +++ b/plan_ramp_interval.go @@ -0,0 +1,122 @@ +// This file is automatically created by Recurly's OpenAPI generation process +// and thus any edits you make by hand will be lost. If you wish to make a +// change to this file, please create a Github issue explaining the changes you +// need and we will usher them to the appropriate places. +package recurly + +import ( + "context" + "net/http" +) + +type PlanRampInterval struct { + recurlyResponse *ResponseMetadata + + // Represents the first billing cycle of a ramp. + StartingBillingCycle int `json:"starting_billing_cycle,omitempty"` + + // Represents the price for the ramp interval. + Currencies []PlanRampPricing `json:"currencies,omitempty"` +} + +// GetResponse returns the ResponseMetadata that generated this resource +func (resource *PlanRampInterval) GetResponse() *ResponseMetadata { + return resource.recurlyResponse +} + +// setResponse sets the ResponseMetadata that generated this resource +func (resource *PlanRampInterval) setResponse(res *ResponseMetadata) { + resource.recurlyResponse = res +} + +// internal struct for deserializing accounts +type planRampIntervalList struct { + ListMetadata + Data []PlanRampInterval `json:"data"` + recurlyResponse *ResponseMetadata +} + +// GetResponse returns the ResponseMetadata that generated this resource +func (resource *planRampIntervalList) GetResponse() *ResponseMetadata { + return resource.recurlyResponse +} + +// setResponse sets the ResponseMetadata that generated this resource +func (resource *planRampIntervalList) setResponse(res *ResponseMetadata) { + resource.recurlyResponse = res +} + +// PlanRampIntervalList allows you to paginate PlanRampInterval objects +type PlanRampIntervalList struct { + client HTTPCaller + requestOptions *RequestOptions + nextPagePath string + hasMore bool + data []PlanRampInterval +} + +func NewPlanRampIntervalList(client HTTPCaller, nextPagePath string, requestOptions *RequestOptions) *PlanRampIntervalList { + return &PlanRampIntervalList{ + client: client, + requestOptions: requestOptions, + nextPagePath: nextPagePath, + hasMore: true, + } +} + +type PlanRampIntervalLister interface { + Fetch() error + FetchWithContext(ctx context.Context) error + Count() (*int64, error) + CountWithContext(ctx context.Context) (*int64, error) + Data() []PlanRampInterval + HasMore() bool + Next() string +} + +func (list *PlanRampIntervalList) HasMore() bool { + return list.hasMore +} + +func (list *PlanRampIntervalList) Next() string { + return list.nextPagePath +} + +func (list *PlanRampIntervalList) Data() []PlanRampInterval { + return list.data +} + +// Fetch fetches the next page of data into the `Data` property +func (list *PlanRampIntervalList) FetchWithContext(ctx context.Context) error { + resources := &planRampIntervalList{} + err := list.client.Call(ctx, http.MethodGet, list.nextPagePath, nil, nil, list.requestOptions, resources) + if err != nil { + return err + } + // copy over properties from the response + list.nextPagePath = resources.Next + list.hasMore = resources.HasMore + list.data = resources.Data + return nil +} + +// Fetch fetches the next page of data into the `Data` property +func (list *PlanRampIntervalList) Fetch() error { + return list.FetchWithContext(context.Background()) +} + +// Count returns the count of items on the server that match this pager +func (list *PlanRampIntervalList) CountWithContext(ctx context.Context) (*int64, error) { + resources := &planRampIntervalList{} + err := list.client.Call(ctx, http.MethodHead, list.nextPagePath, nil, nil, list.requestOptions, resources) + if err != nil { + return nil, err + } + resp := resources.GetResponse() + return resp.TotalRecords, nil +} + +// Count returns the count of items on the server that match this pager +func (list *PlanRampIntervalList) Count() (*int64, error) { + return list.CountWithContext(context.Background()) +} diff --git a/plan_ramp_interval_create.go b/plan_ramp_interval_create.go new file mode 100644 index 0000000..a79f0bb --- /dev/null +++ b/plan_ramp_interval_create.go @@ -0,0 +1,16 @@ +// This file is automatically created by Recurly's OpenAPI generation process +// and thus any edits you make by hand will be lost. If you wish to make a +// change to this file, please create a Github issue explaining the changes you +// need and we will usher them to the appropriate places. +package recurly + +import () + +type PlanRampIntervalCreate struct { + + // Represents the first billing cycle of a ramp. + StartingBillingCycle *int `json:"starting_billing_cycle,omitempty"` + + // Represents the price for the ramp interval. + Currencies []PlanRampPricingCreate `json:"currencies,omitempty"` +} diff --git a/plan_ramp_pricing.go b/plan_ramp_pricing.go new file mode 100644 index 0000000..0534b6d --- /dev/null +++ b/plan_ramp_pricing.go @@ -0,0 +1,122 @@ +// This file is automatically created by Recurly's OpenAPI generation process +// and thus any edits you make by hand will be lost. If you wish to make a +// change to this file, please create a Github issue explaining the changes you +// need and we will usher them to the appropriate places. +package recurly + +import ( + "context" + "net/http" +) + +type PlanRampPricing struct { + recurlyResponse *ResponseMetadata + + // 3-letter ISO 4217 currency code. + Currency string `json:"currency,omitempty"` + + // Represents the price for the Ramp Interval. + UnitAmount float64 `json:"unit_amount,omitempty"` +} + +// GetResponse returns the ResponseMetadata that generated this resource +func (resource *PlanRampPricing) GetResponse() *ResponseMetadata { + return resource.recurlyResponse +} + +// setResponse sets the ResponseMetadata that generated this resource +func (resource *PlanRampPricing) setResponse(res *ResponseMetadata) { + resource.recurlyResponse = res +} + +// internal struct for deserializing accounts +type planRampPricingList struct { + ListMetadata + Data []PlanRampPricing `json:"data"` + recurlyResponse *ResponseMetadata +} + +// GetResponse returns the ResponseMetadata that generated this resource +func (resource *planRampPricingList) GetResponse() *ResponseMetadata { + return resource.recurlyResponse +} + +// setResponse sets the ResponseMetadata that generated this resource +func (resource *planRampPricingList) setResponse(res *ResponseMetadata) { + resource.recurlyResponse = res +} + +// PlanRampPricingList allows you to paginate PlanRampPricing objects +type PlanRampPricingList struct { + client HTTPCaller + requestOptions *RequestOptions + nextPagePath string + hasMore bool + data []PlanRampPricing +} + +func NewPlanRampPricingList(client HTTPCaller, nextPagePath string, requestOptions *RequestOptions) *PlanRampPricingList { + return &PlanRampPricingList{ + client: client, + requestOptions: requestOptions, + nextPagePath: nextPagePath, + hasMore: true, + } +} + +type PlanRampPricingLister interface { + Fetch() error + FetchWithContext(ctx context.Context) error + Count() (*int64, error) + CountWithContext(ctx context.Context) (*int64, error) + Data() []PlanRampPricing + HasMore() bool + Next() string +} + +func (list *PlanRampPricingList) HasMore() bool { + return list.hasMore +} + +func (list *PlanRampPricingList) Next() string { + return list.nextPagePath +} + +func (list *PlanRampPricingList) Data() []PlanRampPricing { + return list.data +} + +// Fetch fetches the next page of data into the `Data` property +func (list *PlanRampPricingList) FetchWithContext(ctx context.Context) error { + resources := &planRampPricingList{} + err := list.client.Call(ctx, http.MethodGet, list.nextPagePath, nil, nil, list.requestOptions, resources) + if err != nil { + return err + } + // copy over properties from the response + list.nextPagePath = resources.Next + list.hasMore = resources.HasMore + list.data = resources.Data + return nil +} + +// Fetch fetches the next page of data into the `Data` property +func (list *PlanRampPricingList) Fetch() error { + return list.FetchWithContext(context.Background()) +} + +// Count returns the count of items on the server that match this pager +func (list *PlanRampPricingList) CountWithContext(ctx context.Context) (*int64, error) { + resources := &planRampPricingList{} + err := list.client.Call(ctx, http.MethodHead, list.nextPagePath, nil, nil, list.requestOptions, resources) + if err != nil { + return nil, err + } + resp := resources.GetResponse() + return resp.TotalRecords, nil +} + +// Count returns the count of items on the server that match this pager +func (list *PlanRampPricingList) Count() (*int64, error) { + return list.CountWithContext(context.Background()) +} diff --git a/plan_ramp_pricing_create.go b/plan_ramp_pricing_create.go new file mode 100644 index 0000000..96a9862 --- /dev/null +++ b/plan_ramp_pricing_create.go @@ -0,0 +1,16 @@ +// This file is automatically created by Recurly's OpenAPI generation process +// and thus any edits you make by hand will be lost. If you wish to make a +// change to this file, please create a Github issue explaining the changes you +// need and we will usher them to the appropriate places. +package recurly + +import () + +type PlanRampPricingCreate struct { + + // 3-letter ISO 4217 currency code. + Currency *string `json:"currency,omitempty"` + + // Represents the price for the Ramp Interval. + UnitAmount *float64 `json:"unit_amount,omitempty"` +} diff --git a/plan_update.go b/plan_update.go index 3eddd3c..b3a8cf2 100644 --- a/plan_update.go +++ b/plan_update.go @@ -38,6 +38,9 @@ type PlanUpdate struct { // Subscriptions will automatically inherit this value once they are active. If `auto_renew` is `true`, then a subscription will automatically renew its term at renewal. If `auto_renew` is `false`, then a subscription will expire at the end of its term. `auto_renew` can be overridden on the subscription record itself. AutoRenew *bool `json:"auto_renew,omitempty"` + // Ramp Intervals + RampIntervals []PlanRampIntervalCreate `json:"ramp_intervals,omitempty"` + // Revenue schedule type RevenueScheduleType *string `json:"revenue_schedule_type,omitempty"` @@ -59,7 +62,7 @@ type PlanUpdate struct { // `true` exempts tax on the plan, `false` applies tax on the plan. TaxExempt *bool `json:"tax_exempt,omitempty"` - // Pricing + // Optional when the pricing model is 'ramp'. Currencies []PlanPricingCreate `json:"currencies,omitempty"` // Hosted pages settings diff --git a/scripts/clean b/scripts/clean index fc9d4e2..43e513a 100755 --- a/scripts/clean +++ b/scripts/clean @@ -48,6 +48,7 @@ rm -f add_on_mini.go rm -f subscription_add_on_tier.go rm -f subscription_add_on_percentage_tier.go rm -f subscription_change_billing_info.go +rm -f subscription_ramp_interval_response.go rm -f unique_coupon_code_params.go rm -f unique_coupon_code.go rm -f custom_field_definition.go @@ -56,6 +57,8 @@ rm -f pricing.go rm -f measured_unit.go rm -f binary_file.go rm -f plan.go +rm -f plan_ramp_interval.go +rm -f plan_ramp_pricing.go rm -f plan_pricing.go rm -f plan_hosted_pages.go rm -f add_on.go @@ -104,6 +107,8 @@ rm -f invoice_refund.go rm -f line_item_refund.go rm -f external_refund.go rm -f plan_create.go +rm -f plan_ramp_interval_create.go +rm -f plan_ramp_pricing_create.go rm -f plan_pricing_create.go rm -f plan_hosted_pages_create.go rm -f add_on_create.go @@ -121,6 +126,7 @@ rm -f subscription_shipping_create.go rm -f subscription_add_on_create.go rm -f subscription_add_on_tier_create.go rm -f subscription_add_on_percentage_tier_create.go +rm -f subscription_ramp_interval.go rm -f subscription_update.go rm -f subscription_shipping_update.go rm -f subscription_cancel.go diff --git a/subscription.go b/subscription.go index 5776f75..5143edf 100644 --- a/subscription.go +++ b/subscription.go @@ -70,6 +70,9 @@ type Subscription struct { // Whether the subscription renews at the end of its term. AutoRenew bool `json:"auto_renew,omitempty"` + // The ramp intervals representing the pricing schedule for the subscription. + RampIntervals []SubscriptionRampIntervalResponse `json:"ramp_intervals,omitempty"` + // Null unless subscription is paused or will pause at the end of the current billing period. PausedAt time.Time `json:"paused_at,omitempty"` diff --git a/subscription_change.go b/subscription_change.go index 3b5815e..82389a2 100644 --- a/subscription_change.go +++ b/subscription_change.go @@ -66,6 +66,9 @@ type SubscriptionChange struct { // Accept nested attributes for three_d_secure_action_result_token_id BillingInfo SubscriptionChangeBillingInfo `json:"billing_info,omitempty"` + + // The ramp intervals representing the pricing schedule for the subscription. + RampIntervals []SubscriptionRampIntervalResponse `json:"ramp_intervals,omitempty"` } // GetResponse returns the ResponseMetadata that generated this resource diff --git a/subscription_change_create.go b/subscription_change_create.go index 5c30d0b..75d34bb 100644 --- a/subscription_change_create.go +++ b/subscription_change_create.go @@ -68,4 +68,7 @@ type SubscriptionChangeCreate struct { TransactionType *string `json:"transaction_type,omitempty"` BillingInfo *SubscriptionChangeBillingInfoCreate `json:"billing_info,omitempty"` + + // The new set of ramp intervals for the subscription. + RampIntervals []SubscriptionRampInterval `json:"ramp_intervals,omitempty"` } diff --git a/subscription_create.go b/subscription_create.go index 52bd9c5..f7aa3db 100644 --- a/subscription_create.go +++ b/subscription_create.go @@ -66,6 +66,9 @@ type SubscriptionCreate struct { // Whether the subscription renews at the end of its term. AutoRenew *bool `json:"auto_renew,omitempty"` + // The new set of ramp intervals for the subscription. + RampIntervals []SubscriptionRampInterval `json:"ramp_intervals,omitempty"` + // Revenue schedule type RevenueScheduleType *string `json:"revenue_schedule_type,omitempty"` diff --git a/subscription_purchase.go b/subscription_purchase.go index 4eb00bd..d0f71d5 100644 --- a/subscription_purchase.go +++ b/subscription_purchase.go @@ -54,4 +54,7 @@ type SubscriptionPurchase struct { // Revenue schedule type RevenueScheduleType *string `json:"revenue_schedule_type,omitempty"` + + // The new set of ramp intervals for the subscription. + RampIntervals []SubscriptionRampInterval `json:"ramp_intervals,omitempty"` } diff --git a/subscription_ramp_interval.go b/subscription_ramp_interval.go new file mode 100644 index 0000000..5ac3585 --- /dev/null +++ b/subscription_ramp_interval.go @@ -0,0 +1,16 @@ +// This file is automatically created by Recurly's OpenAPI generation process +// and thus any edits you make by hand will be lost. If you wish to make a +// change to this file, please create a Github issue explaining the changes you +// need and we will usher them to the appropriate places. +package recurly + +import () + +type SubscriptionRampInterval struct { + + // Represents how many billing cycles are included in a ramp interval. + StartingBillingCycle *int `json:"starting_billing_cycle,omitempty"` + + // Represents the price for the ramp interval. + UnitAmount *int `json:"unit_amount,omitempty"` +} diff --git a/subscription_ramp_interval_response.go b/subscription_ramp_interval_response.go new file mode 100644 index 0000000..0e1294c --- /dev/null +++ b/subscription_ramp_interval_response.go @@ -0,0 +1,125 @@ +// This file is automatically created by Recurly's OpenAPI generation process +// and thus any edits you make by hand will be lost. If you wish to make a +// change to this file, please create a Github issue explaining the changes you +// need and we will usher them to the appropriate places. +package recurly + +import ( + "context" + "net/http" +) + +type SubscriptionRampIntervalResponse struct { + recurlyResponse *ResponseMetadata + + // Represents how many billing cycles are included in a ramp interval. + StartingBillingCycle int `json:"starting_billing_cycle,omitempty"` + + // Represents how many billing cycles are left in a ramp interval. + RemainingBillingCycles int `json:"remaining_billing_cycles,omitempty"` + + // Represents the price for the ramp interval. + UnitAmount int `json:"unit_amount,omitempty"` +} + +// GetResponse returns the ResponseMetadata that generated this resource +func (resource *SubscriptionRampIntervalResponse) GetResponse() *ResponseMetadata { + return resource.recurlyResponse +} + +// setResponse sets the ResponseMetadata that generated this resource +func (resource *SubscriptionRampIntervalResponse) setResponse(res *ResponseMetadata) { + resource.recurlyResponse = res +} + +// internal struct for deserializing accounts +type subscriptionRampIntervalResponseList struct { + ListMetadata + Data []SubscriptionRampIntervalResponse `json:"data"` + recurlyResponse *ResponseMetadata +} + +// GetResponse returns the ResponseMetadata that generated this resource +func (resource *subscriptionRampIntervalResponseList) GetResponse() *ResponseMetadata { + return resource.recurlyResponse +} + +// setResponse sets the ResponseMetadata that generated this resource +func (resource *subscriptionRampIntervalResponseList) setResponse(res *ResponseMetadata) { + resource.recurlyResponse = res +} + +// SubscriptionRampIntervalResponseList allows you to paginate SubscriptionRampIntervalResponse objects +type SubscriptionRampIntervalResponseList struct { + client HTTPCaller + requestOptions *RequestOptions + nextPagePath string + hasMore bool + data []SubscriptionRampIntervalResponse +} + +func NewSubscriptionRampIntervalResponseList(client HTTPCaller, nextPagePath string, requestOptions *RequestOptions) *SubscriptionRampIntervalResponseList { + return &SubscriptionRampIntervalResponseList{ + client: client, + requestOptions: requestOptions, + nextPagePath: nextPagePath, + hasMore: true, + } +} + +type SubscriptionRampIntervalResponseLister interface { + Fetch() error + FetchWithContext(ctx context.Context) error + Count() (*int64, error) + CountWithContext(ctx context.Context) (*int64, error) + Data() []SubscriptionRampIntervalResponse + HasMore() bool + Next() string +} + +func (list *SubscriptionRampIntervalResponseList) HasMore() bool { + return list.hasMore +} + +func (list *SubscriptionRampIntervalResponseList) Next() string { + return list.nextPagePath +} + +func (list *SubscriptionRampIntervalResponseList) Data() []SubscriptionRampIntervalResponse { + return list.data +} + +// Fetch fetches the next page of data into the `Data` property +func (list *SubscriptionRampIntervalResponseList) FetchWithContext(ctx context.Context) error { + resources := &subscriptionRampIntervalResponseList{} + err := list.client.Call(ctx, http.MethodGet, list.nextPagePath, nil, nil, list.requestOptions, resources) + if err != nil { + return err + } + // copy over properties from the response + list.nextPagePath = resources.Next + list.hasMore = resources.HasMore + list.data = resources.Data + return nil +} + +// Fetch fetches the next page of data into the `Data` property +func (list *SubscriptionRampIntervalResponseList) Fetch() error { + return list.FetchWithContext(context.Background()) +} + +// Count returns the count of items on the server that match this pager +func (list *SubscriptionRampIntervalResponseList) CountWithContext(ctx context.Context) (*int64, error) { + resources := &subscriptionRampIntervalResponseList{} + err := list.client.Call(ctx, http.MethodHead, list.nextPagePath, nil, nil, list.requestOptions, resources) + if err != nil { + return nil, err + } + resp := resources.GetResponse() + return resp.TotalRecords, nil +} + +// Count returns the count of items on the server that match this pager +func (list *SubscriptionRampIntervalResponseList) Count() (*int64, error) { + return list.CountWithContext(context.Background()) +}