From 4b77eb2b72a64a5aaa95a85a9eb1fce4962f9c90 Mon Sep 17 00:00:00 2001 From: Recurly Integrations Date: Sat, 14 Dec 2024 00:55:15 +0000 Subject: [PATCH] Generated Latest Changes for v2021-02-25 --- account_external_subscription.go | 13 + business_entity_mini.go | 128 +++++ client_operations.go | 78 ++- external_account_create.go | 2 +- external_account_update.go | 2 +- external_product_reference_base.go | 3 +- external_product_reference_connection_type.go | 10 + external_product_reference_create.go | 3 +- external_product_reference_update.go | 16 + external_subscription_create.go | 48 ++ external_subscription_update.go | 46 ++ invoice_create.go | 6 + openapi/api.yaml | 452 +++++++++++++++++- purchase_create.go | 9 + scripts/clean | 6 + subscription.go | 3 + subscription_change.go | 3 + subscription_change_create.go | 6 + subscription_create.go | 6 + transaction.go | 14 + 20 files changed, 839 insertions(+), 15 deletions(-) create mode 100644 account_external_subscription.go create mode 100644 business_entity_mini.go create mode 100644 external_product_reference_connection_type.go create mode 100644 external_product_reference_update.go create mode 100644 external_subscription_create.go create mode 100644 external_subscription_update.go diff --git a/account_external_subscription.go b/account_external_subscription.go new file mode 100644 index 0000000..b2c7594 --- /dev/null +++ b/account_external_subscription.go @@ -0,0 +1,13 @@ +// 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 AccountExternalSubscription struct { + + // The account code of a new or existing account to be used when creating the external subscription. + AccountCode *string `json:"account_code,omitempty"` +} diff --git a/business_entity_mini.go b/business_entity_mini.go new file mode 100644 index 0000000..f29c061 --- /dev/null +++ b/business_entity_mini.go @@ -0,0 +1,128 @@ +// 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 BusinessEntityMini struct { + recurlyResponse *ResponseMetadata + + // Business entity ID + Id string `json:"id,omitempty"` + + // Object type + Object string `json:"object,omitempty"` + + // The entity code of the business entity. + Code string `json:"code,omitempty"` + + // This name describes your business entity and will appear on the invoice. + Name string `json:"name,omitempty"` +} + +// GetResponse returns the ResponseMetadata that generated this resource +func (resource *BusinessEntityMini) GetResponse() *ResponseMetadata { + return resource.recurlyResponse +} + +// setResponse sets the ResponseMetadata that generated this resource +func (resource *BusinessEntityMini) setResponse(res *ResponseMetadata) { + resource.recurlyResponse = res +} + +// internal struct for deserializing accounts +type businessEntityMiniList struct { + ListMetadata + Data []BusinessEntityMini `json:"data"` + recurlyResponse *ResponseMetadata +} + +// GetResponse returns the ResponseMetadata that generated this resource +func (resource *businessEntityMiniList) GetResponse() *ResponseMetadata { + return resource.recurlyResponse +} + +// setResponse sets the ResponseMetadata that generated this resource +func (resource *businessEntityMiniList) setResponse(res *ResponseMetadata) { + resource.recurlyResponse = res +} + +// BusinessEntityMiniList allows you to paginate BusinessEntityMini objects +type BusinessEntityMiniList struct { + client HTTPCaller + requestOptions *RequestOptions + nextPagePath string + hasMore bool + data []BusinessEntityMini +} + +func NewBusinessEntityMiniList(client HTTPCaller, nextPagePath string, requestOptions *RequestOptions) *BusinessEntityMiniList { + return &BusinessEntityMiniList{ + client: client, + requestOptions: requestOptions, + nextPagePath: nextPagePath, + hasMore: true, + } +} + +type BusinessEntityMiniLister interface { + Fetch() error + FetchWithContext(ctx context.Context) error + Count() (*int64, error) + CountWithContext(ctx context.Context) (*int64, error) + Data() []BusinessEntityMini + HasMore() bool + Next() string +} + +func (list *BusinessEntityMiniList) HasMore() bool { + return list.hasMore +} + +func (list *BusinessEntityMiniList) Next() string { + return list.nextPagePath +} + +func (list *BusinessEntityMiniList) Data() []BusinessEntityMini { + return list.data +} + +// Fetch fetches the next page of data into the `Data` property +func (list *BusinessEntityMiniList) FetchWithContext(ctx context.Context) error { + resources := &businessEntityMiniList{} + 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 *BusinessEntityMiniList) Fetch() error { + return list.FetchWithContext(context.Background()) +} + +// Count returns the count of items on the server that match this pager +func (list *BusinessEntityMiniList) CountWithContext(ctx context.Context) (*int64, error) { + resources := &businessEntityMiniList{} + 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 *BusinessEntityMiniList) Count() (*int64, error) { + return list.CountWithContext(context.Background()) +} diff --git a/client_operations.go b/client_operations.go index 36207c8..bde7ef2 100644 --- a/client_operations.go +++ b/client_operations.go @@ -255,11 +255,17 @@ type ClientInterface interface { DeactivateExternalProductExternalProductReference(externalProductId string, externalProductReferenceId string, opts ...Option) (*ExternalProductReferenceMini, error) DeactivateExternalProductExternalProductReferenceWithContext(ctx context.Context, externalProductId string, externalProductReferenceId string, opts ...Option) (*ExternalProductReferenceMini, error) + CreateExternalSubscription(body *ExternalSubscriptionCreate, opts ...Option) (*ExternalSubscription, error) + CreateExternalSubscriptionWithContext(ctx context.Context, body *ExternalSubscriptionCreate, opts ...Option) (*ExternalSubscription, error) + ListExternalSubscriptions(params *ListExternalSubscriptionsParams, opts ...Option) (ExternalSubscriptionLister, error) GetExternalSubscription(externalSubscriptionId string, opts ...Option) (*ExternalSubscription, error) GetExternalSubscriptionWithContext(ctx context.Context, externalSubscriptionId string, opts ...Option) (*ExternalSubscription, error) + PutExternalSubscription(externalSubscriptionId string, params *PutExternalSubscriptionParams, opts ...Option) (*ExternalSubscription, error) + PutExternalSubscriptionWithContext(ctx context.Context, externalSubscriptionId string, params *PutExternalSubscriptionParams, opts ...Option) (*ExternalSubscription, error) + ListExternalSubscriptionExternalInvoices(externalSubscriptionId string, params *ListExternalSubscriptionExternalInvoicesParams, opts ...Option) (ExternalInvoiceLister, error) ListInvoices(params *ListInvoicesParams, opts ...Option) (InvoiceLister, error) @@ -4122,6 +4128,35 @@ func (c *Client) deactivateExternalProductExternalProductReference(ctx context.C return result, err } +// CreateExternalSubscription wraps CreateExternalSubscriptionWithContext using the background context +func (c *Client) CreateExternalSubscription(body *ExternalSubscriptionCreate, opts ...Option) (*ExternalSubscription, error) { + ctx := context.Background() + return c.createExternalSubscription(ctx, body, opts...) +} + +// CreateExternalSubscriptionWithContext Create an external subscription +// +// API Documentation: https://developers.recurly.com/api/v2021-02-25#operation/create_external_subscription +// +// Returns: Returns the external subscription +func (c *Client) CreateExternalSubscriptionWithContext(ctx context.Context, body *ExternalSubscriptionCreate, opts ...Option) (*ExternalSubscription, error) { + return c.createExternalSubscription(ctx, body, opts...) +} + +func (c *Client) createExternalSubscription(ctx context.Context, body *ExternalSubscriptionCreate, opts ...Option) (*ExternalSubscription, error) { + path, err := c.InterpolatePath("/external_subscriptions") + if err != nil { + return nil, err + } + requestOptions := NewRequestOptions(opts...) + result := &ExternalSubscription{} + err = c.Call(ctx, http.MethodPost, path, body, nil, requestOptions, result) + if err != nil { + return nil, err + } + return result, err +} + type ListExternalSubscriptionsParams struct { // Sort - Sort field. You *really* only want to sort by `updated_at` in ascending @@ -4140,7 +4175,7 @@ func (list *ListExternalSubscriptionsParams) URLParams() []KeyValue { return options } -// ListExternalSubscriptions List a site's external subscriptions +// ListExternalSubscriptions List the external subscriptions on a site // // API Documentation: https://developers.recurly.com/api/v2021-02-25#operation/list_external_subscriptions // @@ -4184,6 +4219,47 @@ func (c *Client) getExternalSubscription(ctx context.Context, externalSubscripti return result, err } +type PutExternalSubscriptionParams struct { + + // Body - The body of the request. + Body *ExternalSubscriptionUpdate +} + +func (list *PutExternalSubscriptionParams) URLParams() []KeyValue { + var options []KeyValue + + return options +} + +// PutExternalSubscription wraps PutExternalSubscriptionWithContext using the background context +func (c *Client) PutExternalSubscription(externalSubscriptionId string, params *PutExternalSubscriptionParams, opts ...Option) (*ExternalSubscription, error) { + ctx := context.Background() + return c.putExternalSubscription(ctx, externalSubscriptionId, params, opts...) +} + +// PutExternalSubscriptionWithContext Update an external subscription +// +// API Documentation: https://developers.recurly.com/api/v2021-02-25#operation/put_external_subscription +// +// Returns: Settings for an external subscription. +func (c *Client) PutExternalSubscriptionWithContext(ctx context.Context, externalSubscriptionId string, params *PutExternalSubscriptionParams, opts ...Option) (*ExternalSubscription, error) { + return c.putExternalSubscription(ctx, externalSubscriptionId, params, opts...) +} + +func (c *Client) putExternalSubscription(ctx context.Context, externalSubscriptionId string, params *PutExternalSubscriptionParams, opts ...Option) (*ExternalSubscription, error) { + path, err := c.InterpolatePath("/external_subscriptions/{external_subscription_id}", externalSubscriptionId) + if err != nil { + return nil, err + } + requestOptions := NewRequestOptions(opts...) + result := &ExternalSubscription{} + err = c.Call(ctx, http.MethodPut, path, nil, params, requestOptions, result) + if err != nil { + return nil, err + } + return result, err +} + type ListExternalSubscriptionExternalInvoicesParams struct { // Sort - Sort field. You *really* only want to sort by `updated_at` in ascending diff --git a/external_account_create.go b/external_account_create.go index aff7bd1..acd3aee 100644 --- a/external_account_create.go +++ b/external_account_create.go @@ -11,6 +11,6 @@ type ExternalAccountCreate struct { // Represents the account code for the external account. ExternalAccountCode *string `json:"external_account_code,omitempty"` - // Represents the connection type. `AppleAppStore` or `GooglePlayStore` + // Represents the connection type. One of the connection types of your enabled App Connectors ExternalConnectionType *string `json:"external_connection_type,omitempty"` } diff --git a/external_account_update.go b/external_account_update.go index c77f36e..161c50f 100644 --- a/external_account_update.go +++ b/external_account_update.go @@ -11,6 +11,6 @@ type ExternalAccountUpdate struct { // Represents the account code for the external account. ExternalAccountCode *string `json:"external_account_code,omitempty"` - // Represents the connection type. `AppleAppStore` or `GooglePlayStore` + // Represents the connection type. One of the connection types of your enabled App Connectors ExternalConnectionType *string `json:"external_connection_type,omitempty"` } diff --git a/external_product_reference_base.go b/external_product_reference_base.go index 00e105d..c4b5818 100644 --- a/external_product_reference_base.go +++ b/external_product_reference_base.go @@ -11,5 +11,6 @@ type ExternalProductReferenceBase struct { // A code which associates the external product to a corresponding object or resource in an external platform like the Apple App Store or Google Play Store. ReferenceCode *string `json:"reference_code,omitempty"` - ExternalConnectionType *string `json:"external_connection_type,omitempty"` + // Represents the connection type. One of the connection types of your enabled App Connectors + ExternalConnectionType *ExternalProductReferenceConnectionType `json:"external_connection_type,omitempty"` } diff --git a/external_product_reference_connection_type.go b/external_product_reference_connection_type.go new file mode 100644 index 0000000..fd6b589 --- /dev/null +++ b/external_product_reference_connection_type.go @@ -0,0 +1,10 @@ +// 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 ExternalProductReferenceConnectionType struct { +} diff --git a/external_product_reference_create.go b/external_product_reference_create.go index 2bed4f6..1d9fe51 100644 --- a/external_product_reference_create.go +++ b/external_product_reference_create.go @@ -11,5 +11,6 @@ type ExternalProductReferenceCreate struct { // A code which associates the external product to a corresponding object or resource in an external platform like the Apple App Store or Google Play Store. ReferenceCode *string `json:"reference_code,omitempty"` - ExternalConnectionType *string `json:"external_connection_type,omitempty"` + // Represents the connection type. One of the connection types of your enabled App Connectors + ExternalConnectionType *ExternalProductReferenceConnectionType `json:"external_connection_type,omitempty"` } diff --git a/external_product_reference_update.go b/external_product_reference_update.go new file mode 100644 index 0000000..74c6137 --- /dev/null +++ b/external_product_reference_update.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 ExternalProductReferenceUpdate struct { + + // A code which associates the external product to a corresponding object or resource in an external platform like the Apple App Store or Google Play Store. + ReferenceCode *string `json:"reference_code,omitempty"` + + // Represents the connection type. One of the connection types of your enabled App Connectors + ExternalConnectionType *ExternalProductReferenceConnectionType `json:"external_connection_type,omitempty"` +} diff --git a/external_subscription_create.go b/external_subscription_create.go new file mode 100644 index 0000000..9d5e275 --- /dev/null +++ b/external_subscription_create.go @@ -0,0 +1,48 @@ +// 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 ( + "time" +) + +type ExternalSubscriptionCreate struct { + Account *AccountExternalSubscription `json:"account,omitempty"` + + ExternalProductReference *ExternalProductReferenceCreate `json:"external_product_reference,omitempty"` + + // Id of the subscription in the external system, i.e. Apple App Store or Google Play Store. + ExternalId *string `json:"external_id,omitempty"` + + // When a new billing event occurred on the external subscription in conjunction with a recent billing period, reactivation or upgrade/downgrade. + LastPurchased *time.Time `json:"last_purchased,omitempty"` + + // An indication of whether or not the external subscription will auto-renew at the expiration date. + AutoRenew *bool `json:"auto_renew,omitempty"` + + // External subscriptions can be active, canceled, expired, past_due, voided, revoked, or paused. + State *string `json:"state,omitempty"` + + // Identifier of the app that generated the external subscription. + AppIdentifier *string `json:"app_identifier,omitempty"` + + // An indication of the quantity of a subscribed item's quantity. + Quantity *int `json:"quantity,omitempty"` + + // When the external subscription was activated in the external platform. + ActivatedAt *time.Time `json:"activated_at,omitempty"` + + // When the external subscription expires in the external platform. + ExpiresAt *time.Time `json:"expires_at,omitempty"` + + // When the external subscription trial period started in the external platform. + TrialStartedAt *time.Time `json:"trial_started_at,omitempty"` + + // When the external subscription trial period ends in the external platform. + TrialEndsAt *time.Time `json:"trial_ends_at,omitempty"` + + // An indication of whether or not the external subscription was being created by a historical data import. + Imported *bool `json:"imported,omitempty"` +} diff --git a/external_subscription_update.go b/external_subscription_update.go new file mode 100644 index 0000000..29c7334 --- /dev/null +++ b/external_subscription_update.go @@ -0,0 +1,46 @@ +// 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 ( + "time" +) + +type ExternalSubscriptionUpdate struct { + ExternalProductReference *ExternalProductReferenceUpdate `json:"external_product_reference,omitempty"` + + // Id of the subscription in the external system, i.e. Apple App Store or Google Play Store. + ExternalId *string `json:"external_id,omitempty"` + + // When a new billing event occurred on the external subscription in conjunction with a recent billing period, reactivation or upgrade/downgrade. + LastPurchased *time.Time `json:"last_purchased,omitempty"` + + // An indication of whether or not the external subscription will auto-renew at the expiration date. + AutoRenew *bool `json:"auto_renew,omitempty"` + + // External subscriptions can be active, canceled, expired, past_due, voided, revoked, or paused. + State *string `json:"state,omitempty"` + + // Identifier of the app that generated the external subscription. + AppIdentifier *string `json:"app_identifier,omitempty"` + + // An indication of the quantity of a subscribed item's quantity. + Quantity *int `json:"quantity,omitempty"` + + // When the external subscription was activated in the external platform. + ActivatedAt *time.Time `json:"activated_at,omitempty"` + + // When the external subscription expires in the external platform. + ExpiresAt *time.Time `json:"expires_at,omitempty"` + + // When the external subscription trial period started in the external platform. + TrialStartedAt *time.Time `json:"trial_started_at,omitempty"` + + // When the external subscription trial period ends in the external platform. + TrialEndsAt *time.Time `json:"trial_ends_at,omitempty"` + + // An indication of whether or not the external subscription was being created by a historical data import. + Imported *bool `json:"imported,omitempty"` +} diff --git a/invoice_create.go b/invoice_create.go index a91ae86..c63ba90 100644 --- a/invoice_create.go +++ b/invoice_create.go @@ -11,6 +11,12 @@ type InvoiceCreate struct { // 3-letter ISO 4217 currency code. Currency *string `json:"currency,omitempty"` + // The `business_entity_id` is the value that represents a specific business entity for an end customer which will be assigned to the invoice. Available when the `Multiple Business Entities` feature is enabled. If both `business_entity_id` and `business_entity_code` are present, `business_entity_id` will be used. + BusinessEntityId *string `json:"business_entity_id,omitempty"` + + // The `business_entity_code` is the value that represents a specific business entity for an end customer which will be assigned to the invoice. Available when the `Multiple Business Entities` feature is enabled. If both `business_entity_id` and `business_entity_code` are present, `business_entity_id` will be used. + BusinessEntityCode *string `json:"business_entity_code,omitempty"` + // An automatic invoice means a corresponding transaction is run using the account's billing information at the same time the invoice is created. Manual invoices are created without a corresponding transaction. The merchant must enter a manual payment transaction or have the customer pay the invoice with an automatic method, like credit card, PayPal, Amazon, or ACH bank payment. CollectionMethod *string `json:"collection_method,omitempty"` diff --git a/openapi/api.yaml b/openapi/api.yaml index bcad8e3..460dd35 100644 --- a/openapi/api.yaml +++ b/openapi/api.yaml @@ -8198,11 +8198,49 @@ paths: "$ref": "#/components/schemas/Error" x-code-samples: [] "/external_subscriptions": + post: + tags: + - external_subscriptions + operationId: create_external_subscription + summary: Create an external subscription + requestBody: + content: + application/json: + schema: + "$ref": "#/components/schemas/ExternalSubscriptionCreate" + required: true + responses: + '201': + description: Returns the external subscription + content: + application/json: + schema: + "$ref": "#/components/schemas/ExternalSubscription" + '400': + description: Bad request; perhaps missing or invalid parameters. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + '404': + description: External subscription cannot be completed for the specified + reason. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + default: + description: Unexpected error. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + x-code-samples: [] get: tags: - external_subscriptions operationId: list_external_subscriptions - summary: List a site's external subscriptions + summary: List the external subscriptions on a site description: See the [Pagination Guide](/developers/guides/pagination.html) to learn how to use pagination in the API and Client Libraries. parameters: @@ -8228,9 +8266,9 @@ paths: "$ref": "#/components/schemas/Error" x-code-samples: [] "/external_subscriptions/{external_subscription_id}": - parameters: - - "$ref": "#/components/parameters/external_subscription_id_fetch" get: + parameters: + - "$ref": "#/components/parameters/external_subscription_id_fetch" tags: - external_subscriptions operationId: get_external_subscription @@ -8262,6 +8300,52 @@ paths: schema: "$ref": "#/components/schemas/Error" x-code-samples: [] + put: + parameters: + - "$ref": "#/components/parameters/external_subscription_id" + tags: + - external_subscriptions + operationId: put_external_subscription + summary: Update an external subscription + requestBody: + content: + application/json: + schema: + "$ref": "#/components/schemas/ExternalSubscriptionUpdate" + required: false + responses: + '200': + description: Settings for an external subscription. + content: + application/json: + schema: + "$ref": "#/components/schemas/ExternalSubscription" + '400': + description: Bad request; perhaps missing or invalid parameters. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + '404': + description: Incorrect site or external subscription ID. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + '422': + description: Validation error with external resource connection or feature + flag. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + default: + description: Unexpected error. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + x-code-samples: [] "/external_subscriptions/{external_subscription_id}/external_invoices": parameters: - "$ref": "#/components/parameters/external_subscription_id" @@ -20294,6 +20378,22 @@ components: title: Currency description: 3-letter ISO 4217 currency code. maxLength: 3 + business_entity_id: + type: string + title: Business Entity ID + description: The `business_entity_id` is the value that represents a specific + business entity for an end customer which will be assigned to the invoice. + Available when the `Multiple Business Entities` feature is enabled. If + both `business_entity_id` and `business_entity_code` are present, `business_entity_id` + will be used. + business_entity_code: + type: string + title: Business Entity Code + description: The `business_entity_code` is the value that represents a specific + business entity for an end customer which will be assigned to the invoice. + Available when the `Multiple Business Entities` feature is enabled. If + both `business_entity_id` and `business_entity_code` are present, `business_entity_id` + will be used. collection_method: title: Collection method description: An automatic invoice means a corresponding transaction is run @@ -22820,6 +22920,13 @@ components: subscription. maxLength: 13 readOnly: true + business_entity_id: + type: string + title: Business Entity ID + description: The ID of the business entity associated with the subscription. + This will be `null` if the subscription relies on resolving the business + entity during renewal. + maxLength: 13 started_with_gift: type: boolean default: false @@ -23186,6 +23293,9 @@ components: invoice_collection: title: Invoice Collection "$ref": "#/components/schemas/InvoiceCollection" + business_entity: + title: Business Entity + "$ref": "#/components/schemas/BusinessEntityMini" custom_fields: "$ref": "#/components/schemas/CustomFields" created_at: @@ -23251,6 +23361,26 @@ components: maxLength: 50 description: If you want to change to a new plan, you can provide the plan's code or id. If both are provided the `plan_id` will be used. + business_entity_id: + type: string + title: Business Entity ID + description: The `business_entity_id` is the value that represents a specific + business entity for an end customer. When `business_entity_id` is used + to assign a business entity to the subscription, all future billing events + for the subscription will bill to the specified business entity. Available + when the `Multiple Business Entities` feature is enabled. If both `business_entity_id` + and `business_entity_code` are present, `business_entity_id` will be used. + Only allowed if the `timeframe` is not `now`. + business_entity_code: + type: string + title: Business Entity Code + description: The `business_entity_code` is the value that represents a specific + business entity for an end customer. When `business_entity_code` is used + to assign a business entity to the subscription, all future billing events + for the subscription will bill to the specified business entity. Available + when the `Multiple Business Entities` feature is enabled. If both `business_entity_id` + and `business_entity_code` are present, `business_entity_id` will be used. + Only allowed if the `timeframe` is not `now`. unit_amount: type: number format: float @@ -23399,6 +23529,24 @@ components: maxLength: 13 description: You must provide either a `plan_code` or `plan_id`. If both are provided the `plan_id` will be used. + business_entity_id: + type: string + title: Business Entity ID + description: The `business_entity_id` is the value that represents a specific + business entity for an end customer. When `business_entity_id` is used + to assign a business entity to the subscription, all future billing events + for the subscription will bill to the specified business entity. Available + when the `Multiple Business Entities` feature is enabled. If both `business_entity_id` + and `business_entity_code` are present, `business_entity_id` will be used. + business_entity_code: + type: string + title: Business Entity Code + description: The `business_entity_code` is the value that represents a specific + business entity for an end customer. When `business_entity_code` is used + to assign a business entity to the subscription, all future billing events + for the subscription will bill to the specified business entity. Available + when the `Multiple Business Entities` feature is enabled. If both `business_entity_id` + and `business_entity_code` are present, `business_entity_id` will be used. account: "$ref": "#/components/schemas/AccountCreate" billing_info_id: @@ -24023,8 +24171,12 @@ components: maxLength: 13 account: "$ref": "#/components/schemas/AccountMini" + indicator: + "$ref": "#/components/schemas/TransactionIndicatorEnum" invoice: "$ref": "#/components/schemas/InvoiceMini" + merchant_reason_code: + "$ref": "#/components/schemas/TransactionMerchantReasonCodeEnum" voided_by_invoice: "$ref": "#/components/schemas/InvoiceMini" subscription_ids: @@ -24511,6 +24663,24 @@ components: billing info to the subscription, all future billing events for the subscription will bill to the specified billing info. `billing_info_id` can ONLY be used for sites utilizing the Wallet feature. + business_entity_id: + type: string + title: Business Entity ID + description: The `business_entity_id` is the value that represents a specific + business entity for an end customer. When `business_entity_id` is used + to assign a business entity to the subscription, all future billing events + for the subscription will bill to the specified business entity. Available + when the `Multiple Business Entities` feature is enabled. If both `business_entity_id` + and `business_entity_code` are present, `business_entity_id` will be used. + business_entity_code: + type: string + title: Business Entity Code + description: The `business_entity_code` is the value that represents a specific + business entity for an end customer. When `business_entity_code` is used + to assign a business entity to the subscription, all future billing events + for the subscription will bill to the specified business entity. Available + when the `Multiple Business Entities` feature is enabled. If both `business_entity_id` + and `business_entity_code` are present, `business_entity_id` will be used. collection_method: title: Collection method description: Must be set to manual in order to preview a purchase for an @@ -24552,6 +24722,17 @@ components: type: string title: Terms and conditions description: Terms and conditions to be put on the purchase invoice. + transaction: + type: object + description: "(Transaction Data, Card on File) - Options for flagging transactions + as Customer or Merchant Initiated Unscheduled." + allOf: + - type: object + properties: + indicator: + "$ref": "#/components/schemas/Transaction/properties/indicator" + merchant_reason_code: + "$ref": "#/components/schemas/Transaction/properties/merchant_reason_code" customer_notes: type: string title: Customer notes @@ -24807,6 +24988,38 @@ components: type: string format: date-time description: Time the object was last updated + ExternalChargeCreate: + type: object + properties: + currency: + type: string + title: Currency + description: 3-letter ISO 4217 currency code. + maxLength: 3 + unit_amount: + type: string + format: decimal + quantity: + type: integer + description: + type: string + external_product_reference: + "$ref": "#/components/schemas/ExternalProductReferenceCreate" + required: + - quantity + - currency + - unit_amount + AccountExternalSubscription: + allOf: + - type: object + properties: + account_code: + type: string + description: The account code of a new or existing account to be used + when creating the external subscription. + maxLength: 50 + required: + - account_code ExternalPaymentPhase: type: object description: Details of payments in the lifecycle of a subscription from an @@ -24974,7 +25187,7 @@ components: Google Play Store. maxLength: 255 external_connection_type: - "$ref": "#/components/schemas/ExternalProductReferenceConnectionTypeEnum" + "$ref": "#/components/schemas/ExternalProductReferenceConnectionType" ExternalProductReferenceCollection: type: object properties: @@ -25001,11 +25214,10 @@ components: ExternalProductReferenceUpdate: allOf: - "$ref": "#/components/schemas/ExternalProductReferenceBase" - ExternalProductReferenceConnectionTypeEnum: + ExternalProductReferenceConnectionType: type: string - enum: - - apple_app_store - - google_play_store + description: Represents the connection type. One of the connection types of + your enabled App Connectors ExternalAccountList: type: object properties: @@ -25031,7 +25243,8 @@ components: description: Represents the account code for the external account. external_connection_type: type: string - description: Represents the connection type. `AppleAppStore` or `GooglePlayStore` + description: Represents the connection type. One of the connection types + of your enabled App Connectors required: - external_account_code - external_connection_type @@ -25043,7 +25256,8 @@ components: description: Represents the account code for the external account. external_connection_type: type: string - description: Represents the connection type. `AppleAppStore` or `GooglePlayStore` + description: Represents the connection type. One of the connection types + of your enabled App Connectors ExternalAccount: type: object title: External Account @@ -25217,6 +25431,91 @@ components: format: date-time title: Updated at description: When the external subscription was updated in Recurly. + ExternalSubscriptionBase: + type: object + properties: + external_id: + type: string + title: External Id + description: Id of the subscription in the external system, i.e. Apple App + Store or Google Play Store. + last_purchased: + type: string + format: date-time + title: Last purchased + description: When a new billing event occurred on the external subscription + in conjunction with a recent billing period, reactivation or upgrade/downgrade. + auto_renew: + type: boolean + title: Auto-renew + description: An indication of whether or not the external subscription will + auto-renew at the expiration date. + default: false + state: + type: string + description: External subscriptions can be active, canceled, expired, past_due, + voided, revoked, or paused. + default: active + app_identifier: + type: string + title: App identifier + description: Identifier of the app that generated the external subscription. + quantity: + type: integer + title: Quantity + description: An indication of the quantity of a subscribed item's quantity. + default: 1 + minimum: 0 + activated_at: + type: string + format: date-time + title: Activated at + description: When the external subscription was activated in the external + platform. + expires_at: + type: string + format: date-time + title: Expires at + description: When the external subscription expires in the external platform. + trial_started_at: + type: string + format: date-time + title: Trial started at + description: When the external subscription trial period started in the + external platform. + trial_ends_at: + type: string + format: date-time + title: Trial ends at + description: When the external subscription trial period ends in the external + platform. + imported: + type: boolean + title: Import + description: An indication of whether or not the external subscription was + being created by a historical data import. + default: false + ExternalSubscriptionCreate: + allOf: + - type: object + properties: + account: + "$ref": "#/components/schemas/AccountExternalSubscription" + external_product_reference: + "$ref": "#/components/schemas/ExternalProductReferenceCreate" + - "$ref": "#/components/schemas/ExternalSubscriptionBase" + required: + - external_id + - quantity + - activated_at + - expires_at + ExternalSubscriptionUpdate: + allOf: + - type: object + properties: + external_product_reference: + "$ref": "#/components/schemas/ExternalProductReferenceUpdate" + - "$ref": "#/components/schemas/ExternalSubscriptionBase" ExternalSubscriptionList: type: object properties: @@ -25282,6 +25581,86 @@ components: format: date-time title: Updated at description: When the external invoice was updated in Recurly. + ExternalPaymentPhaseBase: + type: object + properties: + started_at: + type: string + format: date-time + title: Started At + ends_at: + type: string + format: date-time + title: Ends At + starting_billing_period_index: + type: integer + title: Starting Billing Period Index + ending_billing_period_index: + type: integer + title: Ending Billing Period Index + offer_type: + type: string + title: Offer Type + description: Type of discount offer given, e.g. "FREE_TRIAL" + offer_name: + type: string + title: Offer Name + description: Name of the discount offer given, e.g. "introductory" + period_count: + type: integer + title: Period Count + description: Number of billing periods + period_length: + type: string + title: Period Length + description: Billing cycle length + amount: + type: string + format: decimal + title: Amount + minimum: 0 + description: Allows up to 9 decimal places + currency: + type: string + title: Currency + description: 3-letter ISO 4217 currency code. + maxLength: 3 + ExternalInvoiceCreate: + type: object + properties: + external_id: + type: string + description: An identifier which associates the external invoice to a corresponding + object in an external platform. + state: + "$ref": "#/components/schemas/ExternalInvoiceStateEnum" + total: + type: string + format: decimal + currency: + type: string + title: Currency + description: 3-letter ISO 4217 currency code. + maxLength: 3 + purchased_at: + type: string + format: date-time + description: When the invoice was created in the external platform. + line_items: + type: array + items: + "$ref": "#/components/schemas/ExternalChargeCreate" + external_payment_phase: + "$ref": "#/components/schemas/ExternalPaymentPhaseBase" + external_payment_phase_id: + type: string + description: External payment phase ID, e.g. `a34ypb2ef9w1`. + required: + - external_id + - state + - total + - currency + - purchased_at ExternalInvoiceList: type: object properties: @@ -25584,6 +25963,30 @@ components: format: date-time title: Last updated at readOnly: true + BusinessEntityMini: + type: object + description: Business entity details + properties: + id: + title: Business entity ID + type: string + maxLength: 13 + readOnly: true + object: + title: Object type + type: string + readOnly: true + code: + title: Business entity code + type: string + maxLength: 50 + description: The entity code of the business entity. + name: + type: string + title: Name + description: This name describes your business entity and will appear on + the invoice. + maxLength: 255 GiftCardList: type: object properties: @@ -26907,3 +27310,32 @@ components: enum: - destination - origin + TransactionMerchantReasonCodeEnum: + type: string + default: none + description: | + This conditional parameter is useful for merchants in specific industries who need to submit one-time Merchant Initiated transactions in specific cases. + Not all gateways support these methods, but will support a generic one-time Merchant Initiated transaction. + Only use this if the initiator value is "merchant". Otherwise, it will be ignored. + - Incremental: Send `incremental` with an additional purchase if the original authorization amount is not sufficient to cover the costs of your service or product. For example, if the customer adds goods or services or there are additional expenses. + - No Show: Send `no_show` if you charge customers a fee due to an agreed-upon cancellation policy in your industry. + - Resubmission: Send `resubmission` if you need to attempt collection on a declined transaction. You may also use the force collection behavior which has the same effect. + - Service Extension: Send `service_extension` if you are in a service industry and the customer has increased/extended their service in some way. For example: adding a day onto a car rental agreement. + - Split Shipment: Send `split_shipment` if you sell physical product and need to split up a shipment into multiple transactions when the customer is no longer in session. + - Top Up: Send `top_up` if you process one-time transactions based on a pre-arranged agreement with your customer where there is a pre-arranged account balance that needs maintaining. For example, if the customer has agreed to maintain an account balance of 30.00 and their current balance is 20.00, the MIT amount would be at least 10.00 to meet that 30.00 threshold. + enum: + - incremental + - no_show + - resubmission + - service_extension + - split_shipment + - top_up + TransactionIndicatorEnum: + type: string + description: Must be sent for one-time transactions in order to provide context + on which entity is submitting the transaction to ensure proper fraud checks + are observed, such as 3DS. If the customer is in session, send `customer`. + If this is a merchant initiated one-time transaction, send `merchant`. + enum: + - customer + - merchant diff --git a/purchase_create.go b/purchase_create.go index 213cff9..a5173c5 100644 --- a/purchase_create.go +++ b/purchase_create.go @@ -16,6 +16,12 @@ type PurchaseCreate struct { // The `billing_info_id` is the value that represents a specific billing info for an end customer. When `billing_info_id` is used to assign billing info to the subscription, all future billing events for the subscription will bill to the specified billing info. `billing_info_id` can ONLY be used for sites utilizing the Wallet feature. BillingInfoId *string `json:"billing_info_id,omitempty"` + // The `business_entity_id` is the value that represents a specific business entity for an end customer. When `business_entity_id` is used to assign a business entity to the subscription, all future billing events for the subscription will bill to the specified business entity. Available when the `Multiple Business Entities` feature is enabled. If both `business_entity_id` and `business_entity_code` are present, `business_entity_id` will be used. + BusinessEntityId *string `json:"business_entity_id,omitempty"` + + // The `business_entity_code` is the value that represents a specific business entity for an end customer. When `business_entity_code` is used to assign a business entity to the subscription, all future billing events for the subscription will bill to the specified business entity. Available when the `Multiple Business Entities` feature is enabled. If both `business_entity_id` and `business_entity_code` are present, `business_entity_id` will be used. + BusinessEntityCode *string `json:"business_entity_code,omitempty"` + // Must be set to manual in order to preview a purchase for an Account that does not have payment information associated with the Billing Info. CollectionMethod *string `json:"collection_method,omitempty"` @@ -45,6 +51,9 @@ type PurchaseCreate struct { // Terms and conditions to be put on the purchase invoice. TermsAndConditions *string `json:"terms_and_conditions,omitempty"` + // (Transaction Data, Card on File) - Options for flagging transactions as Customer or Merchant Initiated Unscheduled. + Transaction *map[string]interface{} `json:"transaction,omitempty"` + // Customer notes CustomerNotes *string `json:"customer_notes,omitempty"` diff --git a/scripts/clean b/scripts/clean index 937c387..0c272bc 100755 --- a/scripts/clean +++ b/scripts/clean @@ -56,6 +56,7 @@ rm -f subscription_add_on.go rm -f add_on_mini.go rm -f subscription_add_on_tier.go rm -f subscription_add_on_percentage_tier.go +rm -f business_entity_mini.go rm -f subscription_change_billing_info.go rm -f subscription_ramp_interval_response.go rm -f unique_coupon_code_params.go @@ -127,8 +128,13 @@ rm -f measured_unit_create.go rm -f measured_unit_update.go rm -f external_product_create.go rm -f external_product_reference_base.go +rm -f external_product_reference_connection_type.go rm -f external_product_update.go rm -f external_product_reference_create.go +rm -f external_subscription_create.go +rm -f account_external_subscription.go +rm -f external_subscription_update.go +rm -f external_product_reference_update.go rm -f invoice_update.go rm -f invoice_address_create.go rm -f invoice_collect.go diff --git a/subscription.go b/subscription.go index 6341596..7a75153 100644 --- a/subscription.go +++ b/subscription.go @@ -177,6 +177,9 @@ type Subscription struct { // The invoice ID of the latest invoice created for an active subscription. ActiveInvoiceId string `json:"active_invoice_id,omitempty"` + // The ID of the business entity associated with the subscription. This will be `null` if the subscription relies on resolving the business entity during renewal. + BusinessEntityId string `json:"business_entity_id,omitempty"` + // Whether the subscription was started with a gift certificate. StartedWithGift bool `json:"started_with_gift,omitempty"` diff --git a/subscription_change.go b/subscription_change.go index 82389a2..2833f76 100644 --- a/subscription_change.go +++ b/subscription_change.go @@ -52,6 +52,9 @@ type SubscriptionChange struct { // Invoice Collection InvoiceCollection InvoiceCollection `json:"invoice_collection,omitempty"` + // Business entity details + BusinessEntity BusinessEntityMini `json:"business_entity,omitempty"` + // The custom fields will only be altered when they are included in a request. Sending an empty array will not remove any existing values. To remove a field send the name with a null or empty value. CustomFields []CustomField `json:"custom_fields,omitempty"` diff --git a/subscription_change_create.go b/subscription_change_create.go index 8679d3e..30c4a0b 100644 --- a/subscription_change_create.go +++ b/subscription_change_create.go @@ -17,6 +17,12 @@ type SubscriptionChangeCreate struct { // If you want to change to a new plan, you can provide the plan's code or id. If both are provided the `plan_id` will be used. PlanCode *string `json:"plan_code,omitempty"` + // The `business_entity_id` is the value that represents a specific business entity for an end customer. When `business_entity_id` is used to assign a business entity to the subscription, all future billing events for the subscription will bill to the specified business entity. Available when the `Multiple Business Entities` feature is enabled. If both `business_entity_id` and `business_entity_code` are present, `business_entity_id` will be used. Only allowed if the `timeframe` is not `now`. + BusinessEntityId *string `json:"business_entity_id,omitempty"` + + // The `business_entity_code` is the value that represents a specific business entity for an end customer. When `business_entity_code` is used to assign a business entity to the subscription, all future billing events for the subscription will bill to the specified business entity. Available when the `Multiple Business Entities` feature is enabled. If both `business_entity_id` and `business_entity_code` are present, `business_entity_id` will be used. Only allowed if the `timeframe` is not `now`. + BusinessEntityCode *string `json:"business_entity_code,omitempty"` + // Optionally, sets custom pricing for the subscription, overriding the plan's default unit amount. The subscription's current currency will be used. UnitAmount *float64 `json:"unit_amount,omitempty"` diff --git a/subscription_create.go b/subscription_create.go index 25de6be..876a221 100644 --- a/subscription_create.go +++ b/subscription_create.go @@ -16,6 +16,12 @@ type SubscriptionCreate struct { // You must provide either a `plan_code` or `plan_id`. If both are provided the `plan_id` will be used. PlanId *string `json:"plan_id,omitempty"` + // The `business_entity_id` is the value that represents a specific business entity for an end customer. When `business_entity_id` is used to assign a business entity to the subscription, all future billing events for the subscription will bill to the specified business entity. Available when the `Multiple Business Entities` feature is enabled. If both `business_entity_id` and `business_entity_code` are present, `business_entity_id` will be used. + BusinessEntityId *string `json:"business_entity_id,omitempty"` + + // The `business_entity_code` is the value that represents a specific business entity for an end customer. When `business_entity_code` is used to assign a business entity to the subscription, all future billing events for the subscription will bill to the specified business entity. Available when the `Multiple Business Entities` feature is enabled. If both `business_entity_id` and `business_entity_code` are present, `business_entity_id` will be used. + BusinessEntityCode *string `json:"business_entity_code,omitempty"` + Account *AccountCreate `json:"account,omitempty"` // The `billing_info_id` is the value that represents a specific billing info for an end customer. When `billing_info_id` is used to assign billing info to the subscription, all future billing events for the subscription will bill to the specified billing info. `billing_info_id` can ONLY be used for sites utilizing the Wallet feature. diff --git a/transaction.go b/transaction.go index 00be0ef..53833a9 100644 --- a/transaction.go +++ b/transaction.go @@ -28,9 +28,23 @@ type Transaction struct { // Account mini details Account AccountMini `json:"account,omitempty"` + // Must be sent for one-time transactions in order to provide context on which entity is submitting the transaction to ensure proper fraud checks are observed, such as 3DS. If the customer is in session, send `customer`. If this is a merchant initiated one-time transaction, send `merchant`. + Indicator string `json:"indicator,omitempty"` + // Invoice mini details Invoice InvoiceMini `json:"invoice,omitempty"` + // This conditional parameter is useful for merchants in specific industries who need to submit one-time Merchant Initiated transactions in specific cases. + // Not all gateways support these methods, but will support a generic one-time Merchant Initiated transaction. + // Only use this if the initiator value is "merchant". Otherwise, it will be ignored. + // - Incremental: Send `incremental` with an additional purchase if the original authorization amount is not sufficient to cover the costs of your service or product. For example, if the customer adds goods or services or there are additional expenses. + // - No Show: Send `no_show` if you charge customers a fee due to an agreed-upon cancellation policy in your industry. + // - Resubmission: Send `resubmission` if you need to attempt collection on a declined transaction. You may also use the force collection behavior which has the same effect. + // - Service Extension: Send `service_extension` if you are in a service industry and the customer has increased/extended their service in some way. For example: adding a day onto a car rental agreement. + // - Split Shipment: Send `split_shipment` if you sell physical product and need to split up a shipment into multiple transactions when the customer is no longer in session. + // - Top Up: Send `top_up` if you process one-time transactions based on a pre-arranged agreement with your customer where there is a pre-arranged account balance that needs maintaining. For example, if the customer has agreed to maintain an account balance of 30.00 and their current balance is 20.00, the MIT amount would be at least 10.00 to meet that 30.00 threshold. + MerchantReasonCode string `json:"merchant_reason_code,omitempty"` + // Invoice mini details VoidedByInvoice InvoiceMini `json:"voided_by_invoice,omitempty"`