From 17a1f63b19ee0715bcd5fbc2f9fceea02230110d Mon Sep 17 00:00:00 2001 From: DX Codefresh Date: Tue, 2 Aug 2022 18:43:14 +0000 Subject: [PATCH] Generated Latest Changes for v2019-10-10 --- openapi/api.yaml | 127 ++++++++++++++++++++++++- plan.go | 8 ++ plan_create.go | 8 ++ plan_pricing.go | 2 +- plan_pricing_create.go | 2 +- plan_ramp_interval.go | 100 +++++++++++++++++++ plan_ramp_interval_create.go | 26 +++++ plan_ramp_pricing.go | 100 +++++++++++++++++++ plan_ramp_pricing_create.go | 26 +++++ plan_update.go | 3 + scripts/clean | 6 ++ subscription.go | 3 + subscription_change.go | 3 + subscription_change_create.go | 3 + subscription_change_preview.go | 3 + subscription_create.go | 3 + subscription_purchase.go | 3 + subscription_ramp_interval.go | 26 +++++ subscription_ramp_interval_response.go | 103 ++++++++++++++++++++ 19 files changed, 552 insertions(+), 3 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 987ab66..2f9944b 100644 --- a/openapi/api.yaml +++ b/openapi/api.yaml @@ -17259,7 +17259,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 @@ -18828,6 +18828,22 @@ 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 + 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. + ramp_intervals: + type: array + title: Ramp Intervals + items: + "$ref": "#/components/schemas/PlanRampInterval" accounting_code: type: string title: Plan accounting code @@ -19006,6 +19022,22 @@ 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 + 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. + ramp_intervals: + type: array + title: Ramp Intervals + items: + "$ref": "#/components/schemas/PlanRampInterval" revenue_schedule_type: type: string title: Revenue schedule type @@ -19137,6 +19169,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: @@ -19214,6 +19247,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: type: string title: Revenue schedule type @@ -19291,6 +19329,19 @@ components: a non-default dunning campaign should be assigned to this plan. For sites without multiple dunning campaigns enabled, the default dunning campaign will always be used. + 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" AddOnPricing: type: object properties: @@ -19314,6 +19365,24 @@ components: required: - currency - unit_amount + 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: @@ -19899,6 +19968,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 @@ -20362,6 +20438,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 @@ -20501,6 +20584,12 @@ components: - moto 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" SubscriptionChangePreview: type: object allOf: @@ -20652,6 +20741,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: type: string title: Revenue schedule type @@ -20803,6 +20898,12 @@ components: - evenly - at_range_end - at_range_start + 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: @@ -20986,6 +21087,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 diff --git a/plan.go b/plan.go index 3145162..c759fac 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"` + // Accounting code for invoice line items for the plan. If no value is provided, it defaults to plan's code. AccountingCode string `json:"accounting_code,omitempty"` diff --git a/plan_create.go b/plan_create.go index 1c9e9dc..b65dbed 100644 --- a/plan_create.go +++ b/plan_create.go @@ -42,6 +42,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 f66f56b..2b5c332 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 9122063..0bddae3 100644 --- a/plan_pricing_create.go +++ b/plan_pricing_create.go @@ -15,7 +15,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..1dc44e7 --- /dev/null +++ b/plan_ramp_interval.go @@ -0,0 +1,100 @@ +// 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, + } +} + +// 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..4362de3 --- /dev/null +++ b/plan_ramp_interval_create.go @@ -0,0 +1,26 @@ +// 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 { + Params `json:"-"` + + // 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"` +} + +func (attr *PlanRampIntervalCreate) toParams() *Params { + return &Params{ + IdempotencyKey: attr.IdempotencyKey, + Header: attr.Header, + Context: attr.Context, + Data: attr, + } +} diff --git a/plan_ramp_pricing.go b/plan_ramp_pricing.go new file mode 100644 index 0000000..922c13d --- /dev/null +++ b/plan_ramp_pricing.go @@ -0,0 +1,100 @@ +// 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, + } +} + +// 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..6212454 --- /dev/null +++ b/plan_ramp_pricing_create.go @@ -0,0 +1,26 @@ +// 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 { + Params `json:"-"` + + // 3-letter ISO 4217 currency code. + Currency *string `json:"currency,omitempty"` + + // Represents the price for the Ramp Interval. + UnitAmount *float64 `json:"unit_amount,omitempty"` +} + +func (attr *PlanRampPricingCreate) toParams() *Params { + return &Params{ + IdempotencyKey: attr.IdempotencyKey, + Header: attr.Header, + Context: attr.Context, + Data: attr, + } +} diff --git a/plan_update.go b/plan_update.go index 2d88be1..81f621b 100644 --- a/plan_update.go +++ b/plan_update.go @@ -39,6 +39,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"` diff --git a/scripts/clean b/scripts/clean index 7de16bd..a4823b3 100755 --- a/scripts/clean +++ b/scripts/clean @@ -46,6 +46,7 @@ rm -f subscription_add_on.go rm -f add_on_mini.go rm -f subscription_add_on_tier.go rm -f subscription_change_billing_info.go +rm -f subscription_ramp_interval_response.go rm -f unique_coupon_code.go rm -f custom_field_definition.go rm -f item.go @@ -53,6 +54,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 @@ -98,6 +101,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 @@ -111,6 +116,7 @@ rm -f subscription_create.go rm -f subscription_shipping_create.go rm -f subscription_add_on_create.go rm -f subscription_add_on_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 2acd256..c7d50a7 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 4b82dd5..7c8ca52 100644 --- a/subscription_change.go +++ b/subscription_change.go @@ -69,6 +69,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 37c717d..6e9bb9a 100644 --- a/subscription_change_create.go +++ b/subscription_change_create.go @@ -68,6 +68,9 @@ 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"` } func (attr *SubscriptionChangeCreate) toParams() *Params { diff --git a/subscription_change_preview.go b/subscription_change_preview.go index 33a8844..f9a3d51 100644 --- a/subscription_change_preview.go +++ b/subscription_change_preview.go @@ -69,6 +69,9 @@ type SubscriptionChangePreview 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_create.go b/subscription_create.go index f70d6fb..ac00f70 100644 --- a/subscription_create.go +++ b/subscription_create.go @@ -67,6 +67,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 1080866..cbea713 100644 --- a/subscription_purchase.go +++ b/subscription_purchase.go @@ -55,6 +55,9 @@ 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"` } func (attr *SubscriptionPurchase) toParams() *Params { diff --git a/subscription_ramp_interval.go b/subscription_ramp_interval.go new file mode 100644 index 0000000..a1c1de7 --- /dev/null +++ b/subscription_ramp_interval.go @@ -0,0 +1,26 @@ +// 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 { + Params `json:"-"` + + // 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"` +} + +func (attr *SubscriptionRampInterval) toParams() *Params { + return &Params{ + IdempotencyKey: attr.IdempotencyKey, + Header: attr.Header, + Context: attr.Context, + Data: attr, + } +} diff --git a/subscription_ramp_interval_response.go b/subscription_ramp_interval_response.go new file mode 100644 index 0000000..6d4208b --- /dev/null +++ b/subscription_ramp_interval_response.go @@ -0,0 +1,103 @@ +// 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, + } +} + +// 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()) +}