diff --git a/README.md b/README.md index 9e01dc5..979e48b 100644 --- a/README.md +++ b/README.md @@ -29,14 +29,14 @@ curl -u :x -H Accept:application/json -H Content-Type:application/json Run the following command from your project directory to install the package from npm: ```bash -npm install @maxio-com/advanced-billing-sdk@7.0.1 +npm install @maxio-com/advanced-billing-sdk@8.0.0 ``` -For additional package details, see the [Npm page for the @maxio-com/advanced-billing-sdk@7.0.1 npm](https://www.npmjs.com/package/@maxio-com/advanced-billing-sdk/v/7.0.1). +For additional package details, see the [Npm page for the @maxio-com/advanced-billing-sdk@8.0.0 npm](https://www.npmjs.com/package/@maxio-com/advanced-billing-sdk/v/8.0.0). ## Initialize the API Client -**_Note:_** Documentation for the client can be found [here.](https://www.github.com/maxio-com/ab-typescript-sdk/tree/7.0.1/doc/client.md) +**_Note:_** Documentation for the client can be found [here.](https://www.github.com/maxio-com/ab-typescript-sdk/tree/8.0.0/doc/client.md) The following parameters are configurable for the API Client: @@ -45,9 +45,9 @@ The following parameters are configurable for the API Client: | site | `string` | The subdomain for your Advanced Billing site.
*Default*: `'subdomain'` | | environment | `Environment` | The API environment.
**Default: `Environment.US`** | | timeout | `number` | Timeout for API calls.
*Default*: `120000` | -| httpClientOptions | [`Partial`](https://www.github.com/maxio-com/ab-typescript-sdk/tree/7.0.1/doc/http-client-options.md) | Stable configurable http client options. | +| httpClientOptions | [`Partial`](https://www.github.com/maxio-com/ab-typescript-sdk/tree/8.0.0/doc/http-client-options.md) | Stable configurable http client options. | | unstableHttpClientOptions | `any` | Unstable configurable http client options. | -| basicAuthCredentials | [`BasicAuthCredentials`](https://www.github.com/maxio-com/ab-typescript-sdk/tree/7.0.1/doc/auth/basic-authentication.md) | The credential object for basicAuth | +| basicAuthCredentials | [`BasicAuthCredentials`](https://www.github.com/maxio-com/ab-typescript-sdk/tree/8.0.0/doc/auth/basic-authentication.md) | The credential object for basicAuth | The API client can be initialized as follows: @@ -80,57 +80,57 @@ The SDK can be configured to use a different environment for making API calls. A This API uses the following authentication schemes. -* [`BasicAuth (Basic Authentication)`](https://www.github.com/maxio-com/ab-typescript-sdk/tree/7.0.1/doc/auth/basic-authentication.md) +* [`BasicAuth (Basic Authentication)`](https://www.github.com/maxio-com/ab-typescript-sdk/tree/8.0.0/doc/auth/basic-authentication.md) ## List of APIs -* [API Exports](https://www.github.com/maxio-com/ab-typescript-sdk/tree/7.0.1/doc/controllers/api-exports.md) -* [Advance Invoice](https://www.github.com/maxio-com/ab-typescript-sdk/tree/7.0.1/doc/controllers/advance-invoice.md) -* [Billing Portal](https://www.github.com/maxio-com/ab-typescript-sdk/tree/7.0.1/doc/controllers/billing-portal.md) -* [Component Price Points](https://www.github.com/maxio-com/ab-typescript-sdk/tree/7.0.1/doc/controllers/component-price-points.md) -* [Custom Fields](https://www.github.com/maxio-com/ab-typescript-sdk/tree/7.0.1/doc/controllers/custom-fields.md) -* [Events-Based Billing Segments](https://www.github.com/maxio-com/ab-typescript-sdk/tree/7.0.1/doc/controllers/events-based-billing-segments.md) -* [Payment Profiles](https://www.github.com/maxio-com/ab-typescript-sdk/tree/7.0.1/doc/controllers/payment-profiles.md) -* [Product Families](https://www.github.com/maxio-com/ab-typescript-sdk/tree/7.0.1/doc/controllers/product-families.md) -* [Product Price Points](https://www.github.com/maxio-com/ab-typescript-sdk/tree/7.0.1/doc/controllers/product-price-points.md) -* [Proforma Invoices](https://www.github.com/maxio-com/ab-typescript-sdk/tree/7.0.1/doc/controllers/proforma-invoices.md) -* [Reason Codes](https://www.github.com/maxio-com/ab-typescript-sdk/tree/7.0.1/doc/controllers/reason-codes.md) -* [Referral Codes](https://www.github.com/maxio-com/ab-typescript-sdk/tree/7.0.1/doc/controllers/referral-codes.md) -* [Sales Commissions](https://www.github.com/maxio-com/ab-typescript-sdk/tree/7.0.1/doc/controllers/sales-commissions.md) -* [Subscription Components](https://www.github.com/maxio-com/ab-typescript-sdk/tree/7.0.1/doc/controllers/subscription-components.md) -* [Subscription Groups](https://www.github.com/maxio-com/ab-typescript-sdk/tree/7.0.1/doc/controllers/subscription-groups.md) -* [Subscription Group Invoice Account](https://www.github.com/maxio-com/ab-typescript-sdk/tree/7.0.1/doc/controllers/subscription-group-invoice-account.md) -* [Subscription Group Status](https://www.github.com/maxio-com/ab-typescript-sdk/tree/7.0.1/doc/controllers/subscription-group-status.md) -* [Subscription Invoice Account](https://www.github.com/maxio-com/ab-typescript-sdk/tree/7.0.1/doc/controllers/subscription-invoice-account.md) -* [Subscription Notes](https://www.github.com/maxio-com/ab-typescript-sdk/tree/7.0.1/doc/controllers/subscription-notes.md) -* [Subscription Products](https://www.github.com/maxio-com/ab-typescript-sdk/tree/7.0.1/doc/controllers/subscription-products.md) -* [Subscription Status](https://www.github.com/maxio-com/ab-typescript-sdk/tree/7.0.1/doc/controllers/subscription-status.md) -* [Coupons](https://www.github.com/maxio-com/ab-typescript-sdk/tree/7.0.1/doc/controllers/coupons.md) -* [Components](https://www.github.com/maxio-com/ab-typescript-sdk/tree/7.0.1/doc/controllers/components.md) -* [Customers](https://www.github.com/maxio-com/ab-typescript-sdk/tree/7.0.1/doc/controllers/customers.md) -* [Events](https://www.github.com/maxio-com/ab-typescript-sdk/tree/7.0.1/doc/controllers/events.md) -* [Insights](https://www.github.com/maxio-com/ab-typescript-sdk/tree/7.0.1/doc/controllers/insights.md) -* [Invoices](https://www.github.com/maxio-com/ab-typescript-sdk/tree/7.0.1/doc/controllers/invoices.md) -* [Offers](https://www.github.com/maxio-com/ab-typescript-sdk/tree/7.0.1/doc/controllers/offers.md) -* [Products](https://www.github.com/maxio-com/ab-typescript-sdk/tree/7.0.1/doc/controllers/products.md) -* [Sites](https://www.github.com/maxio-com/ab-typescript-sdk/tree/7.0.1/doc/controllers/sites.md) -* [Subscriptions](https://www.github.com/maxio-com/ab-typescript-sdk/tree/7.0.1/doc/controllers/subscriptions.md) -* [Webhooks](https://www.github.com/maxio-com/ab-typescript-sdk/tree/7.0.1/doc/controllers/webhooks.md) +* [API Exports](https://www.github.com/maxio-com/ab-typescript-sdk/tree/8.0.0/doc/controllers/api-exports.md) +* [Advance Invoice](https://www.github.com/maxio-com/ab-typescript-sdk/tree/8.0.0/doc/controllers/advance-invoice.md) +* [Billing Portal](https://www.github.com/maxio-com/ab-typescript-sdk/tree/8.0.0/doc/controllers/billing-portal.md) +* [Component Price Points](https://www.github.com/maxio-com/ab-typescript-sdk/tree/8.0.0/doc/controllers/component-price-points.md) +* [Custom Fields](https://www.github.com/maxio-com/ab-typescript-sdk/tree/8.0.0/doc/controllers/custom-fields.md) +* [Events-Based Billing Segments](https://www.github.com/maxio-com/ab-typescript-sdk/tree/8.0.0/doc/controllers/events-based-billing-segments.md) +* [Payment Profiles](https://www.github.com/maxio-com/ab-typescript-sdk/tree/8.0.0/doc/controllers/payment-profiles.md) +* [Product Families](https://www.github.com/maxio-com/ab-typescript-sdk/tree/8.0.0/doc/controllers/product-families.md) +* [Product Price Points](https://www.github.com/maxio-com/ab-typescript-sdk/tree/8.0.0/doc/controllers/product-price-points.md) +* [Proforma Invoices](https://www.github.com/maxio-com/ab-typescript-sdk/tree/8.0.0/doc/controllers/proforma-invoices.md) +* [Reason Codes](https://www.github.com/maxio-com/ab-typescript-sdk/tree/8.0.0/doc/controllers/reason-codes.md) +* [Referral Codes](https://www.github.com/maxio-com/ab-typescript-sdk/tree/8.0.0/doc/controllers/referral-codes.md) +* [Sales Commissions](https://www.github.com/maxio-com/ab-typescript-sdk/tree/8.0.0/doc/controllers/sales-commissions.md) +* [Subscription Components](https://www.github.com/maxio-com/ab-typescript-sdk/tree/8.0.0/doc/controllers/subscription-components.md) +* [Subscription Groups](https://www.github.com/maxio-com/ab-typescript-sdk/tree/8.0.0/doc/controllers/subscription-groups.md) +* [Subscription Group Invoice Account](https://www.github.com/maxio-com/ab-typescript-sdk/tree/8.0.0/doc/controllers/subscription-group-invoice-account.md) +* [Subscription Group Status](https://www.github.com/maxio-com/ab-typescript-sdk/tree/8.0.0/doc/controllers/subscription-group-status.md) +* [Subscription Invoice Account](https://www.github.com/maxio-com/ab-typescript-sdk/tree/8.0.0/doc/controllers/subscription-invoice-account.md) +* [Subscription Notes](https://www.github.com/maxio-com/ab-typescript-sdk/tree/8.0.0/doc/controllers/subscription-notes.md) +* [Subscription Products](https://www.github.com/maxio-com/ab-typescript-sdk/tree/8.0.0/doc/controllers/subscription-products.md) +* [Subscription Status](https://www.github.com/maxio-com/ab-typescript-sdk/tree/8.0.0/doc/controllers/subscription-status.md) +* [Coupons](https://www.github.com/maxio-com/ab-typescript-sdk/tree/8.0.0/doc/controllers/coupons.md) +* [Components](https://www.github.com/maxio-com/ab-typescript-sdk/tree/8.0.0/doc/controllers/components.md) +* [Customers](https://www.github.com/maxio-com/ab-typescript-sdk/tree/8.0.0/doc/controllers/customers.md) +* [Events](https://www.github.com/maxio-com/ab-typescript-sdk/tree/8.0.0/doc/controllers/events.md) +* [Insights](https://www.github.com/maxio-com/ab-typescript-sdk/tree/8.0.0/doc/controllers/insights.md) +* [Invoices](https://www.github.com/maxio-com/ab-typescript-sdk/tree/8.0.0/doc/controllers/invoices.md) +* [Offers](https://www.github.com/maxio-com/ab-typescript-sdk/tree/8.0.0/doc/controllers/offers.md) +* [Products](https://www.github.com/maxio-com/ab-typescript-sdk/tree/8.0.0/doc/controllers/products.md) +* [Sites](https://www.github.com/maxio-com/ab-typescript-sdk/tree/8.0.0/doc/controllers/sites.md) +* [Subscriptions](https://www.github.com/maxio-com/ab-typescript-sdk/tree/8.0.0/doc/controllers/subscriptions.md) +* [Webhooks](https://www.github.com/maxio-com/ab-typescript-sdk/tree/8.0.0/doc/controllers/webhooks.md) ## SDK Infrastructure ### Configuration -* [HttpClientOptions](https://www.github.com/maxio-com/ab-typescript-sdk/tree/7.0.1/doc/http-client-options.md) -* [RetryConfiguration](https://www.github.com/maxio-com/ab-typescript-sdk/tree/7.0.1/doc/retry-configuration.md) -* [ProxySettings](https://www.github.com/maxio-com/ab-typescript-sdk/tree/7.0.1/doc/proxy-settings.md) +* [HttpClientOptions](https://www.github.com/maxio-com/ab-typescript-sdk/tree/8.0.0/doc/http-client-options.md) +* [RetryConfiguration](https://www.github.com/maxio-com/ab-typescript-sdk/tree/8.0.0/doc/retry-configuration.md) +* [ProxySettings](https://www.github.com/maxio-com/ab-typescript-sdk/tree/8.0.0/doc/proxy-settings.md) ### HTTP -* [HttpRequest](https://www.github.com/maxio-com/ab-typescript-sdk/tree/7.0.1/doc/http-request.md) +* [HttpRequest](https://www.github.com/maxio-com/ab-typescript-sdk/tree/8.0.0/doc/http-request.md) ### Utilities -* [ApiResponse](https://www.github.com/maxio-com/ab-typescript-sdk/tree/7.0.1/doc/api-response.md) -* [ApiError](https://www.github.com/maxio-com/ab-typescript-sdk/tree/7.0.1/doc/api-error.md) +* [ApiResponse](https://www.github.com/maxio-com/ab-typescript-sdk/tree/8.0.0/doc/api-response.md) +* [ApiError](https://www.github.com/maxio-com/ab-typescript-sdk/tree/8.0.0/doc/api-error.md) diff --git a/doc/controllers/advance-invoice.md b/doc/controllers/advance-invoice.md index 4497155..885198c 100644 --- a/doc/controllers/advance-invoice.md +++ b/doc/controllers/advance-invoice.md @@ -17,7 +17,7 @@ const advanceInvoiceController = new AdvanceInvoiceController(client); # Issue Advance Invoice -Generate an invoice in advance for a subscription's next renewal date. [Please see our docs](https://maxio.zendesk.com/hc/en-us/articles/24252026404749-Issue-Invoice-In-Advance) for more information on advance invoices, including eligibility on generating one; for the most part, they function like any other invoice, except they are issued early and have special behavior upon being voided. +Generate an invoice in advance for a subscription's next renewal date. [See our docs](https://maxio.zendesk.com/hc/en-us/articles/24252026404749-Issue-Invoice-In-Advance) for more information on advance invoices, including eligibility on generating one; for the most part, they function like any other invoice, except they are issued early and have special behavior upon being voided. A subscription may only have one advance invoice per billing period. Attempting to issue an advance invoice when one already exists will return an error. That said, regeneration of the invoice may be forced with the params `force: true`, which will void an advance invoice if one exists and generate a new one. If no advance invoice exists, a new one will be generated. We recommend using either the create or preview endpoints for proforma invoices to preview this advance invoice before using this endpoint to generate it. @@ -52,16 +52,28 @@ const body: IssueAdvanceInvoiceRequest = { }; try { - const { result, ...httpResponse } = await advanceInvoiceController.issueAdvanceInvoice( + const response = await advanceInvoiceController.issueAdvanceInvoice( subscriptionId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -102,13 +114,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const subscriptionId = 222; try { - const { result, ...httpResponse } = await advanceInvoiceController.readAdvanceInvoice(subscriptionId); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await advanceInvoiceController.readAdvanceInvoice(subscriptionId); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -123,7 +147,7 @@ try { # Void Advance Invoice Void a subscription's existing advance invoice. Once voided, it can later be regenerated if desired. -A `reason` is required in order to void, and the invoice must have an open status. Voiding will cause any prepayments and credits that were applied to the invoice to be returned to the subscription. For a full overview of the impact of voiding, please [see our help docs](../../doc/models/invoice.md). +A `reason` is required in order to void, and the invoice must have an open status. Voiding will cause any prepayments and credits that were applied to the invoice to be returned to the subscription. For a full overview of the impact of voiding, [see our help docs](../../doc/models/invoice.md). ```ts async voidAdvanceInvoice( @@ -151,13 +175,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const subscriptionId = 222; try { - const { result, ...httpResponse } = await advanceInvoiceController.voidAdvanceInvoice(subscriptionId); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await advanceInvoiceController.voidAdvanceInvoice(subscriptionId); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` diff --git a/doc/controllers/api-exports.md b/doc/controllers/api-exports.md index 612cd85..de7d67b 100644 --- a/doc/controllers/api-exports.md +++ b/doc/controllers/api-exports.md @@ -61,17 +61,29 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const collect = { batchId: 'batch_id8', perPage: 100, - page: 2 + page: 1 } try { - const { result, ...httpResponse } = await aPIExportsController.listExportedProformaInvoices(collect); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await aPIExportsController.listExportedProformaInvoices(collect); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -123,17 +135,29 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const collect = { batchId: 'batch_id8', perPage: 100, - page: 2 + page: 1 } try { - const { result, ...httpResponse } = await aPIExportsController.listExportedInvoices(collect); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await aPIExportsController.listExportedInvoices(collect); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -185,17 +209,29 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const collect = { batchId: 'batch_id8', perPage: 100, - page: 2 + page: 1 } try { - const { result, ...httpResponse } = await aPIExportsController.listExportedSubscriptions(collect); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await aPIExportsController.listExportedSubscriptions(collect); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -233,13 +269,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The ```ts try { - const { result, ...httpResponse } = await aPIExportsController.exportProformaInvoices(); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await aPIExportsController.exportProformaInvoices(); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -276,13 +324,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The ```ts try { - const { result, ...httpResponse } = await aPIExportsController.exportInvoices(); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await aPIExportsController.exportInvoices(); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -319,13 +379,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The ```ts try { - const { result, ...httpResponse } = await aPIExportsController.exportSubscriptions(); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await aPIExportsController.exportSubscriptions(); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -365,13 +437,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const batchId = 'batch_id8'; try { - const { result, ...httpResponse } = await aPIExportsController.readProformaInvoicesExport(batchId); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await aPIExportsController.readProformaInvoicesExport(batchId); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -411,13 +495,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const batchId = 'batch_id8'; try { - const { result, ...httpResponse } = await aPIExportsController.readInvoicesExport(batchId); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await aPIExportsController.readInvoicesExport(batchId); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -457,13 +553,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const batchId = 'batch_id8'; try { - const { result, ...httpResponse } = await aPIExportsController.readSubscriptionsExport(batchId); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await aPIExportsController.readSubscriptionsExport(batchId); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` diff --git a/doc/controllers/billing-portal.md b/doc/controllers/billing-portal.md index 3a46225..47707aa 100644 --- a/doc/controllers/billing-portal.md +++ b/doc/controllers/billing-portal.md @@ -32,7 +32,7 @@ If your customer has been invited to the Billing Portal, then they will receive If you need to provide your customer their Management URL through other means, you can retrieve it via the API. Because the URL is cryptographically signed with a timestamp, it is not possible for merchants to generate the URL without requesting it from Advanced Billing. -In order to prevent abuse & overuse, we ask that you request a new URL only when absolutely necessary. Management URLs are good for 65 days, so you should re-use a previously generated one as much as possible. If you use the URL frequently (such as to display on your website), please **do not** make an API request to Advanced Billing every time. +In order to prevent abuse & overuse, we ask that you request a new URL only when absolutely necessary. Management URLs are good for 65 days, so you should re-use a previously generated one as much as possible. If you use the URL frequently (such as to display on your website), **do not** make an API request to Advanced Billing every time. ```ts async enableBillingPortalForCustomer( @@ -60,13 +60,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const customerId = 150; try { - const { result, ...httpResponse } = await billingPortalController.enableBillingPortalForCustomer(customerId); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await billingPortalController.enableBillingPortalForCustomer(customerId); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -114,13 +126,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const customerId = 150; try { - const { result, ...httpResponse } = await billingPortalController.readBillingPortalLink(customerId); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await billingPortalController.readBillingPortalLink(customerId); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -186,13 +210,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const customerId = 150; try { - const { result, ...httpResponse } = await billingPortalController.resendBillingPortalInvitation(customerId); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await billingPortalController.resendBillingPortalInvitation(customerId); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -250,13 +286,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const customerId = 150; try { - const { result, ...httpResponse } = await billingPortalController.revokeBillingPortalAccess(customerId); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await billingPortalController.revokeBillingPortalAccess(customerId); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` diff --git a/doc/controllers/component-price-points.md b/doc/controllers/component-price-points.md index 1405abc..f4c0543 100644 --- a/doc/controllers/component-price-points.md +++ b/doc/controllers/component-price-points.md @@ -59,16 +59,28 @@ const componentId = 222; const pricePointId = 10; try { - const { result, ...httpResponse } = await componentPricePointsController.promoteComponentPricePointToDefault( + const response = await componentPricePointsController.promoteComponentPricePointToDefault( componentId, pricePointId ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -158,16 +170,28 @@ const body: CreateComponentPricePointRequest = { }; try { - const { result, ...httpResponse } = await componentPricePointsController.createComponentPricePoint( + const response = await componentPricePointsController.createComponentPricePoint( componentId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -228,19 +252,31 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The ```ts const collect = { componentId: 222, - page: 2, + page: 1, perPage: 50, filterType: Liquid error: Value cannot be null. (Parameter 'key') } try { - const { result, ...httpResponse } = await componentPricePointsController.listComponentPricePoints(collect); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await componentPricePointsController.listComponentPricePoints(collect); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -363,16 +399,28 @@ const body: CreateComponentPricePointsRequest = { }; try { - const { result, ...httpResponse } = await componentPricePointsController.bulkCreateComponentPricePoints( + const response = await componentPricePointsController.bulkCreateComponentPricePoints( componentId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -435,7 +483,7 @@ try { # Update Component Price Point -When updating a price point, it's prices can be updated as well by creating new prices or editing / removing existing ones. +When updating a price point, prices can be updated as well by creating new prices or editing / removing existing ones. Passing in a price bracket without an `id` will attempt to create a new price. @@ -494,17 +542,29 @@ const body: UpdateComponentPricePointRequest = { }; try { - const { result, ...httpResponse } = await componentPricePointsController.updateComponentPricePoint( + const response = await componentPricePointsController.updateComponentPricePoint( componentId, pricePointId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -550,16 +610,28 @@ const componentId: ReadComponentPricePointComponentId = 144; const pricePointId: ReadComponentPricePointPricePointId = 188; try { - const { result, ...httpResponse } = await componentPricePointsController.readComponentPricePoint( + const response = await componentPricePointsController.readComponentPricePoint( componentId, pricePointId ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -597,16 +669,28 @@ const componentId: ArchiveComponentPricePointComponentId = 144; const pricePointId: ArchiveComponentPricePointPricePointId = 188; try { - const { result, ...httpResponse } = await componentPricePointsController.archiveComponentPricePoint( + const response = await componentPricePointsController.archiveComponentPricePoint( componentId, pricePointId ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -684,16 +768,28 @@ const componentId = 222; const pricePointId = 10; try { - const { result, ...httpResponse } = await componentPricePointsController.unarchiveComponentPricePoint( + const response = await componentPricePointsController.unarchiveComponentPricePoint( componentId, pricePointId ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -782,16 +878,28 @@ const body: CreateCurrencyPricesRequest = { }; try { - const { result, ...httpResponse } = await componentPricePointsController.createCurrencyPrices( + const response = await componentPricePointsController.createCurrencyPrices( pricePointId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -865,16 +973,28 @@ const body: UpdateCurrencyPricesRequest = { }; try { - const { result, ...httpResponse } = await componentPricePointsController.updateCurrencyPrices( + const response = await componentPricePointsController.updateCurrencyPrices( pricePointId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -946,7 +1066,7 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The ```ts const collect = { include: ListComponentsPricePointsInclude.CurrencyPrices, - page: 2, + page: 1, perPage: 50, filter: { startDate: '2011-12-17', @@ -967,13 +1087,25 @@ const collect = { } try { - const { result, ...httpResponse } = await componentPricePointsController.listAllComponentPricePoints(collect); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await componentPricePointsController.listAllComponentPricePoints(collect); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` diff --git a/doc/controllers/components.md b/doc/controllers/components.md index 07d7bca..c728cd8 100644 --- a/doc/controllers/components.md +++ b/doc/controllers/components.md @@ -32,7 +32,7 @@ Metered components are used to bill for any type of unit that resets to 0 at the Note that this is different from recurring quantity-based components, which DO NOT reset to zero at the start of every billing period. If you want to bill for a quantity of something that does not change unless you change it, then you want quantity components, instead. -For more information on components, please see our documentation [here](https://maxio.zendesk.com/hc/en-us/articles/24261141522189-Components-Overview). +For more information on components, see our documentation [here](https://maxio.zendesk.com/hc/en-us/articles/24261141522189-Components-Overview). ```ts async createMeteredComponent( @@ -75,16 +75,28 @@ const body: CreateMeteredComponent = { }; try { - const { result, ...httpResponse } = await componentsController.createMeteredComponent( + const response = await componentsController.createMeteredComponent( productFamilyId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -163,7 +175,7 @@ One-time quantity-based components are used to create ad hoc usage charges that The allocated quantity for one-time quantity-based components immediately gets reset back to zero after the allocation is made. -For more information on components, please see our documentation [here](https://maxio.zendesk.com/hc/en-us/articles/24261141522189-Components-Overview). +For more information on components, see our documentation [here](https://maxio.zendesk.com/hc/en-us/articles/24261141522189-Components-Overview). ```ts async createQuantityBasedComponent( @@ -207,16 +219,28 @@ const body: CreateQuantityBasedComponent = { }; try { - const { result, ...httpResponse } = await componentsController.createQuantityBasedComponent( + const response = await componentsController.createQuantityBasedComponent( productFamilyId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -285,7 +309,7 @@ This request will create a component definition of kind **on_off_component** und On/off components are used for any flat fee, recurring add on (think $99/month for tech support or a flat add on shipping fee). -For more information on components, please see our documentation [here](https://maxio.zendesk.com/hc/en-us/articles/24261141522189-Components-Overview). +For more information on components, see our documentation [here](https://maxio.zendesk.com/hc/en-us/articles/24261141522189-Components-Overview). ```ts async createOnOffComponent( @@ -326,16 +350,28 @@ const body: CreateOnOffComponent = { }; try { - const { result, ...httpResponse } = await componentsController.createOnOffComponent( + const response = await componentsController.createOnOffComponent( productFamilyId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -392,7 +428,7 @@ This request will create a component definition of kind **prepaid_usage_componen Prepaid components allow customers to pre-purchase units that can be used up over time on their subscription. In a sense, they are the mirror image of metered components; while metered components charge at the end of the period for the amount of units used, prepaid components are charged for at the time of purchase, and we subsequently keep track of the usage against the amount purchased. -For more information on components, please see our documentation [here](https://maxio.zendesk.com/hc/en-us/articles/24261141522189-Components-Overview). +For more information on components, see our documentation [here](https://maxio.zendesk.com/hc/en-us/articles/24261141522189-Components-Overview). ```ts async createPrepaidUsageComponent( @@ -447,16 +483,28 @@ const body: CreatePrepaidComponent = { }; try { - const { result, ...httpResponse } = await componentsController.createPrepaidUsageComponent( + const response = await componentsController.createPrepaidUsageComponent( productFamilyId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -539,7 +587,7 @@ Event-based components are similar to other component types, in that you define So, instead of reporting usage directly for each component (as you would with metered components), the usage is derived from analysis of your events. -For more information on components, please see our documentation [here](https://maxio.zendesk.com/hc/en-us/articles/24261141522189-Components-Overview). +For more information on components, see our documentation [here](https://maxio.zendesk.com/hc/en-us/articles/24261141522189-Components-Overview). ```ts async createEventBasedComponent( @@ -585,16 +633,28 @@ const body: CreateEBBComponent = { }; try { - const { result, ...httpResponse } = await componentsController.createEventBasedComponent( + const response = await componentsController.createEventBasedComponent( productFamilyId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -674,13 +734,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const handle = 'handle6'; try { - const { result, ...httpResponse } = await componentsController.findComponent(handle); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await componentsController.findComponent(handle); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -750,16 +822,28 @@ const productFamilyId = 140; const componentId = 'component_id8'; try { - const { result, ...httpResponse } = await componentsController.readComponent( + const response = await componentsController.readComponent( productFamilyId, componentId ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -838,17 +922,29 @@ const body: UpdateComponentRequest = { }; try { - const { result, ...httpResponse } = await componentsController.updateProductFamilyComponent( + const response = await componentsController.updateProductFamilyComponent( productFamilyId, componentId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -922,16 +1018,28 @@ const productFamilyId = 140; const componentId = 'component_id8'; try { - const { result, ...httpResponse } = await componentsController.archiveComponent( + const response = await componentsController.archiveComponent( productFamilyId, componentId ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -1024,7 +1132,7 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The ```ts const collect = { dateField: BasicDateField.UpdatedAt, - page: 2, + page: 1, perPage: 50, filter: { ids: [ @@ -1036,13 +1144,25 @@ const collect = { } try { - const { result, ...httpResponse } = await componentsController.listComponents(collect); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await componentsController.listComponents(collect); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -1185,16 +1305,28 @@ const body: UpdateComponentRequest = { }; try { - const { result, ...httpResponse } = await componentsController.updateComponent( + const response = await componentsController.updateComponent( componentId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -1294,7 +1426,7 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The ```ts const collect = { productFamilyId: 140, - page: 2, + page: 1, perPage: 50, filter: { ids: [ @@ -1307,13 +1439,25 @@ const collect = { } try { - const { result, ...httpResponse } = await componentsController.listComponentsForProductFamily(collect); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await componentsController.listComponentsForProductFamily(collect); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` diff --git a/doc/controllers/coupons.md b/doc/controllers/coupons.md index 3bca43b..45bccf1 100644 --- a/doc/controllers/coupons.md +++ b/doc/controllers/coupons.md @@ -30,9 +30,9 @@ const couponsController = new CouponsController(client); ## Coupons Documentation -Coupons can be administered in the Advanced Billing application or created via API. Please view our section on [creating coupons](https://maxio.zendesk.com/hc/en-us/articles/24261212433165-Creating-Editing-Deleting-Coupons) for more information. +Coupons can be administered in the Advanced Billing application or created via API. View our section on [creating coupons](https://maxio.zendesk.com/hc/en-us/articles/24261212433165-Creating-Editing-Deleting-Coupons) for more information. -Additionally, for documentation on how to apply a coupon to a subscription within the Advanced Billing UI, please see our documentation [here](https://maxio.zendesk.com/hc/en-us/articles/24261259337101-Coupons-and-Subscriptions). +Additionally, for documentation on how to apply a coupon to a subscription within the Advanced Billing UI, see our documentation [here](https://maxio.zendesk.com/hc/en-us/articles/24261259337101-Coupons-and-Subscriptions). ## Create Coupon @@ -93,16 +93,28 @@ const body: CouponRequest = { }; try { - const { result, ...httpResponse } = await couponsController.createCoupon( + const response = await couponsController.createCoupon( productFamilyId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -118,8 +130,6 @@ try { List coupons for a specific Product Family in a Site. -If the coupon is set to `use_site_exchange_rate: true`, it will return pricing based on the current exchange rate. If the flag is set to false, it will return all of the defined prices for each currency. - ```ts async listCouponsForProductFamily( { @@ -159,7 +169,7 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The ```ts const collect = { productFamilyId: 140, - page: 2, + page: 1, perPage: 50, filter: { startDate: '2011-12-17', @@ -180,13 +190,25 @@ const collect = { } try { - const { result, ...httpResponse } = await couponsController.listCouponsForProductFamily(collect); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await couponsController.listCouponsForProductFamily(collect); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -317,17 +339,29 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const currencyPrices = true; try { - const { result, ...httpResponse } = await couponsController.findCoupon( + const response = await couponsController.findCoupon( undefined, undefined, currencyPrices ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -374,17 +408,29 @@ const couponId = 162; const currencyPrices = true; try { - const { result, ...httpResponse } = await couponsController.readCoupon( + const response = await couponsController.readCoupon( productFamilyId, couponId, currencyPrices ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -480,17 +526,29 @@ const body: CouponRequest = { }; try { - const { result, ...httpResponse } = await couponsController.updateCoupon( + const response = await couponsController.updateCoupon( productFamilyId, couponId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -565,16 +623,28 @@ const productFamilyId = 140; const couponId = 162; try { - const { result, ...httpResponse } = await couponsController.archiveCoupon( + const response = await couponsController.archiveCoupon( productFamilyId, couponId ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -613,8 +683,6 @@ try { You can retrieve a list of coupons. -If the coupon is set to `use_site_exchange_rate: true`, it will return pricing based on the current exchange rate. If the flag is set to false, it will return all of the defined prices for each currency. - ```ts async listCoupons( { @@ -650,7 +718,7 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The ```ts const collect = { - page: 2, + page: 1, perPage: 50, filter: { startDate: '2011-12-17', @@ -671,13 +739,25 @@ const collect = { } try { - const { result, ...httpResponse } = await couponsController.listCoupons(collect); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await couponsController.listCoupons(collect); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -747,8 +827,8 @@ async readCouponUsage( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `productFamilyId` | `number` | Template, Required | The Advanced Billing id of the product family to which the coupon belongs | -| `couponId` | `number` | Template, Required | The Advanced Billing id of the coupon | +| `productFamilyId` | `number` | Template, Required | The Advanced Billing id of the product family to which the coupon belongs. | +| `couponId` | `number` | Template, Required | The Advanced Billing id of the coupon. | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | ## Response Type @@ -763,16 +843,28 @@ const productFamilyId = 140; const couponId = 162; try { - const { result, ...httpResponse } = await couponsController.readCouponUsage( + const response = await couponsController.readCouponUsage( productFamilyId, couponId ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -862,13 +954,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const code = 'code8'; try { - const { result, ...httpResponse } = await couponsController.validateCoupon(code); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await couponsController.validateCoupon(code); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -954,16 +1058,28 @@ const body: CouponCurrencyRequest = { }; try { - const { result, ...httpResponse } = await couponsController.createOrUpdateCouponCurrencyPrices( + const response = await couponsController.createOrUpdateCouponCurrencyPrices( couponId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -1001,7 +1117,7 @@ When creating a coupon subcode, you must specify a coupon to attach it to using Full documentation on how to create coupon subcodes in the Advanced Billing UI can be located [here](https://maxio.zendesk.com/hc/en-us/articles/24261208729229-Coupon-Codes). -Additionally, for documentation on how to apply a coupon to a Subscription within the Advanced Billing UI, please see our documentation [here](https://maxio.zendesk.com/hc/en-us/articles/24261259337101-Coupons-and-Subscriptions). +Additionally, for documentation on how to apply a coupon to a Subscription within the Advanced Billing UI, see our documentation [here](https://maxio.zendesk.com/hc/en-us/articles/24261259337101-Coupons-and-Subscriptions). ## Create Coupon Subcode @@ -1052,16 +1168,28 @@ const body: CouponSubcodes = { }; try { - const { result, ...httpResponse } = await couponsController.createCouponSubcodes( + const response = await couponsController.createCouponSubcodes( couponId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -1116,18 +1244,30 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The ```ts const collect = { couponId: 162, - page: 2, + page: 1, perPage: 50 } try { - const { result, ...httpResponse } = await couponsController.listCouponSubcodes(collect); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await couponsController.listCouponSubcodes(collect); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -1210,16 +1350,28 @@ const body: CouponSubcodes = { }; try { - const { result, ...httpResponse } = await couponsController.updateCouponSubcodes( + const response = await couponsController.updateCouponSubcodes( couponId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -1278,16 +1430,28 @@ const couponId = 162; const subcode = 'subcode4'; try { - const { result, ...httpResponse } = await couponsController.deleteCouponSubcode( + const response = await couponsController.deleteCouponSubcode( couponId, subcode ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` diff --git a/doc/controllers/custom-fields.md b/doc/controllers/custom-fields.md index 6bccc7b..c55e9d2 100644 --- a/doc/controllers/custom-fields.md +++ b/doc/controllers/custom-fields.md @@ -23,30 +23,20 @@ const customFieldsController = new CustomFieldsController(client); # Create Metafields -## Custom Fields: Metafield Intro +Creates metafields on a Site for either the Subscriptions or Customers resource. -**Advanced Billing refers to Custom Fields in the API documentation as metafields and metadata.** Within the Advanced Billing UI, metadata and metafields are grouped together under the umbrella of "Custom Fields." All of our UI-based documentation that references custom fields will not cite the terminology metafields or metadata. +Metafields and their metadata are created in the Custom Fields configuration page on your Site. Metafields can be populated with metadata when you create them or later with the [Update Metafield](../../doc/controllers/custom-fields.md#update-metafield), [Create Metadata](../../doc/controllers/custom-fields.md#create-metadata), or [Update Metadata](../../doc/controllers/custom-fields.md#update-metadata) endpoints. The Create Metadata and Update Metadata endpoints allow you to add metafields and metadata values to a specific subscription or customer. -+ **Metafield is the custom field** -+ **Metadata is the data populating the custom field.** +Each site is limited to 100 unique metafields per resource. This means you can have 100 metafields for Subscriptions and another 100 for Customers. -Advanced Billing Metafields are used to add meaningful attributes to subscription and customer resources. Full documentation on how to create Custom Fields in the Advanced Billing UI can be located [here](https://maxio.zendesk.com/hc/en-us/sections/24266118312589-Custom-Fields). For additional documentation on how to record data within custom fields, please see our subscription-based documentation [here](https://maxio.zendesk.com/hc/en-us/articles/24251701302925-Subscription-Summary-Custom-Fields-Tab). +> Note: After creating a metafield, the resource type cannot be modified. -Metafield are the place where you will set up your resource to accept additional data. It is scoped to the site instead of a specific customer or subscription. Think of it as the key, and Metadata as the value on every record. +In the UI and product documentation, metafields and metadata are called Custom Fields. -## Create Metafields +- Metafield is the custom field +- Metadata is the data populating the custom field. -Use this endpoint to create metafields for your Site. Metafields can be populated with metadata after the fact. - -Each site is limited to 100 unique Metafields (i.e. keys, or names) per resource. This means you can have 100 Metafields for Subscription and another 100 for Customer. - -### Metafields "On-the-Fly" - -It is possible to create Metafields “on the fly” when you create your Metadata – if a non-existent name is passed when creating Metadata, a Metafield for that key will be automatically created. The Metafield API, however, gives you more control over your “keys”. - -### Metafield Scope Warning - -If configuring metafields in the Admin UI or via the API, be careful sending updates to metafields with the scope attribute – **if a partial update is sent it will overwrite the current configuration**. +See [Custom Fields Reference](https://docs.maxio.com/hc/en-us/articles/24266140850573-Custom-Fields-Reference) and [Custom Fields Tab](https://maxio.zendesk.com/hc/en-us/articles/24251701302925-Subscription-Summary-Custom-Fields-Tab) for information on using Custom Fields in the Advanced Billing UI. ```ts async createMetafields( @@ -60,7 +50,7 @@ async createMetafields( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `resourceType` | [`ResourceType`](../../doc/models/resource-type.md) | Template, Required | the resource type to which the metafields belong | +| `resourceType` | [`ResourceType`](../../doc/models/resource-type.md) | Template, Required | The resource type to which the metafields belong. | | `body` | [`CreateMetafieldsRequest \| undefined`](../../doc/models/create-metafields-request.md) | Body, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | @@ -77,8 +67,10 @@ const body: CreateMetafieldsRequest = { metafields: { name: 'Dropdown field', scope: { - publicShow: IncludeOption.Include, - publicEdit: IncludeOption.Include, + csv: IncludeOption.Exclude, + invoices: IncludeOption.Exclude, + statements: IncludeOption.Exclude, + portal: IncludeOption.Include, }, inputType: MetafieldInput.Dropdown, mEnum: [ @@ -89,16 +81,28 @@ const body: CreateMetafieldsRequest = { }; try { - const { result, ...httpResponse } = await customFieldsController.createMetafields( + const response = await customFieldsController.createMetafields( resourceType, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -143,7 +147,7 @@ try { # List Metafields -This endpoint lists metafields associated with a site. The metafield description and usage is contained in the response. +Lists the metafields and their associated details for a Site and resource type. You can filter the request to a specific metafield. ```ts async listMetafields( @@ -168,8 +172,8 @@ async listMetafields( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `resourceType` | [`ResourceType`](../../doc/models/resource-type.md) | Template, Required | the resource type to which the metafields belong | -| `name` | `string \| undefined` | Query, Optional | filter by the name of the metafield | +| `resourceType` | [`ResourceType`](../../doc/models/resource-type.md) | Template, Required | The resource type to which the metafields belong. | +| `name` | `string \| undefined` | Query, Optional | Filter by the name of the metafield. | | `page` | `number \| undefined` | Query, Optional | Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
Use in query `page=1`.

**Default**: `1`

**Constraints**: `>= 1` | | `perPage` | `number \| undefined` | Query, Optional | This parameter indicates how many records to fetch in each request. Default value is 20. The maximum allowed values is 200; any per_page value over 200 will be changed to 200.
Use in query `per_page=200`.

**Default**: `20`

**Constraints**: `<= 200` | | `direction` | [`SortingDirection \| undefined`](../../doc/models/sorting-direction.md) | Query, Optional | Controls the order in which results are returned.
Use in query `direction=asc`. | @@ -184,18 +188,30 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The ```ts const collect = { resourceType: ResourceType.Subscriptions, - page: 2, + page: 1, perPage: 50 } try { - const { result, ...httpResponse } = await customFieldsController.listMetafields(collect); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await customFieldsController.listMetafields(collect); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -204,10 +220,10 @@ try { ```json { - "total_count": 0, - "current_page": 0, + "total_count": 1, + "current_page": 1, "total_pages": 0, - "per_page": 0, + "per_page": 50, "metafields": [ { "id": 0, @@ -231,7 +247,33 @@ try { # Update Metafield -Use the following method to update metafields for your Site. Metafields can be populated with metadata after the fact. +Updates metafields on your Site for a resource type. Depending on the request structure, you can update or add metafields and metadata to the Subscriptions or Customers resource. + +With this endpoint, you can: + +- Add metafields. If the metafield specified in current_name does not exist, a new metafield is added. + + > Note: Each site is limited to 100 unique metafields per resource. This means you can have 100 metafields for Subscriptions and another 100 for Customers. + +- Change the name of a metafield. + + > Note: To keep the metafield name the same and only update the metadata for the metafield, you must use the current metafield name in both the `current_name` and `name` parameters. + +- Change the input type for the metafield. For example, you can change a metafield input type from text to a dropdown. If you change the input type from text to a dropdown or radio, you must update the specific subscriptions or customers where the metafield was used to reflect the updated metafield and metadata. + +- Add metadata values to the existing metadata for a dropdown or radio metafield. + + > Note: Updates to metadata overwrite. To add one or more values, you must specify all metadata values including the new value you want to add. + +- Add new metadata to a dropdown or radio for a metafield that was created without metadata. + +- Remove metadata for a dropdown or radio for a metafield. + + > Note: Updates to metadata overwrite existing values. To remove one or more values, specify all metadata values except those you want to remove. + +- Add or update scope settings for a metafield. + + > Note: Scope changes overwrite existing settings. You must specify the complete scope, including the changes you want to make. ```ts async updateMetafield( @@ -245,7 +287,7 @@ async updateMetafield( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `resourceType` | [`ResourceType`](../../doc/models/resource-type.md) | Template, Required | the resource type to which the metafields belong | +| `resourceType` | [`ResourceType`](../../doc/models/resource-type.md) | Template, Required | The resource type to which the metafields belong. | | `body` | [`UpdateMetafieldsRequest \| undefined`](../../doc/models/update-metafields-request.md) | Body, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | @@ -259,13 +301,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const resourceType = ResourceType.Subscriptions; try { - const { result, ...httpResponse } = await customFieldsController.updateMetafield(resourceType); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await customFieldsController.updateMetafield(resourceType); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -279,9 +333,7 @@ try { # Delete Metafield -Use the following method to delete a metafield. This will remove the metafield from the Site. - -Additionally, this will remove the metafield and associated metadata with all Subscriptions on the Site. +Deletes a metafield from your Site. Removes the metafield and associated metadata from all Subscriptions or Customers resources on the Site. ```ts async deleteMetafield( @@ -295,7 +347,7 @@ async deleteMetafield( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `resourceType` | [`ResourceType`](../../doc/models/resource-type.md) | Template, Required | the resource type to which the metafields belong | +| `resourceType` | [`ResourceType`](../../doc/models/resource-type.md) | Template, Required | The resource type to which the metafields belong. | | `name` | `string \| undefined` | Query, Optional | The name of the metafield to be deleted | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | @@ -309,13 +361,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. const resourceType = ResourceType.Subscriptions; try { - const { result, ...httpResponse } = await customFieldsController.deleteMetafield(resourceType); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await customFieldsController.deleteMetafield(resourceType); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -329,28 +393,11 @@ try { # Create Metadata -## Custom Fields: Metadata Intro - -**Advanced Billing refers to Custom Fields in the API documentation as metafields and metadata.** Within the Advanced Billing UI, metadata and metafields are grouped together under the umbrella of "Custom Fields." All of our UI-based documentation that references custom fields will not cite the terminology metafields or metadata. - -+ **Metafield is the custom field** -+ **Metadata is the data populating the custom field.** - -Advanced Billing Metafields are used to add meaningful attributes to subscription and customer resources. Full documentation on how to create Custom Fields in the Advanced Billing UI can be located [here](https://maxio.zendesk.com/hc/en-us/articles/24266164865677-Custom-Fields-Overview). For additional documentation on how to record data within custom fields, please see our subscription-based documentation [here.](https://maxio.zendesk.com/hc/en-us/articles/24251701302925-Subscription-Summary-Custom-Fields-Tab) - -Metadata is associated to a customer or subscription, and corresponds to a Metafield. When creating a new metadata object for a given record, **if the metafield is not present it will be created**. - -## Metadata limits - -Metadata values are limited to 2kB in size. Additonally, there are limits on the number of unique metafields available per resource. +Creates metadata and metafields for a specific subscription or customer, or updates metadata values of existing metafields for a subscription or customer. Metadata values are limited to 2 KB in size. -## Create Metadata +If you create metadata on a subscription or customer with a metafield that does not already exist, the metafield is created with the metadata you specify and it is always added as a text field. You can update the input_type for the metafield with the [Update Metafield](../../doc/controllers/custom-fields.md#update-metafield) endpoint. -This method will create a metafield for the site on the fly if it does not already exist, and populate the metadata value. - -### Subscription or Customer Resource - -Please pay special attention to the resource you use when creating metadata. +> Note: Each site is limited to 100 unique metafields per resource. This means you can have 100 metafields for Subscriptions and another 100 for Customers. ```ts async createMetadata( @@ -365,7 +412,7 @@ async createMetadata( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `resourceType` | [`ResourceType`](../../doc/models/resource-type.md) | Template, Required | the resource type to which the metafields belong | +| `resourceType` | [`ResourceType`](../../doc/models/resource-type.md) | Template, Required | The resource type to which the metafields belong. | | `resourceId` | `number` | Template, Required | The Advanced Billing id of the customer or the subscription for which the metadata applies | | `body` | [`CreateMetadataRequest \| undefined`](../../doc/models/create-metadata-request.md) | Body, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | @@ -395,17 +442,29 @@ const body: CreateMetadataRequest = { }; try { - const { result, ...httpResponse } = await customFieldsController.createMetadata( + const response = await customFieldsController.createMetadata( resourceType, resourceId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -419,11 +478,7 @@ try { # List Metadata -This request will list all of the metadata belonging to a particular resource (ie. subscription, customer) that is specified. - -## Metadata Data - -This endpoint will also display the current stats of your metadata to use as a tool for pagination. +Lists metadata and metafields for a specific customer or subscription. ```ts async listMetadata( @@ -446,7 +501,7 @@ async listMetadata( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `resourceType` | [`ResourceType`](../../doc/models/resource-type.md) | Template, Required | the resource type to which the metafields belong | +| `resourceType` | [`ResourceType`](../../doc/models/resource-type.md) | Template, Required | The resource type to which the metafields belong. | | `resourceId` | `number` | Template, Required | The Advanced Billing id of the customer or the subscription for which the metadata applies | | `page` | `number \| undefined` | Query, Optional | Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
Use in query `page=1`.

**Default**: `1`

**Constraints**: `>= 1` | | `perPage` | `number \| undefined` | Query, Optional | This parameter indicates how many records to fetch in each request. Default value is 20. The maximum allowed values is 200; any per_page value over 200 will be changed to 200.
Use in query `per_page=200`.

**Default**: `20`

**Constraints**: `<= 200` | @@ -462,26 +517,63 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const collect = { resourceType: ResourceType.Subscriptions, resourceId: 60, - page: 2, + page: 1, perPage: 50 } try { - const { result, ...httpResponse } = await customFieldsController.listMetadata(collect); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await customFieldsController.listMetadata(collect); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` +## Example Response *(as JSON)* + +```json +{ + "total_count": 1, + "current_page": 1, + "total_pages": 1, + "per_page": 50, + "metadata": [ + { + "id": 77889911, + "value": "green", + "resource_id": 1234567, + "metafield_id": 112233, + "deleted_at": null, + "name": "Color" + } + ] +} +``` + # Update Metadata -This method allows you to update the existing metadata associated with a subscription or customer. +Updates metadata and metafields on the Site and the customer or subscription specified, and updates the metadata value on a subscription or customer. + +If you update metadata on a subscription or customer with a metafield that does not already exist, the metafield is created with the metadata you specify and it is always added as a text field to the Site and to the subscription or customer you specify. You can update the input_type for the metafield with the Update Metafield endpoint. + +Each site is limited to 100 unique metafields per resource. This means you can have 100 metafields for Subscription and another 100 for Customer. ```ts async updateMetadata( @@ -496,7 +588,7 @@ async updateMetadata( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `resourceType` | [`ResourceType`](../../doc/models/resource-type.md) | Template, Required | the resource type to which the metafields belong | +| `resourceType` | [`ResourceType`](../../doc/models/resource-type.md) | Template, Required | The resource type to which the metafields belong. | | `resourceId` | `number` | Template, Required | The Advanced Billing id of the customer or the subscription for which the metadata applies | | `body` | [`UpdateMetadataRequest \| undefined`](../../doc/models/update-metadata-request.md) | Body, Optional | - | | `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. | @@ -513,16 +605,28 @@ const resourceType = ResourceType.Subscriptions; const resourceId = 60; try { - const { result, ...httpResponse } = await customFieldsController.updateMetadata( + const response = await customFieldsController.updateMetadata( resourceType, resourceId ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -536,29 +640,7 @@ try { # Delete Metadata -This method removes the metadata from the subscriber/customer cited. - -## Query String Usage - -For instance if you wanted to delete the metadata for customer 99 named weight you would request: - -``` -https://acme.chargify.com/customers/99/metadata.json?name=weight -``` - -If you want to delete multiple metadata fields for a customer 99 named: `weight` and `age` you wrould request: - -``` -https://acme.chargify.com/customers/99/metadata.json?names[]=weight&names[]=age -``` - -## Successful Response - -For a success, there will be a code `200` and the plain text response `true`. - -## Unsuccessful Response - -When a failed response is encountered, you will receive a `404` response and the plain text response of `true`. +Deletes one or more metafields (and associated metadata) from the specified subscription or customer. ```ts async deleteMetadata( @@ -574,7 +656,7 @@ async deleteMetadata( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `resourceType` | [`ResourceType`](../../doc/models/resource-type.md) | Template, Required | the resource type to which the metafields belong | +| `resourceType` | [`ResourceType`](../../doc/models/resource-type.md) | Template, Required | The resource type to which the metafields belong. | | `resourceId` | `number` | Template, Required | The Advanced Billing id of the customer or the subscription for which the metadata applies | | `name` | `string \| undefined` | Query, Optional | Name of field to be removed. | | `names` | `string[] \| undefined` | Query, Optional | Names of fields to be removed. Use in query: `names[]=field1&names[]=my-field&names[]=another-field`. | @@ -592,16 +674,28 @@ const resourceType = ResourceType.Subscriptions; const resourceId = 60; try { - const { result, ...httpResponse } = await customFieldsController.deleteMetadata( + const response = await customFieldsController.deleteMetadata( resourceType, resourceId ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -615,19 +709,7 @@ try { # List Metadata for Resource Type -This method will provide you information on usage of metadata across your selected resource (ie. subscriptions, customers) - -## Metadata Data - -This endpoint will also display the current stats of your metadata to use as a tool for pagination. - -### Metadata for multiple records - -`https://acme.chargify.com/subscriptions/metadata.json?resource_ids[]=1&resource_ids[]=2` - -## Read Metadata for a Site - -This endpoint will list the number of pages of metadata information that are contained within a site. +Lists metadata for a specified array of subscriptions or customers. ```ts async listMetadataForResourceType( @@ -664,7 +746,7 @@ async listMetadataForResourceType( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `resourceType` | [`ResourceType`](../../doc/models/resource-type.md) | Template, Required | the resource type to which the metafields belong | +| `resourceType` | [`ResourceType`](../../doc/models/resource-type.md) | Template, Required | The resource type to which the metafields belong. | | `page` | `number \| undefined` | Query, Optional | Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
Use in query `page=1`.

**Default**: `1`

**Constraints**: `>= 1` | | `perPage` | `number \| undefined` | Query, Optional | This parameter indicates how many records to fetch in each request. Default value is 20. The maximum allowed values is 200; any per_page value over 200 will be changed to 200.
Use in query `per_page=200`.

**Default**: `20`

**Constraints**: `<= 200` | | `dateField` | [`BasicDateField \| undefined`](../../doc/models/basic-date-field.md) | Query, Optional | The type of filter you would like to apply to your search. | @@ -686,19 +768,31 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The ```ts const collect = { resourceType: ResourceType.Subscriptions, - page: 2, + page: 1, perPage: 50, dateField: BasicDateField.UpdatedAt } try { - const { result, ...httpResponse } = await customFieldsController.listMetadataForResourceType(collect); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await customFieldsController.listMetadataForResourceType(collect); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` diff --git a/doc/controllers/customers.md b/doc/controllers/customers.md index ef53c3b..fe1745a 100644 --- a/doc/controllers/customers.md +++ b/doc/controllers/customers.md @@ -31,7 +31,7 @@ Full documentation on how to locate, create and edit Customers in the Advanced B Advanced Billing requires that you use the ISO Standard Country codes when formatting country attribute of the customer. -Countries should be formatted as 2 characters. For more information, please see the following wikipedia article on [ISO_3166-1.](http://en.wikipedia.org/wiki/ISO_3166-1#Current_codes) +Countries should be formatted as 2 characters. For more information, see the following wikipedia article on [ISO_3166-1.](http://en.wikipedia.org/wiki/ISO_3166-1#Current_codes) ## Required State Format @@ -39,7 +39,7 @@ Advanced Billing requires that you use the ISO Standard State codes when formatt + US States (2 characters): [ISO_3166-2](https://en.wikipedia.org/wiki/ISO_3166-2:US) -+ States Outside the US (2-3 characters): To find the correct state codes outside of the US, please go to [ISO_3166-1](http://en.wikipedia.org/wiki/ISO_3166-1#Current_codes) and click on the link in the “ISO 3166-2 codes” column next to country you wish to populate. ++ States Outside the US (2-3 characters): To find the correct state codes outside of the US, go to [ISO_3166-1](http://en.wikipedia.org/wiki/ISO_3166-1#Current_codes) and click on the link in the “ISO 3166-2 codes” column next to country you wish to populate. ## Locale @@ -87,13 +87,25 @@ const body: CreateCustomerRequest = { }; try { - const { result, ...httpResponse } = await customersController.createCustomer(body); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await customersController.createCustomer(body); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -156,7 +168,7 @@ Common use cases are: + Search by a reference value from your application + Search by a first or last name -To retrieve a single, exact match by reference, please use the [lookup endpoint](https://developers.chargify.com/docs/api-docs/b710d8fbef104-read-customer-by-reference). +To retrieve a single, exact match by reference, use the [lookup endpoint](https://developers.chargify.com/docs/api-docs/b710d8fbef104-read-customer-by-reference). ```ts async listCustomers( @@ -208,19 +220,31 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The ```ts const collect = { - page: 2, + page: 1, perPage: 30, dateField: BasicDateField.UpdatedAt } try { - const { result, ...httpResponse } = await customersController.listCustomers(collect); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await customersController.listCustomers(collect); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -338,13 +362,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const id = 112; try { - const { result, ...httpResponse } = await customersController.readCustomer(id); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await customersController.readCustomer(id); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -425,16 +461,28 @@ const body: UpdateCustomerRequest = { }; try { - const { result, ...httpResponse } = await customersController.updateCustomer( + const response = await customersController.updateCustomer( id, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -506,13 +554,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. const id = 112; try { - const { result, ...httpResponse } = await customersController.deleteCustomer(id); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await customersController.deleteCustomer(id); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -546,13 +606,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const reference = 'reference4'; try { - const { result, ...httpResponse } = await customersController.readCustomerByReference(reference); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await customersController.readCustomerByReference(reference); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -586,13 +658,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const customerId = 150; try { - const { result, ...httpResponse } = await customersController.listCustomerSubscriptions(customerId); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await customersController.listCustomerSubscriptions(customerId); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` diff --git a/doc/controllers/events-based-billing-segments.md b/doc/controllers/events-based-billing-segments.md index cb3cd87..f97a3ec 100644 --- a/doc/controllers/events-based-billing-segments.md +++ b/doc/controllers/events-based-billing-segments.md @@ -73,17 +73,29 @@ const body: CreateSegmentRequest = { }; try { - const { result, ...httpResponse } = await eventsBasedBillingSegmentsController.createSegment( + const response = await eventsBasedBillingSegmentsController.createSegment( componentId, pricePointId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -144,7 +156,7 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const collect = { componentId: 'component_id8', pricePointId: 'price_point_id8', - page: 2, + page: 1, perPage: 50, filter: { segmentProperty1Value: 'EU', @@ -152,13 +164,25 @@ const collect = { } try { - const { result, ...httpResponse } = await eventsBasedBillingSegmentsController.listSegmentsForPricePoint(collect); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await eventsBasedBillingSegmentsController.listSegmentsForPricePoint(collect); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -211,17 +235,29 @@ const pricePointId = 'price_point_id8'; const id = 60; try { - const { result, ...httpResponse } = await eventsBasedBillingSegmentsController.updateSegment( + const response = await eventsBasedBillingSegmentsController.updateSegment( componentId, pricePointId, id ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -272,17 +308,29 @@ const pricePointId = 'price_point_id8'; const id = 60; try { - const { result, ...httpResponse } = await eventsBasedBillingSegmentsController.deleteSegment( + const response = await eventsBasedBillingSegmentsController.deleteSegment( componentId, pricePointId, id ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -333,16 +381,28 @@ const componentId = 'component_id8'; const pricePointId = 'price_point_id8'; try { - const { result, ...httpResponse } = await eventsBasedBillingSegmentsController.bulkCreateSegments( + const response = await eventsBasedBillingSegmentsController.bulkCreateSegments( componentId, pricePointId ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -393,16 +453,28 @@ const componentId = 'component_id8'; const pricePointId = 'price_point_id8'; try { - const { result, ...httpResponse } = await eventsBasedBillingSegmentsController.bulkUpdateSegments( + const response = await eventsBasedBillingSegmentsController.bulkUpdateSegments( componentId, pricePointId ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` diff --git a/doc/controllers/events.md b/doc/controllers/events.md index d0a2b11..997c11f 100644 --- a/doc/controllers/events.md +++ b/doc/controllers/events.md @@ -142,7 +142,7 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The ```ts const collect = { - page: 2, + page: 1, perPage: 50, direction: Direction.Desc, filter: [ @@ -153,13 +153,25 @@ const collect = { } try { - const { result, ...httpResponse } = await eventsController.listEvents(collect); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await eventsController.listEvents(collect); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -286,7 +298,7 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The ```ts const collect = { subscriptionId: 222, - page: 2, + page: 1, perPage: 50, direction: Direction.Desc, filter: [ @@ -296,13 +308,25 @@ const collect = { } try { - const { result, ...httpResponse } = await eventsController.listSubscriptionEvents(collect); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await eventsController.listSubscriptionEvents(collect); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -396,7 +420,7 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The ```ts const collect = { - page: 2, + page: 1, perPage: 50, direction: Direction.Desc, filter: [ @@ -406,13 +430,25 @@ const collect = { } try { - const { result, ...httpResponse } = await eventsController.readEventsCount(collect); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await eventsController.readEventsCount(collect); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` diff --git a/doc/controllers/insights.md b/doc/controllers/insights.md index c514eb1..9bfdc37 100644 --- a/doc/controllers/insights.md +++ b/doc/controllers/insights.md @@ -48,13 +48,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The ```ts try { - const { result, ...httpResponse } = await insightsController.readSiteStats(); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await insightsController.readSiteStats(); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -109,13 +121,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The ```ts try { - const { result, ...httpResponse } = await insightsController.readMrr(); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await insightsController.readMrr(); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -205,18 +229,30 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The ```ts const collect = { - page: 2, + page: 1, perPage: 20 } try { - const { result, ...httpResponse } = await insightsController.listMrrMovements(collect); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await insightsController.listMrrMovements(collect); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -326,19 +362,31 @@ const collect = { ], }, atTime: 'at_time=2022-01-10T10:00:00-05:00', - page: 2, + page: 1, perPage: 50, direction: Direction.Desc } try { - const { result, ...httpResponse } = await insightsController.listMrrPerSubscription(collect); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await insightsController.listMrrPerSubscription(collect); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` diff --git a/doc/controllers/invoices.md b/doc/controllers/invoices.md index 41c6966..42ddf5e 100644 --- a/doc/controllers/invoices.md +++ b/doc/controllers/invoices.md @@ -76,16 +76,28 @@ const body: RefundInvoiceRequest = { }; try { - const { result, ...httpResponse } = await invoicesController.refundInvoice( + const response = await invoicesController.refundInvoice( uid, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -193,7 +205,7 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The ```ts const collect = { - page: 2, + page: 1, perPage: 50, direction: Direction.Desc, lineItems: false, @@ -221,13 +233,25 @@ const collect = { } try { - const { result, ...httpResponse } = await invoicesController.listInvoices(collect); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await invoicesController.listInvoices(collect); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -276,7 +300,7 @@ try { "organization": "", "email": "meg@example.com" }, - "memo": "Please pay within 15 days.", + "memo": "Payment due within 15 days of receipt.", "billing_address": { "street": "123 I Love Cats Way", "line2": "", @@ -342,7 +366,7 @@ try { "organization": "", "email": "food@example.com" }, - "memo": "Please pay within 15 days.", + "memo": "Payment due within 15 days of receipt.", "billing_address": { "street": "", "line2": "", @@ -408,7 +432,7 @@ try { "organization": "123", "email": "example@example.com" }, - "memo": "Please pay within 15 days.", + "memo": "Payment due within 15 days of receipt.", "billing_address": { "street": "123 Anywhere Street", "line2": "", @@ -474,7 +498,7 @@ try { "organization": "", "email": "example@example.com" }, - "memo": "Please pay within 15 days.", + "memo": "Payment due within 15 days of receipt.", "billing_address": { "street": "123 I Love Cats Way", "line2": "", @@ -547,13 +571,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const uid = 'uid0'; try { - const { result, ...httpResponse } = await invoicesController.readInvoice(uid); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await invoicesController.readInvoice(uid); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -600,7 +636,7 @@ try { "organization": null, "email": "joe@example.com" }, - "memo": "Please pay within 15 days.", + "memo": "Payment due within 15 days of receipt.", "billing_address": { "street": null, "line2": null, @@ -739,18 +775,30 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The ```ts const collect = { - page: 2, + page: 1, perPage: 100 } try { - const { result, ...httpResponse } = await invoicesController.listInvoiceEvents(collect); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await invoicesController.listInvoiceEvents(collect); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -1178,16 +1226,28 @@ const body: CreateInvoicePaymentRequest = { }; try { - const { result, ...httpResponse } = await invoicesController.recordPaymentForInvoice( + const response = await invoicesController.recordPaymentForInvoice( uid, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -1269,13 +1329,25 @@ const body: CreateMultiInvoicePaymentRequest = { }; try { - const { result, ...httpResponse } = await invoicesController.recordPaymentForMultipleInvoices(body); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await invoicesController.recordPaymentForMultipleInvoices(body); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -1364,7 +1436,7 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The ```ts const collect = { - page: 2, + page: 1, perPage: 50, lineItems: false, discounts: false, @@ -1374,13 +1446,25 @@ const collect = { } try { - const { result, ...httpResponse } = await invoicesController.listCreditNotes(collect); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await invoicesController.listCreditNotes(collect); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -1715,13 +1799,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const uid = 'uid0'; try { - const { result, ...httpResponse } = await invoicesController.readCreditNote(uid); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await invoicesController.readCreditNote(uid); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -2081,16 +2177,28 @@ const body: RecordPaymentRequest = { }; try { - const { result, ...httpResponse } = await invoicesController.recordPaymentForSubscription( + const response = await invoicesController.recordPaymentForSubscription( subscriptionId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -2163,13 +2271,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const uid = 'uid0'; try { - const { result, ...httpResponse } = await invoicesController.reopenInvoice(uid); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await invoicesController.reopenInvoice(uid); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -2218,16 +2338,28 @@ const body: VoidInvoiceRequest = { }; try { - const { result, ...httpResponse } = await invoicesController.voidInvoice( + const response = await invoicesController.voidInvoice( uid, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -2280,19 +2412,31 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The ```ts const collect = { invoiceUid: 'invoice_uid0', - page: 2, + page: 1, perPage: 50, direction: Direction.Asc } try { - const { result, ...httpResponse } = await invoicesController.listConsolidatedInvoiceSegments(collect); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await invoicesController.listConsolidatedInvoiceSegments(collect); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -2341,7 +2485,7 @@ try { "organization": "", "email": "meg@example.com" }, - "memo": "Please pay within 15 days.", + "memo": "Payment due within 15 days of receipt.", "billing_address": { "street": "123 I Love Cats Way", "line2": "", @@ -2407,7 +2551,7 @@ try { "organization": "", "email": "food@example.com" }, - "memo": "Please pay within 15 days.", + "memo": "Payment due within 15 days of receipt.", "billing_address": { "street": "", "line2": "", @@ -2473,7 +2617,7 @@ try { "organization": "123", "email": "example@example.com" }, - "memo": "Please pay within 15 days.", + "memo": "Payment due within 15 days of receipt.", "billing_address": { "street": "123 Anywhere Street", "line2": "", @@ -2539,7 +2683,7 @@ try { "organization": "", "email": "example@example.com" }, - "memo": "Please pay within 15 days.", + "memo": "Payment due within 15 days of receipt.", "billing_address": { "street": "123 I Love Cats Way", "line2": "", @@ -2664,6 +2808,42 @@ If You want to use existing coupon for discount creation, only `code` and option ... ``` +#### Using Coupon Subcodes + +You can also use coupon subcodes to apply existing coupons with specific subcodes: + +```json +... + "coupons": [ + { + "subcode": "SUB1", + "product_family_id": 1 + } + ] +... +``` + +**Important:** You cannot specify both `code` and `subcode` for the same coupon. Use either: + +- `code` to apply a main coupon +- `subcode` to apply a specific coupon subcode + +The API response will include both the main coupon code and the subcode used: + +```json +... + "coupons": [ + { + "code": "MAIN123", + "subcode": "SUB1", + "product_family_id": 1, + "percentage": 10, + "description": "Special discount" + } + ] +... +``` + ### Coupon options #### Code @@ -2672,6 +2852,10 @@ Coupon `code` will be displayed on invoice discount section. Coupon code can only contain uppercase letters, numbers, and allowed special characters. Lowercase letters will be converted to uppercase. It can be used to select an existing coupon from the catalog, or as an ad hoc coupon when passed with `percentage` or `amount`. +#### Subcode + +Coupon `subcode` allows you to apply existing coupons using their subcodes. When a subcode is used, the API response will include both the main coupon code and the specific subcode that was applied. Subcodes are case-insensitive and will be converted to uppercase automatically. + #### Percentage Coupon `percentage` can take values from 0 to 100 and up to 4 decimal places. It cannot be used with `amount`. Only for ad hoc coupons, will be ignored if `code` is used to select an existing coupon from the catalog. @@ -2731,7 +2915,7 @@ By default, invoices will be created with a due date matching the date of invoic #### Addresses -The seller, shipping and billing addresses can be sent to override the site's defaults. Each address requires to send a `first_name` at a minimum in order to work. Please see below for the details on which parameters can be sent for each address object. +The seller, shipping and billing addresses can be sent to override the site's defaults. Each address requires to send a `first_name` at a minimum in order to work. See below for the details on which parameters can be sent for each address object. #### Memo and Payment Instructions @@ -2779,16 +2963,28 @@ const body: CreateInvoiceRequest = { }; try { - const { result, ...httpResponse } = await invoicesController.createInvoice( + const response = await invoicesController.createInvoice( subscriptionId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -2901,9 +3097,9 @@ try { This endpoint allows for invoices to be programmatically delivered via email. This endpoint supports the delivery of both ad-hoc and automatically generated invoices. Additionally, this endpoint supports email delivery to direct recipients, carbon-copy (cc) recipients, and blind carbon-copy (bcc) recipients. -Please note that if no recipient email addresses are specified in the request, then the subscription's default email configuration will be used. For example, if `recipient_emails` is left blank, then the invoice will be delivered to the subscription's customer email address. +If no recipient email addresses are specified in the request, then the subscription's default email configuration will be used. For example, if `recipient_emails` is left blank, then the invoice will be delivered to the subscription's customer email address. -On success, a 204 no-content response will be returned. Please note that this does not indicate that email(s) have been delivered, but instead indicates that emails have been successfully queued for delivery. If _any_ invalid or malformed email address is found in the request body, the entire request will be rejected and a 422 response will be returned. +On success, a 204 no-content response will be returned. The response does not indicate that email(s) have been delivered, but instead indicates that emails have been successfully queued for delivery. If _any_ invalid or malformed email address is found in the request body, the entire request will be rejected and a 422 response will be returned. ```ts async sendInvoice( @@ -2943,16 +3139,28 @@ const body: SendInvoiceRequest = { }; try { - const { result, ...httpResponse } = await invoicesController.sendInvoice( + const response = await invoicesController.sendInvoice( uid, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -2994,13 +3202,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const uid = 'uid0'; try { - const { result, ...httpResponse } = await invoicesController.previewCustomerInformationChanges(uid); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await invoicesController.previewCustomerInformationChanges(uid); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -3096,13 +3316,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const uid = 'uid0'; try { - const { result, ...httpResponse } = await invoicesController.updateCustomerInformation(uid); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await invoicesController.updateCustomerInformation(uid); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -3347,16 +3579,28 @@ const body: IssueInvoiceRequest = { }; try { - const { result, ...httpResponse } = await invoicesController.issueInvoice( + const response = await invoicesController.issueInvoice( uid, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` diff --git a/doc/controllers/offers.md b/doc/controllers/offers.md index d8f39f8..c2d5d02 100644 --- a/doc/controllers/offers.md +++ b/doc/controllers/offers.md @@ -74,13 +74,25 @@ const body: CreateOfferRequest = { }; try { - const { result, ...httpResponse } = await offersController.createOffer(body); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await offersController.createOffer(body); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -170,19 +182,31 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The ```ts const collect = { - page: 2, + page: 1, perPage: 50, includeArchived: true } try { - const { result, ...httpResponse } = await offersController.listOffers(collect); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await offersController.listOffers(collect); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -277,13 +301,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const offerId = 130; try { - const { result, ...httpResponse } = await offersController.readOffer(offerId); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await offersController.readOffer(offerId); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -317,13 +353,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. const offerId = 130; try { - const { result, ...httpResponse } = await offersController.archiveOffer(offerId); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await offersController.archiveOffer(offerId); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -357,13 +405,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. const offerId = 130; try { - const { result, ...httpResponse } = await offersController.unarchiveOffer(offerId); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await offersController.unarchiveOffer(offerId); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` diff --git a/doc/controllers/payment-profiles.md b/doc/controllers/payment-profiles.md index a0fdeee..55676a8 100644 --- a/doc/controllers/payment-profiles.md +++ b/doc/controllers/payment-profiles.md @@ -26,236 +26,37 @@ const paymentProfilesController = new PaymentProfilesController(client); # Create Payment Profile -Use this endpoint to create a payment profile for a customer. +Creates a payment profile for a customer. -Payment Profiles house the credit card, ACH (Authorize.Net or Stripe only,) or PayPal (Braintree only,) data for a customer. The payment information is attached to the customer within Advanced Billing, as opposed to the Subscription itself. +When you create a new payment profile for a customer via the API, it does not automatically make the profile current for any of the customer’s subscriptions. To use the payment profile as the default, you must set it explicitly for the subscription or subscription group. -You must include a customer_id so that Advanced Billing will attach it to the customer entry. If no customer_id is included the API will return a 404. +Select an option from the **Request Examples** drop-down on the right side of the portal to see examples of common scenarios for creating payment profiles. -## Create a Payment Profile for ACH usage +Do not use real card information for testing. See the Sites articles that cover [testing your site setup](https://docs.maxio.com/hc/en-us/articles/24250712113165-Testing-Overview#testing-overview-0-0) for more details on testing in your sandbox. -If you would like to create a payment method that is a Bank Account applicable for ACH payments use the following: +Note that collecting and sending raw card details in production requires [PCI compliance](https://docs.maxio.com/hc/en-us/articles/24183956938381-PCI-Compliance#pci-compliance-0-0) on your end. If your business is not PCI compliant, use [Chargify.js](https://docs.maxio.com/hc/en-us/articles/38163190843789-Chargify-js-Overview#chargify-js-overview-0-0) to collect credit card or bank account information. -```json -{ -"payment_profile": { - "customer_id": [Valid-Customer-ID], - "bank_name": "Best Bank", - "bank_routing_number": "021000089", - "bank_account_number": "111111111111", - "bank_account_type": "checking", - "bank_account_holder_type": "business", - "payment_type": "bank_account" - } -} -``` - -## Taxable Subscriptions - -If your subscriber pays taxes on their purchased product, and you are attempting to create or update the `payment_profile`, complete address information is required. For information on required address formatting to allow your subscriber to be taxed, please see our documentation [here](https://developers.chargify.com/docs/developer-docs/d2e9e34db740e-signups#taxes) - -## Payment Profile Documentation - -Full documentation on how Payment Profiles operate within Advanced Billing can be located under the following links: +See the following articles to learn more about subscriptions and payments: + [Subscriber Payment Details](https://maxio.zendesk.com/hc/en-us/articles/24251599929613-Subscription-Summary-Payment-Details-Tab) + [Self Service Pages](https://maxio.zendesk.com/hc/en-us/articles/24261425318541-Self-Service-Pages) (Allows credit card updates by Subscriber) + [Public Signup Pages payment settings](https://maxio.zendesk.com/hc/en-us/articles/24261368332557-Individual-Page-Settings) - -## Create a Payment Profile with a Chargify.js token - -```json -{ - "payment_profile": { - "customer_id": 1036, - "chargify_token": "tok_w68qcpnftyv53jk33jv6wk3w" - } -} -``` - -## Active Payment Methods - -Creating a new payment profile for a Customer via the API will not make that Payment Profile current for any of the Customer’s Subscriptions. In order to utilize the payment profile as the default, it must be set as the default payment profile for the subscription or subscription group. - -## Requirements - -Either the full_number, expiration_month, and expiration_year or if you have an existing vault_token from your gateway, that vault_token and the current_vault are required. -Passing in the vault_token and current_vault are only allowed when creating a new payment profile. - -### Taxable Subscriptions - -If your subscriber pays taxes on their purchased product, and you are attempting to create or update the `payment_profile`, complete address information is required. For information on required address formatting to allow your subscriber to be taxed, please see our documentation [here](https://developers.chargify.com/docs/developer-docs/d2e9e34db740e-signups#taxes) - -## BraintreeBlue - -Some merchants use Braintree JavaScript libraries directly and then pass `payment_method_nonce` and/or `paypal_email` to create a payment profile. This implementation is deprecated and does not handle 3D Secure. Instead, we have provided [Chargify.js](https://developers.chargify.com/docs/developer-docs/ZG9jOjE0NjAzNDI0-overview) which is continuously improved and supports Credit Cards (along with 3D Secure), PayPal and ApplePay payment types. - -## GoCardless - -For more information on GoCardless, please view the following resources: - ++ [Taxes](https://developers.chargify.com/docs/developer-docs/d2e9e34db740e-signups#taxes) ++ [Chargify.js](https://docs.maxio.com/hc/en-us/articles/38163190843789-Chargify-js-Overview) + + [Chargify.js with GoCardless - minimal example](https://docs.maxio.com/hc/en-us/articles/38206331271693-Examples#h_01K0PJ15QQZKCER8CFK40MR6XJ) + + [Chargify.js with GoCardless - full example](https://docs.maxio.com/hc/en-us/articles/38206331271693-Examples#h_01K0PJ15QR09JVHWW0MCA7HVJV) + + [Chargify.js with Stripe Direct Debit - minimal example](https://docs.maxio.com/hc/en-us/articles/38206331271693-Examples#h_01K0PJ15QQFKKN8Z7B7DZ9AJS5) + + [Chargify.js with Stripe Direct Debit - full example](https://docs.maxio.com/hc/en-us/articles/38206331271693-Examples#h_01K0PJ15QRECQQ4ECS3ZA55GY7) + + [Chargify.js with Stripe BECS Direct Debit - minimal example](https://developers.chargify.com/docs/developer-docs/ZG9jOjE0NjAzNDIy-examples#minimal-example-with-sepa-or-becs-direct-debit-stripe-gateway) + + [Chargify.js with Stripe BECS Direct Debit - full example](https://developers.chargify.com/docs/developer-docs/ZG9jOjE0NjAzNDIy-examples#full-example-with-sepa-direct-debit-stripe-gateway) + [Full documentation on GoCardless](https://maxio.zendesk.com/hc/en-us/articles/24176159136909-GoCardless) - -+ [Using Chargify.js with GoCardless - minimal example](https://docs.maxio.com/hc/en-us/articles/38206331271693-Examples#h_01K0PJ15QQZKCER8CFK40MR6XJ) - -+ [Using Chargify.js with GoCardless - full example](https://docs.maxio.com/hc/en-us/articles/38206331271693-Examples#h_01K0PJ15QR09JVHWW0MCA7HVJV) - -### GoCardless with Local Bank Details - -Following examples create customer, bank account and mandate in GoCardless: - -```json -{ - "payment_profile": { - "customer_id": "Valid-Customer-ID", - "bank_name": "Royal Bank of France", - "bank_account_number": "0000000", - "bank_routing_number": "0003", - "bank_branch_code": "00006", - "payment_type": "bank_account", - "billing_address": "20 Place de la Gare", - "billing_city": "Colombes", - "billing_state": "Île-de-France", - "billing_zip": "92700", - "billing_country": "FR" - } -} -``` - -### GoCardless with IBAN - -```json -{ - "payment_profile": { - "customer_id": "24907598", - "bank_name": "French Bank", - "bank_iban": "FR1420041010050500013M02606", - "payment_type": "bank_account", - "billing_address": "20 Place de la Gare", - "billing_city": "Colombes", - "billing_state": "Île-de-France", - "billing_zip": "92700", - "billing_country": "FR" - } -} -``` - -### Importing GoCardless - -If the customer, bank account, and mandate already exist in GoCardless, a payment profile can be created by using the IDs. In order to create masked versions of `bank_account_number` and `bank_routing_number` that are used to display within Advanced Billing Admin UI, you can pass the last four digits for this fields which then will be saved in this form `XXXX[four-provided-digits]`. - -```json -{ - "payment_profile": { - "customer_id": "24907598", - "customer_vault_token": [Existing GoCardless Customer ID] - "vault_token": [Existing GoCardless Mandate ID], - "current_vault": "gocardless", - "bank_name": "French Bank", - "bank_account_number": [Last Four Of The Existing Account Number or IBAN if applicable], - "bank_routing_number": [Last Four Of The Existing Routing Number], - "payment_type": "bank_account", - "billing_address": "20 Place de la Gare", - "billing_city": "Colombes", - "billing_state": "Île-de-France", - "billing_zip": "92700", - "billing_country": "FR" - } -} -``` - -## SEPA Direct Debit - -For more information on Stripe SEPA Direct Debit, please view the following resources: - + [Full documentation on Stripe SEPA Direct Debit](https://maxio.zendesk.com/hc/en-us/articles/24176170430093-Stripe-SEPA-and-BECS-Direct-Debit) - -+ [Using Chargify.js with Stripe Direct Debit - minimal example](https://docs.maxio.com/hc/en-us/articles/38206331271693-Examples#h_01K0PJ15QQFKKN8Z7B7DZ9AJS5) - -+ [Using Chargify.js with Stripe Direct Debit - full example](https://docs.maxio.com/hc/en-us/articles/38206331271693-Examples#h_01K0PJ15QRECQQ4ECS3ZA55GY7) - -### Stripe SEPA Direct Debit Payment Profiles - -The following example creates a customer, bank account and mandate in Stripe: - -```json -{ - "payment_profile": { - "customer_id": "24907598", - "bank_name": "Deutsche bank", - "bank_iban": "DE89370400440532013000", - "payment_type": "bank_account", - "billing_address": "Test", - "billing_city": "Berlin", - "billing_state": "Brandenburg", - "billing_zip": "12345", - "billing_country": "DE" - } -} -``` - -## Stripe BECS Direct Debit - -For more information on Stripe BECS Direct Debit, please view the following resources: - + [Full documentation on Stripe BECS Direct Debit](https://maxio.zendesk.com/hc/en-us/articles/24176170430093-Stripe-SEPA-and-BECS-Direct-Debit) - -+ [Using Chargify.js with Stripe BECS Direct Debit - minimal example](https://developers.chargify.com/docs/developer-docs/ZG9jOjE0NjAzNDIy-examples#minimal-example-with-sepa-or-becs-direct-debit-stripe-gateway) - -+ [Using Chargify.js with Stripe BECS Direct Debit - full example](https://developers.chargify.com/docs/developer-docs/ZG9jOjE0NjAzNDIy-examples#full-example-with-sepa-direct-debit-stripe-gateway) - -### Stripe BECS Direct Debit Payment Profiles - -The following example creates a customer, bank account and mandate in Stripe: - -```json -{ - "payment_profile": { - "customer_id": "24907598", - "bank_name": "Australian bank", - "bank_branch_code": "000000", - "bank_account_number": "000123456" - "payment_type": "bank_account", - "billing_address": "Test", - "billing_city": "Stony Rise", - "billing_state": "Tasmania", - "billing_zip": "12345", - "billing_country": "AU" - } -} -``` - -## Stripe BACS Direct Debit - -Contact the support team to enable this payment method. -For more information on Stripe BACS Direct Debit, please view the following resources: - + [Full documentation on Stripe BACS Direct Debit](https://maxio.zendesk.com/hc/en-us/articles/24176170430093-Stripe-SEPA-and-BECS-Direct-Debit) -### Stripe BACS Direct Debit Payment Profiles - -The following example creates a customer, bank account and mandate in Stripe: - -```json -{ - "payment_profile": { - "customer_id": "24907598", - "bank_name": "British bank", - "bank_branch_code": "108800", - "bank_account_number": "00012345" - "payment_type": "bank_account", - "billing_address": "Test", - "billing_city": "London", - "billing_state": "LND", - "billing_zip": "12345", - "billing_country": "GB" - } -} -``` - -## 3D Secure - Checkout +## 3D Secure Authentication during payment profile creation. -It may happen that a payment needs 3D Secure Authentication when the payment profile is created; this is referred to in our help docs as a [post-authentication flow](https://maxio.zendesk.com/hc/en-us/articles/24176278996493-Testing-Implementing-3D-Secure#psd2-flows-pre-authentication-and-post-authentication). The server returns `422 Unprocessable Entity` in this case with the following response: +When a payment requires 3D Secure Authentication to adhear to Strong Customer Authentication (SCA) during payment profile creation, the request enters a [post-authentication flow](https://maxio.zendesk.com/hc/en-us/articles/24176278996493-Testing-Implementing-3D-Secure#psd2-flows-pre-authentication-and-post-authentication). In this case, a 422 Unprocessable Entity status is returned with the following response: ```json { @@ -275,29 +76,34 @@ It may happen that a payment needs 3D Secure Authentication when the payment pro ``` To let the customer go through 3D Secure Authentication, they need to be redirected to the URL specified in `action_link`. -Optionally, you can specify `callback_url` parameter in the `action_link` URL if you’d like to be notified about the result of 3D Secure Authentication. The `callback_url` will return the following information: + +Optionally, you can specify the `callback_url` parameter in the `action_link` URL to receive notification about the result of 3D Secure Authentication. + +The `callback_url` will return the following information: - whether the authentication was successful (`success`) - the payment profile ID (`payment_profile_id`) -Lastly, you can also specify a `redirect_url` parameter within the `action_link` URL if you’d like to redirect a customer back to your site. +You can also specify a `redirect_url` parameter in the `action_link` URL to redirect the customer back to your site. -It is not possible to use `action_link` in an iframe inside a custom application. You have to redirect the customer directly to the `action_link`, then, to be notified about the result, use `redirect_url` or `callback_url`. +You cannot use action_link in an iframe inside a custom application. You must redirect the customer directly to the `action_link` and use the `redirect_url` or `callback_url` to be notified of the result. -The final URL that you send a customer to complete 3D Secure may resemble the following, where the first half is the `action_link` and the second half contains a `redirect_url` and `callback_url`: `https://checkout-test.chargifypay.test/3d-secure/checkout/pay_uerzhsxd5uhkbodx5jhvkg6yeu?one_time_token_id=93&callback_url=http://localhost:4000&redirect_url=https://yourpage.com` +The final URL that you send a customer to complete 3D Secure may resemble the following, where the first half is the `action_link` and the second half contains a `redirect_url` and `callback_url`: + +`https://checkout-test.chargifypay.test/3d-secure/checkout/pay_uerzhsxd5uhkbodx5jhvkg6yeu?one_time_token_id=93&callback_url=http://localhost:4000&redirect_url=https://yourpage.com` ### Example Redirect Flow -You may wish to redirect customers to different pages depending on whether their SCA was performed successfully. Here's an example flow to use as a reference: +Here's an example flow to redirect customers to different pages depending on whether SCA was performed successfully: -1. Create a payment profile via API; it requires 3DS -2. You receive a `action_link` in the response. -3. Use this `action_link` to, for example, connect with your internal resources or generate a session_id -4. Include 1 of those attributes inside the `callback_url` and `redirect_url` to be aware which “session” this applies to +1. Create a payment profile via the API; it requires 3DS. +2. You receive an `action_link` in the response. +3. Use this `action_link` to, for example, connect with your internal resources or generate a `session_id`. +4. Include one of those attributes inside the `callback_url` and `redirect_url` to be aware which “session” this applies to. 5. Redirect the customer to the `action_link` with `callback_url` and `redirect_url` applied -6. After the customer finishes 3DS authentication, we let you know the result by making a request to applied `callback_url`. -7. After that, we redirect the customer to the `redirect_url`; at this point the result of authentication is known -8. Optionally, you can use the applied "msg" param in the `redirect_url` to determine whether it was successful or not +6. After the customer completes 3DS authentication, we notify you of the result via the applied `callback_url`. +7. After that, we redirect the customer to the `redirect_url`; at this point the result of authentication is known. +8. Optionally, you can use the applied "msg" param in the `redirect_url` to determine if the redirect was successful. ```ts async createPaymentProfile( @@ -322,24 +128,31 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The ```ts const body: CreatePaymentProfileRequest = { paymentProfile: { - paymentType: PaymentType.BankAccount, - customerId: 123, - bankName: 'Best Bank', - bankRoutingNumber: '021000089', - bankAccountNumber: '111111111111', - bankAccountType: BankAccountType.Checking, - bankAccountHolderType: BankAccountHolderType.Business, + chargifyToken: 'tok_w68qcpnftyv53jk33jv6wk3w', + customerId: 1036, }, }; try { - const { result, ...httpResponse } = await paymentProfilesController.createPaymentProfile(body); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await paymentProfilesController.createPaymentProfile(body); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -417,18 +230,30 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The ```ts const collect = { - page: 2, + page: 1, perPage: 50 } try { - const { result, ...httpResponse } = await paymentProfilesController.listPaymentProfiles(collect); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await paymentProfilesController.listPaymentProfiles(collect); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -501,7 +326,7 @@ try { Using the GET method you can retrieve a Payment Profile identified by its unique ID. -Please note that a different JSON object will be returned if the card method on file is a bank account. +Note that a different JSON object will be returned if the card method on file is a bank account. ### Response for Bank Account @@ -561,13 +386,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const paymentProfileId = 198; try { - const { result, ...httpResponse } = await paymentProfilesController.readPaymentProfile(paymentProfileId); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await paymentProfilesController.readPaymentProfile(paymentProfileId); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -676,11 +513,6 @@ const body: UpdatePaymentProfileRequest = { paymentProfile: { firstName: 'Graham', lastName: 'Test', - fullNumber: '4111111111111111', - cardType: CardType.Master, - expirationMonth: '04', - expirationYear: '2030', - currentVault: AllVaults.Bogus, billingAddress: '456 Juniper Court', billingCity: 'Boulder', billingState: 'CO', @@ -691,16 +523,28 @@ const body: UpdatePaymentProfileRequest = { }; try { - const { result, ...httpResponse } = await paymentProfilesController.updatePaymentProfile( + const response = await paymentProfilesController.updatePaymentProfile( paymentProfileId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -713,23 +557,13 @@ try { "id": 10088716, "first_name": "Test", "last_name": "Subscription", - "masked_card_number": "XXXX-XXXX-XXXX-1", - "card_type": "bogus", - "expiration_month": 1, - "expiration_year": 2022, - "customer_id": 14543792, - "current_vault": "bogus", - "vault_token": "1", "billing_address": "123 Montana Way", "billing_city": "Billings", "billing_state": "MT", "billing_zip": "59101", "billing_country": "US", - "customer_vault_token": null, "billing_address_2": "", - "payment_type": "credit_card", - "site_gateway_setting_id": 1, - "gateway_handle": null + "payment_type": "bank_account" } } ``` @@ -772,13 +606,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. const paymentProfileId = 198; try { - const { result, ...httpResponse } = await paymentProfilesController.deleteUnusedPaymentProfile(paymentProfileId); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await paymentProfilesController.deleteUnusedPaymentProfile(paymentProfileId); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -827,16 +673,28 @@ const subscriptionId = 222; const paymentProfileId = 198; try { - const { result, ...httpResponse } = await paymentProfilesController.deleteSubscriptionsPaymentProfile( + const response = await paymentProfilesController.deleteSubscriptionsPaymentProfile( subscriptionId, paymentProfileId ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -879,16 +737,28 @@ const body: BankAccountVerificationRequest = { }; try { - const { result, ...httpResponse } = await paymentProfilesController.verifyBankAccount( + const response = await paymentProfilesController.verifyBankAccount( bankAccountId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -899,8 +769,8 @@ try { { "payment_profile": { "id": 10089892, - "first_name": "Chester", - "last_name": "Tester", + "first_name": "John", + "last_name": "Doe", "customer_id": 14543792, "current_vault": "stripe_connect", "vault_token": "cus_0123abc456def", @@ -963,16 +833,28 @@ const uid = 'uid0'; const paymentProfileId = 198; try { - const { result, ...httpResponse } = await paymentProfilesController.deleteSubscriptionGroupPaymentProfile( + const response = await paymentProfilesController.deleteSubscriptionGroupPaymentProfile( uid, paymentProfileId ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -1012,16 +894,28 @@ const subscriptionId = 222; const paymentProfileId = 198; try { - const { result, ...httpResponse } = await paymentProfilesController.changeSubscriptionDefaultPaymentProfile( + const response = await paymentProfilesController.changeSubscriptionDefaultPaymentProfile( subscriptionId, paymentProfileId ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -1099,16 +993,28 @@ const uid = 'uid0'; const paymentProfileId = 198; try { - const { result, ...httpResponse } = await paymentProfilesController.changeSubscriptionGroupDefaultPaymentProfile( + const response = await paymentProfilesController.changeSubscriptionGroupDefaultPaymentProfile( uid, paymentProfileId ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -1181,13 +1087,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const chargifyToken = 'chargify_token8'; try { - const { result, ...httpResponse } = await paymentProfilesController.readOneTimeToken(chargifyToken); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await paymentProfilesController.readOneTimeToken(chargifyToken); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -1233,13 +1151,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. const subscriptionId = 222; try { - const { result, ...httpResponse } = await paymentProfilesController.sendRequestUpdatePaymentEmail(subscriptionId); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await paymentProfilesController.sendRequestUpdatePaymentEmail(subscriptionId); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` diff --git a/doc/controllers/product-families.md b/doc/controllers/product-families.md index 5e4a81c..b87c238 100644 --- a/doc/controllers/product-families.md +++ b/doc/controllers/product-families.md @@ -18,7 +18,7 @@ const productFamiliesController = new ProductFamiliesController(client); # List Products for Product Family -This method allows to retrieve a list of Products belonging to a Product Family. +Retrieves a list of Products belonging to a Product Family. ```ts async listProductsForProductFamily( @@ -77,7 +77,7 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The ```ts const collect = { productFamilyId: 'product_family_id4', - page: 2, + page: 1, perPage: 50, dateField: BasicDateField.UpdatedAt, filter: { @@ -91,13 +91,25 @@ const collect = { } try { - const { result, ...httpResponse } = await productFamiliesController.listProductsForProductFamily(collect); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await productFamiliesController.listProductsForProductFamily(collect); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -210,7 +222,7 @@ try { # Create Product Family -This method will create a Product Family within your Advanced Billing site. Create a Product Family to act as a container for your products, components and coupons. +Creates a Product Family within your Advanced Billing site. Create a Product Family to act as a container for your products, components and coupons. Full documentation on how Product Families operate within the Advanced Billing UI can be located [here](https://maxio.zendesk.com/hc/en-us/articles/24261098936205-Product-Families). @@ -243,13 +255,25 @@ const body: CreateProductFamilyRequest = { }; try { - const { result, ...httpResponse } = await productFamiliesController.createProductFamily(body); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await productFamiliesController.createProductFamily(body); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -277,7 +301,7 @@ try { # List Product Families -This method allows to retrieve a list of Product Families for a site. +Retrieve a list of Product Families for a site. ```ts async listProductFamilies( @@ -321,13 +345,25 @@ const collect = { } try { - const { result, ...httpResponse } = await productFamiliesController.listProductFamilies(collect); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await productFamiliesController.listProductFamilies(collect); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -364,7 +400,7 @@ try { # Read Product Family -This method allows to retrieve a Product Family via the `product_family_id`. The response will contain a Product Family object. +Retrieves a Product Family via the `product_family_id`. The response will contain a Product Family object. The product family can be specified either with the id number, or with the `handle:my-family` format. @@ -392,13 +428,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const id = 112; try { - const { result, ...httpResponse } = await productFamiliesController.readProductFamily(id); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await productFamiliesController.readProductFamily(id); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` diff --git a/doc/controllers/product-price-points.md b/doc/controllers/product-price-points.md index 4e5b8b7..48b2211 100644 --- a/doc/controllers/product-price-points.md +++ b/doc/controllers/product-price-points.md @@ -25,7 +25,7 @@ const productPricePointsController = new ProductPricePointsController(client); # Create Product Price Point -[Product Price Point Documentation](https://maxio.zendesk.com/hc/en-us/articles/24261111947789-Product-Price-Points) +Creates a Product Price Point. See the [Product Price Point](https://maxio.zendesk.com/hc/en-us/articles/24261111947789-Product-Price-Points) documentation for details. ```ts async createProductPricePoint( @@ -62,7 +62,7 @@ const body: CreateProductPricePointRequest = { trialPriceInCents: BigInt(4900), trialInterval: 1, trialIntervalUnit: IntervalUnit.Month, - trialType: 'payment_expected', + trialType: TrialType.PaymentExpected, initialChargeInCents: BigInt(120000), initialChargeAfterTrial: false, expirationInterval: 12, @@ -71,16 +71,28 @@ const body: CreateProductPricePointRequest = { }; try { - const { result, ...httpResponse } = await productPricePointsController.createProductPricePoint( + const response = await productPricePointsController.createProductPricePoint( productId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -121,7 +133,7 @@ try { # List Product Price Points -Use this endpoint to retrieve a list of product price points. +Retrieves a list of product price points. ```ts async listProductPricePoints( @@ -165,19 +177,31 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The ```ts const collect = { productId: 124, - page: 2, + page: 1, perPage: 10, filterType: Liquid error: Value cannot be null. (Parameter 'key') } try { - const { result, ...httpResponse } = await productPricePointsController.listProductPricePoints(collect); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await productPricePointsController.listProductPricePoints(collect); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -214,9 +238,9 @@ try { # Update Product Price Point -Use this endpoint to update a product price point. +Updates a product price point. -Note: Custom product price points are not able to be updated. +Note: Custom product price points cannot be updated. ```ts async updateProductPricePoint( @@ -255,17 +279,29 @@ const body: UpdateProductPricePointRequest = { }; try { - const { result, ...httpResponse } = await productPricePointsController.updateProductPricePoint( + const response = await productPricePointsController.updateProductPricePoint( productId, pricePointId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -332,16 +368,28 @@ const productId: ReadProductPricePointProductId = 124; const pricePointId: ReadProductPricePointPricePointId = 188; try { - const { result, ...httpResponse } = await productPricePointsController.readProductPricePoint( + const response = await productPricePointsController.readProductPricePoint( productId, pricePointId ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -376,7 +424,7 @@ try { # Archive Product Price Point -Use this endpoint to archive a product price point. +Archives a product price point. ```ts async archiveProductPricePoint( @@ -406,16 +454,28 @@ const productId: ArchiveProductPricePointProductId = 124; const pricePointId: ArchiveProductPricePointPricePointId = 188; try { - const { result, ...httpResponse } = await productPricePointsController.archiveProductPricePoint( + const response = await productPricePointsController.archiveProductPricePoint( productId, pricePointId ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -486,16 +546,28 @@ const productId = 202; const pricePointId = 10; try { - const { result, ...httpResponse } = await productPricePointsController.unarchiveProductPricePoint( + const response = await productPricePointsController.unarchiveProductPricePoint( productId, pricePointId ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -530,9 +602,9 @@ try { # Promote Product Price Point to Default -Use this endpoint to make a product price point the default for the product. +Sets a product price point as the default for the product. -Note: Custom product price points are not able to be set as the default for a product. +Note: Custom product price points cannot be set as the default for a product. ```ts async promoteProductPricePointToDefault( @@ -562,16 +634,28 @@ const productId = 202; const pricePointId = 10; try { - const { result, ...httpResponse } = await productPricePointsController.promoteProductPricePointToDefault( + const response = await productPricePointsController.promoteProductPricePointToDefault( productId, pricePointId ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -632,7 +716,7 @@ try { # Bulk Create Product Price Points -Use this endpoint to create multiple product price points in one request. +Creates multiple product price points in one request. ```ts async bulkCreateProductPricePoints( @@ -670,7 +754,7 @@ const body: BulkCreateProductPricePointsRequest = { trialPriceInCents: BigInt(4900), trialInterval: 1, trialIntervalUnit: IntervalUnit.Month, - trialType: 'payment_expected', + trialType: TrialType.PaymentExpected, initialChargeInCents: BigInt(120000), initialChargeAfterTrial: false, expirationInterval: 12, @@ -685,7 +769,7 @@ const body: BulkCreateProductPricePointsRequest = { trialPriceInCents: BigInt(4900), trialInterval: 1, trialIntervalUnit: IntervalUnit.Month, - trialType: 'payment_expected', + trialType: TrialType.PaymentExpected, initialChargeInCents: BigInt(120000), initialChargeAfterTrial: false, expirationInterval: 12, @@ -695,16 +779,28 @@ const body: BulkCreateProductPricePointsRequest = { }; try { - const { result, ...httpResponse } = await productPricePointsController.bulkCreateProductPricePoints( + const response = await productPricePointsController.bulkCreateProductPricePoints( productId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -747,7 +843,7 @@ try { # Create Product Currency Prices -This endpoint allows you to create currency prices for a given currency that has been defined on the site level in your settings. +Creates currency prices for a given currency that has been defined on the site level in your settings. When creating currency prices, they need to mirror the structure of your primary pricing. If the product price point defines a trial and/or setup fee, each currency must also define a trial and/or setup fee. @@ -799,16 +895,28 @@ const body: CreateProductCurrencyPricesRequest = { }; try { - const { result, ...httpResponse } = await productPricePointsController.createProductCurrencyPrices( + const response = await productPricePointsController.createProductCurrencyPrices( productPricePointId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -839,11 +947,11 @@ try { # Update Product Currency Prices -This endpoint allows you to update the `price`s of currency prices for a given currency that exists on the product price point. +Updates the `price`s of currency prices for a given currency that exists on the product price point. When updating the pricing, it needs to mirror the structure of your primary pricing. If the product price point defines a trial and/or setup fee, each currency must also define a trial and/or setup fee. -Note: Currency Prices are not able to be updated for custom product price points. +Note: Currency Prices cannot be updated for custom product price points. ```ts async updateProductCurrencyPrices( @@ -884,16 +992,28 @@ const body: UpdateCurrencyPricesRequest = { }; try { - const { result, ...httpResponse } = await productPricePointsController.updateProductCurrencyPrices( + const response = await productPricePointsController.updateProductCurrencyPrices( productPricePointId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -981,18 +1101,30 @@ const collect = { ], }, include: ListProductsPricePointsInclude.CurrencyPrices, - page: 2, + page: 1, perPage: 50 } try { - const { result, ...httpResponse } = await productPricePointsController.listAllProductPricePoints(collect); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await productPricePointsController.listAllProductPricePoints(collect); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` diff --git a/doc/controllers/products.md b/doc/controllers/products.md index 822795f..ae0a6e3 100644 --- a/doc/controllers/products.md +++ b/doc/controllers/products.md @@ -20,7 +20,9 @@ const productsController = new ProductsController(client); # Create Product -Use this method to create a product within your Advanced Billing site. +Creates a product in your Advanced Billing site. + +See the following product docuemation for more information: + [Products Documentation](https://maxio.zendesk.com/hc/en-us/articles/24261090117645-Products-Overview) + [Changing a Subscription's Product](https://maxio.zendesk.com/hc/en-us/articles/24252069837581-Product-Changes-and-Migrations) @@ -66,16 +68,28 @@ const body: CreateOrUpdateProductRequest = { }; try { - const { result, ...httpResponse } = await productsController.createProduct( + const response = await productsController.createProduct( productFamilyId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -138,7 +152,7 @@ try { # Read Product -This endpoint allows you to read the current details of a product that you've created in Advanced Billing. +Reads the current details of a product. ```ts async readProduct( @@ -164,13 +178,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const productId = 202; try { - const { result, ...httpResponse } = await productsController.readProduct(productId); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await productsController.readProduct(productId); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -221,7 +247,7 @@ try { # Update Product -Use this method to change aspects of an existing product. +Updates aspects of an existing product. ### Input Attributes Update Notes @@ -257,13 +283,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const productId = 202; try { - const { result, ...httpResponse } = await productsController.updateProduct(productId); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await productsController.updateProduct(productId); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -325,7 +363,7 @@ try { # Archive Product -Sending a DELETE request to this endpoint will archive the product. All current subscribers will be unffected; their subscription/purchase will continue to be charged monthly. +Archives the product. All current subscribers will be unffected; their subscription/purchase will continue to be charged monthly. This will restrict the option to chose the product for purchase via the Billing Portal, as well as disable Public Signup Pages for the product. @@ -353,13 +391,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const productId = 202; try { - const { result, ...httpResponse } = await productsController.archiveProduct(productId); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await productsController.archiveProduct(productId); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -416,7 +466,7 @@ try { # Read Product by Handle -This method allows to retrieve a Product object by its `api_handle`. +Retrieves a Product object by its `api_handle`. ```ts async readProductByHandle( @@ -442,13 +492,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const apiHandle = 'api_handle6'; try { - const { result, ...httpResponse } = await productsController.readProductByHandle(apiHandle); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await productsController.readProductByHandle(apiHandle); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -587,20 +649,32 @@ const collect = { 3 ], }, - page: 2, + page: 1, perPage: 50, includeArchived: true, include: ListProductsInclude.PrepaidProductPricePoint } try { - const { result, ...httpResponse } = await productsController.listProducts(collect); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await productsController.listProducts(collect); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` diff --git a/doc/controllers/proforma-invoices.md b/doc/controllers/proforma-invoices.md index 2ac7228..71f5aef 100644 --- a/doc/controllers/proforma-invoices.md +++ b/doc/controllers/proforma-invoices.md @@ -55,13 +55,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. const uid = 'uid0'; try { - const { result, ...httpResponse } = await proformaInvoicesController.createConsolidatedProformaInvoice(uid); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await proformaInvoicesController.createConsolidatedProformaInvoice(uid); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -133,13 +145,25 @@ const collect = { } try { - const { result, ...httpResponse } = await proformaInvoicesController.listSubscriptionGroupProformaInvoices(collect); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await proformaInvoicesController.listSubscriptionGroupProformaInvoices(collect); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -183,13 +207,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const proformaInvoiceUid = 'proforma_invoice_uid4'; try { - const { result, ...httpResponse } = await proformaInvoicesController.readProformaInvoice(proformaInvoiceUid); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await proformaInvoicesController.readProformaInvoice(proformaInvoiceUid); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -205,7 +241,7 @@ try { This endpoint will create a proforma invoice and return it as a response. If the information becomes outdated, simply void the old proforma invoice and generate a new one. -If you would like to preview the next billing amounts without generating a full proforma invoice, please use the renewal preview endpoint. +If you would like to preview the next billing amounts without generating a full proforma invoice, use the renewal preview endpoint. ## Restrictions @@ -235,13 +271,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const subscriptionId = 222; try { - const { result, ...httpResponse } = await proformaInvoicesController.createProformaInvoice(subscriptionId); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await proformaInvoicesController.createProformaInvoice(subscriptionId); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -320,7 +368,7 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The ```ts const collect = { subscriptionId: 222, - page: 2, + page: 1, perPage: 50, direction: Direction.Desc, lineItems: false, @@ -332,13 +380,25 @@ const collect = { } try { - const { result, ...httpResponse } = await proformaInvoicesController.listProformaInvoices(collect); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await proformaInvoicesController.listProformaInvoices(collect); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -382,13 +442,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const proformaInvoiceUid = 'proforma_invoice_uid4'; try { - const { result, ...httpResponse } = await proformaInvoicesController.voidProformaInvoice(proformaInvoiceUid); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await proformaInvoicesController.voidProformaInvoice(proformaInvoiceUid); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -435,13 +507,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const subscriptionId = 222; try { - const { result, ...httpResponse } = await proformaInvoicesController.previewProformaInvoice(subscriptionId); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await proformaInvoicesController.previewProformaInvoice(subscriptionId); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -497,13 +581,25 @@ const body: CreateSubscriptionRequest = { }; try { - const { result, ...httpResponse } = await proformaInvoicesController.createSignupProformaInvoice(body); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await proformaInvoicesController.createSignupProformaInvoice(body); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -561,16 +657,28 @@ const body: CreateSubscriptionRequest = { }; try { - const { result, ...httpResponse } = await proformaInvoicesController.previewSignupProformaInvoice( + const response = await proformaInvoicesController.previewSignupProformaInvoice( undefined, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` diff --git a/doc/controllers/reason-codes.md b/doc/controllers/reason-codes.md index 4eafbc4..451876b 100644 --- a/doc/controllers/reason-codes.md +++ b/doc/controllers/reason-codes.md @@ -65,13 +65,25 @@ const body: CreateReasonCodeRequest = { }; try { - const { result, ...httpResponse } = await reasonCodesController.createReasonCode(body); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await reasonCodesController.createReasonCode(body); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -116,18 +128,30 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The ```ts const collect = { - page: 2, + page: 1, perPage: 50 } try { - const { result, ...httpResponse } = await reasonCodesController.listReasonCodes(collect); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await reasonCodesController.listReasonCodes(collect); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -207,13 +231,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const reasonCodeId = 32; try { - const { result, ...httpResponse } = await reasonCodesController.readReasonCode(reasonCodeId); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await reasonCodesController.readReasonCode(reasonCodeId); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -255,13 +291,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const reasonCodeId = 32; try { - const { result, ...httpResponse } = await reasonCodesController.updateReasonCode(reasonCodeId); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await reasonCodesController.updateReasonCode(reasonCodeId); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -302,13 +350,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const reasonCodeId = 32; try { - const { result, ...httpResponse } = await reasonCodesController.deleteReasonCode(reasonCodeId); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await reasonCodesController.deleteReasonCode(reasonCodeId); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` diff --git a/doc/controllers/referral-codes.md b/doc/controllers/referral-codes.md index b7a00ac..40e3734 100644 --- a/doc/controllers/referral-codes.md +++ b/doc/controllers/referral-codes.md @@ -45,13 +45,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const code = 'code8'; try { - const { result, ...httpResponse } = await referralCodesController.validateReferralCode(code); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await referralCodesController.validateReferralCode(code); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` diff --git a/doc/controllers/sales-commissions.md b/doc/controllers/sales-commissions.md index 1dae68d..f3972e2 100644 --- a/doc/controllers/sales-commissions.md +++ b/doc/controllers/sales-commissions.md @@ -23,7 +23,7 @@ Endpoint returns subscriptions with associated sales reps The Sales Commission API differs from other Chargify API endpoints. This resource is associated with the seller itself. Up to now all available resources were at the level of the site, therefore creating the API Key per site was a sufficient solution. To share resources at the seller level, a new authentication method was introduced, which is user authentication. Creating an API Key for a user is a required step to correctly use the Sales Commission API, more details [here](https://developers.chargify.com/docs/developer-docs/ZG9jOjMyNzk5NTg0-2020-04-20-new-api-authentication). -Access to the Sales Commission API endpoints is available to users with financial access, where the seller has the Advanced Analytics component enabled. For further information on getting access to Advanced Analytics please contact Maxio support. +Access to the Sales Commission API endpoints is available to users with financial access, where the seller has the Advanced Analytics component enabled. For further information on getting access to Advanced Analytics contact Maxio support. > Note: The request is at seller level, it means `<>` variable will be replaced by `app` @@ -67,18 +67,30 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const collect = { sellerId: 'seller_id8', authorization: 'Bearer <>', - page: 2, + page: 1, perPage: 100 } try { - const { result, ...httpResponse } = await salesCommissionsController.listSalesCommissionSettings(collect); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await salesCommissionsController.listSalesCommissionSettings(collect); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -126,7 +138,7 @@ Endpoint returns sales rep list with details The Sales Commission API differs from other Chargify API endpoints. This resource is associated with the seller itself. Up to now all available resources were at the level of the site, therefore creating the API Key per site was a sufficient solution. To share resources at the seller level, a new authentication method was introduced, which is user authentication. Creating an API Key for a user is a required step to correctly use the Sales Commission API, more details [here](https://developers.chargify.com/docs/developer-docs/ZG9jOjMyNzk5NTg0-2020-04-20-new-api-authentication). -Access to the Sales Commission API endpoints is available to users with financial access, where the seller has the Advanced Analytics component enabled. For further information on getting access to Advanced Analytics please contact Maxio support. +Access to the Sales Commission API endpoints is available to users with financial access, where the seller has the Advanced Analytics component enabled. For further information on getting access to Advanced Analytics contact Maxio support. > Note: The request is at seller level, it means `<>` variable will be replaced by `app` @@ -170,18 +182,30 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const collect = { sellerId: 'seller_id8', authorization: 'Bearer <>', - page: 2, + page: 1, perPage: 100 } try { - const { result, ...httpResponse } = await salesCommissionsController.listSalesReps(collect); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await salesCommissionsController.listSalesReps(collect); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -278,7 +302,7 @@ Endpoint returns sales rep and attached subscriptions details. The Sales Commission API differs from other Chargify API endpoints. This resource is associated with the seller itself. Up to now all available resources were at the level of the site, therefore creating the API Key per site was a sufficient solution. To share resources at the seller level, a new authentication method was introduced, which is user authentication. Creating an API Key for a user is a required step to correctly use the Sales Commission API, more details [here](https://developers.chargify.com/docs/developer-docs/ZG9jOjMyNzk5NTg0-2020-04-20-new-api-authentication). -Access to the Sales Commission API endpoints is available to users with financial access, where the seller has the Advanced Analytics component enabled. For further information on getting access to Advanced Analytics please contact Maxio support. +Access to the Sales Commission API endpoints is available to users with financial access, where the seller has the Advanced Analytics component enabled. For further information on getting access to Advanced Analytics contact Maxio support. > Note: The request is at seller level, it means `<>` variable will be replaced by `app` @@ -319,12 +343,12 @@ const salesRepId = 'sales_rep_id4'; const authorization = 'Bearer <>'; -const page = 2; +const page = 1; const perPage = 100; try { - const { result, ...httpResponse } = await salesCommissionsController.readSalesRep( + const response = await salesCommissionsController.readSalesRep( sellerId, salesRepId, authorization, @@ -332,12 +356,24 @@ try { page, perPage ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` diff --git a/doc/controllers/sites.md b/doc/controllers/sites.md index 58b0908..f8fef71 100644 --- a/doc/controllers/sites.md +++ b/doc/controllers/sites.md @@ -54,13 +54,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The ```ts try { - const { result, ...httpResponse } = await sitesController.readSite(); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await sitesController.readSite(); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -147,13 +159,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. const cleanupScope = CleanupScope.All; try { - const { result, ...httpResponse } = await sitesController.clearSite(cleanupScope); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await sitesController.clearSite(cleanupScope); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -192,18 +216,30 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The ```ts const collect = { - page: 2, + page: 1, perPage: 50 } try { - const { result, ...httpResponse } = await sitesController.listChargifyJsPublicKeys(collect); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await sitesController.listChargifyJsPublicKeys(collect); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` diff --git a/doc/controllers/subscription-components.md b/doc/controllers/subscription-components.md index da19f39..2e1dae4 100644 --- a/doc/controllers/subscription-components.md +++ b/doc/controllers/subscription-components.md @@ -61,16 +61,28 @@ const subscriptionId = 222; const componentId = 222; try { - const { result, ...httpResponse } = await subscriptionComponentsController.readSubscriptionComponent( + const response = await subscriptionComponentsController.readSubscriptionComponent( subscriptionId, componentId ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -194,13 +206,25 @@ const collect = { } try { - const { result, ...httpResponse } = await subscriptionComponentsController.listSubscriptionComponents(collect); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await subscriptionComponentsController.listSubscriptionComponents(collect); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -288,16 +312,28 @@ const body: BulkComponentsPricePointAssignment = { }; try { - const { result, ...httpResponse } = await subscriptionComponentsController.bulkUpdateSubscriptionComponentsPricePoints( + const response = await subscriptionComponentsController.bulkUpdateSubscriptionComponentsPricePoints( subscriptionId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -356,13 +392,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const subscriptionId = 222; try { - const { result, ...httpResponse } = await subscriptionComponentsController.bulkResetSubscriptionComponentsPricePoints(subscriptionId); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await subscriptionComponentsController.bulkResetSubscriptionComponentsPricePoints(subscriptionId); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -557,17 +605,29 @@ const body: CreateAllocationRequest = { }; try { - const { result, ...httpResponse } = await subscriptionComponentsController.allocateComponent( + const response = await subscriptionComponentsController.allocateComponent( subscriptionId, componentId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -659,20 +719,32 @@ const subscriptionId = 222; const componentId = 222; -const page = 2; +const page = 1; try { - const { result, ...httpResponse } = await subscriptionComponentsController.listAllocations( + const response = await subscriptionComponentsController.listAllocations( subscriptionId, componentId, page ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -781,16 +853,28 @@ const body: AllocateComponents = { }; try { - const { result, ...httpResponse } = await subscriptionComponentsController.allocateComponents( + const response = await subscriptionComponentsController.allocateComponents( subscriptionId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -896,16 +980,28 @@ const body: PreviewAllocationsRequest = { }; try { - const { result, ...httpResponse } = await subscriptionComponentsController.previewAllocations( + const response = await subscriptionComponentsController.previewAllocations( subscriptionId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -1074,18 +1170,30 @@ const body: UpdateAllocationExpirationDate = { }; try { - const { result, ...httpResponse } = await subscriptionComponentsController.updatePrepaidUsageAllocationExpirationDate( + const response = await subscriptionComponentsController.updatePrepaidUsageAllocationExpirationDate( subscriptionId, componentId, allocationId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -1148,18 +1256,30 @@ const body: CreditSchemeRequest = { }; try { - const { result, ...httpResponse } = await subscriptionComponentsController.deletePrepaidUsageAllocation( + const response = await subscriptionComponentsController.deletePrepaidUsageAllocation( subscriptionId, componentId, allocationId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -1174,34 +1294,35 @@ try { # Create Usage -## Documentation +Records an instance of metered or prepaid usage for a subscription. + +You can report metered or prepaid usage to Advanced Billing as often as you wish. You can report usage as it happens or periodically, such as each night or once per billing period. -Full documentation on how to create Components in the Advanced Billing UI can be located [here](https://maxio.zendesk.com/hc/en-us/articles/24261149711501-Create-Edit-and-Archive-Components). Additionally, for information on how to record component usage against a subscription, please see the following resources: +Full documentation on how to create Components in the Advanced Billing UI can be located [here](https://maxio.zendesk.com/hc/en-us/articles/24261149711501-Create-Edit-and-Archive-Components). Additionally, for information on how to record component usage against a subscription, see the following resources: -+ [Recording Metered Component Usage](https://maxio.zendesk.com/hc/en-us/articles/24251890500109-Reporting-Component-Allocations#reporting-metered-component-usage) -+ [Reporting Prepaid Component Status](https://maxio.zendesk.com/hc/en-us/articles/24251890500109-Reporting-Component-Allocations#reporting-prepaid-component-status) +It is not possible to record metered usage for more than one component at a time Usage should be reported as one API call per component on a single subscription. For example, to record that a subscriber has sent both an SMS Message and an Email, send an API call for each. -You may choose to report metered or prepaid usage to Advanced Billing as often as you wish. You may report usage as it happens. You may also report usage periodically, such as each night or once per billing period. If usage events occur in your system very frequently (on the order of thousands of times an hour), it is best to accumulate usage into batches on your side, and then report those batches less frequently, such as daily. This will ensure you remain below any API throttling limits. If your use case requires higher rates of usage reporting, we recommend utilizing Events Based Components. +See the following product documention articles for more information: -## Create Usage for Subscription +- [Create and Manage Components](https://maxio.zendesk.com/hc/en-us/articles/24261149711501-Create-Edit-and-Archive-Components). A +- [Recording Metered Component Usage](https://maxio.zendesk.com/hc/en-us/articles/24251890500109-Reporting-Component-Allocations#reporting-metered-component-usage) +- [Reporting Prepaid Component Status](https://maxio.zendesk.com/hc/en-us/articles/24251890500109-Reporting-Component-Allocations#reporting-prepaid-component-status) -This endpoint allows you to record an instance of metered or prepaid usage for a subscription. The `quantity` from usage for each component is accumulated to the `unit_balance` on the [Component Line Item](./b3A6MTQxMDgzNzQ-read-subscription-component) for the subscription. +The `quantity` from usage for each component is accumulated to the `unit_balance` on the [Component Line Item](../../doc/controllers/subscription-components.md#read-subscription-component) for the subscription. ## Price Point ID usage -If you are using price points, for metered and prepaid usage components, Advanced Billing gives you the option to specify a price point in your request. +If you are using price points, for metered and prepaid usage components Advanced Billing gives you the option to specify a price point in your request. You do not need to specify a price point ID. If a price point is not included, the default price point for the component will be used when the usage is recorded. -If an invalid `price_point_id` is submitted, the endpoint will return an error. - ## Deducting Usage -In the event that you need to reverse a previous usage report or otherwise deduct from the current usage balance, you may provide a negative quantity. +If you need to reverse a previous usage report or otherwise deduct from the current usage balance, you can provide a negative quantity. Example: -Previously recorded: +Previously recorded quantity was 5000: ```json { @@ -1212,7 +1333,7 @@ Previously recorded: } ``` -At this point, `unit_balance` would be `5000`. To reduce the balance to `0`, POST the following payload: +To reduce the quantity to `0`, POST the following payload: ```json { @@ -1225,12 +1346,6 @@ At this point, `unit_balance` would be `5000`. To reduce the balance to `0`, POS The `unit_balance` has a floor of `0`; negative unit balances are never allowed. For example, if the usage balance is 100 and you deduct 200 units, the unit balance would then be `0`, not `-100`. -## FAQ - -Q. Is it possible to record metered usage for more than one component at a time? - -A. No. Usage should be reported as one API call per component on a single subscription. For example, to record that a subscriber has sent both an SMS Message and an Email, send an API call for each. - ```ts async createUsage( subscriptionIdOrReference: CreateUsageSubscriptionIdOrReference, @@ -1269,17 +1384,29 @@ const body: CreateUsageRequest = { }; try { - const { result, ...httpResponse } = await subscriptionComponentsController.createUsage( + const response = await subscriptionComponentsController.createUsage( subscriptionIdOrReference, componentId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -1375,18 +1502,30 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const collect = { subscriptionIdOrReference: 234, componentId: 144, - page: 2, + page: 1, perPage: 50 } try { - const { result, ...httpResponse } = await subscriptionComponentsController.listUsages(collect); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await subscriptionComponentsController.listUsages(collect); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -1483,17 +1622,29 @@ const body: ActivateEventBasedComponent = { }; try { - const { result, ...httpResponse } = await subscriptionComponentsController.activateEventBasedComponent( + const response = await subscriptionComponentsController.activateEventBasedComponent( subscriptionId, componentId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -1531,16 +1682,28 @@ const subscriptionId = 222; const componentId = 222; try { - const { result, ...httpResponse } = await subscriptionComponentsController.deactivateEventBasedComponent( + const response = await subscriptionComponentsController.deactivateEventBasedComponent( subscriptionId, componentId ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -1603,17 +1766,29 @@ const body: EBBEvent = { }; try { - const { result, ...httpResponse } = await subscriptionComponentsController.recordEvent( + const response = await subscriptionComponentsController.recordEvent( apiHandle, undefined, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -1664,17 +1839,29 @@ const body: EBBEvent[] = [ ]; try { - const { result, ...httpResponse } = await subscriptionComponentsController.bulkRecordEvents( + const response = await subscriptionComponentsController.bulkRecordEvents( apiHandle, undefined, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -1749,7 +1936,7 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The ```ts const collect = { - page: 2, + page: 1, perPage: 50, sort: ListSubscriptionComponentsSort.UpdatedAt, filter: { @@ -1774,13 +1961,25 @@ const collect = { } try { - const { result, ...httpResponse } = await subscriptionComponentsController.listSubscriptionComponentsForSite(collect); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await subscriptionComponentsController.listSubscriptionComponentsForSite(collect); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` diff --git a/doc/controllers/subscription-group-invoice-account.md b/doc/controllers/subscription-group-invoice-account.md index 10080d9..0e50c04 100644 --- a/doc/controllers/subscription-group-invoice-account.md +++ b/doc/controllers/subscription-group-invoice-account.md @@ -46,13 +46,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const uid = 'uid0'; try { - const { result, ...httpResponse } = await subscriptionGroupInvoiceAccountController.createSubscriptionGroupPrepayment(uid); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await subscriptionGroupInvoiceAccountController.createSubscriptionGroupPrepayment(uid); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -116,7 +128,7 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The ```ts const collect = { uid: 'uid0', - page: 2, + page: 1, perPage: 50, filter: { dateField: ListPrepaymentDateField.CreatedAt, @@ -126,13 +138,25 @@ const collect = { } try { - const { result, ...httpResponse } = await subscriptionGroupInvoiceAccountController.listPrepaymentsForSubscriptionGroup(collect); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await subscriptionGroupInvoiceAccountController.listPrepaymentsForSubscriptionGroup(collect); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -203,16 +227,28 @@ const body: IssueServiceCreditRequest = { }; try { - const { result, ...httpResponse } = await subscriptionGroupInvoiceAccountController.issueSubscriptionGroupServiceCredit( + const response = await subscriptionGroupInvoiceAccountController.issueSubscriptionGroupServiceCredit( uid, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -275,16 +311,28 @@ const body: DeductServiceCreditRequest = { }; try { - const { result, ...httpResponse } = await subscriptionGroupInvoiceAccountController.deductSubscriptionGroupServiceCredit( + const response = await subscriptionGroupInvoiceAccountController.deductSubscriptionGroupServiceCredit( uid, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` diff --git a/doc/controllers/subscription-group-status.md b/doc/controllers/subscription-group-status.md index bc6f5ae..b61e115 100644 --- a/doc/controllers/subscription-group-status.md +++ b/doc/controllers/subscription-group-status.md @@ -18,9 +18,9 @@ const subscriptionGroupStatusController = new SubscriptionGroupStatusController( # Cancel Subscriptions in Group -This endpoint will immediately cancel all subscriptions within the specified group. The group is identified by it's `uid` passed in the URL. To successfully cancel the group, the primary subscription must be on automatic billing. The group members as well must be on automatic billing or they must be prepaid. +Cancels all subscriptions within the specified group immediately. The group is identified by the `uid` that is passed in the URL. To successfully cancel the group, the primary subscription must be on automatic billing. The group members must be on automatic billing or prepaid. -In order to cancel a subscription group while also charging for any unbilled usage on metered or prepaid components, the `charge_unbilled_usage=true` parameter must be included in the request. +To cancel a subscription group while also charging for any unbilled usage on metered or prepaid components, the `charge_unbilled_usage=true` parameter must be included in the request. ```ts async cancelSubscriptionsInGroup( @@ -52,16 +52,28 @@ const body: CancelGroupedSubscriptionsRequest = { }; try { - const { result, ...httpResponse } = await subscriptionGroupStatusController.cancelSubscriptionsInGroup( + const response = await subscriptionGroupStatusController.cancelSubscriptionsInGroup( uid, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -75,7 +87,7 @@ try { # Initiate Delayed Cancellation for Group -This endpoint will schedule all subscriptions within the specified group to be canceled at the end of their billing period. The group is identified by it's uid passed in the URL. +This endpoint will schedule all subscriptions within the specified group to be canceled at the end of their billing period. The group is identified by its uid passed in the URL. All subscriptions in the group must be on automatic billing in order to successfully cancel them, and the group must not be in a "past_due" state. @@ -103,13 +115,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. const uid = 'uid0'; try { - const { result, ...httpResponse } = await subscriptionGroupStatusController.initiateDelayedCancellationForGroup(uid); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await subscriptionGroupStatusController.initiateDelayedCancellationForGroup(uid); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -149,13 +173,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. const uid = 'uid0'; try { - const { result, ...httpResponse } = await subscriptionGroupStatusController.cancelDelayedCancellationForGroup(uid); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await subscriptionGroupStatusController.cancelDelayedCancellationForGroup(uid); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -219,16 +255,28 @@ const body: ReactivateSubscriptionGroupRequest = { }; try { - const { result, ...httpResponse } = await subscriptionGroupStatusController.reactivateSubscriptionGroup( + const response = await subscriptionGroupStatusController.reactivateSubscriptionGroup( uid, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` diff --git a/doc/controllers/subscription-groups.md b/doc/controllers/subscription-groups.md index 5af3c26..b1fd9b9 100644 --- a/doc/controllers/subscription-groups.md +++ b/doc/controllers/subscription-groups.md @@ -32,6 +32,8 @@ You must provide one and only one of the `payment_profile_id`/`credit_card_attri Only one of the `subscriptions` can have `"primary": true` attribute set. When passing product to a subscription you can use either `product_id` or `product_handle` or `offer_id`. You can also use `custom_price` instead. +The subscription request examples below will be split into two sections. +The first section, "Subscription Customization", will focus on passing different information with a subscription, such as components, calendar billing, and custom fields. These examples will presume you are using a secure chargify_token generated by Chargify.js. ```ts async signupWithSubscriptionGroup( @@ -74,13 +76,25 @@ const body: SubscriptionGroupSignupRequest = { }; try { - const { result, ...httpResponse } = await subscriptionGroupsController.signupWithSubscriptionGroup(body); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await subscriptionGroupsController.signupWithSubscriptionGroup(body); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -129,13 +143,25 @@ const body: CreateSubscriptionGroupRequest = { }; try { - const { result, ...httpResponse } = await subscriptionGroupsController.createSubscriptionGroup(body); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await subscriptionGroupsController.createSubscriptionGroup(body); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -209,7 +235,7 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The ```ts const collect = { - page: 2, + page: 1, perPage: 50, include: [ SubscriptionGroupsListInclude.AccountBalances @@ -217,13 +243,25 @@ const collect = { } try { - const { result, ...httpResponse } = await subscriptionGroupsController.listSubscriptionGroups(collect); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await subscriptionGroupsController.listSubscriptionGroups(collect); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -305,16 +343,28 @@ const include: SubscriptionGroupInclude[] = [ ]; try { - const { result, ...httpResponse } = await subscriptionGroupsController.readSubscriptionGroup( + const response = await subscriptionGroupsController.readSubscriptionGroup( uid, include ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -403,16 +453,28 @@ const body: UpdateSubscriptionGroupRequest = { }; try { - const { result, ...httpResponse } = await subscriptionGroupsController.updateSubscriptionGroupMembers( + const response = await subscriptionGroupsController.updateSubscriptionGroupMembers( uid, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -474,13 +536,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const uid = 'uid0'; try { - const { result, ...httpResponse } = await subscriptionGroupsController.deleteSubscriptionGroup(uid); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await subscriptionGroupsController.deleteSubscriptionGroup(uid); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -531,13 +605,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const subscriptionId = 'subscription_id0'; try { - const { result, ...httpResponse } = await subscriptionGroupsController.findSubscriptionGroup(subscriptionId); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await subscriptionGroupsController.findSubscriptionGroup(subscriptionId); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -596,7 +682,7 @@ For sites making use of the [Relationship Billing](https://maxio.zendesk.com/hc/ Passing `group` parameters with a `target` containing a `type` and optional `id` is all that's needed. When the `target` parameter specifies a `"customer"` or `"subscription"` that is already part of a hierarchy, the subscription will become a member of the customer's subscription group. If the target customer or subscription is not part of a subscription group, a new group will be created and the subscription will become part of the group with the specified target customer set as the responsible payer for the group's subscriptions. -**Please Note:** In order to add an existing subscription to a subscription group, it must belong to either the same customer record as the target, or be within the same customer hierarchy. +**Note:** In order to add an existing subscription to a subscription group, it must belong to either the same customer record as the target, or be within the same customer hierarchy. Rather than specifying a customer, the `target` parameter could instead simply have a value of @@ -604,7 +690,7 @@ Rather than specifying a customer, the `target` parameter could instead simply h * `"parent"` which indicates the subscription will be paid for by the subscribing customer's parent within a customer hierarchy, or * `"eldest"` which indicates the subscription will be paid for by the root-level customer in the subscribing customer's hierarchy. -To create a new subscription into a subscription group, please reference the following: +To create a new subscription into a subscription group, reference the following: [Create Subscription in a Subscription Group](https://developers.chargify.com/docs/api-docs/d571659cf0f24-create-subscription#subscription-in-a-subscription-group) ```ts @@ -647,16 +733,28 @@ const body: AddSubscriptionToAGroup = { }; try { - const { result, ...httpResponse } = await subscriptionGroupsController.addSubscriptionToGroup( + const response = await subscriptionGroupsController.addSubscriptionToGroup( subscriptionId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -712,13 +810,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. const subscriptionId = 222; try { - const { result, ...httpResponse } = await subscriptionGroupsController.removeSubscriptionFromGroup(subscriptionId); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await subscriptionGroupsController.removeSubscriptionFromGroup(subscriptionId); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` diff --git a/doc/controllers/subscription-invoice-account.md b/doc/controllers/subscription-invoice-account.md index dbab998..0643164 100644 --- a/doc/controllers/subscription-invoice-account.md +++ b/doc/controllers/subscription-invoice-account.md @@ -47,13 +47,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const subscriptionId = 222; try { - const { result, ...httpResponse } = await subscriptionInvoiceAccountController.readAccountBalances(subscriptionId); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await subscriptionInvoiceAccountController.readAccountBalances(subscriptionId); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -67,7 +79,7 @@ In order to specify a prepayment made against a subscription, specify the `amoun When the `method` specified is `"credit_card_on_file"`, the prepayment amount will be collected using the default credit card payment profile and applied to the prepayment account balance. This is especially useful for manual replenishment of prepaid subscriptions. -Please note that you **can't** pass `amount_in_cents`. +Note that passing `amount_in_cents` is now allowed. ```ts async createPrepayment( @@ -104,16 +116,28 @@ const body: CreatePrepaymentRequest = { }; try { - const { result, ...httpResponse } = await subscriptionInvoiceAccountController.createPrepayment( + const response = await subscriptionInvoiceAccountController.createPrepayment( subscriptionId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -181,7 +205,7 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The ```ts const collect = { subscriptionId: 222, - page: 2, + page: 1, perPage: 50, filter: { dateField: ListPrepaymentDateField.CreatedAt, @@ -191,13 +215,25 @@ const collect = { } try { - const { result, ...httpResponse } = await subscriptionInvoiceAccountController.listPrepayments(collect); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await subscriptionInvoiceAccountController.listPrepayments(collect); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -266,16 +302,28 @@ const body: IssueServiceCreditRequest = { }; try { - const { result, ...httpResponse } = await subscriptionInvoiceAccountController.issueServiceCredit( + const response = await subscriptionInvoiceAccountController.issueServiceCredit( subscriptionId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -336,16 +384,28 @@ const body: DeductServiceCreditRequest = { }; try { - const { result, ...httpResponse } = await subscriptionInvoiceAccountController.deductServiceCredit( + const response = await subscriptionInvoiceAccountController.deductServiceCredit( subscriptionId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -390,22 +450,34 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The ```ts const subscriptionId = 222; -const page = 2; +const page = 1; const perPage = 50; try { - const { result, ...httpResponse } = await subscriptionInvoiceAccountController.listServiceCredits( + const response = await subscriptionInvoiceAccountController.listServiceCredits( subscriptionId, page, perPage ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -483,16 +555,28 @@ const subscriptionId = 222; const prepaymentId = BigInt(228); try { - const { result, ...httpResponse } = await subscriptionInvoiceAccountController.refundPrepayment( + const response = await subscriptionInvoiceAccountController.refundPrepayment( subscriptionId, prepaymentId ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` diff --git a/doc/controllers/subscription-notes.md b/doc/controllers/subscription-notes.md index 10571d9..86b6df7 100644 --- a/doc/controllers/subscription-notes.md +++ b/doc/controllers/subscription-notes.md @@ -62,16 +62,28 @@ const body: UpdateSubscriptionNoteRequest = { }; try { - const { result, ...httpResponse } = await subscriptionNotesController.createSubscriptionNote( + const response = await subscriptionNotesController.createSubscriptionNote( subscriptionId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -120,18 +132,30 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The ```ts const collect = { subscriptionId: 222, - page: 2, + page: 1, perPage: 50 } try { - const { result, ...httpResponse } = await subscriptionNotesController.listSubscriptionNotes(collect); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await subscriptionNotesController.listSubscriptionNotes(collect); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -202,16 +226,28 @@ const subscriptionId = 222; const noteId = 66; try { - const { result, ...httpResponse } = await subscriptionNotesController.readSubscriptionNote( + const response = await subscriptionNotesController.readSubscriptionNote( subscriptionId, noteId ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -273,17 +309,29 @@ const body: UpdateSubscriptionNoteRequest = { }; try { - const { result, ...httpResponse } = await subscriptionNotesController.updateSubscriptionNote( + const response = await subscriptionNotesController.updateSubscriptionNote( subscriptionId, noteId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -327,16 +375,28 @@ const subscriptionId = 222; const noteId = 66; try { - const { result, ...httpResponse } = await subscriptionNotesController.deleteSubscriptionNote( + const response = await subscriptionNotesController.deleteSubscriptionNote( subscriptionId, noteId ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` diff --git a/doc/controllers/subscription-products.md b/doc/controllers/subscription-products.md index c44fa82..9bc41d2 100644 --- a/doc/controllers/subscription-products.md +++ b/doc/controllers/subscription-products.md @@ -30,11 +30,11 @@ Full documentation on how to record Migrations in the Advanced Billing UI can be ## Failed Migrations -One of the most common ways that a migration can fail is when the attempt is made to migrate a subscription to it's current product. Please be aware of this issue! +Importaint note: One of the most common ways that a migration can fail is when the attempt is made to migrate a subscription to its current product. ## Migration 3D Secure - Stripe -It may happen that a payment needs 3D Secure Authentication when the subscription is migrated to a new product; this is referred to in our help docs as a [post-authentication flow](https://maxio.zendesk.com/hc/en-us/articles/24176278996493-Testing-Implementing-3D-Secure#psd2-flows-pre-authentication-and-post-authentication). The server returns `422 Unprocessable Entity` in this case with the following response: +When a payment requires 3D Secure Authentication to adhear to Strong Customer Authentication (SCA) when the subscription is migrated to a new product, the request enters a [post-authentication flow](https://maxio.zendesk.com/hc/en-us/articles/24176278996493-Testing-Implementing-3D-Secure#psd2-flows-pre-authentication-and-post-authentication). The server returns `422 Unprocessable Entity` in this case with the following response: ```json { @@ -62,7 +62,7 @@ The final URL that you send a customer to to complete 3D Secure may resemble the ### Example Redirect Flow -You may wish to redirect customers to different pages depending on whether their SCA was performed successfully. Here's an example flow to use as a reference: +You may wish to redirect customers to different pages depending on whether SCA was performed successfully. Here's an example flow to use as a reference: 1. Create a migration via API; it requires 3DS 2. You receive a `gateway_payment_id` in the `action_link` along other params in the response. @@ -109,16 +109,28 @@ const body: SubscriptionProductMigrationRequest = { }; try { - const { result, ...httpResponse } = await subscriptionProductsController.migrateSubscriptionProduct( + const response = await subscriptionProductsController.migrateSubscriptionProduct( subscriptionId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -297,16 +309,28 @@ const body: SubscriptionMigrationPreviewRequest = { }; try { - const { result, ...httpResponse } = await subscriptionProductsController.previewSubscriptionProductMigration( + const response = await subscriptionProductsController.previewSubscriptionProductMigration( subscriptionId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` diff --git a/doc/controllers/subscription-status.md b/doc/controllers/subscription-status.md index 521513e..51d0c49 100644 --- a/doc/controllers/subscription-status.md +++ b/doc/controllers/subscription-status.md @@ -58,13 +58,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const subscriptionId = 222; try { - const { result, ...httpResponse } = await subscriptionStatusController.retrySubscription(subscriptionId); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await subscriptionStatusController.retrySubscription(subscriptionId); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -242,13 +254,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const subscriptionId = 222; try { - const { result, ...httpResponse } = await subscriptionStatusController.cancelSubscription(subscriptionId); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await subscriptionStatusController.cancelSubscription(subscriptionId); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -427,13 +451,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const subscriptionId = 222; try { - const { result, ...httpResponse } = await subscriptionStatusController.resumeSubscription(subscriptionId); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await subscriptionStatusController.resumeSubscription(subscriptionId); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -560,7 +596,7 @@ This will place the subscription in the on_hold state and it will not renew. ## Limitations -You may not place a subscription on hold if the `next_billing` date is within 24 hours. +You may not place a subscription on hold if the `next_billing_at` date is within 24 hours. ```ts async pauseSubscription( @@ -594,16 +630,28 @@ const body: PauseRequest = { }; try { - const { result, ...httpResponse } = await subscriptionStatusController.pauseSubscription( + const response = await subscriptionStatusController.pauseSubscription( subscriptionId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -766,16 +814,28 @@ const body: PauseRequest = { }; try { - const { result, ...httpResponse } = await subscriptionStatusController.updateAutomaticSubscriptionResumption( + const response = await subscriptionStatusController.updateAutomaticSubscriptionResumption( subscriptionId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -911,8 +971,7 @@ try { Advanced Billing offers the ability to reactivate a previously canceled subscription. For details on how the reactivation works, and how to reactivate subscriptions through the application, see [reactivation](https://maxio.zendesk.com/hc/en-us/articles/24252109503629-Reactivating-and-Resuming). -**Please note: The term -"resume" is used also during another process in Advanced Billing. This occurs when an on-hold subscription is "resumed". This returns the subscription to an active state.** +**Note: The term "resume" is used also during another process in Advanced Billing. This occurs when an on-hold subscription is "resumed". This returns the subscription to an active state.** + The response returns the subscription object in the `active` or `trialing` state. + The `canceled_at` and `cancellation_message` fields do not have values. @@ -1106,16 +1165,28 @@ const body: ReactivateSubscriptionRequest = { }; try { - const { result, ...httpResponse } = await subscriptionStatusController.reactivateSubscription( + const response = await subscriptionStatusController.reactivateSubscription( subscriptionId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -1271,13 +1342,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const subscriptionId = 222; try { - const { result, ...httpResponse } = await subscriptionStatusController.initiateDelayedCancellation(subscriptionId); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await subscriptionStatusController.initiateDelayedCancellation(subscriptionId); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -1320,13 +1403,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const subscriptionId = 222; try { - const { result, ...httpResponse } = await subscriptionStatusController.cancelDelayedCancellation(subscriptionId); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await subscriptionStatusController.cancelDelayedCancellation(subscriptionId); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -1374,13 +1469,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const subscriptionId = 222; try { - const { result, ...httpResponse } = await subscriptionStatusController.cancelDunning(subscriptionId); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await subscriptionStatusController.cancelDunning(subscriptionId); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -1396,7 +1503,7 @@ try { The Chargify API allows you to preview a renewal by posting to the renewals endpoint. Renewal Preview is an object representing a subscription’s next assessment. You can retrieve it to see a snapshot of how much your customer will be charged on their next renewal. -The "Next Billing" amount and "Next Billing" date are already represented in the UI on each Subscriber's Summary. For more information, please see our documentation [here](https://maxio.zendesk.com/hc/en-us/articles/24252493695757-Subscriber-Interface-Overview). +The "Next Billing" amount and "Next Billing" date are already represented in the UI on each Subscriber's Summary. For more information, see our documentation [here](https://maxio.zendesk.com/hc/en-us/articles/24252493695757-Subscriber-Interface-Overview). ## Optional Component Fields @@ -1462,16 +1569,28 @@ const body: RenewalPreviewRequest = { }; try { - const { result, ...httpResponse } = await subscriptionStatusController.previewRenewal( + const response = await subscriptionStatusController.previewRenewal( subscriptionId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` diff --git a/doc/controllers/subscriptions.md b/doc/controllers/subscriptions.md index 2535498..5af01db 100644 --- a/doc/controllers/subscriptions.md +++ b/doc/controllers/subscriptions.md @@ -26,624 +26,21 @@ const subscriptionsController = new SubscriptionsController(client); # Create Subscription -Full documentation on how subscriptions operate within Advanced Billing can be located under the following topics: +Creates a Subscription for a customer and product -+ [Subscriptions Reference](https://maxio.zendesk.com/hc/en-us/articles/24251526991757-Subscription-Overview) -+ [Subscriptions Actions](https://maxio.zendesk.com/hc/en-us/articles/24251983024653-Subscription-Actions-Overview) -+ [Subscription Cancellation](https://maxio.zendesk.com/hc/en-us/articles/24251957778829-Cancel-Subscriptions) -+ [Subscription Reactivation](https://maxio.zendesk.com/hc/en-us/articles/24252109503629-Reactivating-and-Resuming) -+ [Subscription Import](https://maxio.zendesk.com/hc/en-us/articles/24251489107213-Imports) +Specify the product with `product_id` or `product_handle`. To set a specific product pricepPoint, use `product_price_point_handle` or `product_price_point_id`. -When creating a subscription, you must specify a product and a customer. Credit card details may be required, depending on the options for the Product being subscribed ([see Product Options](https://maxio.zendesk.com/hc/en-us/articles/24261076617869-Product-Editing)). +Identify an existing customer with `customer_id` or `customer_reference`. Optionally, include an existing payment profile using `payment_profile_id`. To create a new customer, pass customer_attributes. -The product may be specified by `product_id` or by `product_handle` (API Handle). In similar fashion, to pass a particular product price point, you may either use `product_price_point_handle` or `product_price_point_id`. +Select an option from the **Request Examples** drop-down on the right side of the portal to see examples of common scenarios for creating subscriptions. -An existing customer may be specified by a `customer_id` (ID within Advanced Billing) or a `customer_reference` (unique value within your app that you have shared with Advanced Billing via the reference attribute on a customer). You may also pass in an existing payment profile for that customer with `payment_profile_id`. A new customer may be created by providing `customer_attributes`. +Payment information may be required to create a subscription, depending on the options for the Product being subscribed. See [product options](https://docs.maxio.com/hc/en-us/articles/24261076617869-Edit-Products) for more information. See the [Payments Profile](../../doc/controllers/payment-profiles.md#create-payment-profile) endpoint for details on payment parameters. -Credit card details may be required, depending on the options for the product being subscribed. The product can be specified by `product_id` or by `product_handle` (API Handle). +Do not use real card information for testing. See the Sites articles that cover [testing your site setup](https://docs.maxio.com/hc/en-us/articles/24250712113165-Testing-Overview#testing-overview-0-0) for more details on testing in your sandbox. -If you are creating a subscription with a payment profile, the attribute to send will be `credit_card_attributes` or `bank_account_attributes` for ACH and Direct Debit. That said, when you read the subscription after creation, we return the profile details under `credit_card` or `bank_account`. +Note that collecting and sending raw card details in production requires [PCI compliance](https://docs.maxio.com/hc/en-us/articles/24183956938381-PCI-Compliance#pci-compliance-0-0) on your end. If your business is not PCI compliant, use [Chargify.js](https://docs.maxio.com/hc/en-us/articles/38163190843789-Chargify-js-Overview#chargify-js-overview-0-0) to collect credit card or bank account information. -## Bulk creation of subscriptions - -Bulk creation of subscriptions is currently not supported. For scenarios where multiple subscriptions must be added, particularly when assigning to the same subscription group, it is essential to switch to a single-threaded approach. - -To avoid data conflicts or inaccuracies, incorporate a sleep interval between requests. - -While this single-threaded approach may impact performance, it ensures data consistency and accuracy in cases where concurrent creation attempts could otherwise lead to issues with subscription alignment and integrity. - -## Taxable Subscriptions - -If your intent is to charge your subscribers tax via [Avalara Taxes](https://maxio.zendesk.com/hc/en-us/articles/24287043035661-Avalara-VAT-Tax) or [Custom Taxes](https://maxio.zendesk.com/hc/en-us/articles/24287044212749-Custom-Taxes), there are a few considerations to be made regarding collecting subscription data. -For subscribers to be eligible to be taxed, the following information for the `customer` object or `payment_profile` object must by supplied: - -+ A subscription to a [taxable product](https://maxio.zendesk.com/hc/en-us/articles/24261076617869-Product-Editing#tax-settings) -+ [Full valid billing or shipping address](https://maxio.zendesk.com/hc/en-us/articles/24287008131853-Advanced-Billing-Managed-Sales-Tax#full-address-required-for-taxable-subscriptions) to identify the tax locale -+ The portion of the address that houses the [state information](https://maxio.zendesk.com/hc/en-us/articles/24287008131853-Advanced-Billing-Managed-Sales-Tax#required-state-format-for-taxable-subscriptions) of either adddress must adhere to the ISO standard of a 2-3 character limit/format. -+ The portion of the address that houses the [country information](https://maxio.zendesk.com/hc/en-us/articles/24287008131853-Advanced-Billing-Managed-Sales-Tax#required-country-format-for-taxable-subscriptions) must adhere to the ISO standard of a 2 character limit/format. - -## Subscription Request Examples - -The subscription examples below will be split into two sections. - -The first section, "Subscription Customization", will focus on passing different information with a subscription, such as components, calendar billing, and custom fields. These examples will presume you are using a secure `chargify_token` generated by Chargify.js. - -The second section, "Passing Payment Information", will focus on passing payment information into Advanced Billing. Please be aware that collecting and sending Advanced Billing raw card details requires PCI compliance on your end; these examples are provided as guidance. If your business is not PCI compliant, we recommend using Chargify.js to collect credit cards or bank accounts. - -# Subscription Customization - -## With Components - -Different components require slightly different data. For example, quantity-based and on/off components accept `allocated_quantity`, while metered components accept `unit_balance`. - -When creating a subscription with a component, a `price_point_id` can be passed in along with the `component_id` to specify which price point to use. If not passed in, the default price point will be used. - -Note: if an invalid `price_point_id` is used, the subscription will still proceed but will use the component's default price point. - -Components and their price points may be added by ID or by handle. See the example request body labeled "Components By Handle (Quantity-Based)"; the format will be the same for other component types. - -## With Coupon(s) - -Pass an array of `coupon_codes`. See the example request body "With Coupon". - -## With Manual Invoice Collection - -The `invoice` collection method works only on legacy Statement Architecture. - -On Relationship Invoicing Architecture use the `remittance` collection method. - -## Prepaid Subscription - -A prepaid subscription can be created with the usual subscription creation parameters, specifying `prepaid` as the `payment_collection_method` and including a nested `prepaid_configuration`. - -After a prepaid subscription has been created, additional funds can be manually added to the prepayment account through the [Create Prepayment Endpoint](https://developers.chargify.com/docs/api-docs/7ec482de77ba7-create-prepayment). - -Prepaid subscriptions do not work on legacy Statement Architecture. - -## With Metafields - -Metafields can either attach to subscriptions or customers. Metafields are popuplated with the supplied metadata to the resource specified. - -If the metafield doesn't exist yet, it will be created on-the-fly. - -## With Custom Pricing - -Custom pricing is pricing specific to the subscription in question. -Create a subscription with custom pricing by passing pricing information instead of a price point. -For a custom priced product, pass the custom_price object in place of `product_price_point_id`. For a custom priced component, pass the `custom_price` object within the component object. -Custom prices and price points can exist in harmony on a subscription. - -# Passing Payment Information - -## Subscription with Chargify.js token - -The `chargify_token` can be obtained using [Chargify.js](https://docs.maxio.com/hc/en-us/articles/38163190843789-Chargify-js-Overview#chargify-js-overview-0-0). The token represents payment profile attributes that were provided by the customer in their browser and stored at the payment gateway. - -The `payment_type` attribute may either be `credit_card` or `bank_account`, depending on the type of payment method being added. If a bank account is being passed, the payment attributes should be changed to `bank_account_attributes`. - -```json -{ - "subscription": { - "product_handle": "pro-plan", - "customer_attributes": { - "first_name": "Joe", - "last_name": "Smith", - "email": "j.smith@example.com" - }, - "credit_card_attributes": { - "chargify_token": "tok_cwhvpfcnbtgkd8nfkzf9dnjn", - "payment_type": "credit_card" - } - } -} -``` - -## Subscription with vault token - -If you already have a customer and card stored in your payment gateway, you may create a subscription with a `vault_token`. Providing the last_four, card type and expiration date will allow the card to be displayed properly in the Advanced Billing UI. - -```json -{ - "subscription": { - "product_handle": "pro-plan", - "customer_attributes": { - "first_name": "Joe", - "last_name": "Smith", - "email": "j.smith@example.com" - }, - "credit_card_attributes": { - first_name: "Joe, - last_name: "Smith", - card_type: "visa", - expiration_month: "05", - expiration_year: "2025", - last_four: "1234", - vault_token: "12345abc", - current_vault: "braintree_blue" - } -} -``` - -## Subscription with ACH as Payment Profile - -```json -{ - "subscription": { - "product_handle": "gold-product", - "customer_attributes": { - "first_name": "Joe", - "last_name": "Blow", - "email": "joe@example.com", - "zip": "02120", - "state": "MA", - "reference": "XYZ", - "phone": "(617) 111 - 0000", - "organization": "Acme", - "country": "US", - "city": "Boston", - "address_2": null, - "address": "123 Mass Ave." - }, - "bank_account_attributes": { - "bank_name": "Best Bank", - "bank_routing_number": "021000089", - "bank_account_number": "111111111111", - "bank_account_type": "checking", - "bank_account_holder_type": "business", - "payment_type": "bank_account" - } - } -} -``` - -## Subscription with PayPal payment profile - -### With the nonce from Braintree JS - -```json -{ "subscription": { - "product_handle":"test-product-b", - "customer_attributes": { - "first_name":"Amelia", - "last_name":"Johnson", - "email":"amelia@example.com", - "organization":"My Awesome Company" - }, - "payment_profile_attributes":{ - "paypal_email": "amelia@example.com", - "current_vault": "braintree_blue", - "payment_method_nonce":"abc123", - "payment_type":"paypal_account" - } - } -``` - -### With the Braintree Customer ID as the vault token: - -```json -{ "subscription": { - "product_handle":"test-product-b", - "customer_attributes": { - "first_name":"Amelia", - "last_name":"Johnson", - "email":"amelia@example.com", - "organization":"My Awesome Company" - }, - "payment_profile_attributes":{ - "paypal_email": "amelia@example.com", - "current_vault": "braintree_blue", - "vault_token":"58271347", - "payment_type":"paypal_account" - } - } -``` - -## Subscription using GoCardless Bank Number - -These examples creates a customer, bank account and mandate in GoCardless. - -For more information on GoCardless, please view the following two resources: - -+ [Payment Profiles via API for GoCardless](https://developers.chargify.com/docs/api-docs/1f10a4f170405-create-payment-profile#gocardless) - -+ [Full documentation on GoCardless](https://maxio.zendesk.com/hc/en-us/articles/24176159136909-GoCardless) - -+ [Using Chargify.js with GoCardless - minimal example](https://docs.maxio.com/hc/en-us/articles/38206331271693-Examples#h_01K0PJ15QQZKCER8CFK40MR6XJ) - -+ [Using Chargify.js with GoCardless - full example](https://docs.maxio.com/hc/en-us/articles/38206331271693-Examples#h_01K0PJ15QR09JVHWW0MCA7HVJV) - -```json -{ - "subscription": { - "product_handle": "gold-product", - "customer_attributes": { - "first_name": "Jane", - "last_name": "Doe", - "email": "jd@chargify.test" - }, - "bank_account_attributes": { - "bank_name": "Royal Bank of France", - "bank_account_number": "0000000", - "bank_routing_number": "0003", - "bank_branch_code": "00006", - "payment_type": "bank_account", - "billing_address": "20 Place de la Gare", - "billing_city": "Colombes", - "billing_state": "Île-de-France", - "billing_zip": "92700", - "billing_country": "FR" - } - } -} -``` - -## Subscription using GoCardless IBAN Number - -```json -{ - "subscription": { - "product_handle": "gold-product", - "customer_attributes": { - "first_name": "Jane", - "last_name": "Doe", - "email": "jd@chargify.test" - }, - "bank_account_attributes": { - "bank_name": "French Bank", - "bank_iban": "FR1420041010050500013M02606", - "payment_type": "bank_account", - "billing_address": "20 Place de la Gare", - "billing_city": "Colombes", - "billing_state": "Île-de-France", - "billing_zip": "92700", - "billing_country": "FR" - } - } -} -``` - -## Subscription using Stripe SEPA Direct Debit - -For more information on Stripe Direct Debit, please view the following two resources: - -+ [Payment Profiles via API for Stripe SEPA Direct Debit](https://developers.chargify.com/docs/api-docs/1f10a4f170405-create-payment-profile#sepa-direct-debit) - -+ [Full documentation on Stripe Direct Debit](https://maxio.zendesk.com/hc/en-us/articles/24176170430093-Stripe-SEPA-and-BECS-Direct-Debit) - -+ [Using Chargify.js with Stripe SEPA or BECS Direct Debit - minimal example](https://docs.maxio.com/hc/en-us/articles/38206331271693-Examples#h_01K0PJ15QQFKKN8Z7B7DZ9AJS5) - -+ [Using Chargify.js with Stripe SEPA Direct Debit - full example](https://docs.maxio.com/hc/en-us/articles/38206331271693-Examples#h_01K0PJ15QR09JVHWW0MCA7HVJV) - -```json -{ - "subscription": { - "product_handle": "gold-product", - "customer_attributes": { - "first_name": "Jane", - "last_name": "Doe", - "email": "jd@chargify.test" - }, - "bank_account_attributes": { - "bank_name": "Test Bank", - "bank_iban": "DE89370400440532013000", - "payment_type": "bank_account" - } - } -} -``` - -## Subscription using Stripe BECS Direct Debit - -For more information on Stripe Direct Debit, please view the following two resources: - -+ [Payment Profiles via API for Stripe BECS Direct Debit](../../doc/controllers/payment-profiles.md#create-payment-profile) - -+ [Full documentation on Stripe Direct Debit](https://maxio.zendesk.com/hc/en-us/articles/24176170430093-Stripe-SEPA-and-BECS-Direct-Debit) - -+ [Using Chargify.js with Stripe SEPA, BECS or BACS Direct Debit - minimal example](https://docs.maxio.com/hc/en-us/articles/38206331271693-Examples#h_01K0PJ15QQFKKN8Z7B7DZ9AJS5) - -+ [Using Chargify.js with Stripe BECS Direct Debit - full example](https://docs.maxio.com/hc/en-us/articles/38206331271693-Examples#h_01K0PJ15QRX4B1TYZKZD8ZND6D) - -```json -{ - "subscription": { - "product_handle": "gold-product", - "customer_attributes": { - "first_name": "Jane", - "last_name": "Doe", - "email": "jd@chargify.test" - }, - "bank_account_attributes": { - "bank_name": "Test Bank", - "bank_branch_code": "000000", - "bank_account_number": "000123456", - "payment_type": "bank_account" - } - } -} -``` - -## Subscription using Stripe BACS Direct Debit - -For more information on Stripe Direct Debit, please view the following two resources: - -+ [Payment Profiles via API for Stripe BACS Direct Debit](../../doc/controllers/payment-profiles.md#create-payment-profile) - -+ [Full documentation on Stripe Direct Debit](https://maxio.zendesk.com/hc/en-us/articles/24176170430093-Stripe-SEPA-and-BECS-Direct-Debit) - -+ [Using Chargify.js with Stripe SEPA, BECS or BACS Direct Debit - minimal example](https://docs.maxio.com/hc/en-us/articles/38206331271693-Examples#h_01K0PJ15QQFKKN8Z7B7DZ9AJS5) - -+ [Using Chargify.js with Stripe BACS Direct Debit - full example](https://docs.maxio.com/hc/en-us/articles/38206331271693-Examples#h_01K0PJ15QR7PA1DJ3XE9MD05FM) - -```json -{ - "subscription": { - "product_handle": "gold-product", - "customer_attributes": { - "first_name": "Jane", - "last_name": "Doe", - "email": "jd@chargify.test" - }, - "bank_account_attributes": { - "bank_name": "Test Bank", - "bank_branch_code": "108800", - "bank_account_number": "00012345", - "payment_type": "bank_account", - "billing_address": "123 Main St.", - "billing_city": "London", - "billing_state": "LND", - "billing_zip": "W1A 1AA", - "billing_country": "GB" - } - } -} -``` - -## 3D Secure - Stripe - -It may happen that a payment needs 3D Secure Authentication when the subscription is created; this is referred to in our help docs as a [post-authentication flow](https://maxio.zendesk.com/hc/en-us/articles/24176278996493-Testing-Implementing-3D-Secure#psd2-flows-pre-authentication-and-post-authentication). The server returns `422 Unprocessable Entity` in this case with the following response: - -```json -{ - "errors": [ - "Your card was declined. This transaction requires 3D secure authentication." - ], - "gateway_payment_id": "pi_1F0aGoJ2UDb3Q4av7zU3sHPh", - "description": "This card requires 3D secure authentication. Redirect the customer to the URL from the action_link attribute to authenticate. Attach callback_url param to this URL if you want to be notified about the result of 3D Secure authentication. Attach redirect_url param to this URL if you want to redirect a customer back to your page after 3D Secure authentication. Example: https://mysite.chargify.com/3d-secure/pi_1FCm4RKDeye4C0XfbqquXRYm?one_time_token_id=128&callback_url=https://localhost:4000&redirect_url=https://yourpage.com will do a POST request to https://localhost:4000 after payment is authenticated and will redirect a customer to https://yourpage.com after 3DS authentication.", - "action_link": "http://acme.chargify.com/3d-secure/pi_1F0aGoJ2UDb3Q4av7zU3sHPh?one_time_token_id=242" -} -``` - -To let the customer go through 3D Secure Authentication, they need to be redirected to the URL specified in `action_link`. -Optionally, you can specify `callback_url` parameter in the `action_link` URL if you’d like to be notified about the result of 3D Secure Authentication. The `callback_url` will return the following information: - -- whether the authentication was successful (`success`) -- the gateway ID for the payment (`gateway_payment_id`) -- the subscription ID (`subscription_id`) - -Lastly, you can also specify a `redirect_url` within the `action_link` URL if you’d like to redirect a customer back to your site. - -It is not possible to use `action_link` in an iframe inside a custom application. You have to redirect the customer directly to the `action_link`, then, to be notified about the result, use `redirect_url` or `callback_url`. - -The final URL that you send a customer to to complete 3D Secure may resemble the following, where the first half is the `action_link` and the second half contains a `redirect_url` and `callback_url`: `https://mysite.chargify.com/3d-secure/pi_1FCm4RKDeye4C0XfbqquXRYm?one_time_token_id=128&callback_url=https://localhost:4000&redirect_url=https://yourpage.com` - -## 3D Secure - Checkout - -It may happen that a payment needs 3D Secure Authentication when the subscription is created; this is referred to in our help docs as a [post-authentication flow](https://maxio.zendesk.com/hc/en-us/articles/24176278996493-Testing-Implementing-3D-Secure#psd2-flows-pre-authentication-and-post-authentication). The server returns `422 Unprocessable Entity` in this case with the following response: - -```json -{ - "errors": [ - "Your card was declined. This transaction requires 3D secure authentication." - ], - "gateway_payment_id": "pay_6gjofv7dlyrkpizlolsuspvtiu", - "description": "This card requires 3D secure authentication. Redirect the customer to the URL from the action_link attribute to authenticate. Attach callback_url param to this URL if you want to be notified about the result of 3D Secure authentication. Attach redirect_url param to this URL if you want to redirect a customer back to your page after 3D Secure authentication. Example: https://mysite.chargify.com/3d-secure/pay_6gjofv7dlyrkpizlolsuspvtiu?one_time_token_id=123&callback_url=https://localhost:4000&redirect_url=https://yourpage.com will do a POST request to https://localhost:4000 after payment is authenticated and will redirect a customer to https://yourpage.com after 3DS authentication.", - "action_link": "http://mysite.chargify.com/3d-secure/pay_6gjofv7dlyrkpizlolsuspvtiu?one_time_token_id=123" -} -``` - -To let the customer go through 3D Secure Authentication, they need to be redirected to the URL specified in `action_link`. -Optionally, you can specify `callback_url` parameter in the `action_link` URL if you’d like to be notified about the result of 3D Secure Authentication. The `callback_url` will return the following information: - -- whether the authentication was successful (`success`) -- the gateway ID for the payment (`gateway_payment_id`) -- the subscription ID (`subscription_id`) - -Lastly, you can also specify a `redirect_url` parameter within the `action_link` URL if you’d like to redirect a customer back to your site. - -It is not possible to use `action_link` in an iframe inside a custom application. You have to redirect the customer directly to the `action_link`, then, to be notified about the result, use `redirect_url` or `callback_url`. - -The final URL that you send a customer to complete 3D Secure may resemble the following, where the first half is the `action_link` and the second half contains a `redirect_url` and `callback_url`: `https://mysite.chargify.com/3d-secure/pay_6gjofv7dlyrkpizlolsuspvtiu?one_time_token_id=123&callback_url=https://localhost:4000&redirect_url=https://yourpage.com` - -### Example Redirect Flow - -You may wish to redirect customers to different pages depending on whether their SCA was performed successfully. Here's an example flow to use as a reference: - -1. Create a subscription via API; it requires 3DS -2. You receive a `gateway_payment_id` in the `action_link` along other params in the response. -3. Use this `gateway_payment_id` to, for example, connect with your internal resources or generate a session_id -4. Include 1 of those attributes inside the `callback_url` and `redirect_url` to be aware which “session” this applies to -5. Redirect the customer to the `action_link` with `callback_url` and `redirect_url` applied -6. After the customer finishes 3DS authentication, we let you know the result by making a request to applied `callback_url`. -7. After that, we redirect the customer to the `redirect_url`; at this point the result of authentication is known -8. Optionally, you can use the applied "msg" param in the `redirect_url` to determine whether it was successful or not - -## Subscriptions Import - -Subscriptions can be “imported” via the API to handle the following scenarios: - -+ You already have existing subscriptions with specific start and renewal dates that you would like to import to Advanced Billing -+ You already have credit cards stored in your provider’s vault and you would like to create subscriptions using those tokens - -Before importing, you should have already set up your products to match your offerings. Then, you can create Subscriptions via the API just like you normally would, but using a few special attributes. - -Full documentation on how import Subscriptions using the **import tool** in the Advanced Billing UI can be located [here](https://maxio.zendesk.com/hc/en-us/articles/24251489107213-Imports). - -### Important Notices and Disclaimers regarding Imports - -Before performing a bulk import of subscriptions via the API, we suggest reading the [Subscriptions Import](https://maxio.zendesk.com/hc/en-us/articles/24251489107213-Imports) instructions to understand the repurcussions of a large import. - -### Subscription Input Attributes - -The following _additional_ attributes to the subscription input attributes make imports possible: `next_billing_at`, `previous_billing_at`, and `import_mrr`. - -### Current Vault - -If you are using a Legacy gateway such as "eWAY Rapid (Legacy)" or "Stripe (Legacy)" then please contact Support for further instructions on subscription imports. - -### Braintree Blue (Braintree v2) Imports - -Braintree Blue is Braintree’s newer (version 2) API. For this gateway, please provide the `vault_token` parameter with the value from Braintree’s “Customer ID” rather than the “Payment Profile Token”. At this time we do not use `current_vault_token` with the Braintree Blue gateway, and we only support a single payment profile per Braintree Customer. - -When importing PayPal type payment profiles, please set `payment_type` to `paypal_account`. - -### Stripe ACH Imports - -If the bank account has already been verified, currently you will need to create the customer, create the payment profile in Advanced Billing - setting verified=true, then create a subscription using the customer_id and payment_profile_id. - -### Webhooks During Import - -If no `next_billing_at` is provided, webhooks will be fired as normal. If you do set a future `next_billing_at`, only a subset of the webhooks are fired when the subscription is created. Keep reading for more information as to what webhooks will be fired under which scenarios. - -#### Successful creation with Billing Date - -Scenario: If `next_billing_at` provided - -+ `signup_success` -+ `billing_date_change` - -#### Successful creation without Billing Date - -Scenario: If no `next_billing_at` provided - -+ `signup_success` -+ `payment_success` - -#### Unsuccessful creation - -Scenario: If card can’t be charged, and no `next_billing_at` provided - -+ signup_failure - -#### Webhooks fired when next_billing_at is reached: - -+ `renewal_success or renewal_failure` -+ `payment_success or payment_failure` - -### Date and Time Formats - -We will attempt to parse any string you send as the value of next_billing_at in to a date or time. For best results, use a known format like described in “Date and Time Specification” of RFC 2822 or ISO 8601 . - -The following are all equivalent and will work as input to `next_billing_at`: - -``` -Aug 06 2030 11:34:00 -0400 -Aug 06 2030 11:34 -0400 -2030-08-06T11:34:00-04:00 -8/6/2030 11:34:00 EDT -8/6/2030 8:34:00 PDT -2030-08-06T15:34:00Z -``` - -You may also pass just a date, in which case we will assume the time to be noon - -``` -2010-08-06 -``` - -## Subscription Hierarchies & WhoPays - -When subscription groups were first added to our Relationship Invoicing architecture, to group together invoices for related subscriptions and allow for complex customer hierarchies and WhoPays scenarios, they were designed to consist of a primary and a collection of group members. The primary would control many aspects of the group, such as when the consolidated invoice is generated. As of today, groups still function this way. - -In the future, the concept of a "primary" will be removed in order to offer more flexibility into group management and reduce confusion concerning what actions must be done on a primary level, rather than a member level. - -We have introduced a two scheme system as a bridge between these two group organizations. Scheme 1, which is relevant to all subscription groups today, marks the group as being "ruled" by a primary. - -When reading a subscription via API, they will return a top-level attribute called `group`, which will denote which scheme is being used. At this time, the `scheme` attribute will always be 1. - -### Subscription in a Customer Hierarchy - -For sites making use of the [Relationship Billing](https://maxio.zendesk.com/hc/en-us/articles/24252287829645-Advanced-Billing-Invoices-Overview) and [Customer Hierarchy](https://maxio.zendesk.com/hc/en-us/articles/24252185211533-Customer-Hierarchies-WhoPays) features, it is possible to create subscriptions within a customer hierarchy. This can be achieved through the API by passing group parameters in the **Create Subscription** request. - -+ The `group` parameters are optional and consist of the required `target` and optional `billing` parameters. - -When the `target` parameter specifies a customer that is already part of a hierarchy, the new subscription will become a member of the customer hierarchy as well. If the target customer is not part of a hierarchy, a new customer hierarchy will be created and both the target customer and the new subscription will become part of the hierarchy with the specified target customer set as the responsible payer for the hierarchy's subscriptions. - -Rather than specifying a customer, the `target` parameter could instead simply have a value of `self` which indicates the subscription will be paid for not by some other customer, but by the subscribing customer. This will be true whether the customer is being created new, is already part of a hierarchy, or already exists outside a hierarchy. A valid payment method must also be specified in the subscription parameters. - -Note that when creating subscriptions in a customer hierarchy, if the customer hierarchy does not already have a payment method, passing valid credit card attributes in the subscription parameters will also result in the payment method being established as the default payment method for the customer hierarchy irrespective of the responsible payer. - -The optional `billing` parameters specify how some aspects of the billing for the new subscription should be handled. Rather than capturing payment immediately, the `accrue` parameter can be included so that the new subscription charges accrue until the next assessment date. Regarding the date, the `align_date` parameter can be included so that the billing date of the new subscription matches up with the default subscription group in the customer hierarchy. When choosing to align the dates, the `prorate` parameter can also be specified so that the new subscription charges are prorated based on the billing period of the default subscription group in the customer hierarchy also. - -### Subscription in a Subscription Group - -For sites making use of [Relationship Billing](https://maxio.zendesk.com/hc/en-us/articles/24252287829645-Advanced-Billing-Invoices-Overview) it may be desireable to create a subscription as part of a [subscription group](https://maxio.zendesk.com/hc/en-us/articles/24252172565005-Subscription-Groups-Overview) in order to rely on [invoice consolidation](https://maxio.zendesk.com/hc/en-us/articles/24252269909389-Invoice-Consolidation). This can be achieved through the API by passing group parameters in the Create Subscription request. The `group` parameters are optional and consist of the required `target` and optional `billing` parameters. - -The `target` parameters specify an existing subscription with which the newly created subscription should be grouped. If the target subscription is already part of a group, the new subscription will become a member of the group as well. If the target subscription is not part of a group, a new group will be created and both the target and the new subscription will become part of the group with the target as the group's primary subscription. - -The optional `billing` parameters specify how some aspects of the billing for the new subscription should be handled. Rather than capturing payment immediately, the `accrue` parameter can be included so that the new subscription charges accrue until the next assessment date. Regarding the date, the `align_date` parameter can be included so that the billing date of the new subscription matches up with the target subscription. When choosing to align the dates, the `prorate` parameter can also be specified so that the new subscription charges are prorated based on the billing period of the target subscription also. - -## Providing Agreement Acceptance Params - -It is possible to provide a proof of customer's acceptance of terms and policies. -We will be storing this proof in case it might be required (i.e. chargeback). -Currently, we already keep it for subscriptions created via Public Signup Pages. -In order to create a subscription with the proof of agreement acceptance, you must provide additional parameters `agreement acceptance` with `ip_address` and at least one url to the policy that was accepted: `terms_url` or `privacy_policy_url`. Additional urls that can be provided: `return_refund_policy_url`, `delivery_policy_url` and -`secure_checkout_policy_url`. - -```json - "subscription": { - "product_handle": "gold-product", - "customer_attributes": { - "first_name": "Jane", - "last_name": "Doe", - "email": "jd@chargify.test" - }, - "agreement_acceptance": { - "ip_address": "1.2.3.4", - "terms_url": "https://terms.url", - "privacy_policy_url": "https://privacy_policy.url", - "return_refund_policy_url": "https://return_refund_policy.url", - "delivery_policy_url": "https://delivery_policy.url", - "secure_checkout_policy_url": "https://secure_checkout_policy.url" - } - } -} -``` - -**For Maxio Payments subscriptions, the agreement acceptance params are required, with at least terms_url provided.** - -## Providing ACH Agreement params - -It is also possible to provide a proof that a customer authorized ACH agreement terms. -The proof will be stored and the email will be sent to the customer with a copy of the terms (if enabled). -In order to create a subscription with the proof of authorized ACH agreement terms, you must provide the additional parameter `ach_agreement` with the following nested parameters: `agreement_terms`, `authorizer_first_name`, `authorizer_last_name` and `ip_address`. -Each of them is required. - -```json - "subscription": { - "product_handle": "gold-product", - "customer_attributes": { - "first_name": "Jane", - "last_name": "Doe", - "email": "jd@chargify.test" - }, - "bank_account_attributes": { - "bank_name": "Test Bank", - "bank_routing_number": "021000089", - "bank_account_number": "111111111111", - "bank_account_type": "checking", - "bank_account_holder_type": "business", - "payment_type": "bank_account" - }, - "ach_agreement": { - "agreement_terms": "ACH agreement terms", - "authorizer_first_name": "Jane", - "authorizer_last_name": "Doe", - "ip_address": "1.2.3.4" - } - } -``` +See the [Subscription Signups](page:introduction/basic-concepts/subscription-signup) article for more information on working with subscriptions in Advanced Billing. ```ts async createSubscription( @@ -672,7 +69,7 @@ const body: CreateSubscriptionRequest = { paymentCollectionMethod: CollectionMethod.Remittance, customerAttributes: { firstName: 'Joe', - lastName: 'Blow', + lastName: 'Smith', email: 'joe@example.com', organization: 'Acme', reference: 'XYZ', @@ -688,13 +85,25 @@ const body: CreateSubscriptionRequest = { }; try { - const { result, ...httpResponse } = await subscriptionsController.createSubscription(body); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await subscriptionsController.createSubscription(body); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -928,7 +337,7 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The ```ts const collect = { - page: 2, + page: 1, perPage: 50, startDate: '2022-07-01', endDate: '2022-08-01', @@ -941,13 +350,25 @@ const collect = { } try { - const { result, ...httpResponse } = await subscriptionsController.listSubscriptions(collect); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await subscriptionsController.listSubscriptions(collect); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -955,47 +376,55 @@ try { # Update Subscription -The subscription endpoint allows you to instantly update one or many attributes about a subscription in a single call. +Updates one or more attributes of a subscription. ## Update Subscription Payment Method -Change the card that your Subscriber uses for their subscription. You can also use this method to simply change the expiration date of the card **if your gateway allows**. +Change the card that your subscriber uses for their subscription. You can also use this method to change the expiration date of the card **if your gateway allows**. + +Do not use real card information for testing. See the Sites articles that cover [testing your site setup](https://docs.maxio.com/hc/en-us/articles/24250712113165-Testing-Overview#testing-overview-0-0) for more details on testing in your sandbox. + +Note that collecting and sending raw card details in production requires [PCI compliance](https://docs.maxio.com/hc/en-us/articles/24183956938381-PCI-Compliance#pci-compliance-0-0) on your end. If your business is not PCI compliant, use [Chargify.js](https://docs.maxio.com/hc/en-us/articles/38163190843789-Chargify-js-Overview#chargify-js-overview-0-0) to collect credit card or bank account information. -Note that partial card updates for **Authorize.Net** are not allowed via this endpoint. The existing Payment Profile must be directly updated instead. +> Note: Partial card updates for **Authorize.Net** are not allowed via this endpoint. The existing Payment Profile must be directly updated instead. + +## Update Product You also use this method to change the subscription to a different product by setting a new value for product_handle. A product change can be done in two different ways, **product change** or **delayed product change**. -## Product Change +### Product Change -This endpoint may be used to change a subscription's product. The new payment amount is calculated and charged at the normal start of the next period. If you desire complex product changes or prorated upgrades and downgrades instead, please see the documentation on Migrating Subscription Products. +You can change a subscription's product. The new payment amount is calculated and charged at the normal start of the next period. If you require complex product changes or prorated upgrades and downgrades instead, please see the documentation on [Migrating Subscription Products](https://docs.maxio.com/hc/en-us/articles/24252069837581-Product-Changes-and-Migrations#product-changes-and-migrations-0-0). -To perform a product change, simply set either the `product_handle` or `product_id` attribute to that of a different product from the same site as the subscription. You can also change the price point by passing in either `product_price_point_id` or `product_price_point_handle` - otherwise the new product's default price point will be used. +To perform a product change, set either the `product_handle` or `product_id` attribute to that of a different product from the same site as the subscription. You can also change the price point by passing in either `product_price_point_id` or `product_price_point_handle` - otherwise the new product's default price point is used. ### Delayed Product Change This method also changes the product and/or price point, and the new payment amount is calculated and charged at the normal start of the next period. -This method schedules the product change to happen automatically at the subscription’s next renewal date. To perform a Delayed Product Change, set the `product_handle` attribute as you would in a regular product change, but also set the `product_change_delayed` attribute to `true`. No proration applies in this case. +This method schedules the product change to happen automatically at the subscription’s next renewal date. To perform a delayed product change, set the `product_handle` attribute as you would in a regular product change, but also set the `product_change_delayed` attribute to `true`. No proration applies in this case. You can also perform a delayed change to the price point by passing in either `product_price_point_id` or `product_price_point_handle` -**Note: To cancel a delayed product change, set `next_product_id` to an empty string.** +> **Note:** To cancel a delayed product change, set `next_product_id` to an empty string. ## Billing Date Changes +You can update dates for a subscrption. + ### Regular Billing Date Changes Send the `next_billing_at` to set the next billing date for the subscription. After that date passes and the subscription is processed, the following billing date will be set according to the subscription's product period. -Note that if you pass an invalid date, we will automatically interpret and set the correct date. For example, when February 30 is entered, the next billing will be set to March 2nd in a non-leap year. +> Note: If you pass an invalid date, the correct date is automatically set to he correct date. For example, if February 30 is passed, the next billing would be set to March 2nd in a non-leap year. -The server response will not return data under the key/value pair of `next_billing`. Please view the key/value pair of `current_period_ends_at` to verify that the `next_billing` date has been changed successfully. +The server response will not return data under the key/value pair of `next_billing_at`. View the key/value pair of `current_period_ends_at` to verify that the `next_billing_at` date has been changed successfully. -### Snap Day Changes +### Calendar Billing and Snap Day Changes For a subscription using Calendar Billing, setting the next billing date is a bit different. Send the `snap_day` attribute to change the calendar billing date for **a subscription using a product eligible for calendar billing**. -Note: If you change the product associated with a subscription that contains a `snap_date` and immediately `READ/GET` the subscription data, it will still contain evidence of the existing `snap_date`. This is due to the fact that a product change is instantanous and only affects the product associated with a subscription. After the `next_billing` date arrives, the `snap_day` associated with the subscription will return to `null.` Another way of looking at this is that you willl have to wait for the next billing cycle to arrive before the `snap_date` will reset to `null`. +> Note: If you change the product associated with a subscription that contains a `snap_day` and immediately `READ/GET` the subscription data, it will still contain original `snap_day`. The `snap_day`will will reset to 'null on the next billing cycle. This is because a product change is instantanous and only affects the product associated with a subscription. ```ts async updateSubscription( @@ -1030,16 +459,28 @@ const body: UpdateSubscriptionRequest = { }; try { - const { result, ...httpResponse } = await subscriptionsController.updateSubscription( + const response = await subscriptionsController.updateSubscription( subscriptionId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -1200,16 +641,28 @@ const include: SubscriptionInclude[] = [ ]; try { - const { result, ...httpResponse } = await subscriptionsController.readSubscription( + const response = await subscriptionsController.readSubscription( subscriptionId, include ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -1411,16 +864,28 @@ const body: OverrideSubscriptionRequest = { }; try { - const { result, ...httpResponse } = await subscriptionsController.overrideSubscription( + const response = await subscriptionsController.overrideSubscription( subscriptionId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -1458,13 +923,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The ```ts try { - const { result, ...httpResponse } = await subscriptionsController.findSubscription(); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await subscriptionsController.findSubscription(); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -1482,7 +959,7 @@ For sites in test mode, you may purge individual subscriptions. Provide the subscription ID in the url. To confirm, supply the customer ID in the query string `ack` parameter. You may also delete the customer record and/or payment profiles by passing `cascade` parameters. For example, to delete just the customer record, the query params would be: `?ack={customer_id}&cascade[]=customer` -If you need to remove subscriptions from a live site, please contact support to discuss your use case. +If you need to remove subscriptions from a live site, contact support to discuss your use case. ### Delete customer and payment profile @@ -1523,17 +1000,29 @@ const cascade: SubscriptionPurgeType[] = [ ]; try { - const { result, ...httpResponse } = await subscriptionsController.purgeSubscription( + const response = await subscriptionsController.purgeSubscription( subscriptionId, ack, cascade ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -1584,16 +1073,28 @@ const body: UpsertPrepaidConfigurationRequest = { }; try { - const { result, ...httpResponse } = await subscriptionsController.updatePrepaidSubscriptionConfiguration( + const response = await subscriptionsController.updatePrepaidSubscriptionConfiguration( subscriptionId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -1627,7 +1128,7 @@ The "Next Billing" amount and "Next Billing" date are represented in each Subscr A subscription will not be created by utilizing this endpoint; it is meant to serve as a prediction. -For more information, please see our documentation [here](https://maxio.zendesk.com/hc/en-us/articles/24252493695757-Subscriber-Interface-Overview). +For more information, see our documentation [here](https://maxio.zendesk.com/hc/en-us/articles/24252493695757-Subscriber-Interface-Overview). ## Taxable Subscriptions @@ -1637,15 +1138,15 @@ This endpoint will preview taxes applicable to a purchase. In order for taxes to + The preview must be for the purchase of a taxable product or component, or combination of the two. + The subscription payload must contain a full billing or shipping address in order to calculate tax -For more information about creating taxable previews, please see our documentation guide on how to create [taxable subscriptions.](https://maxio.zendesk.com/hc/en-us/sections/24287012349325-Taxes) +For more information about creating taxable previews, see our documentation guide on how to create [taxable subscriptions.](https://maxio.zendesk.com/hc/en-us/sections/24287012349325-Taxes) -You do **not** need to include a card number to generate tax information when you are previewing a subscription. However, please note that when you actually want to create the subscription, you must include the credit card information if you want the billing address to be stored in Advanced Billing. The billing address and the credit card information are stored together within the payment profile object. Also, you may not send a billing address to Advanced Billing without payment profile information, as the address is stored on the card. +You do **not** need to include a card number to generate tax information when you are previewing a subscription. However, when you actually want to create the subscription, you must include the credit card information if you want the billing address to be stored in Advanced Billing. The billing address and the credit card information are stored together within the payment profile object. Also, you may not send a billing address to Advanced Billing without payment profile information, as the address is stored on the card. You can pass shipping and billing addresses and still decide not to calculate taxes. To do that, pass `skip_billing_manifest_taxes: true` attribute. ## Non-taxable Subscriptions -If you'd like to calculate subscriptions that do not include tax, please feel free to leave off the billing information. +If you'd like to calculate subscriptions that do not include tax you may leave off the billing information. ```ts async previewSubscription( @@ -1675,13 +1176,25 @@ const body: CreateSubscriptionRequest = { }; try { - const { result, ...httpResponse } = await subscriptionsController.previewSubscription(body); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await subscriptionsController.previewSubscription(body); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -1852,17 +1365,29 @@ const body: AddCouponsRequest = { }; try { - const { result, ...httpResponse } = await subscriptionsController.applyCouponsToSubscription( + const response = await subscriptionsController.applyCouponsToSubscription( subscriptionId, undefined, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -2028,7 +1553,7 @@ try { Use this endpoint to remove a coupon from an existing subscription. -For more information on the expected behaviour of removing a coupon from a subscription, please see our documentation [here.](https://maxio.zendesk.com/hc/en-us/articles/24261259337101-Coupons-and-Subscriptions#removing-a-coupon) +For more information on the expected behaviour of removing a coupon from a subscription, See our documentation [here.](https://maxio.zendesk.com/hc/en-us/articles/24261259337101-Coupons-and-Subscriptions#removing-a-coupon) ```ts async removeCouponFromSubscription( @@ -2056,13 +1581,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const subscriptionId = 222; try { - const { result, ...httpResponse } = await subscriptionsController.removeCouponFromSubscription(subscriptionId); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await subscriptionsController.removeCouponFromSubscription(subscriptionId); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -2152,13 +1689,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The const subscriptionId = 222; try { - const { result, ...httpResponse } = await subscriptionsController.activateSubscription(subscriptionId); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await subscriptionsController.activateSubscription(subscriptionId); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` diff --git a/doc/controllers/webhooks.md b/doc/controllers/webhooks.md index 55e0ae2..b306ac8 100644 --- a/doc/controllers/webhooks.md +++ b/doc/controllers/webhooks.md @@ -66,18 +66,30 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The ```ts const collect = { - page: 2, + page: 1, perPage: 50 } try { - const { result, ...httpResponse } = await webhooksController.listWebhooks(collect); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await webhooksController.listWebhooks(collect); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -152,13 +164,25 @@ const body: EnableWebhooksRequest = { }; try { - const { result, ...httpResponse } = await webhooksController.enableWebhooks(body); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await webhooksController.enableWebhooks(body); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -205,13 +229,25 @@ const body: ReplayWebhooksRequest = { }; try { - const { result, ...httpResponse } = await webhooksController.replayWebhooks(body); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await webhooksController.replayWebhooks(body); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -262,13 +298,25 @@ const body: CreateOrUpdateEndpointRequest = { }; try { - const { result, ...httpResponse } = await webhooksController.createEndpoint(body); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await webhooksController.createEndpoint(body); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -321,13 +369,25 @@ This method returns an [`ApiResponse`](../../doc/api-response.md) instance. The ```ts try { - const { result, ...httpResponse } = await webhooksController.listEndpoints(); - // Get more response info... - // const { statusCode, headers } = httpResponse; + const response = await webhooksController.listEndpoints(); + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` @@ -406,16 +466,28 @@ const body: CreateOrUpdateEndpointRequest = { }; try { - const { result, ...httpResponse } = await webhooksController.updateEndpoint( + const response = await webhooksController.updateEndpoint( endpointId, body ); - // Get more response info... - // const { statusCode, headers } = httpResponse; + + // Extracting fully parsed response body. + console.log(response.result); + + // Extracting response status code. + console.log(response.statusCode); + // Extracting response headers. + console.log(response.headers); + // Extracting response body of type `string | Stream` + console.log(response.body); } catch (error) { if (error instanceof ApiError) { - const errors = error.result; - // const { statusCode, headers } = error; + // Extracting response error status code. + console.log(error.statusCode); + // Extracting response error headers. + console.log(error.headers); + // Extracting response error body of type `string | Stream`. + console.log(error.body); } } ``` diff --git a/doc/models/activate-event-based-component.md b/doc/models/activate-event-based-component.md index 9329404..170e7e7 100644 --- a/doc/models/activate-event-based-component.md +++ b/doc/models/activate-event-based-component.md @@ -10,7 +10,7 @@ | Name | Type | Tags | Description | | --- | --- | --- | --- | | `pricePointId` | `number \| undefined` | Optional | The Chargify id of the price point | -| `billingSchedule` | [`BillingSchedule \| undefined`](../../doc/models/billing-schedule.md) | Optional | This attribute is particularly useful when you need to align billing events for different components on distinct schedules within a subscription. Please note this only works for site with Multifrequency enabled | +| `billingSchedule` | [`BillingSchedule \| undefined`](../../doc/models/billing-schedule.md) | Optional | This attribute is particularly useful when you need to align billing events for different components on distinct schedules within a subscription. This only works for site with Multifrequency enabled. | | `customPrice` | [`ComponentCustomPrice \| undefined`](../../doc/models/component-custom-price.md) | Optional | Create or update custom pricing unique to the subscription. Used in place of `price_point_id`. | ## Example (as JSON) @@ -37,7 +37,8 @@ "ending_quantity": 40, "unit_price": 23.26 } - ] + ], + "renew_prepaid_allocation": false } } ``` diff --git a/doc/models/billing-schedule.md b/doc/models/billing-schedule.md index e06d4d8..a82b3a4 100644 --- a/doc/models/billing-schedule.md +++ b/doc/models/billing-schedule.md @@ -1,7 +1,7 @@ # Billing Schedule -This attribute is particularly useful when you need to align billing events for different components on distinct schedules within a subscription. Please note this only works for site with Multifrequency enabled +This attribute is particularly useful when you need to align billing events for different components on distinct schedules within a subscription. This only works for site with Multifrequency enabled. ## Structure diff --git a/doc/models/bulk-create-product-price-points-request.md b/doc/models/bulk-create-product-price-points-request.md index 6738245..4467975 100644 --- a/doc/models/bulk-create-product-price-points-request.md +++ b/doc/models/bulk-create-product-price-points-request.md @@ -26,7 +26,7 @@ "trial_price_in_cents": 196, "trial_interval": 250, "trial_interval_unit": "day", - "trial_type": "trial_type6" + "trial_type": "no_obligation" } ] } diff --git a/doc/models/calendar-billing.md b/doc/models/calendar-billing.md index 8bea8c8..52f66f5 100644 --- a/doc/models/calendar-billing.md +++ b/doc/models/calendar-billing.md @@ -11,14 +11,14 @@ | Name | Type | Tags | Description | | --- | --- | --- | --- | -| `snapDay` | [`CalendarBillingSnapDay \| undefined`](../../doc/models/containers/calendar-billing-snap-day.md) | Optional | This is a container for one-of cases. | +| `snapDay` | [`CalendarBillingSnapDay \| null \| undefined`](../../doc/models/containers/calendar-billing-snap-day.md) | Optional | This is a container for one-of cases. | | `calendarBillingFirstCharge` | [`FirstChargeType \| undefined`](../../doc/models/first-charge-type.md) | Optional | - | ## Example (as JSON) ```json { - "snap_day": 210, + "snap_day": 28, "calendar_billing_first_charge": "prorated" } ``` diff --git a/doc/models/chargify-ebb.md b/doc/models/chargify-ebb.md index 9892813..7c3be83 100644 --- a/doc/models/chargify-ebb.md +++ b/doc/models/chargify-ebb.md @@ -10,8 +10,8 @@ | Name | Type | Tags | Description | | --- | --- | --- | --- | | `timestamp` | `string \| undefined` | Optional | This timestamp determines what billing period the event will be billed in. If your request payload does not include it, Chargify will add `chargify.timestamp` to the event payload and set the value to `now`. | -| `id` | `string \| undefined` | Optional | A unique ID set by Chargify. Please note that this field is reserved. If `chargify.id` is present in the request payload, it will be overwritten. | -| `createdAt` | `string \| undefined` | Optional | An ISO-8601 timestamp, set by Chargify at the time each event is recorded. Please note that this field is reserved. If `chargify.created_at` is present in the request payload, it will be overwritten. | +| `id` | `string \| undefined` | Optional | A unique ID set by Chargify. This field is reserved. If `chargify.id` is present in the request payload, it will be overwritten. | +| `createdAt` | `string \| undefined` | Optional | An ISO-8601 timestamp, set by Chargify at the time each event is recorded. This field is reserved. If `chargify.created_at` is present in the request payload, it will be overwritten. | | `uniquenessToken` | `string \| undefined` | Optional | User-defined string scoped per-stream. Duplicate events within a stream will be silently ignored. Tokens expire after 31 days.

**Constraints**: *Maximum Length*: `64` | | `subscriptionId` | `number \| undefined` | Optional | Id of Maxio Advanced Billing Subscription which is connected to this event.
Provide `subscription_id` if you configured `chargify.subscription_id` as Subscription Identifier in your Event Stream. | | `subscriptionReference` | `string \| undefined` | Optional | Reference of Maxio Advanced Billing Subscription which is connected to this event.
Provide `subscription_reference` if you configured `chargify.subscription_reference` as Subscription Identifier in your Event Stream. | diff --git a/doc/models/component-custom-price.md b/doc/models/component-custom-price.md index 3bc5780..277aaab 100644 --- a/doc/models/component-custom-price.md +++ b/doc/models/component-custom-price.md @@ -16,6 +16,10 @@ Create or update custom pricing unique to the subscription. Used in place of `pr | `interval` | `number \| undefined` | Optional | The numerical interval. i.e. an interval of ‘30’ coupled with an interval_unit of day would mean this component price point would renew every 30 days. This property is only available for sites with Multifrequency enabled. | | `intervalUnit` | [`IntervalUnit \| null \| undefined`](../../doc/models/interval-unit.md) | Optional | A string representing the interval unit for this component price point, either month or day. This property is only available for sites with Multifrequency enabled. | | `prices` | [`Price[]`](../../doc/models/price.md) | Required | On/off components only need one price bracket starting at 1 | +| `renewPrepaidAllocation` | `boolean \| undefined` | Optional | Applicable only to prepaid usage components. Controls whether the allocated quantity renews each period. | +| `rolloverPrepaidRemainder` | `boolean \| undefined` | Optional | Applicable only to prepaid usage components. Controls whether remaining units roll over to the next period. | +| `expirationInterval` | `number \| null \| undefined` | Optional | Applicable only when rollover is enabled. Number of `expiration_interval_unit`s after which rollover amounts expire. | +| `expirationIntervalUnit` | [`ExpirationIntervalUnit \| null \| undefined`](../../doc/models/expiration-interval-unit.md) | Optional | Applicable only when rollover is enabled. Interval unit for rollover expiration (month or day). | ## Example (as JSON) @@ -31,7 +35,8 @@ Create or update custom pricing unique to the subscription. Used in place of `pr "tax_included": false, "pricing_scheme": "stairstep", "interval": 162, - "interval_unit": "day" + "interval_unit": "day", + "renew_prepaid_allocation": false } ``` diff --git a/doc/models/component.md b/doc/models/component.md index 7807c44..8a49425 100644 --- a/doc/models/component.md +++ b/doc/models/component.md @@ -21,7 +21,6 @@ | `pricePerUnitInCents` | `bigint \| null \| undefined` | Optional | deprecated - use unit_price instead | | `kind` | [`ComponentKind \| undefined`](../../doc/models/component-kind.md) | Optional | A handle for the component type | | `archived` | `boolean \| undefined` | Optional | Boolean flag describing whether a component is archived or not. | -| `taxable` | `boolean \| undefined` | Optional | Boolean flag describing whether a component is taxable or not. | | `description` | `string \| null \| undefined` | Optional | The description of the component. | | `defaultPricePointId` | `number \| null \| undefined` | Optional | - | | `overagePrices` | [`ComponentPrice[] \| null \| undefined`](../../doc/models/component-price.md) | Optional | Applicable only to prepaid usage components. An array of overage price brackets. | @@ -29,7 +28,8 @@ | `pricePointCount` | `number \| undefined` | Optional | Count for the number of price points associated with the component | | `pricePointsUrl` | `string \| null \| undefined` | Optional | URL that points to the location to read the existing price points via GET request | | `defaultPricePointName` | `string \| undefined` | Optional | - | -| `taxCode` | `string \| null \| undefined` | Optional | A string representing the tax code related to the component type. This is especially important when using the Avalara service to tax based on locale. This attribute has a max length of 10 characters. | +| `taxable` | `boolean \| undefined` | Optional | Boolean flag describing whether a component is taxable or not. | +| `taxCode` | `string \| null \| undefined` | Optional | A string representing the tax code related to the component type. This is especially important when using AvaTax to tax based on locale. This attribute has a max length of 25 characters. | | `recurring` | `boolean \| undefined` | Optional | - | | `upgradeCharge` | [`CreditType \| null \| undefined`](../../doc/models/credit-type.md) | Optional | The type of credit to be created when upgrading/downgrading. Defaults to the component and then site setting if one is not provided.
Available values: `full`, `prorated`, `none`. | | `downgradeCredit` | [`CreditType \| null \| undefined`](../../doc/models/credit-type.md) | Optional | The type of credit to be created when upgrading/downgrading. Defaults to the component and then site setting if one is not provided.
Available values: `full`, `prorated`, `none`. | diff --git a/doc/models/containers/calendar-billing-snap-day.md b/doc/models/containers/calendar-billing-snap-day.md index d45b10c..62b5c39 100644 --- a/doc/models/containers/calendar-billing-snap-day.md +++ b/doc/models/containers/calendar-billing-snap-day.md @@ -10,5 +10,5 @@ | Type | | --- | | `number` | -| `string` | +| [`SnapDay`](../../../doc/models/snap-day.md) | diff --git a/doc/models/containers/subscription-snap-day.md b/doc/models/containers/subscription-snap-day.md new file mode 100644 index 0000000..9f6fb37 --- /dev/null +++ b/doc/models/containers/subscription-snap-day.md @@ -0,0 +1,14 @@ + +# Subscription Snap Day + +## Class Name + +`SubscriptionSnapDay` + +## Cases + +| Type | +| --- | +| `number` | +| [`SnapDay`](../../../doc/models/snap-day.md) | + diff --git a/doc/models/containers/update-subscription-snap-day.md b/doc/models/containers/update-subscription-snap-day.md index 857df6c..65ec627 100644 --- a/doc/models/containers/update-subscription-snap-day.md +++ b/doc/models/containers/update-subscription-snap-day.md @@ -9,6 +9,6 @@ | Type | | --- | -| [`SnapDay`](../../../doc/models/snap-day.md) | | `number` | +| [`SnapDay`](../../../doc/models/snap-day.md) | diff --git a/doc/models/create-allocation.md b/doc/models/create-allocation.md index 270cfd6..312e6fe 100644 --- a/doc/models/create-allocation.md +++ b/doc/models/create-allocation.md @@ -19,7 +19,7 @@ | `upgradeCharge` | [`CreditType \| null \| undefined`](../../doc/models/credit-type.md) | Optional | The type of credit to be created when upgrading/downgrading. Defaults to the component and then site setting if one is not provided.
Available values: `full`, `prorated`, `none`. | | `initiateDunning` | `boolean \| undefined` | Optional | If set to true, if the immediate component payment fails, initiate dunning for the subscription.
Otherwise, leave the charges on the subscription to pay for at renewal. Defaults to false. | | `pricePointId` | [`CreateAllocationPricePointId \| null \| undefined`](../../doc/models/containers/create-allocation-price-point-id.md) | Optional | This is a container for one-of cases. | -| `billingSchedule` | [`BillingSchedule \| undefined`](../../doc/models/billing-schedule.md) | Optional | This attribute is particularly useful when you need to align billing events for different components on distinct schedules within a subscription. Please note this only works for site with Multifrequency enabled | +| `billingSchedule` | [`BillingSchedule \| undefined`](../../doc/models/billing-schedule.md) | Optional | This attribute is particularly useful when you need to align billing events for different components on distinct schedules within a subscription. This only works for site with Multifrequency enabled. | ## Example (as JSON) diff --git a/doc/models/create-invoice-coupon.md b/doc/models/create-invoice-coupon.md index d36943c..ebb7cb4 100644 --- a/doc/models/create-invoice-coupon.md +++ b/doc/models/create-invoice-coupon.md @@ -10,6 +10,7 @@ | Name | Type | Tags | Description | | --- | --- | --- | --- | | `code` | `string \| undefined` | Optional | - | +| `subcode` | `string \| undefined` | Optional | - | | `percentage` | [`CreateInvoiceCouponPercentage \| undefined`](../../doc/models/containers/create-invoice-coupon-percentage.md) | Optional | This is a container for one-of cases. | | `amount` | [`CreateInvoiceCouponAmount \| undefined`](../../doc/models/containers/create-invoice-coupon-amount.md) | Optional | This is a container for one-of cases. | | `description` | `string \| undefined` | Optional | **Constraints**: *Maximum Length*: `255` | @@ -22,9 +23,9 @@ { "percentage": 50.0, "code": "code4", + "subcode": "subcode8", "amount": "String9", - "description": "description4", - "product_family_id": "String3" + "description": "description4" } ``` diff --git a/doc/models/create-invoice-item.md b/doc/models/create-invoice-item.md index 28a0ef3..624d9c2 100644 --- a/doc/models/create-invoice-item.md +++ b/doc/models/create-invoice-item.md @@ -12,8 +12,8 @@ | `title` | `string \| undefined` | Optional | - | | `quantity` | [`CreateInvoiceItemQuantity \| undefined`](../../doc/models/containers/create-invoice-item-quantity.md) | Optional | This is a container for one-of cases. | | `unitPrice` | [`CreateInvoiceItemUnitPrice \| undefined`](../../doc/models/containers/create-invoice-item-unit-price.md) | Optional | This is a container for one-of cases. | -| `taxable` | `boolean \| undefined` | Optional | Set to true to automatically calculate taxes. Site must be configured to use and calculate taxes.

If using Avalara, a tax_code parameter must also be sent. | -| `taxCode` | `string \| undefined` | Optional | - | +| `taxable` | `boolean \| undefined` | Optional | Set to true to automatically calculate taxes. Site must be configured to use and calculate taxes. If using AvaTax, a tax_code parameter must also be sent. | +| `taxCode` | `string \| undefined` | Optional | A string representing the tax code related to the product type. This is especially important when using AvaTax to tax based on locale. This attribute has a max length of 25 characters. | | `periodRangeStart` | `string \| undefined` | Optional | YYYY-MM-DD | | `periodRangeEnd` | `string \| undefined` | Optional | YYYY-MM-DD | | `productId` | [`CreateInvoiceItemProductId \| undefined`](../../doc/models/containers/create-invoice-item-product-id.md) | Optional | This is a container for one-of cases. | diff --git a/doc/models/create-metafield.md b/doc/models/create-metafield.md index 8576b28..94631d9 100644 --- a/doc/models/create-metafield.md +++ b/doc/models/create-metafield.md @@ -11,7 +11,7 @@ | --- | --- | --- | --- | | `name` | `string \| undefined` | Optional | - | | `scope` | [`MetafieldScope \| undefined`](../../doc/models/metafield-scope.md) | Optional | Warning: When updating a metafield's scope attribute, all scope attributes must be passed. Partially complete scope attributes will override the existing settings. | -| `inputType` | [`MetafieldInput \| undefined`](../../doc/models/metafield-input.md) | Optional | Indicates how data should be added to the metafield. For example, a text type is just a string, so a given metafield of this type can have any value attached. On the other hand, dropdown and radio have a set of allowed values that can be input, and appear differently on a Public Signup Page. Defaults to 'text' | +| `inputType` | [`MetafieldInput \| undefined`](../../doc/models/metafield-input.md) | Optional | Indicates the type of metafield. A text metafield allows any string value. Dropdown and radio metafields have a set of values that can be selected. Defaults to 'text'. | | `mEnum` | `string[] \| undefined` | Optional | Only applicable when input_type is radio or dropdown. Empty strings will not be submitted. | ## Example (as JSON) diff --git a/doc/models/create-or-update-product.md b/doc/models/create-or-update-product.md index d7d3a16..09cf274 100644 --- a/doc/models/create-or-update-product.md +++ b/doc/models/create-or-update-product.md @@ -13,18 +13,18 @@ | `handle` | `string \| undefined` | Optional | The product API handle | | `description` | `string` | Required | The product description | | `accountingCode` | `string \| undefined` | Optional | E.g. Internal ID or SKU Number | -| `requireCreditCard` | `boolean \| undefined` | Optional | Deprecated value that can be ignored unless you have legacy hosted pages. For Public Signup Page users, please read this attribute from under the signup page. | +| `requireCreditCard` | `boolean \| undefined` | Optional | Deprecated value that can be ignored unless you have legacy hosted pages. For Public Signup Page users, read this attribute from under the signup page. | | `priceInCents` | `bigint` | Required | The product price, in integer cents | | `interval` | `number` | Required | The numerical interval. i.e. an interval of ‘30’ coupled with an interval_unit of day would mean this product would renew every 30 days | | `intervalUnit` | [`IntervalUnit`](../../doc/models/interval-unit.md) | Required | A string representing the interval unit for this product, either month or day | | `trialPriceInCents` | `bigint \| undefined` | Optional | The product trial price, in integer cents | | `trialInterval` | `number \| undefined` | Optional | The numerical trial interval. i.e. an interval of ‘30’ coupled with a trial_interval_unit of day would mean this product trial would last 30 days. | | `trialIntervalUnit` | [`IntervalUnit \| null \| undefined`](../../doc/models/interval-unit.md) | Optional | A string representing the trial interval unit for this product, either month or day | -| `trialType` | `string \| undefined` | Optional | - | +| `trialType` | [`TrialType \| null \| undefined`](../../doc/models/trial-type.md) | Optional | Indicates how a trial is handled when the trail period ends and there is no credit card on file. For `no_obligation`, the subscription transitions to a Trial Ended state. Maxio will not send any emails or statements. For `payment_expected`, the subscription transitions to a Past Due state. Maxio will send normal dunning emails and statements according to your other settings. | | `expirationInterval` | `number \| undefined` | Optional | The numerical expiration interval. i.e. an expiration_interval of ‘30’ coupled with an expiration_interval_unit of day would mean this product would expire after 30 days. | | `expirationIntervalUnit` | [`ExpirationIntervalUnit \| null \| undefined`](../../doc/models/expiration-interval-unit.md) | Optional | A string representing the expiration interval unit for this product, either month, day or never | | `autoCreateSignupPage` | `boolean \| undefined` | Optional | - | -| `taxCode` | `string \| undefined` | Optional | A string representing the tax code related to the product type. This is especially important when using the Avalara service to tax based on locale. This attribute has a max length of 10 characters.

**Constraints**: *Maximum Length*: `10` | +| `taxCode` | `string \| undefined` | Optional | A string representing the tax code related to the product type. This is especially important when using AvaTax to tax based on locale. This attribute has a max length of 25 characters. | ## Example (as JSON) diff --git a/doc/models/create-payment-profile.md b/doc/models/create-payment-profile.md index 216c880..2539dbc 100644 --- a/doc/models/create-payment-profile.md +++ b/doc/models/create-payment-profile.md @@ -9,7 +9,7 @@ | Name | Type | Tags | Description | | --- | --- | --- | --- | -| `chargifyToken` | `string \| undefined` | Optional | Token received after sending billing informations using chargify.js. | +| `chargifyToken` | `string \| undefined` | Optional | Token received after sending billing information using chargify.js. | | `id` | `number \| undefined` | Optional | - | | `paymentType` | [`PaymentType \| undefined`](../../doc/models/payment-type.md) | Optional | - | | `firstName` | `string \| undefined` | Optional | First name on card or bank account. If omitted, the first_name from customer attributes will be used. | @@ -23,7 +23,7 @@ | `billingAddress2` | `string \| null \| undefined` | Optional | Second line of the customer’s billing address i.e. Apt. 100 | | `billingCity` | `string \| undefined` | Optional | The credit card or bank account billing address city (i.e. “Boston”). This value is merely passed through to the payment gateway. | | `billingState` | `string \| undefined` | Optional | The credit card or bank account billing address state (i.e. MA). This value is merely passed through to the payment gateway. This must conform to the [ISO_3166-1](https://en.wikipedia.org/wiki/ISO_3166-1#Current_codes) in order to be valid for tax locale purposes. | -| `billingCountry` | `string \| undefined` | Optional | The credit card or bank account billing address country, required in [ISO_3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) format (i.e. “US”). This value is merely passed through to the payment gateway. Some gateways require country codes in a specific format. Please check your gateway’s documentation. If creating an ACH subscription, only US is supported at this time. | +| `billingCountry` | `string \| undefined` | Optional | The credit card or bank account billing address country, required in [ISO_3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) format (i.e. “US”). This value is merely passed through to the payment gateway. Some gateways require country codes in a specific format. Check your gateway’s documentation. If creating an ACH subscription, only US is supported at this time. | | `billingZip` | `string \| undefined` | Optional | The credit card or bank account billing address zip code (i.e. 12345). This value is merely passed through to the payment gateway. | | `currentVault` | [`AllVaults \| undefined`](../../doc/models/all-vaults.md) | Optional | The vault that stores the payment profile with the provided `vault_token`. Use `bogus` for testing. | | `vaultToken` | `string \| undefined` | Optional | The “token” provided by your vault storage for an already stored payment profile | diff --git a/doc/models/create-product-price-point-request.md b/doc/models/create-product-price-point-request.md index 7af2cfb..857c48c 100644 --- a/doc/models/create-product-price-point-request.md +++ b/doc/models/create-product-price-point-request.md @@ -25,7 +25,7 @@ "trial_price_in_cents": 108, "trial_interval": 202, "trial_interval_unit": "day", - "trial_type": "trial_type4" + "trial_type": "no_obligation" } } ``` diff --git a/doc/models/create-product-price-point.md b/doc/models/create-product-price-point.md index b0d673d..0ffe27b 100644 --- a/doc/models/create-product-price-point.md +++ b/doc/models/create-product-price-point.md @@ -17,7 +17,7 @@ | `trialPriceInCents` | `bigint \| undefined` | Optional | The product price point trial price, in integer cents | | `trialInterval` | `number \| undefined` | Optional | The numerical trial interval. i.e. an interval of ‘30’ coupled with a trial_interval_unit of day would mean this product price point trial would last 30 days. | | `trialIntervalUnit` | [`IntervalUnit \| undefined`](../../doc/models/interval-unit.md) | Optional | A string representing the trial interval unit for this product price point, either month or day | -| `trialType` | `string \| undefined` | Optional | - | +| `trialType` | [`TrialType \| null \| undefined`](../../doc/models/trial-type.md) | Optional | Indicates how a trial is handled when the trail period ends and there is no credit card on file. For `no_obligation`, the subscription transitions to a Trial Ended state. Maxio will not send any emails or statements. For `payment_expected`, the subscription transitions to a Past Due state. Maxio will send normal dunning emails and statements according to your other settings. | | `initialChargeInCents` | `bigint \| undefined` | Optional | The product price point initial charge, in integer cents | | `initialChargeAfterTrial` | `boolean \| undefined` | Optional | - | | `expirationInterval` | `number \| undefined` | Optional | The numerical expiration interval. i.e. an expiration_interval of ‘30’ coupled with an expiration_interval_unit of day would mean this product price point would expire after 30 days. | @@ -37,7 +37,7 @@ "trial_price_in_cents": 48, "trial_interval": 102, "trial_interval_unit": "day", - "trial_type": "trial_type0" + "trial_type": "no_obligation" } ``` diff --git a/doc/models/create-usage-request.md b/doc/models/create-usage-request.md index 22f0850..b73791b 100644 --- a/doc/models/create-usage-request.md +++ b/doc/models/create-usage-request.md @@ -21,6 +21,25 @@ "memo": "memo2", "billing_schedule": { "initial_billing_at": "2016-03-13T12:52:32.123Z" + }, + "custom_price": { + "tax_included": false, + "pricing_scheme": "stairstep", + "interval": 66, + "interval_unit": "day", + "prices": [ + { + "starting_quantity": 242, + "ending_quantity": 40, + "unit_price": 23.26 + }, + { + "starting_quantity": 242, + "ending_quantity": 40, + "unit_price": 23.26 + } + ], + "renew_prepaid_allocation": false } } } diff --git a/doc/models/create-usage.md b/doc/models/create-usage.md index b9d1655..c4c00ef 100644 --- a/doc/models/create-usage.md +++ b/doc/models/create-usage.md @@ -12,7 +12,8 @@ | `quantity` | `number \| undefined` | Optional | integer by default or decimal number if fractional quantities are enabled for the component | | `pricePointId` | `string \| undefined` | Optional | - | | `memo` | `string \| undefined` | Optional | - | -| `billingSchedule` | [`BillingSchedule \| undefined`](../../doc/models/billing-schedule.md) | Optional | This attribute is particularly useful when you need to align billing events for different components on distinct schedules within a subscription. Please note this only works for site with Multifrequency enabled | +| `billingSchedule` | [`BillingSchedule \| undefined`](../../doc/models/billing-schedule.md) | Optional | This attribute is particularly useful when you need to align billing events for different components on distinct schedules within a subscription. This only works for site with Multifrequency enabled. | +| `customPrice` | [`ComponentCustomPrice \| undefined`](../../doc/models/component-custom-price.md) | Optional | Create or update custom pricing unique to the subscription. Used in place of `price_point_id`. | ## Example (as JSON) @@ -23,6 +24,25 @@ "memo": "memo2", "billing_schedule": { "initial_billing_at": "2016-03-13T12:52:32.123Z" + }, + "custom_price": { + "tax_included": false, + "pricing_scheme": "stairstep", + "interval": 66, + "interval_unit": "day", + "prices": [ + { + "starting_quantity": 242, + "ending_quantity": 40, + "unit_price": 23.26 + }, + { + "starting_quantity": 242, + "ending_quantity": 40, + "unit_price": 23.26 + } + ], + "renew_prepaid_allocation": false } } ``` diff --git a/doc/models/ebb-component.md b/doc/models/ebb-component.md index e040d85..186bf30 100644 --- a/doc/models/ebb-component.md +++ b/doc/models/ebb-component.md @@ -18,7 +18,7 @@ | `prices` | [`Price[] \| undefined`](../../doc/models/price.md) | Optional | (Not required for ‘per_unit’ pricing schemes) One or more price brackets. See [Price Bracket Rules](https://maxio.zendesk.com/hc/en-us/articles/24261149166733-Component-Pricing-Schemes#price-bracket-rules) for an overview of how price brackets work for different pricing schemes. | | `pricePoints` | [`ComponentPricePointItem[] \| undefined`](../../doc/models/component-price-point-item.md) | Optional | - | | `unitPrice` | [`EBBComponentUnitPrice \| undefined`](../../doc/models/containers/ebb-component-unit-price.md) | Optional | This is a container for one-of cases. | -| `taxCode` | `string \| undefined` | Optional | A string representing the tax code related to the component type. This is especially important when using the Avalara service to tax based on locale. This attribute has a max length of 10 characters. | +| `taxCode` | `string \| undefined` | Optional | A string representing the tax code related to the component type. This is especially important when using AvaTax to tax based on locale. This attribute has a max length of 25 characters. | | `hideDateRangeOnInvoice` | `boolean \| undefined` | Optional | (Only available on Relationship Invoicing sites) Boolean flag describing if the service date range should show for the component on generated invoices. | | `eventBasedBillingMetricId` | `number` | Required | The ID of an event based billing metric that will be attached to this component. | | `interval` | `number \| undefined` | Optional | The numerical interval. i.e. an interval of ‘30’ coupled with an interval_unit of day would mean this component's default price point would renew every 30 days. This property is only available for sites with Multifrequency enabled. | diff --git a/doc/models/list-coupons-filter.md b/doc/models/list-coupons-filter.md index becd273..cd4a23d 100644 --- a/doc/models/list-coupons-filter.md +++ b/doc/models/list-coupons-filter.md @@ -16,7 +16,8 @@ | `endDatetime` | `string \| undefined` | Optional | The end date and time (format YYYY-MM-DD HH:MM:SS) with which to filter the date_field. Returns coupons with a timestamp at or before exact time provided in query. You can specify timezone in query - otherwise your site's time zone will be used. If provided, this parameter will be used instead of end_date. Use in query `filter[end_datetime]=2011-12-1T10:15:30+01:00`. | | `ids` | `number[] \| undefined` | Optional | Allows fetching coupons with matching id based on provided values. Use in query `filter[ids]=1,2,3`.

**Constraints**: *Minimum Items*: `1` | | `codes` | `string[] \| undefined` | Optional | Allows fetching coupons with matching codes based on provided values. Use in query `filter[codes]=free,free_trial`. | -| `useSiteExchangeRate` | `boolean \| undefined` | Optional | Allows fetching coupons with matching use_site_exchange_rate based on provided value. Use in query `filter[use_site_exchange_rate]=true`. | +| `useSiteExchangeRate` | `boolean \| undefined` | Optional | If true, restricts the list to coupons whose pricing is recalculated from the site’s current exchange rates, so their currency_prices array contains on-the-fly conversions rather than stored price records. If false, restricts the list to coupons that have manually defined amounts for each currency, ensuring the response includes the saved currency_prices entries instead of exchange-rate-derived values. Use in query `filter[use_site_exchange_rate]=true`. | +| `includeArchived` | `boolean \| undefined` | Optional | Controls returning archived coupons. | ## Example (as JSON) diff --git a/doc/models/metafield-input.md b/doc/models/metafield-input.md index 6bf7403..74bf0d5 100644 --- a/doc/models/metafield-input.md +++ b/doc/models/metafield-input.md @@ -1,7 +1,7 @@ # Metafield Input -Indicates how data should be added to the metafield. For example, a text type is just a string, so a given metafield of this type can have any value attached. On the other hand, dropdown and radio have a set of allowed values that can be input, and appear differently on a Public Signup Page. Defaults to 'text' +Indicates the type of metafield. A text metafield allows any string value. Dropdown and radio metafields have a set of values that can be selected. Defaults to 'text'. ## Enumeration diff --git a/doc/models/metafield-scope.md b/doc/models/metafield-scope.md index 83a44b3..e2939de 100644 --- a/doc/models/metafield-scope.md +++ b/doc/models/metafield-scope.md @@ -15,8 +15,8 @@ Warning: When updating a metafield's scope attribute, all scope attributes must | `invoices` | [`IncludeOption \| undefined`](../../doc/models/include-option.md) | Optional | Include (1) or exclude (0) metafields from invoices. | | `statements` | [`IncludeOption \| undefined`](../../doc/models/include-option.md) | Optional | Include (1) or exclude (0) metafields from statements. | | `portal` | [`IncludeOption \| undefined`](../../doc/models/include-option.md) | Optional | Include (1) or exclude (0) metafields from the portal. | -| `publicShow` | [`IncludeOption \| undefined`](../../doc/models/include-option.md) | Optional | Include (1) or exclude (0) metafields from being viewable by your ecosystem. | -| `publicEdit` | [`IncludeOption \| undefined`](../../doc/models/include-option.md) | Optional | Include (1) or exclude (0) metafields from being edited by your ecosystem. | +| `publicShow` | [`IncludeOption \| undefined`](../../doc/models/include-option.md) | Optional | Include (1) or exclude (0) metafields used in [Embeddable Components](page:development-tools/embeddable-components/overview) from being viewable by your ecosystem. | +| `publicEdit` | [`IncludeOption \| undefined`](../../doc/models/include-option.md) | Optional | Include (1) or exclude (0) metafields used in [Embeddable Components](page:development-tools/embeddable-components/overview) from being editable by your ecosystem. | | `hosted` | `string[] \| undefined` | Optional | - | ## Example (as JSON) diff --git a/doc/models/metafield.md b/doc/models/metafield.md index 86b4c0c..2dfe7fe 100644 --- a/doc/models/metafield.md +++ b/doc/models/metafield.md @@ -12,8 +12,8 @@ | `id` | `number \| undefined` | Optional | - | | `name` | `string \| undefined` | Optional | - | | `scope` | [`MetafieldScope \| undefined`](../../doc/models/metafield-scope.md) | Optional | Warning: When updating a metafield's scope attribute, all scope attributes must be passed. Partially complete scope attributes will override the existing settings. | -| `dataCount` | `number \| undefined` | Optional | the amount of subscriptions this metafield has been applied to in Chargify | -| `inputType` | [`MetafieldInput \| undefined`](../../doc/models/metafield-input.md) | Optional | Indicates how data should be added to the metafield. For example, a text type is just a string, so a given metafield of this type can have any value attached. On the other hand, dropdown and radio have a set of allowed values that can be input, and appear differently on a Public Signup Page. Defaults to 'text' | +| `dataCount` | `number \| undefined` | Optional | The amount of subscriptions this metafield has been applied to in Advanced Billing. | +| `inputType` | [`MetafieldInput \| undefined`](../../doc/models/metafield-input.md) | Optional | Indicates the type of metafield. A text metafield allows any string value. Dropdown and radio metafields have a set of values that can be selected. Defaults to 'text'. | | `mEnum` | [`MetafieldEnum \| null \| undefined`](../../doc/models/containers/metafield-enum.md) | Optional | This is a container for one-of cases. | ## Example (as JSON) diff --git a/doc/models/metered-component.md b/doc/models/metered-component.md index d727a5d..f6fd46c 100644 --- a/doc/models/metered-component.md +++ b/doc/models/metered-component.md @@ -18,7 +18,7 @@ | `prices` | [`Price[] \| undefined`](../../doc/models/price.md) | Optional | (Not required for ‘per_unit’ pricing schemes) One or more price brackets. See [Price Bracket Rules](https://maxio.zendesk.com/hc/en-us/articles/24261149166733-Component-Pricing-Schemes#price-bracket-rules) for an overview of how price brackets work for different pricing schemes. | | `pricePoints` | [`ComponentPricePointItem[] \| undefined`](../../doc/models/component-price-point-item.md) | Optional | - | | `unitPrice` | [`MeteredComponentUnitPrice \| undefined`](../../doc/models/containers/metered-component-unit-price.md) | Optional | This is a container for one-of cases. | -| `taxCode` | `string \| undefined` | Optional | A string representing the tax code related to the component type. This is especially important when using the Avalara service to tax based on locale. This attribute has a max length of 10 characters. | +| `taxCode` | `string \| undefined` | Optional | A string representing the tax code related to the component type. This is especially important when using AvaTax to tax based on locale. This attribute has a max length of 25 characters. | | `hideDateRangeOnInvoice` | `boolean \| undefined` | Optional | (Only available on Relationship Invoicing sites) Boolean flag describing if the service date range should show for the component on generated invoices. | | `displayOnHostedPage` | `boolean \| undefined` | Optional | - | | `allowFractionalQuantities` | `boolean \| undefined` | Optional | - | diff --git a/doc/models/on-off-component.md b/doc/models/on-off-component.md index d43bc74..8649a14 100644 --- a/doc/models/on-off-component.md +++ b/doc/models/on-off-component.md @@ -17,7 +17,7 @@ | `downgradeCredit` | [`CreditType \| null \| undefined`](../../doc/models/credit-type.md) | Optional | The type of credit to be created when upgrading/downgrading. Defaults to the component and then site setting if one is not provided.
Available values: `full`, `prorated`, `none`. | | `pricePoints` | [`ComponentPricePointItem[] \| undefined`](../../doc/models/component-price-point-item.md) | Optional | - | | `unitPrice` | [`OnOffComponentUnitPrice`](../../doc/models/containers/on-off-component-unit-price.md) | Required | This is a container for one-of cases. | -| `taxCode` | `string \| undefined` | Optional | A string representing the tax code related to the component type. This is especially important when using the Avalara service to tax based on locale. This attribute has a max length of 10 characters. | +| `taxCode` | `string \| undefined` | Optional | A string representing the tax code related to the component type. This is especially important when using AvaTax to tax based on locale. This attribute has a max length of 25 characters. | | `hideDateRangeOnInvoice` | `boolean \| undefined` | Optional | (Only available on Relationship Invoicing sites) Boolean flag describing if the service date range should show for the component on generated invoices. | | `displayOnHostedPage` | `boolean \| undefined` | Optional | - | | `allowFractionalQuantities` | `boolean \| undefined` | Optional | - | diff --git a/doc/models/payment-profile-attributes.md b/doc/models/payment-profile-attributes.md index 15a5272..fb53b47 100644 --- a/doc/models/payment-profile-attributes.md +++ b/doc/models/payment-profile-attributes.md @@ -25,7 +25,7 @@ alias to credit_card_attributes | `billingAddress2` | `string \| null \| undefined` | Optional | (Optional) Second line of the customer’s billing address i.e. Apt. 100 | | `billingCity` | `string \| undefined` | Optional | (Optional, may be required by your product configuration or gateway settings) The credit card or bank account billing address city (i.e. “Boston”). This value is merely passed through to the payment gateway. | | `billingState` | `string \| undefined` | Optional | (Optional, may be required by your product configuration or gateway settings) The credit card or bank account billing address state (i.e. MA). This value is merely passed through to the payment gateway. This must conform to the [ISO_3166-1](https://en.wikipedia.org/wiki/ISO_3166-1#Current_codes) in order to be valid for tax locale purposes. | -| `billingCountry` | `string \| undefined` | Optional | (Optional, may be required by your product configuration or gateway settings) The credit card or bank account billing address country, required in [ISO_3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) format (i.e. “US”). This value is merely passed through to the payment gateway. Some gateways require country codes in a specific format. Please check your gateway’s documentation. If creating an ACH subscription, only US is supported at this time. | +| `billingCountry` | `string \| undefined` | Optional | (Optional, may be required by your product configuration or gateway settings) The credit card or bank account billing address country, required in [ISO_3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) format (i.e. “US”). This value is merely passed through to the payment gateway. Some gateways require country codes in a specific format. Check your gateway’s documentation. If creating an ACH subscription, only US is supported at this time. | | `billingZip` | `string \| undefined` | Optional | (Optional, may be required by your product configuration or gateway settings) The credit card or bank account billing address zip code (i.e. 12345). This value is merely passed through to the payment gateway. | | `currentVault` | [`AllVaults \| undefined`](../../doc/models/all-vaults.md) | Optional | (Optional, used only for Subscription Import) The vault that stores the payment profile with the provided vault_token. | | `vaultToken` | `string \| undefined` | Optional | (Optional, used only for Subscription Import) The “token” provided by your vault storage for an already stored payment profile | diff --git a/doc/models/prepaid-usage-component.md b/doc/models/prepaid-usage-component.md index 16f52b0..8504bbb 100644 --- a/doc/models/prepaid-usage-component.md +++ b/doc/models/prepaid-usage-component.md @@ -20,7 +20,7 @@ | `downgradeCredit` | [`CreditType \| null \| undefined`](../../doc/models/credit-type.md) | Optional | The type of credit to be created when upgrading/downgrading. Defaults to the component and then site setting if one is not provided.
Available values: `full`, `prorated`, `none`. | | `pricePoints` | [`CreatePrepaidUsageComponentPricePoint[] \| undefined`](../../doc/models/create-prepaid-usage-component-price-point.md) | Optional | - | | `unitPrice` | [`PrepaidUsageComponentUnitPrice \| undefined`](../../doc/models/containers/prepaid-usage-component-unit-price.md) | Optional | This is a container for one-of cases. | -| `taxCode` | `string \| undefined` | Optional | A string representing the tax code related to the component type. This is especially important when using the Avalara service to tax based on locale. This attribute has a max length of 10 characters. | +| `taxCode` | `string \| undefined` | Optional | A string representing the tax code related to the component type. This is especially important when using AvaTax to tax based on locale. This attribute has a max length of 25 characters. | | `hideDateRangeOnInvoice` | `boolean \| undefined` | Optional | (Only available on Relationship Invoicing sites) Boolean flag describing if the service date range should show for the component on generated invoices. | | `overagePricing` | [`OveragePricing`](../../doc/models/overage-pricing.md) | Required | - | | `rolloverPrepaidRemainder` | `boolean \| undefined` | Optional | Boolean which controls whether or not remaining units should be rolled over to the next period | diff --git a/doc/models/product-price-point.md b/doc/models/product-price-point.md index 6d4b8d8..1a718e8 100644 --- a/doc/models/product-price-point.md +++ b/doc/models/product-price-point.md @@ -18,7 +18,7 @@ | `trialPriceInCents` | `bigint \| null \| undefined` | Optional | The product price point trial price, in integer cents | | `trialInterval` | `number \| null \| undefined` | Optional | The numerical trial interval. i.e. an interval of ‘30’ coupled with a trial_interval_unit of day would mean this product price point trial would last 30 days | | `trialIntervalUnit` | [`IntervalUnit \| null \| undefined`](../../doc/models/interval-unit.md) | Optional | A string representing the trial interval unit for this product price point, either month or day | -| `trialType` | `string \| undefined` | Optional | - | +| `trialType` | [`TrialType \| null \| undefined`](../../doc/models/trial-type.md) | Optional | Indicates how a trial is handled when the trail period ends and there is no credit card on file. For `no_obligation`, the subscription transitions to a Trial Ended state. Maxio will not send any emails or statements. For `payment_expected`, the subscription transitions to a Past Due state. Maxio will send normal dunning emails and statements according to your other settings. | | `introductoryOffer` | `boolean \| null \| undefined` | Optional | reserved for future use | | `initialChargeInCents` | `bigint \| null \| undefined` | Optional | The product price point initial charge, in integer cents | | `initialChargeAfterTrial` | `boolean \| null \| undefined` | Optional | - | diff --git a/doc/models/product.md b/doc/models/product.md index b37ad78..f1ceeea 100644 --- a/doc/models/product.md +++ b/doc/models/product.md @@ -14,7 +14,7 @@ | `handle` | `string \| null \| undefined` | Optional | The product API handle | | `description` | `string \| null \| undefined` | Optional | The product description | | `accountingCode` | `string \| null \| undefined` | Optional | E.g. Internal ID or SKU Number | -| `requestCreditCard` | `boolean \| undefined` | Optional | Deprecated value that can be ignored unless you have legacy hosted pages. For Public Signup Page users, please read this attribute from under the signup page. | +| `requestCreditCard` | `boolean \| undefined` | Optional | Deprecated value that can be ignored unless you have legacy hosted pages. For Public Signup Page users, read this attribute from under the signup page. | | `expirationInterval` | `number \| null \| undefined` | Optional | A numerical interval for the length a subscription to this product will run before it expires. See the description of interval for a description of how this value is coupled with an interval unit to calculate the full interval | | `expirationIntervalUnit` | [`ExpirationIntervalUnit \| null \| undefined`](../../doc/models/expiration-interval-unit.md) | Optional | A string representing the expiration interval unit for this product, either month, day or never | | `createdAt` | `string \| undefined` | Optional | Timestamp indicating when this product was created | @@ -40,7 +40,7 @@ | `requestBillingAddress` | `boolean \| undefined` | Optional | A boolean indicating whether to request a billing address on any Self-Service Pages that are used by subscribers of this product. | | `requireBillingAddress` | `boolean \| undefined` | Optional | A boolean indicating whether a billing address is required to add a payment profile, especially at signup. | | `requireShippingAddress` | `boolean \| undefined` | Optional | A boolean indicating whether a shipping address is required for the customer, especially at signup. | -| `taxCode` | `string \| null \| undefined` | Optional | A string representing the tax code related to the product type. This is especially important when using the Avalara service to tax based on locale. This attribute has a max length of 10 characters. | +| `taxCode` | `string \| null \| undefined` | Optional | A string representing the tax code related to the product type. This is especially important when using AvaTax to tax based on locale. This attribute has a max length of 25 characters. | | `defaultProductPricePointId` | `number \| undefined` | Optional | - | | `useSiteExchangeRate` | `boolean \| null \| undefined` | Optional | - | | `itemCategory` | `string \| null \| undefined` | Optional | One of the following: Business Software, Consumer Software, Digital Services, Physical Goods, Other | diff --git a/doc/models/quantity-based-component.md b/doc/models/quantity-based-component.md index 18a193d..c298f25 100644 --- a/doc/models/quantity-based-component.md +++ b/doc/models/quantity-based-component.md @@ -20,7 +20,7 @@ | `downgradeCredit` | [`CreditType \| null \| undefined`](../../doc/models/credit-type.md) | Optional | The type of credit to be created when upgrading/downgrading. Defaults to the component and then site setting if one is not provided.
Available values: `full`, `prorated`, `none`. | | `pricePoints` | [`ComponentPricePointItem[] \| undefined`](../../doc/models/component-price-point-item.md) | Optional | - | | `unitPrice` | [`QuantityBasedComponentUnitPrice \| undefined`](../../doc/models/containers/quantity-based-component-unit-price.md) | Optional | This is a container for one-of cases. | -| `taxCode` | `string \| undefined` | Optional | A string representing the tax code related to the component type. This is especially important when using the Avalara service to tax based on locale. This attribute has a max length of 10 characters. | +| `taxCode` | `string \| undefined` | Optional | A string representing the tax code related to the component type. This is especially important when using AvaTax to tax based on locale. This attribute has a max length of 25 characters. | | `hideDateRangeOnInvoice` | `boolean \| undefined` | Optional | (Only available on Relationship Invoicing sites) Boolean flag describing if the service date range should show for the component on generated invoices. | | `recurring` | `boolean \| undefined` | Optional | - | | `displayOnHostedPage` | `boolean \| undefined` | Optional | - | diff --git a/doc/models/resume-options.md b/doc/models/resume-options.md index aa071c0..881637b 100644 --- a/doc/models/resume-options.md +++ b/doc/models/resume-options.md @@ -9,7 +9,7 @@ | Name | Type | Tags | Description | | --- | --- | --- | --- | -| `requireResume` | `boolean \| undefined` | Optional | Chargify will only attempt to resume the subscription's billing period. If not resumable, the subscription will be left in it's current state. | +| `requireResume` | `boolean \| undefined` | Optional | Chargify will only attempt to resume the subscription's billing period. If not resumable, the subscription will be left in its current state. | | `forgiveBalance` | `boolean \| undefined` | Optional | Indicates whether or not Chargify should clear the subscription's existing balance before attempting to resume the subscription. If subscription cannot be resumed, the balance will remain as it was before the attempt to resume was made. | ## Example (as JSON) diff --git a/doc/models/snap-day.md b/doc/models/snap-day.md index 4015f17..92da90e 100644 --- a/doc/models/snap-day.md +++ b/doc/models/snap-day.md @@ -1,8 +1,6 @@ # Snap Day -Use for subscriptions with product eligible for calendar billing only. Value can be 1-28 or 'end'. - ## Enumeration `SnapDay` diff --git a/doc/models/subscription-custom-price.md b/doc/models/subscription-custom-price.md index 1a8ee0e..b26bec8 100644 --- a/doc/models/subscription-custom-price.md +++ b/doc/models/subscription-custom-price.md @@ -19,6 +19,7 @@ | `trialPriceInCents` | [`SubscriptionCustomPriceTrialPriceInCents \| undefined`](../../doc/models/containers/subscription-custom-price-trial-price-in-cents.md) | Optional | This is a container for one-of cases. | | `trialInterval` | [`SubscriptionCustomPriceTrialInterval \| undefined`](../../doc/models/containers/subscription-custom-price-trial-interval.md) | Optional | This is a container for one-of cases. | | `trialIntervalUnit` | [`IntervalUnit \| undefined`](../../doc/models/interval-unit.md) | Optional | (Optional) | +| `trialType` | [`TrialType \| null \| undefined`](../../doc/models/trial-type.md) | Optional | Indicates how a trial is handled when the trail period ends and there is no credit card on file. For `no_obligation`, the subscription transitions to a Trial Ended state. Maxio will not send any emails or statements. For `payment_expected`, the subscription transitions to a Past Due state. Maxio will send normal dunning emails and statements according to your other settings. | | `initialChargeInCents` | [`SubscriptionCustomPriceInitialChargeInCents \| undefined`](../../doc/models/containers/subscription-custom-price-initial-charge-in-cents.md) | Optional | This is a container for one-of cases. | | `initialChargeAfterTrial` | `boolean \| undefined` | Optional | (Optional) | | `expirationInterval` | [`SubscriptionCustomPriceExpirationInterval \| undefined`](../../doc/models/containers/subscription-custom-price-expiration-interval.md) | Optional | This is a container for one-of cases. | diff --git a/doc/models/subscription-group-component-custom-price.md b/doc/models/subscription-group-component-custom-price.md index ecf99cf..6b8fc6e 100644 --- a/doc/models/subscription-group-component-custom-price.md +++ b/doc/models/subscription-group-component-custom-price.md @@ -39,7 +39,8 @@ Used in place of `price_point_id` to define a custom price point unique to the s "ending_quantity": 40, "unit_price": 23.26 } - ] + ], + "renew_prepaid_allocation": false } ] } diff --git a/doc/models/subscription-group-signup-component.md b/doc/models/subscription-group-signup-component.md index bc9f4a7..904ba4a 100644 --- a/doc/models/subscription-group-signup-component.md +++ b/doc/models/subscription-group-signup-component.md @@ -49,7 +49,8 @@ "ending_quantity": 40, "unit_price": 23.26 } - ] + ], + "renew_prepaid_allocation": false }, { "tax_included": false, @@ -62,7 +63,8 @@ "ending_quantity": 40, "unit_price": 23.26 } - ] + ], + "renew_prepaid_allocation": false }, { "tax_included": false, @@ -75,7 +77,8 @@ "ending_quantity": 40, "unit_price": 23.26 } - ] + ], + "renew_prepaid_allocation": false } ] } diff --git a/doc/models/subscription.md b/doc/models/subscription.md index dbe8bc1..7ad119b 100644 --- a/doc/models/subscription.md +++ b/doc/models/subscription.md @@ -33,7 +33,7 @@ | `signupRevenue` | `string \| undefined` | Optional | The revenue, formatted as a string of decimal separated dollars and,cents, from the subscription signup ($50.00 would be formatted as,50.00) | | `delayedCancelAt` | `string \| null \| undefined` | Optional | Timestamp for when the subscription is currently set to cancel. | | `couponCode` | `string \| null \| undefined` | Optional | (deprecated) The coupon code of the single coupon currently applied to the subscription. See coupon_codes instead as subscriptions can now have more than one coupon. | -| `snapDay` | `string \| null \| undefined` | Optional | The day of the month that the subscription will charge according to calendar billing rules, if used. | +| `snapDay` | [`SubscriptionSnapDay \| null \| undefined`](../../doc/models/containers/subscription-snap-day.md) | Optional | This is a container for one-of cases. | | `paymentCollectionMethod` | [`CollectionMethod \| undefined`](../../doc/models/collection-method.md) | Optional | The type of payment collection to be used in the subscription. For legacy Statements Architecture valid options are - `invoice`, `automatic`. For current Relationship Invoicing Architecture valid options are - `remittance`, `automatic`, `prepaid`. | | `customer` | [`Customer \| undefined`](../../doc/models/customer.md) | Optional | - | | `product` | [`Product \| undefined`](../../doc/models/product.md) | Optional | - | @@ -51,7 +51,7 @@ | `couponCodes` | `string[] \| undefined` | Optional | An array for all the coupons attached to the subscription. | | `offerId` | `number \| null \| undefined` | Optional | The ID of the offer associated with the subscription. | | `payerId` | `number \| null \| undefined` | Optional | On Relationship Invoicing, the ID of the individual paying for the subscription. Defaults to the Customer ID unless the 'Customer Hierarchies & WhoPays' feature is enabled. | -| `currentBillingAmountInCents` | `bigint \| undefined` | Optional | The balance in cents plus the estimated renewal amount in cents. Returned ONLY for readSubscription operation as it's compute intensive operation. | +| `currentBillingAmountInCents` | `bigint \| undefined` | Optional | The balance in cents plus the estimated renewal amount in cents. Returned ONLY for the readSubscription operation as it's a compute intensive operation. | | `productPricePointId` | `number \| undefined` | Optional | The product price point currently subscribed to. | | `productPricePointType` | [`PricePointType \| undefined`](../../doc/models/price-point-type.md) | Optional | Price point type. We expose the following types:

1. **default**: a price point that is marked as a default price for a certain product.
2. **custom**: a custom price point.
3. **catalog**: a price point that is **not** marked as a default price for a certain product and is **not** a custom one. | | `nextProductPricePointId` | `number \| null \| undefined` | Optional | If a delayed product change is scheduled, the ID of the product price point that the subscription will be changed to at the next renewal. | diff --git a/doc/models/trial-type.md b/doc/models/trial-type.md new file mode 100644 index 0000000..4807ad0 --- /dev/null +++ b/doc/models/trial-type.md @@ -0,0 +1,16 @@ + +# Trial Type + +Indicates how a trial is handled when the trail period ends and there is no credit card on file. For `no_obligation`, the subscription transitions to a Trial Ended state. Maxio will not send any emails or statements. For `payment_expected`, the subscription transitions to a Past Due state. Maxio will send normal dunning emails and statements according to your other settings. + +## Enumeration + +`TrialType` + +## Fields + +| Name | +| --- | +| `NoObligation` | +| `PaymentExpected` | + diff --git a/doc/models/update-component.md b/doc/models/update-component.md index ad8717f..5f85da5 100644 --- a/doc/models/update-component.md +++ b/doc/models/update-component.md @@ -14,7 +14,7 @@ | `description` | `string \| null \| undefined` | Optional | The description of the component. | | `accountingCode` | `string \| null \| undefined` | Optional | - | | `taxable` | `boolean \| undefined` | Optional | Boolean flag describing whether a component is taxable or not. | -| `taxCode` | `string \| null \| undefined` | Optional | A string representing the tax code related to the component type. This is especially important when using the Avalara service to tax based on locale. This attribute has a max length of 10 characters. | +| `taxCode` | `string \| null \| undefined` | Optional | A string representing the tax code related to the component type. This is especially important when using AvaTax to tax based on locale. This attribute has a max length of 25 characters. | | `itemCategory` | [`ItemCategory \| null \| undefined`](../../doc/models/item-category.md) | Optional | One of the following: Business Software, Consumer Software, Digital Services, Physical Goods, Other | | `displayOnHostedPage` | `boolean \| undefined` | Optional | - | | `upgradeCharge` | [`CreditType \| null \| undefined`](../../doc/models/credit-type.md) | Optional | The type of credit to be created when upgrading/downgrading. Defaults to the component and then site setting if one is not provided.
Available values: `full`, `prorated`, `none`. | diff --git a/doc/models/update-metafield.md b/doc/models/update-metafield.md index 94bb392..351dca8 100644 --- a/doc/models/update-metafield.md +++ b/doc/models/update-metafield.md @@ -12,8 +12,8 @@ | `currentName` | `string \| undefined` | Optional | - | | `name` | `string \| undefined` | Optional | - | | `scope` | [`MetafieldScope \| undefined`](../../doc/models/metafield-scope.md) | Optional | Warning: When updating a metafield's scope attribute, all scope attributes must be passed. Partially complete scope attributes will override the existing settings. | -| `inputType` | [`MetafieldInput \| undefined`](../../doc/models/metafield-input.md) | Optional | Indicates how data should be added to the metafield. For example, a text type is just a string, so a given metafield of this type can have any value attached. On the other hand, dropdown and radio have a set of allowed values that can be input, and appear differently on a Public Signup Page. Defaults to 'text' | -| `mEnum` | `string[] \| undefined` | Optional | Only applicable when input_type is radio or dropdown | +| `inputType` | [`MetafieldInput \| undefined`](../../doc/models/metafield-input.md) | Optional | Indicates the type of metafield. A text metafield allows any string value. Dropdown and radio metafields have a set of values that can be selected. Defaults to 'text'. | +| `mEnum` | `string[] \| undefined` | Optional | Only applicable when input_type is radio or dropdown. | ## Example (as JSON) diff --git a/doc/models/update-payment-profile.md b/doc/models/update-payment-profile.md index bc39aeb..bd4c080 100644 --- a/doc/models/update-payment-profile.md +++ b/doc/models/update-payment-profile.md @@ -20,7 +20,7 @@ | `billingCity` | `string \| undefined` | Optional | The credit card or bank account billing address city (i.e. “Boston”). This value is merely passed through to the payment gateway. | | `billingState` | `string \| undefined` | Optional | The credit card or bank account billing address state (i.e. MA). This value is merely passed through to the payment gateway. This must conform to the [ISO_3166-1](https://en.wikipedia.org/wiki/ISO_3166-1#Current_codes) in order to be valid for tax locale purposes. | | `billingZip` | `string \| undefined` | Optional | The credit card or bank account billing address zip code (i.e. 12345). This value is merely passed through to the payment gateway. | -| `billingCountry` | `string \| undefined` | Optional | The credit card or bank account billing address country, required in [ISO_3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) format (i.e. “US”). This value is merely passed through to the payment gateway. Some gateways require country codes in a specific format. Please check your gateway’s documentation. If creating an ACH subscription, only US is supported at this time. | +| `billingCountry` | `string \| undefined` | Optional | The credit card or bank account billing address country, required in [ISO_3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) format (i.e. “US”). This value is merely passed through to the payment gateway. Some gateways require country codes in a specific format. Check your gateway’s documentation. If creating an ACH subscription, only US is supported at this time. | | `billingAddress2` | `string \| null \| undefined` | Optional | Second line of the customer’s billing address i.e. Apt. 100 | ## Example (as JSON) diff --git a/doc/models/update-subscription-component.md b/doc/models/update-subscription-component.md index 5344d00..c9dcc52 100644 --- a/doc/models/update-subscription-component.md +++ b/doc/models/update-subscription-component.md @@ -33,7 +33,8 @@ "ending_quantity": 40, "unit_price": 23.26 } - ] + ], + "renew_prepaid_allocation": false } } ``` diff --git a/doc/models/update-subscription.md b/doc/models/update-subscription.md index 1bb6c77..730932a 100644 --- a/doc/models/update-subscription.md +++ b/doc/models/update-subscription.md @@ -15,7 +15,7 @@ | `productChangeDelayed` | `boolean \| undefined` | Optional | - | | `nextProductId` | `string \| undefined` | Optional | Set to an empty string to cancel a delayed product change. | | `nextProductPricePointId` | `string \| undefined` | Optional | - | -| `snapDay` | [`UpdateSubscriptionSnapDay \| undefined`](../../doc/models/containers/update-subscription-snap-day.md) | Optional | This is a container for one-of cases. | +| `snapDay` | [`UpdateSubscriptionSnapDay \| null \| undefined`](../../doc/models/containers/update-subscription-snap-day.md) | Optional | This is a container for one-of cases. | | `initialBillingAt` | `string \| undefined` | Optional | (Optional) Set this attribute to a future date/time to update a subscription in the Awaiting Signup Date state, to Awaiting Signup. In the Awaiting Signup state, a subscription behaves like any other. It can be canceled, allocated to, or have its billing date changed. etc. When the `initial_billing_at` date hits, the subscription will transition to the expected state. If the product has a trial, the subscription will enter a trial, otherwise it will go active. Setup fees will be respected either before or after the trial, as configured on the price point. If the payment is due at the initial_billing_at and it fails the subscription will be immediately canceled. You can omit the initial_billing_at date to activate the subscription immediately. See the [subscription import](https://maxio.zendesk.com/hc/en-us/articles/24251489107213-Advanced-Billing-Subscription-Imports#date-format) documentation for more information about Date/Time formats. | | `deferSignup` | `boolean \| undefined` | Optional | (Optional) Set this attribute to true to move the subscription from Awaiting Signup, to Awaiting Signup Date. Use this when you want to update a subscription that has an unknown initial billing date. When the first billing date is known, update a subscription to set the `initial_billing_at` date. The subscription moves to the awaiting signup with a scheduled initial billing date. You can omit the initial_billing_at date to activate the subscription immediately. See [Subscription States](https://maxio-chargify.zendesk.com/hc/en-us/articles/5404222005773-Subscription-States) for more information.

**Default**: `false` | | `nextBillingAt` | `string \| undefined` | Optional | - | diff --git a/e2e/src/sitesController.spec.ts b/e2e/src/sitesController.spec.ts index 391fc9f..2c2caf1 100644 --- a/e2e/src/sitesController.spec.ts +++ b/e2e/src/sitesController.spec.ts @@ -46,6 +46,7 @@ describe('SitesController', () => { automaticNetTerms: 0, remittanceNetTerms: 0, netTermsOnRemittanceSignupsEnabled: false, + net_terms_on_automatic_signups_enabled: false, customNetTermsEnabled: false, }, test: true, diff --git a/jest.config.js b/jest.config.js index cd106b2..7f6bfbe 100644 --- a/jest.config.js +++ b/jest.config.js @@ -6,7 +6,7 @@ const config = { '^.+\\.tsx?$': ['ts-jest', { tsconfig: 'tsconfig.base.json' }], }, moduleNameMapper: { - "(.+)\\.js": "$1", + "^(\\.{1,2}/.*)\\.js$": "$1", }, }; diff --git a/package.json b/package.json index 93d75ae..5fab244 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "7.0.1", + "version": "8.0.0", "license": "MIT", "sideEffects": false, "main": "dist/cjs/index.js", @@ -44,10 +44,10 @@ "typescript": "^5.2.0" }, "dependencies": { - "@apimatic/authentication-adapters": "^0.5.10", - "@apimatic/axios-client-adapter": "^0.3.16", - "@apimatic/core": "^0.10.25", - "@apimatic/schema": "^0.7.19" + "@apimatic/authentication-adapters": "^0.5.14", + "@apimatic/axios-client-adapter": "^0.3.20", + "@apimatic/core": "^0.10.28", + "@apimatic/schema": "^0.7.21" }, "repository": { "type": "git", @@ -65,4 +65,4 @@ "Payments" ], "contributors": [] -} +} \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2b436e4..402b34a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,17 +9,17 @@ importers: .: dependencies: '@apimatic/authentication-adapters': - specifier: ^0.5.10 - version: 0.5.12 + specifier: ^0.5.14 + version: 0.5.14 '@apimatic/axios-client-adapter': - specifier: ^0.3.16 - version: 0.3.18 + specifier: ^0.3.20 + version: 0.3.20 '@apimatic/core': - specifier: ^0.10.25 - version: 0.10.26 + specifier: ^0.10.28 + version: 0.10.28 '@apimatic/schema': - specifier: ^0.7.19 - version: 0.7.20 + specifier: ^0.7.21 + version: 0.7.21 devDependencies: '@types/jest': specifier: ^29.4.0 @@ -97,27 +97,27 @@ importers: packages: - /@apimatic/authentication-adapters@0.5.12: - resolution: {integrity: sha512-H0dVMsuiPRRS6qPSz42T8ktaOUBlvJgKSj5L+DKr4DwBEZaE6rZx4i5kuEdAUZ5oIuteupbGEx5hMJlPi6Y0XA==} + /@apimatic/authentication-adapters@0.5.14: + resolution: {integrity: sha512-V7nhHShPrU8LfjKKHoVJNS50SveSL77CexVuS4aeQyXx99HwdQVJwl2MK0KAYM6/b2ufQbJ7Eee2fzQT0TVXSQ==} engines: {node: '>=14.15.0 || >=16.0.0'} dependencies: - '@apimatic/core-interfaces': 0.2.12 - '@apimatic/http-headers': 0.3.7 - '@apimatic/http-query': 0.3.7 + '@apimatic/core-interfaces': 0.2.14 + '@apimatic/http-headers': 0.3.8 + '@apimatic/http-query': 0.3.9 tslib: 2.8.1 dev: false - /@apimatic/axios-client-adapter@0.3.18: - resolution: {integrity: sha512-4DX6PgMT3VyACsf+EA3IxPrJzE1Schnwm+EGoCDZ8oAt7WYf3nByH1nKbmRVLEw7TGp4ZNU9slUHmdiJZ7FM6A==} + /@apimatic/axios-client-adapter@0.3.20: + resolution: {integrity: sha512-HuwM3rtM+LLnJC6eu4FmniwEz3rsoy2rtTa0rcHv47JbHdp8/AR6Q1AQii1UzTLP9LA2LU7Cq+3xu1htRzvlQQ==} engines: {node: '>=14.15.0 || >=16.0.0'} dependencies: - '@apimatic/convert-to-stream': 0.1.7 - '@apimatic/core-interfaces': 0.2.12 - '@apimatic/file-wrapper': 0.3.7 - '@apimatic/http-headers': 0.3.7 - '@apimatic/http-query': 0.3.7 + '@apimatic/convert-to-stream': 0.1.8 + '@apimatic/core-interfaces': 0.2.14 + '@apimatic/file-wrapper': 0.3.9 + '@apimatic/http-headers': 0.3.8 + '@apimatic/http-query': 0.3.9 '@apimatic/json-bigint': 1.2.0 - '@apimatic/proxy': 0.1.2 + '@apimatic/proxy': 0.1.3 axios: 1.11.0 detect-browser: 5.3.0 detect-node: 2.1.0 @@ -130,32 +130,33 @@ packages: - supports-color dev: false - /@apimatic/convert-to-stream@0.1.7: - resolution: {integrity: sha512-uOCSy8YV0umHI4422l6wXcY/CN/oplLgoitpOY+P52I8dSrkQK+P+8HCITLDW4ND1I5OvRfvb1OwvN4+1JdgvA==} + /@apimatic/convert-to-stream@0.1.8: + resolution: {integrity: sha512-A4VO/wyGFksKtizp4aUOGGtSlejoVI1uAXLGPVymhfpion3wUwrlST/yif9SOj3faVAGeCTNx0w5A+BpVdzSEA==} engines: {node: '>=14.15.0 || >=16.0.0'} dependencies: tslib: 2.8.1 dev: false - /@apimatic/core-interfaces@0.2.12: - resolution: {integrity: sha512-XdEbSEfLEUY6KvKWQVXGMMGQmt589Zj0MnssPZ7FdgWFCrqe4aNgYt2Fl/fOC9r64GZvd7o1T9m4HKFilXi4nw==} + /@apimatic/core-interfaces@0.2.14: + resolution: {integrity: sha512-PQmSU32ndxtDddMCjbkNY/sVvDwQAsHUGKrdG5aGVE7iw/qvB2Tm2zyCarOB5TlDr4OB+/tuLCVhji0icx6MHg==} engines: {node: '>=14.15.0 || >=16.0.0'} dependencies: - '@apimatic/file-wrapper': 0.3.7 + '@apimatic/file-wrapper': 0.3.9 + '@apimatic/json-bigint': 1.2.0 tslib: 2.8.1 dev: false - /@apimatic/core@0.10.26: - resolution: {integrity: sha512-wml7KNNP3P8BXXI2bOXyuMugQpLZ1MpOl6EM40nSOCXmR4lTr1ssfoUi+LrK1n7o6JxLoYp9mGkMNHoR7n35Tw==} + /@apimatic/core@0.10.28: + resolution: {integrity: sha512-/1TsXtfuS6BOu1qRrKxnHuuBSSg3Q6ckf7ZPRyejzaA32PN0ke/eq+tK0tYGhnHrJtq869EXJ1r84mDw6Yb0zw==} engines: {node: '>=14.15.0 || >=16.0.0'} dependencies: - '@apimatic/convert-to-stream': 0.1.7 - '@apimatic/core-interfaces': 0.2.12 - '@apimatic/file-wrapper': 0.3.7 - '@apimatic/http-headers': 0.3.7 - '@apimatic/http-query': 0.3.7 + '@apimatic/convert-to-stream': 0.1.8 + '@apimatic/core-interfaces': 0.2.14 + '@apimatic/file-wrapper': 0.3.9 + '@apimatic/http-headers': 0.3.8 + '@apimatic/http-query': 0.3.9 '@apimatic/json-bigint': 1.2.0 - '@apimatic/schema': 0.7.20 + '@apimatic/schema': 0.7.21 detect-browser: 5.3.0 detect-node: 2.1.0 form-data: 4.0.4 @@ -165,25 +166,26 @@ packages: tslib: 2.8.1 dev: false - /@apimatic/file-wrapper@0.3.7: - resolution: {integrity: sha512-uJh2immpzZiZYOiG+Q9qtArg3bUk7lmx7eYFRI38wIOS2zlxQh90WkuJzaL2nvSmNsJ3p+yg5ePAyRpqoJmw7Q==} + /@apimatic/file-wrapper@0.3.9: + resolution: {integrity: sha512-Fh3UE7UPs2v4wkJdsD+uJFF147+7X0qkQfKBdeLZx6mZ5RmBJOBbS6ApvstQTV279YsHiiedKUZGJ6XLoVU+pQ==} engines: {node: '>=14.15.0 || >=16.0.0'} dependencies: tslib: 2.8.1 dev: false - /@apimatic/http-headers@0.3.7: - resolution: {integrity: sha512-DxLmwDMnAT5sOiuYI7EIuQq2PAVhbV9ICDLSdICRFflklgfKQ9agVEyNRgYVhuXz1m7IDoqqjGb1hs6iMJJpEg==} + /@apimatic/http-headers@0.3.8: + resolution: {integrity: sha512-ShvCuT39hYfBTI+H1I16m5i6XZCyUy2kQJ6Jhfj78TwsW5r6AyCbzW7DEro8GN2nNYRU1+E/hrgH6J85YmriOA==} engines: {node: '>=14.15.0 || >=16.0.0'} dependencies: tslib: 2.8.1 dev: false - /@apimatic/http-query@0.3.7: - resolution: {integrity: sha512-HauS4Jsuve1tGy1pnAidjHNL/TFVLesOxL7QtOdZyb+s0EHiHF6Vhx/kNroJ4mH/yCN3OHcHcqMJlfg0V5ET9g==} + /@apimatic/http-query@0.3.9: + resolution: {integrity: sha512-D6nqXcCR3P6iWbJ9uFXyyF2z1PEhTbGFbHNNuwF1NQ4tnThQk67DW9ou7/XcWi21zLh9MUchDWw9I0iE+5F2xA==} engines: {node: '>=14.15.0 || >=16.0.0'} dependencies: - '@apimatic/file-wrapper': 0.3.7 + '@apimatic/core-interfaces': 0.2.14 + '@apimatic/file-wrapper': 0.3.9 tslib: 2.8.1 dev: false @@ -191,8 +193,8 @@ packages: resolution: {integrity: sha512-+bmVzYMdZu0Ya5L+my4FXFUih54OvQA/qlZsFOYdOoostyUuB27UDrVWQs/WVCmS0ADdo5vTU0eeTrrBkHoySw==} dev: false - /@apimatic/proxy@0.1.2: - resolution: {integrity: sha512-Xo3PO69tos+ssAfjcBGxSxXu1jpdEwse+yYnWC8D8bCsuWKUVJh8TwWl01Zyw3s60FdikyGCGtiQ3LB2cBrbeg==} + /@apimatic/proxy@0.1.3: + resolution: {integrity: sha512-2UQmmbhOxAXHgbkl6WzGiVLG96ubw7udUsm0cv3jqiCLUyC+c15NgC64pJ+jeYHpZm3BtsLG01rMA+dBdHsxYQ==} engines: {node: '>=14.15.0 || >=16.0.0'} dependencies: http-proxy-agent: 7.0.2 @@ -201,8 +203,8 @@ packages: - supports-color dev: false - /@apimatic/schema@0.7.20: - resolution: {integrity: sha512-kMU1LqCypb0AwY8nXLV0aBoyubHHAxD8htyeAMFLYqWmmt+1pUBe33hHIDMdkREkNm+AYpl2n6vHBC1kqgju1w==} + /@apimatic/schema@0.7.21: + resolution: {integrity: sha512-RCke4toXjA7fBRxQVa1GR+Lj9utVOEJ3voDI26dhk+bZuAac4UXPzkTEaIO3AIe/o8pcKCOkpNIzhzm57Cv2Qg==} engines: {node: '>=14.15.0 || >=16.0.0'} dependencies: tslib: 2.8.1 diff --git a/src/client.ts b/src/client.ts index f778201..78f03f6 100644 --- a/src/client.ts +++ b/src/client.ts @@ -51,7 +51,7 @@ export class Client implements ClientInterface { ? this._config.httpClientOptions.timeout : this._config.timeout; this._userAgent = updateUserAgent( - 'AB SDK TypeScript:7.0.1 on OS {os-info}' + 'AB SDK TypeScript:8.0.0 on OS {os-info}' ); this._requestBuilderFactory = createRequestHandlerFactory( (server) => getBaseUri(server, this._config), diff --git a/src/controllers/advanceInvoiceController.ts b/src/controllers/advanceInvoiceController.ts index 49c833b..605c0d3 100644 --- a/src/controllers/advanceInvoiceController.ts +++ b/src/controllers/advanceInvoiceController.ts @@ -21,10 +21,10 @@ import { ErrorListResponseError } from '../errors/errorListResponseError.js'; export class AdvanceInvoiceController extends BaseController { /** - * Generate an invoice in advance for a subscription's next renewal date. [Please see our docs](https: - * //maxio.zendesk.com/hc/en-us/articles/24252026404749-Issue-Invoice-In-Advance) for more information - * on advance invoices, including eligibility on generating one; for the most part, they function like - * any other invoice, except they are issued early and have special behavior upon being voided. + * Generate an invoice in advance for a subscription's next renewal date. [See our docs](https://maxio. + * zendesk.com/hc/en-us/articles/24252026404749-Issue-Invoice-In-Advance) for more information on + * advance invoices, including eligibility on generating one; for the most part, they function like any + * other invoice, except they are issued early and have special behavior upon being voided. * A subscription may only have one advance invoice per billing period. Attempting to issue an advance * invoice when one already exists will return an error. * That said, regeneration of the invoice may be forced with the params `force: true`, which will void @@ -87,7 +87,7 @@ export class AdvanceInvoiceController extends BaseController { * Void a subscription's existing advance invoice. Once voided, it can later be regenerated if desired. * A `reason` is required in order to void, and the invoice must have an open status. Voiding will * cause any prepayments and credits that were applied to the invoice to be returned to the - * subscription. For a full overview of the impact of voiding, please [see our help docs]($m/Invoice). + * subscription. For a full overview of the impact of voiding, [see our help docs]($m/Invoice). * * @param subscriptionId The Chargify id of the subscription * @param body diff --git a/src/controllers/billingPortalController.ts b/src/controllers/billingPortalController.ts index 8bbf3ca..80803f9 100644 --- a/src/controllers/billingPortalController.ts +++ b/src/controllers/billingPortalController.ts @@ -53,8 +53,8 @@ export class BillingPortalController extends BaseController { * * In order to prevent abuse & overuse, we ask that you request a new URL only when absolutely * necessary. Management URLs are good for 65 days, so you should re-use a previously generated one as - * much as possible. If you use the URL frequently (such as to display on your website), please **do - * not** make an API request to Advanced Billing every time. + * much as possible. If you use the URL frequently (such as to display on your website), **do not** + * make an API request to Advanced Billing every time. * * @param customerId The Chargify id of the customer * @param autoInvite When set to 1, an Invitation email will be sent to the Customer. When set to 0, diff --git a/src/controllers/componentPricePointsController.ts b/src/controllers/componentPricePointsController.ts index 5b2df36..5d65bab 100644 --- a/src/controllers/componentPricePointsController.ts +++ b/src/controllers/componentPricePointsController.ts @@ -243,7 +243,7 @@ export class ComponentPricePointsController extends BaseController { } /** - * When updating a price point, it's prices can be updated as well by creating new prices or editing / + * When updating a price point, prices can be updated as well by creating new prices or editing / * removing existing ones. * * Passing in a price bracket without an `id` will attempt to create a new price. diff --git a/src/controllers/componentsController.ts b/src/controllers/componentsController.ts index 6eb6b3d..4e38f4d 100644 --- a/src/controllers/componentsController.ts +++ b/src/controllers/componentsController.ts @@ -60,8 +60,8 @@ export class ComponentsController extends BaseController { * the start of every billing period. If you want to bill for a quantity of something that does not * change unless you change it, then you want quantity components, instead. * - * For more information on components, please see our documentation [here](https://maxio.zendesk. - * com/hc/en-us/articles/24261141522189-Components-Overview). + * For more information on components, see our documentation [here](https://maxio.zendesk.com/hc/en- + * us/articles/24261141522189-Components-Overview). * * @param productFamilyId Either the product family's id or its handle prefixed * with `handle:` @@ -111,8 +111,8 @@ export class ComponentsController extends BaseController { * The allocated quantity for one-time quantity-based components immediately gets reset back to zero * after the allocation is made. * - * For more information on components, please see our documentation [here](https://maxio.zendesk. - * com/hc/en-us/articles/24261141522189-Components-Overview). + * For more information on components, see our documentation [here](https://maxio.zendesk.com/hc/en- + * us/articles/24261141522189-Components-Overview). * * @param productFamilyId Either the product family's id or its handle * prefixed with `handle:` @@ -150,8 +150,8 @@ export class ComponentsController extends BaseController { * On/off components are used for any flat fee, recurring add on (think $99/month for tech support or a * flat add on shipping fee). * - * For more information on components, please see our documentation [here](https://maxio.zendesk. - * com/hc/en-us/articles/24261141522189-Components-Overview). + * For more information on components, see our documentation [here](https://maxio.zendesk.com/hc/en- + * us/articles/24261141522189-Components-Overview). * * @param productFamilyId Either the product family's id or its handle prefixed * with `handle:` @@ -191,8 +191,8 @@ export class ComponentsController extends BaseController { * charge at the end of the period for the amount of units used, prepaid components are charged for at * the time of purchase, and we subsequently keep track of the usage against the amount purchased. * - * For more information on components, please see our documentation [here](https://maxio.zendesk. - * com/hc/en-us/articles/24261141522189-Components-Overview). + * For more information on components, see our documentation [here](https://maxio.zendesk.com/hc/en- + * us/articles/24261141522189-Components-Overview). * * @param productFamilyId Either the product family's id or its handle prefixed * with `handle:` @@ -236,8 +236,8 @@ export class ComponentsController extends BaseController { * So, instead of reporting usage directly for each component (as you would with metered components), * the usage is derived from analysis of your events. * - * For more information on components, please see our documentation [here](https://maxio.zendesk. - * com/hc/en-us/articles/24261141522189-Components-Overview). + * For more information on components, see our documentation [here](https://maxio.zendesk.com/hc/en- + * us/articles/24261141522189-Components-Overview). * * @param productFamilyId Either the product family's id or its handle prefixed with * `handle:` diff --git a/src/controllers/couponsController.ts b/src/controllers/couponsController.ts index 7cabe75..a9efcd0 100644 --- a/src/controllers/couponsController.ts +++ b/src/controllers/couponsController.ts @@ -42,13 +42,13 @@ export class CouponsController extends BaseController { /** * ## Coupons Documentation * - * Coupons can be administered in the Advanced Billing application or created via API. Please view our - * section on [creating coupons](https://maxio.zendesk.com/hc/en-us/articles/24261212433165-Creating- - * Editing-Deleting-Coupons) for more information. + * Coupons can be administered in the Advanced Billing application or created via API. View our section + * on [creating coupons](https://maxio.zendesk.com/hc/en-us/articles/24261212433165-Creating-Editing- + * Deleting-Coupons) for more information. * * Additionally, for documentation on how to apply a coupon to a subscription within the Advanced - * Billing UI, please see our documentation [here](https://maxio.zendesk.com/hc/en- - * us/articles/24261259337101-Coupons-and-Subscriptions). + * Billing UI, see our documentation [here](https://maxio.zendesk.com/hc/en-us/articles/24261259337101- + * Coupons-and-Subscriptions). * * ## Create Coupon * @@ -92,10 +92,6 @@ export class CouponsController extends BaseController { /** * List coupons for a specific Product Family in a Site. * - * If the coupon is set to `use_site_exchange_rate: true`, it will return pricing based on the current - * exchange rate. If the flag is set to false, it will return all of the defined prices for each - * currency. - * * @param productFamilyId The Advanced Billing id of the product family to which the * coupon belongs * @param page Result records are organized in pages. By default, the first @@ -291,10 +287,6 @@ export class CouponsController extends BaseController { /** * You can retrieve a list of coupons. * - * If the coupon is set to `use_site_exchange_rate: true`, it will return pricing based on the current - * exchange rate. If the flag is set to false, it will return all of the defined prices for each - * currency. - * * @param page Result records are organized in pages. By default, the first * page of results is displayed. The page parameter specifies a * page number of results to fetch. You can start navigating @@ -347,8 +339,8 @@ export class CouponsController extends BaseController { /** * This request will provide details about the coupon usage as an array of data hashes, one per product. * - * @param productFamilyId The Advanced Billing id of the product family to which the coupon belongs - * @param couponId The Advanced Billing id of the coupon + * @param productFamilyId The Advanced Billing id of the product family to which the coupon belongs. + * @param couponId The Advanced Billing id of the coupon. * @return Response from the API call */ async readCouponUsage( @@ -489,8 +481,8 @@ export class CouponsController extends BaseController { * [here](https://maxio.zendesk.com/hc/en-us/articles/24261208729229-Coupon-Codes). * * Additionally, for documentation on how to apply a coupon to a Subscription within the Advanced - * Billing UI, please see our documentation [here](https://maxio.zendesk.com/hc/en- - * us/articles/24261259337101-Coupons-and-Subscriptions). + * Billing UI, see our documentation [here](https://maxio.zendesk.com/hc/en-us/articles/24261259337101- + * Coupons-and-Subscriptions). * * ## Create Coupon Subcode * diff --git a/src/controllers/customFieldsController.ts b/src/controllers/customFieldsController.ts index 6a7d1ff..79a627b 100644 --- a/src/controllers/customFieldsController.ts +++ b/src/controllers/customFieldsController.ts @@ -52,48 +52,31 @@ import { SingleErrorResponseError } from '../errors/singleErrorResponseError.js' export class CustomFieldsController extends BaseController { /** - * ## Custom Fields: Metafield Intro + * Creates metafields on a Site for either the Subscriptions or Customers resource. * - * **Advanced Billing refers to Custom Fields in the API documentation as metafields and metadata.** - * Within the Advanced Billing UI, metadata and metafields are grouped together under the umbrella of - * "Custom Fields." All of our UI-based documentation that references custom fields will not cite the - * terminology metafields or metadata. + * Metafields and their metadata are created in the Custom Fields configuration page on your Site. + * Metafields can be populated with metadata when you create them or later with the [Update + * Metafield]($e/Custom%20Fields/updateMetafield), [Create Metadata]($e/Custom%20Fields/createMetadata), + * or [Update Metadata]($e/Custom%20Fields/updateMetadata) endpoints. The Create Metadata and Update + * Metadata endpoints allow you to add metafields and metadata values to a specific subscription or + * customer. * - * + **Metafield is the custom field** - * + **Metadata is the data populating the custom field.** + * Each site is limited to 100 unique metafields per resource. This means you can have 100 metafields + * for Subscriptions and another 100 for Customers. * - * Advanced Billing Metafields are used to add meaningful attributes to subscription and customer - * resources. Full documentation on how to create Custom Fields in the Advanced Billing UI can be - * located [here](https://maxio.zendesk.com/hc/en-us/sections/24266118312589-Custom-Fields). For - * additional documentation on how to record data within custom fields, please see our subscription- - * based documentation [here](https://maxio.zendesk.com/hc/en-us/articles/24251701302925-Subscription- - * Summary-Custom-Fields-Tab). + * > Note: After creating a metafield, the resource type cannot be modified. * - * Metafield are the place where you will set up your resource to accept additional data. It is scoped - * to the site instead of a specific customer or subscription. Think of it as the key, and Metadata as - * the value on every record. + * In the UI and product documentation, metafields and metadata are called Custom Fields. * - * ## Create Metafields + * - Metafield is the custom field + * - Metadata is the data populating the custom field. * - * Use this endpoint to create metafields for your Site. Metafields can be populated with metadata - * after the fact. + * See [Custom Fields Reference](https://docs.maxio.com/hc/en-us/articles/24266140850573-Custom-Fields- + * Reference) and [Custom Fields Tab](https://maxio.zendesk.com/hc/en-us/articles/24251701302925- + * Subscription-Summary-Custom-Fields-Tab) for information on using Custom Fields in the Advanced + * Billing UI. * - * Each site is limited to 100 unique Metafields (i.e. keys, or names) per resource. This means you can - * have 100 Metafields for Subscription and another 100 for Customer. - * - * ### Metafields "On-the-Fly" - * - * It is possible to create Metafields “on the fly” when you create your Metadata – if a non-existent - * name is passed when creating Metadata, a Metafield for that key will be automatically created. The - * Metafield API, however, gives you more control over your “keys”. - * - * ### Metafield Scope Warning - * - * If configuring metafields in the Admin UI or via the API, be careful sending updates to metafields - * with the scope attribute – **if a partial update is sent it will overwrite the current - * configuration**. - * - * @param resourceType the resource type to which the metafields belong + * @param resourceType The resource type to which the metafields belong. * @param body * @return Response from the API call */ @@ -121,11 +104,11 @@ export class CustomFieldsController extends BaseController { } /** - * This endpoint lists metafields associated with a site. The metafield description and usage is - * contained in the response. + * Lists the metafields and their associated details for a Site and resource type. You can filter the + * request to a specific metafield. * - * @param resourceType the resource type to which the metafields belong - * @param name filter by the name of the metafield + * @param resourceType The resource type to which the metafields belong. + * @param name Filter by the name of the metafield. * @param page Result records are organized in pages. By default, the first page of * results is displayed. The page parameter specifies a page number of * results to fetch. You can start navigating through the pages to consume @@ -174,10 +157,40 @@ export class CustomFieldsController extends BaseController { } /** - * Use the following method to update metafields for your Site. Metafields can be populated with - * metadata after the fact. + * Updates metafields on your Site for a resource type. Depending on the request structure, you can + * update or add metafields and metadata to the Subscriptions or Customers resource. + * + * With this endpoint, you can: + * + * - Add metafields. If the metafield specified in current_name does not exist, a new metafield is + * added. + * >Note: Each site is limited to 100 unique metafields per resource. This means you can have 100 + * metafields for Subscriptions and another 100 for Customers. + * + * - Change the name of a metafield. + * >Note: To keep the metafield name the same and only update the metadata for the metafield, you + * must use the current metafield name in both the `current_name` and `name` parameters. + * + * - Change the input type for the metafield. For example, you can change a metafield input type from + * text to a dropdown. If you change the input type from text to a dropdown or radio, you must update + * the specific subscriptions or customers where the metafield was used to reflect the updated + * metafield and metadata. + * + * - Add metadata values to the existing metadata for a dropdown or radio metafield. + * >Note: Updates to metadata overwrite. To add one or more values, you must specify all metadata + * values including the new value you want to add. * - * @param resourceType the resource type to which the metafields belong + * - Add new metadata to a dropdown or radio for a metafield that was created without metadata. + * + * - Remove metadata for a dropdown or radio for a metafield. + * >Note: Updates to metadata overwrite existing values. To remove one or more values, specify all + * metadata values except those you want to remove. + * + * - Add or update scope settings for a metafield. + * >Note: Scope changes overwrite existing settings. You must specify the complete scope, including + * the changes you want to make. + * + * @param resourceType The resource type to which the metafields belong. * @param body * @return Response from the API call */ @@ -205,12 +218,10 @@ export class CustomFieldsController extends BaseController { } /** - * Use the following method to delete a metafield. This will remove the metafield from the Site. + * Deletes a metafield from your Site. Removes the metafield and associated metadata from all + * Subscriptions or Customers resources on the Site. * - * Additionally, this will remove the metafield and associated metadata with all Subscriptions on the - * Site. - * - * @param resourceType the resource type to which the metafields belong + * @param resourceType The resource type to which the metafields belong. * @param name The name of the metafield to be deleted * @return Response from the API call */ @@ -232,41 +243,18 @@ export class CustomFieldsController extends BaseController { } /** - * ## Custom Fields: Metadata Intro - * - * **Advanced Billing refers to Custom Fields in the API documentation as metafields and metadata.** - * Within the Advanced Billing UI, metadata and metafields are grouped together under the umbrella of - * "Custom Fields." All of our UI-based documentation that references custom fields will not cite the - * terminology metafields or metadata. - * - * + **Metafield is the custom field** - * + **Metadata is the data populating the custom field.** - * - * Advanced Billing Metafields are used to add meaningful attributes to subscription and customer - * resources. Full documentation on how to create Custom Fields in the Advanced Billing UI can be - * located [here](https://maxio.zendesk.com/hc/en-us/articles/24266164865677-Custom-Fields-Overview). - * For additional documentation on how to record data within custom fields, please see our subscription- - * based documentation [here.](https://maxio.zendesk.com/hc/en-us/articles/24251701302925-Subscription- - * Summary-Custom-Fields-Tab) - * - * Metadata is associated to a customer or subscription, and corresponds to a Metafield. When creating - * a new metadata object for a given record, **if the metafield is not present it will be created**. - * - * ## Metadata limits - * - * Metadata values are limited to 2kB in size. Additonally, there are limits on the number of unique - * metafields available per resource. + * Creates metadata and metafields for a specific subscription or customer, or updates metadata values + * of existing metafields for a subscription or customer. Metadata values are limited to 2 KB in size. * - * ## Create Metadata + * If you create metadata on a subscription or customer with a metafield that does not already exist, + * the metafield is created with the metadata you specify and it is always added as a text field. You + * can update the input_type for the metafield with the [Update + * Metafield]($e/Custom%20Fields/updateMetafield) endpoint. * - * This method will create a metafield for the site on the fly if it does not already exist, and - * populate the metadata value. + * >Note: Each site is limited to 100 unique metafields per resource. This means you can have 100 + * metafields for Subscriptions and another 100 for Customers. * - * ### Subscription or Customer Resource - * - * Please pay special attention to the resource you use when creating metadata. - * - * @param resourceType the resource type to which the metafields belong + * @param resourceType The resource type to which the metafields belong. * @param resourceId The Advanced Billing id of the customer or the subscription * for which the metadata applies * @param body @@ -298,14 +286,9 @@ export class CustomFieldsController extends BaseController { } /** - * This request will list all of the metadata belonging to a particular resource (ie. subscription, - * customer) that is specified. - * - * ## Metadata Data + * Lists metadata and metafields for a specific customer or subscription. * - * This endpoint will also display the current stats of your metadata to use as a tool for pagination. - * - * @param resourceType the resource type to which the metafields belong + * @param resourceType The resource type to which the metafields belong. * @param resourceId The Advanced Billing id of the customer or the subscription for which the * metadata applies * @param page Result records are organized in pages. By default, the first page of results @@ -348,9 +331,18 @@ export class CustomFieldsController extends BaseController { } /** - * This method allows you to update the existing metadata associated with a subscription or customer. + * Updates metadata and metafields on the Site and the customer or subscription specified, and updates + * the metadata value on a subscription or customer. + * + * If you update metadata on a subscription or customer with a metafield that does not already exist, + * the metafield is created with the metadata you specify and it is always added as a text field to the + * Site and to the subscription or customer you specify. You can update the input_type for the + * metafield with the Update Metafield endpoint. * - * @param resourceType the resource type to which the metafields belong + * Each site is limited to 100 unique metafields per resource. This means you can have 100 metafields + * for Subscription and another 100 for Customer. + * + * @param resourceType The resource type to which the metafields belong. * @param resourceId The Advanced Billing id of the customer or the subscription * for which the metadata applies * @param body @@ -382,32 +374,9 @@ export class CustomFieldsController extends BaseController { } /** - * This method removes the metadata from the subscriber/customer cited. - * - * ## Query String Usage - * - * For instance if you wanted to delete the metadata for customer 99 named weight you would request: - * - * ``` - * https://acme.chargify.com/customers/99/metadata.json?name=weight - * ``` - * - * If you want to delete multiple metadata fields for a customer 99 named: `weight` and `age` you - * wrould request: - * ``` - * https://acme.chargify.com/customers/99/metadata.json?names[]=weight&names[]=age - * ``` + * Deletes one or more metafields (and associated metadata) from the specified subscription or customer. * - * ## Successful Response - * - * For a success, there will be a code `200` and the plain text response `true`. - * - * ## Unsuccessful Response - * - * When a failed response is encountered, you will receive a `404` response and the plain text response - * of `true`. - * - * @param resourceType the resource type to which the metafields belong + * @param resourceType The resource type to which the metafields belong. * @param resourceId The Advanced Billing id of the customer or the subscription for which the * metadata applies * @param name Name of field to be removed. @@ -438,22 +407,9 @@ export class CustomFieldsController extends BaseController { } /** - * This method will provide you information on usage of metadata across your selected resource (ie. - * subscriptions, customers) - * - * ## Metadata Data - * - * This endpoint will also display the current stats of your metadata to use as a tool for pagination. - * - * ### Metadata for multiple records - * - * `https://acme.chargify.com/subscriptions/metadata.json?resource_ids[]=1&resource_ids[]=2` - * - * ## Read Metadata for a Site - * - * This endpoint will list the number of pages of metadata information that are contained within a site. + * Lists metadata for a specified array of subscriptions or customers. * - * @param resourceType the resource type to which the metafields belong + * @param resourceType The resource type to which the metafields belong. * @param page Result records are organized in pages. By default, the first page of * results is displayed. The page parameter specifies a page number of * results to fetch. You can start navigating through the pages to consume diff --git a/src/controllers/customersController.ts b/src/controllers/customersController.ts index 2bcbbd5..52cc2b0 100644 --- a/src/controllers/customersController.ts +++ b/src/controllers/customersController.ts @@ -53,8 +53,8 @@ export class CustomersController extends BaseController { * Advanced Billing requires that you use the ISO Standard Country codes when formatting country * attribute of the customer. * - * Countries should be formatted as 2 characters. For more information, please see the following - * wikipedia article on [ISO_3166-1.](http://en.wikipedia.org/wiki/ISO_3166-1#Current_codes) + * Countries should be formatted as 2 characters. For more information, see the following wikipedia + * article on [ISO_3166-1.](http://en.wikipedia.org/wiki/ISO_3166-1#Current_codes) * * ## Required State Format * @@ -63,9 +63,9 @@ export class CustomersController extends BaseController { * * + US States (2 characters): [ISO_3166-2](https://en.wikipedia.org/wiki/ISO_3166-2:US) * - * + States Outside the US (2-3 characters): To find the correct state codes outside of the US, please - * go to [ISO_3166-1](http://en.wikipedia.org/wiki/ISO_3166-1#Current_codes) and click on the link in - * the “ISO 3166-2 codes” column next to country you wish to populate. + * + States Outside the US (2-3 characters): To find the correct state codes outside of the US, go to + * [ISO_3166-1](http://en.wikipedia.org/wiki/ISO_3166-1#Current_codes) and click on the link in the + * “ISO 3166-2 codes” column next to country you wish to populate. * * ## Locale * @@ -113,7 +113,7 @@ export class CustomersController extends BaseController { * + Search by a reference value from your application * + Search by a first or last name * - * To retrieve a single, exact match by reference, please use the [lookup endpoint](https://developers. + * To retrieve a single, exact match by reference, use the [lookup endpoint](https://developers. * chargify.com/docs/api-docs/b710d8fbef104-read-customer-by-reference). * * @param direction Direction to sort customers by time of creation diff --git a/src/controllers/invoicesController.ts b/src/controllers/invoicesController.ts index 243f0a4..caa1d2c 100644 --- a/src/controllers/invoicesController.ts +++ b/src/controllers/invoicesController.ts @@ -866,12 +866,49 @@ export class InvoicesController extends BaseController { * ... * ``` * + * #### Using Coupon Subcodes + * You can also use coupon subcodes to apply existing coupons with specific subcodes: + * + * ```json + * ... + * "coupons": [ + * { + * "subcode": "SUB1", + * "product_family_id": 1 + * } + * ] + * ... + * ``` + * **Important:** You cannot specify both `code` and `subcode` for the same coupon. Use either: + * - `code` to apply a main coupon + * - `subcode` to apply a specific coupon subcode + * + * The API response will include both the main coupon code and the subcode used: + * + * ```json + * ... + * "coupons": [ + * { + * "code": "MAIN123", + * "subcode": "SUB1", + * "product_family_id": 1, + * "percentage": 10, + * "description": "Special discount" + * } + * ] + * ... + * ``` + * * ### Coupon options * #### Code * Coupon `code` will be displayed on invoice discount section. * Coupon code can only contain uppercase letters, numbers, and allowed special characters. * Lowercase letters will be converted to uppercase. It can be used to select an existing coupon from * the catalog, or as an ad hoc coupon when passed with `percentage` or `amount`. + * #### Subcode + * Coupon `subcode` allows you to apply existing coupons using their subcodes. When a subcode is used, + * the API response will include both the main coupon code and the specific subcode that was applied. + * Subcodes are case-insensitive and will be converted to uppercase automatically. * #### Percentage * Coupon `percentage` can take values from 0 to 100 and up to 4 decimal places. It cannot be used with * `amount`. Only for ad hoc coupons, will be ignored if `code` is used to select an existing coupon @@ -940,8 +977,8 @@ export class InvoicesController extends BaseController { * #### Addresses * * The seller, shipping and billing addresses can be sent to override the site's defaults. Each address - * requires to send a `first_name` at a minimum in order to work. Please see below for the details on - * which parameters can be sent for each address object. + * requires to send a `first_name` at a minimum in order to work. See below for the details on which + * parameters can be sent for each address object. * * #### Memo and Payment Instructions * @@ -985,14 +1022,14 @@ export class InvoicesController extends BaseController { * supports email delivery to direct recipients, carbon-copy (cc) recipients, and blind carbon-copy * (bcc) recipients. * - * Please note that if no recipient email addresses are specified in the request, then the - * subscription's default email configuration will be used. For example, if `recipient_emails` is left - * blank, then the invoice will be delivered to the subscription's customer email address. + * If no recipient email addresses are specified in the request, then the subscription's default email + * configuration will be used. For example, if `recipient_emails` is left blank, then the invoice will + * be delivered to the subscription's customer email address. * - * On success, a 204 no-content response will be returned. Please note that this does not indicate that - * email(s) have been delivered, but instead indicates that emails have been successfully queued for - * delivery. If _any_ invalid or malformed email address is found in the request body, the entire - * request will be rejected and a 422 response will be returned. + * On success, a 204 no-content response will be returned. The response does not indicate that email(s) + * have been delivered, but instead indicates that emails have been successfully queued for delivery. + * If _any_ invalid or malformed email address is found in the request body, the entire request will be + * rejected and a 422 response will be returned. * * @param uid The unique identifier for the invoice, this does not refer to * the public facing invoice number. diff --git a/src/controllers/paymentProfilesController.ts b/src/controllers/paymentProfilesController.ts index 534d2c5..342bb45 100644 --- a/src/controllers/paymentProfilesController.ts +++ b/src/controllers/paymentProfilesController.ts @@ -37,44 +37,26 @@ import { ErrorStringMapResponseError } from '../errors/errorStringMapResponseErr export class PaymentProfilesController extends BaseController { /** - * Use this endpoint to create a payment profile for a customer. + * Creates a payment profile for a customer. * - * Payment Profiles house the credit card, ACH (Authorize.Net or Stripe only,) or PayPal (Braintree - * only,) data for a customer. The payment information is attached to the customer within Advanced - * Billing, as opposed to the Subscription itself. + * When you create a new payment profile for a customer via the API, it does not automatically make the + * profile current for any of the customer’s subscriptions. To use the payment profile as the default, + * you must set it explicitly for the subscription or subscription group. * - * You must include a customer_id so that Advanced Billing will attach it to the customer entry. If no - * customer_id is included the API will return a 404. + * Select an option from the **Request Examples** drop-down on the right side of the portal to see + * examples of common scenarios for creating payment profiles. * - * ## Create a Payment Profile for ACH usage + * Do not use real card information for testing. See the Sites articles that cover [testing your site + * setup](https://docs.maxio.com/hc/en-us/articles/24250712113165-Testing-Overview#testing-overview-0- + * 0) for more details on testing in your sandbox. * - * If you would like to create a payment method that is a Bank Account applicable for ACH payments use - * the following: - * ```json - * { - * "payment_profile": { - * "customer_id": [Valid-Customer-ID], - * "bank_name": "Best Bank", - * "bank_routing_number": "021000089", - * "bank_account_number": "111111111111", - * "bank_account_type": "checking", - * "bank_account_holder_type": "business", - * "payment_type": "bank_account" - * } - * } - * ``` - * - * ## Taxable Subscriptions + * Note that collecting and sending raw card details in production requires [PCI compliance](https: + * //docs.maxio.com/hc/en-us/articles/24183956938381-PCI-Compliance#pci-compliance-0-0) on your end. If + * your business is not PCI compliant, use [Chargify.js](https://docs.maxio.com/hc/en- + * us/articles/38163190843789-Chargify-js-Overview#chargify-js-overview-0-0) to collect credit card or + * bank account information. * - * If your subscriber pays taxes on their purchased product, and you are attempting to create or update - * the `payment_profile`, complete address information is required. For information on required address - * formatting to allow your subscriber to be taxed, please see our documentation [here](https: - * //developers.chargify.com/docs/developer-docs/d2e9e34db740e-signups#taxes) - * - * ## Payment Profile Documentation - * - * Full documentation on how Payment Profiles operate within Advanced Billing can be located under the - * following links: + * See the following articles to learn more about subscriptions and payments: * * + [Subscriber Payment Details](https://maxio.zendesk.com/hc/en-us/articles/24251599929613- * Subscription-Summary-Payment-Details-Tab) @@ -82,232 +64,38 @@ export class PaymentProfilesController extends BaseController { * Pages) (Allows credit card updates by Subscriber) * + [Public Signup Pages payment settings](https://maxio.zendesk.com/hc/en-us/articles/24261368332557- * Individual-Page-Settings) - * - * ## Create a Payment Profile with a Chargify.js token - * - * ```json - * { - * "payment_profile": { - * "customer_id": 1036, - * "chargify_token": "tok_w68qcpnftyv53jk33jv6wk3w" - * } - * } - * ``` - * - * ## Active Payment Methods - * - * Creating a new payment profile for a Customer via the API will not make that Payment Profile current - * for any of the Customer’s Subscriptions. In order to utilize the payment profile as the default, it - * must be set as the default payment profile for the subscription or subscription group. - * - * ## Requirements - * - * Either the full_number, expiration_month, and expiration_year or if you have an existing vault_token - * from your gateway, that vault_token and the current_vault are required. - * Passing in the vault_token and current_vault are only allowed when creating a new payment profile. - * - * ### Taxable Subscriptions - * - * If your subscriber pays taxes on their purchased product, and you are attempting to create or update - * the `payment_profile`, complete address information is required. For information on required address - * formatting to allow your subscriber to be taxed, please see our documentation [here](https: - * //developers.chargify.com/docs/developer-docs/d2e9e34db740e-signups#taxes) - * - * ## BraintreeBlue - * Some merchants use Braintree JavaScript libraries directly and then pass `payment_method_nonce` - * and/or `paypal_email` to create a payment profile. This implementation is deprecated and does not - * handle 3D Secure. Instead, we have provided [Chargify.js](https://developers.chargify. - * com/docs/developer-docs/ZG9jOjE0NjAzNDI0-overview) which is continuously improved and supports - * Credit Cards (along with 3D Secure), PayPal and ApplePay payment types. - * - * ## GoCardless - * - * For more information on GoCardless, please view the following resources: - * - * + [Full documentation on GoCardless](https://maxio.zendesk.com/hc/en-us/articles/24176159136909- - * GoCardless) - * - * + [Using Chargify.js with GoCardless - minimal example](https://docs.maxio.com/hc/en- + * + [Taxes](https://developers.chargify.com/docs/developer-docs/d2e9e34db740e-signups#taxes) + * + [Chargify.js](https://docs.maxio.com/hc/en-us/articles/38163190843789-Chargify-js-Overview) + * + [Chargify.js with GoCardless - minimal example](https://docs.maxio.com/hc/en- * us/articles/38206331271693-Examples#h_01K0PJ15QQZKCER8CFK40MR6XJ) - * - * + [Using Chargify.js with GoCardless - full example](https://docs.maxio.com/hc/en- + * + [Chargify.js with GoCardless - full example](https://docs.maxio.com/hc/en- * us/articles/38206331271693-Examples#h_01K0PJ15QR09JVHWW0MCA7HVJV) - * - * ### GoCardless with Local Bank Details - * - * Following examples create customer, bank account and mandate in GoCardless: - * - * ```json - * { - * "payment_profile": { - * "customer_id": "Valid-Customer-ID", - * "bank_name": "Royal Bank of France", - * "bank_account_number": "0000000", - * "bank_routing_number": "0003", - * "bank_branch_code": "00006", - * "payment_type": "bank_account", - * "billing_address": "20 Place de la Gare", - * "billing_city": "Colombes", - * "billing_state": "Île-de-France", - * "billing_zip": "92700", - * "billing_country": "FR" - * } - * } - * ``` - * - * ### GoCardless with IBAN - * - * ```json - * { - * "payment_profile": { - * "customer_id": "24907598", - * "bank_name": "French Bank", - * "bank_iban": "FR1420041010050500013M02606", - * "payment_type": "bank_account", - * "billing_address": "20 Place de la Gare", - * "billing_city": "Colombes", - * "billing_state": "Île-de-France", - * "billing_zip": "92700", - * "billing_country": "FR" - * } - * } - * ``` - * - * ### Importing GoCardless - * - * If the customer, bank account, and mandate already exist in GoCardless, a payment profile can be - * created by using the IDs. In order to create masked versions of `bank_account_number` and - * `bank_routing_number` that are used to display within Advanced Billing Admin UI, you can pass the - * last four digits for this fields which then will be saved in this form `XXXX[four-provided-digits]`. - * - * ```json - * { - * "payment_profile": { - * "customer_id": "24907598", - * "customer_vault_token": [Existing GoCardless Customer ID] - * "vault_token": [Existing GoCardless Mandate ID], - * "current_vault": "gocardless", - * "bank_name": "French Bank", - * "bank_account_number": [Last Four Of The Existing Account Number or IBAN if applicable], - * "bank_routing_number": [Last Four Of The Existing Routing Number], - * "payment_type": "bank_account", - * "billing_address": "20 Place de la Gare", - * "billing_city": "Colombes", - * "billing_state": "Île-de-France", - * "billing_zip": "92700", - * "billing_country": "FR" - * } - * } - * ``` - * - * ## SEPA Direct Debit - * - * For more information on Stripe SEPA Direct Debit, please view the following resources: - * - * + [Full documentation on Stripe SEPA Direct Debit](https://maxio.zendesk.com/hc/en- - * us/articles/24176170430093-Stripe-SEPA-and-BECS-Direct-Debit) - * - * + [Using Chargify.js with Stripe Direct Debit - minimal example](https://docs.maxio.com/hc/en- + * + [Chargify.js with Stripe Direct Debit - minimal example](https://docs.maxio.com/hc/en- * us/articles/38206331271693-Examples#h_01K0PJ15QQFKKN8Z7B7DZ9AJS5) - * - * + [Using Chargify.js with Stripe Direct Debit - full example](https://docs.maxio.com/hc/en- + * + [Chargify.js with Stripe Direct Debit - full example](https://docs.maxio.com/hc/en- * us/articles/38206331271693-Examples#h_01K0PJ15QRECQQ4ECS3ZA55GY7) - * - * ### Stripe SEPA Direct Debit Payment Profiles - * - * The following example creates a customer, bank account and mandate in Stripe: - * - * - * ```json - * { - * "payment_profile": { - * "customer_id": "24907598", - * "bank_name": "Deutsche bank", - * "bank_iban": "DE89370400440532013000", - * "payment_type": "bank_account", - * "billing_address": "Test", - * "billing_city": "Berlin", - * "billing_state": "Brandenburg", - * "billing_zip": "12345", - * "billing_country": "DE" - * } - * } - * ``` - * - * ## Stripe BECS Direct Debit - * - * For more information on Stripe BECS Direct Debit, please view the following resources: - * - * + [Full documentation on Stripe BECS Direct Debit](https://maxio.zendesk.com/hc/en- - * us/articles/24176170430093-Stripe-SEPA-and-BECS-Direct-Debit) - * - * + [Using Chargify.js with Stripe BECS Direct Debit - minimal example](https://developers.chargify. + * + [Chargify.js with Stripe BECS Direct Debit - minimal example](https://developers.chargify. * com/docs/developer-docs/ZG9jOjE0NjAzNDIy-examples#minimal-example-with-sepa-or-becs-direct-debit- * stripe-gateway) - * - * + [Using Chargify.js with Stripe BECS Direct Debit - full example](https://developers.chargify. + * + [Chargify.js with Stripe BECS Direct Debit - full example](https://developers.chargify. * com/docs/developer-docs/ZG9jOjE0NjAzNDIy-examples#full-example-with-sepa-direct-debit-stripe- * gateway) - * - * ### Stripe BECS Direct Debit Payment Profiles - * - * The following example creates a customer, bank account and mandate in Stripe: - * - * - * ```json - * { - * "payment_profile": { - * "customer_id": "24907598", - * "bank_name": "Australian bank", - * "bank_branch_code": "000000", - * "bank_account_number": "000123456" - * "payment_type": "bank_account", - * "billing_address": "Test", - * "billing_city": "Stony Rise", - * "billing_state": "Tasmania", - * "billing_zip": "12345", - * "billing_country": "AU" - * } - * } - * ``` - * - * ## Stripe BACS Direct Debit - * - * Contact the support team to enable this payment method. - * For more information on Stripe BACS Direct Debit, please view the following resources: - * + * + [Full documentation on GoCardless](https://maxio.zendesk.com/hc/en-us/articles/24176159136909- + * GoCardless) + * + [Full documentation on Stripe SEPA Direct Debit](https://maxio.zendesk.com/hc/en- + * us/articles/24176170430093-Stripe-SEPA-and-BECS-Direct-Debit) + * + [Full documentation on Stripe BECS Direct Debit](https://maxio.zendesk.com/hc/en- + * us/articles/24176170430093-Stripe-SEPA-and-BECS-Direct-Debit) * + [Full documentation on Stripe BACS Direct Debit](https://maxio.zendesk.com/hc/en- * us/articles/24176170430093-Stripe-SEPA-and-BECS-Direct-Debit) * - * ### Stripe BACS Direct Debit Payment Profiles - * - * The following example creates a customer, bank account and mandate in Stripe: + * ## 3D Secure Authentication during payment profile creation. * - * - * ```json - * { - * "payment_profile": { - * "customer_id": "24907598", - * "bank_name": "British bank", - * "bank_branch_code": "108800", - * "bank_account_number": "00012345" - * "payment_type": "bank_account", - * "billing_address": "Test", - * "billing_city": "London", - * "billing_state": "LND", - * "billing_zip": "12345", - * "billing_country": "GB" - * } - * } - * ``` - * - * ## 3D Secure - Checkout - * - * It may happen that a payment needs 3D Secure Authentication when the payment profile is created; - * this is referred to in our help docs as a [post-authentication flow](https://maxio.zendesk.com/hc/en- - * us/articles/24176278996493-Testing-Implementing-3D-Secure#psd2-flows-pre-authentication-and-post- - * authentication). The server returns `422 Unprocessable Entity` in this case with the following - * response: + * When a payment requires 3D Secure Authentication to adhear to Strong Customer Authentication (SCA) + * during payment profile creation, the request enters a [post-authentication flow](https://maxio. + * zendesk.com/hc/en-us/articles/24176278996493-Testing-Implementing-3D-Secure#psd2-flows-pre- + * authentication-and-post-authentication). In this case, a 422 Unprocessable Entity status is returned + * with the following response: * * ```json * { @@ -333,46 +121,48 @@ export class PaymentProfilesController extends BaseController { * ] * } * ``` - * * To let the customer go through 3D Secure Authentication, they need to be redirected to the URL * specified in `action_link`. - * Optionally, you can specify `callback_url` parameter in the `action_link` URL if you’d like to be - * notified about the result of 3D Secure Authentication. The `callback_url` will return the following - * information: + * + * Optionally, you can specify the `callback_url` parameter in the `action_link` URL to receive + * notification about the result of 3D Secure Authentication. + * + * The `callback_url` will return the following information: * * - whether the authentication was successful (`success`) * - the payment profile ID (`payment_profile_id`) * - * Lastly, you can also specify a `redirect_url` parameter within the `action_link` URL if you’d like - * to redirect a customer back to your site. + * You can also specify a `redirect_url` parameter in the `action_link` URL to redirect the customer + * back to your site. * - * It is not possible to use `action_link` in an iframe inside a custom application. You have to - * redirect the customer directly to the `action_link`, then, to be notified about the result, use - * `redirect_url` or `callback_url`. + * You cannot use action_link in an iframe inside a custom application. You must redirect the customer + * directly to the `action_link` and use the `redirect_url` or `callback_url` to be notified of the + * result. * * The final URL that you send a customer to complete 3D Secure may resemble the following, where the * first half is the `action_link` and the second half contains a `redirect_url` and `callback_url`: + * * `https://checkout-test.chargifypay.test/3d-secure/checkout/pay_uerzhsxd5uhkbodx5jhvkg6yeu? * one_time_token_id=93&callback_url=http://localhost:4000&redirect_url=https://yourpage.com` * * ### Example Redirect Flow * - * You may wish to redirect customers to different pages depending on whether their SCA was performed - * successfully. Here's an example flow to use as a reference: + * Here's an example flow to redirect customers to different pages depending on whether SCA was + * performed successfully: * - * 1. Create a payment profile via API; it requires 3DS - * 2. You receive a `action_link` in the response. + * 1. Create a payment profile via the API; it requires 3DS. + * 2. You receive an `action_link` in the response. * 3. Use this `action_link` to, for example, connect with your internal resources or generate a - * session_id - * 4. Include 1 of those attributes inside the `callback_url` and `redirect_url` to be aware which - * “session” this applies to + * `session_id`. + * 4. Include one of those attributes inside the `callback_url` and `redirect_url` to be aware which + * “session” this applies to. * 5. Redirect the customer to the `action_link` with `callback_url` and `redirect_url` applied - * 6. After the customer finishes 3DS authentication, we let you know the result by making a request to - * applied `callback_url`. + * 6. After the customer completes 3DS authentication, we notify you of the result via the applied + * `callback_url`. * 7. After that, we redirect the customer to the `redirect_url`; at this point the result of - * authentication is known - * 8. Optionally, you can use the applied "msg" param in the `redirect_url` to determine whether it was - * successful or not + * authentication is known. + * 8. Optionally, you can use the applied "msg" param in the `redirect_url` to determine if the + * redirect was successful. * * @param body When following the IBAN or the Local Bank details * examples, a customer, bank account and mandate will be @@ -447,8 +237,7 @@ export class PaymentProfilesController extends BaseController { /** * Using the GET method you can retrieve a Payment Profile identified by its unique ID. * - * Please note that a different JSON object will be returned if the card method on file is a bank - * account. + * Note that a different JSON object will be returned if the card method on file is a bank account. * * ### Response for Bank Account * diff --git a/src/controllers/productFamiliesController.ts b/src/controllers/productFamiliesController.ts index 619116e..26039e3 100644 --- a/src/controllers/productFamiliesController.ts +++ b/src/controllers/productFamiliesController.ts @@ -36,7 +36,7 @@ import { ErrorListResponseError } from '../errors/errorListResponseError.js'; export class ProductFamiliesController extends BaseController { /** - * This method allows to retrieve a list of Products belonging to a Product Family. + * Retrieves a list of Products belonging to a Product Family. * * @param productFamilyId Either the product family's id or its handle prefixed with * `handle:` @@ -139,8 +139,8 @@ export class ProductFamiliesController extends BaseController { } /** - * This method will create a Product Family within your Advanced Billing site. Create a Product Family - * to act as a container for your products, components and coupons. + * Creates a Product Family within your Advanced Billing site. Create a Product Family to act as a + * container for your products, components and coupons. * * Full documentation on how Product Families operate within the Advanced Billing UI can be located * [here](https://maxio.zendesk.com/hc/en-us/articles/24261098936205-Product-Families). @@ -169,7 +169,7 @@ export class ProductFamiliesController extends BaseController { } /** - * This method allows to retrieve a list of Product Families for a site. + * Retrieve a list of Product Families for a site. * * @param dateField The type of filter you would like to apply to your search. Use in query: * `date_field=created_at`. @@ -225,8 +225,8 @@ export class ProductFamiliesController extends BaseController { } /** - * This method allows to retrieve a Product Family via the `product_family_id`. The response will - * contain a Product Family object. + * Retrieves a Product Family via the `product_family_id`. The response will contain a Product Family + * object. * * The product family can be specified either with the id number, or with the `handle:my-family` format. * diff --git a/src/controllers/productPricePointsController.ts b/src/controllers/productPricePointsController.ts index 8f7840e..5b9f7f7 100644 --- a/src/controllers/productPricePointsController.ts +++ b/src/controllers/productPricePointsController.ts @@ -102,8 +102,8 @@ import { ProductPricePointErrorResponseError } from '../errors/productPricePoint export class ProductPricePointsController extends BaseController { /** - * [Product Price Point Documentation](https://maxio.zendesk.com/hc/en-us/articles/24261111947789- - * Product-Price-Points) + * Creates a Product Price Point. See the [Product Price Point](https://maxio.zendesk.com/hc/en- + * us/articles/24261111947789-Product-Price-Points) documentation for details. * * @param productId The id or handle of the product. When using the * handle, it must be prefixed with `handle:` @@ -134,7 +134,7 @@ export class ProductPricePointsController extends BaseController { } /** - * Use this endpoint to retrieve a list of product price points. + * Retrieves a list of product price points. * * @param productId The id or handle of the product. When using the * handle, it must be prefixed with `handle:` @@ -203,9 +203,9 @@ export class ProductPricePointsController extends BaseController { } /** - * Use this endpoint to update a product price point. + * Updates a product price point. * - * Note: Custom product price points are not able to be updated. + * Note: Custom product price points cannot be updated. * * @param productId The id or handle of the product. When using the * handle, it must be prefixed with `handle:`. Example: @@ -280,7 +280,7 @@ export class ProductPricePointsController extends BaseController { } /** - * Use this endpoint to archive a product price point. + * Archives a product price point. * * @param productId The id or handle of the product. When using the * handle, it must be prefixed with `handle:`. Example: @@ -336,9 +336,9 @@ export class ProductPricePointsController extends BaseController { } /** - * Use this endpoint to make a product price point the default for the product. + * Sets a product price point as the default for the product. * - * Note: Custom product price points are not able to be set as the default for a product. + * Note: Custom product price points cannot be set as the default for a product. * * @param productId The Advanced Billing id of the product to which the price point belongs * @param pricePointId The Advanced Billing id of the product price point @@ -360,7 +360,7 @@ export class ProductPricePointsController extends BaseController { } /** - * Use this endpoint to create multiple product price points in one request. + * Creates multiple product price points in one request. * * @param productId The Advanced Billing id of the product to which * the price points belong @@ -394,8 +394,8 @@ export class ProductPricePointsController extends BaseController { } /** - * This endpoint allows you to create currency prices for a given currency that has been defined on the - * site level in your settings. + * Creates currency prices for a given currency that has been defined on the site level in your + * settings. * * When creating currency prices, they need to mirror the structure of your primary pricing. If the * product price point defines a trial and/or setup fee, each currency must also define a trial and/or @@ -432,14 +432,13 @@ export class ProductPricePointsController extends BaseController { } /** - * This endpoint allows you to update the `price`s of currency prices for a given currency that exists - * on the product price point. + * Updates the `price`s of currency prices for a given currency that exists on the product price point. * * When updating the pricing, it needs to mirror the structure of your primary pricing. If the product * price point defines a trial and/or setup fee, each currency must also define a trial and/or setup * fee. * - * Note: Currency Prices are not able to be updated for custom product price points. + * Note: Currency Prices cannot be updated for custom product price points. * * @param productPricePointId The Advanced Billing id of the product price * point diff --git a/src/controllers/productsController.ts b/src/controllers/productsController.ts index 44ae354..64937bc 100644 --- a/src/controllers/productsController.ts +++ b/src/controllers/productsController.ts @@ -31,7 +31,9 @@ import { ErrorListResponseError } from '../errors/errorListResponseError.js'; export class ProductsController extends BaseController { /** - * Use this method to create a product within your Advanced Billing site. + * Creates a product in your Advanced Billing site. + * + * See the following product docuemation for more information: * * + [Products Documentation](https://maxio.zendesk.com/hc/en-us/articles/24261090117645-Products- * Overview) @@ -67,8 +69,7 @@ export class ProductsController extends BaseController { } /** - * This endpoint allows you to read the current details of a product that you've created in Advanced - * Billing. + * Reads the current details of a product. * * @param productId The Advanced Billing id of the product * @return Response from the API call @@ -85,7 +86,7 @@ export class ProductsController extends BaseController { } /** - * Use this method to change aspects of an existing product. + * Updates aspects of an existing product. * * ### Input Attributes Update Notes * @@ -126,8 +127,8 @@ export class ProductsController extends BaseController { } /** - * Sending a DELETE request to this endpoint will archive the product. All current subscribers will be - * unffected; their subscription/purchase will continue to be charged monthly. + * Archives the product. All current subscribers will be unffected; their subscription/purchase will + * continue to be charged monthly. * * This will restrict the option to chose the product for purchase via the Billing Portal, as well as * disable Public Signup Pages for the product. @@ -153,7 +154,7 @@ export class ProductsController extends BaseController { } /** - * This method allows to retrieve a Product object by its `api_handle`. + * Retrieves a Product object by its `api_handle`. * * @param apiHandle The handle of the product * @return Response from the API call diff --git a/src/controllers/proformaInvoicesController.ts b/src/controllers/proformaInvoicesController.ts index 97b13bb..1d35270 100644 --- a/src/controllers/proformaInvoicesController.ts +++ b/src/controllers/proformaInvoicesController.ts @@ -164,7 +164,7 @@ export class ProformaInvoicesController extends BaseController { * outdated, simply void the old proforma invoice and generate a new one. * * If you would like to preview the next billing amounts without generating a full proforma invoice, - * please use the renewal preview endpoint. + * use the renewal preview endpoint. * * ## Restrictions * diff --git a/src/controllers/salesCommissionsController.ts b/src/controllers/salesCommissionsController.ts index 23c1d8b..6234f37 100644 --- a/src/controllers/salesCommissionsController.ts +++ b/src/controllers/salesCommissionsController.ts @@ -32,7 +32,7 @@ export class SalesCommissionsController extends BaseController { * * Access to the Sales Commission API endpoints is available to users with financial access, where the * seller has the Advanced Analytics component enabled. For further information on getting access to - * Advanced Analytics please contact Maxio support. + * Advanced Analytics contact Maxio support. * * > Note: The request is at seller level, it means `<>` variable will be replaced by `app` * @@ -99,7 +99,7 @@ export class SalesCommissionsController extends BaseController { * * Access to the Sales Commission API endpoints is available to users with financial access, where the * seller has the Advanced Analytics component enabled. For further information on getting access to - * Advanced Analytics please contact Maxio support. + * Advanced Analytics contact Maxio support. * * > Note: The request is at seller level, it means `<>` variable will be replaced by `app` * @@ -166,7 +166,7 @@ export class SalesCommissionsController extends BaseController { * * Access to the Sales Commission API endpoints is available to users with financial access, where the * seller has the Advanced Analytics component enabled. For further information on getting access to - * Advanced Analytics please contact Maxio support. + * Advanced Analytics contact Maxio support. * * > Note: The request is at seller level, it means `<>` variable will be replaced by `app` * diff --git a/src/controllers/subscriptionComponentsController.ts b/src/controllers/subscriptionComponentsController.ts index b520772..64f4f43 100644 --- a/src/controllers/subscriptionComponentsController.ts +++ b/src/controllers/subscriptionComponentsController.ts @@ -670,50 +670,48 @@ export class SubscriptionComponentsController extends BaseController { } /** - * ## Documentation + * Records an instance of metered or prepaid usage for a subscription. + * + * You can report metered or prepaid usage to Advanced Billing as often as you wish. You can report + * usage as it happens or periodically, such as each night or once per billing period. * * Full documentation on how to create Components in the Advanced Billing UI can be located * [here](https://maxio.zendesk.com/hc/en-us/articles/24261149711501-Create-Edit-and-Archive- * Components). Additionally, for information on how to record component usage against a subscription, - * please see the following resources: + * see the following resources: * - * + [Recording Metered Component Usage](https://maxio.zendesk.com/hc/en-us/articles/24251890500109- - * Reporting-Component-Allocations#reporting-metered-component-usage) - * + [Reporting Prepaid Component Status](https://maxio.zendesk.com/hc/en-us/articles/24251890500109- - * Reporting-Component-Allocations#reporting-prepaid-component-status) + * It is not possible to record metered usage for more than one component at a time Usage should be + * reported as one API call per component on a single subscription. For example, to record that a + * subscriber has sent both an SMS Message and an Email, send an API call for each. * - * You may choose to report metered or prepaid usage to Advanced Billing as often as you wish. You may - * report usage as it happens. You may also report usage periodically, such as each night or once per - * billing period. If usage events occur in your system very frequently (on the order of thousands of - * times an hour), it is best to accumulate usage into batches on your side, and then report those - * batches less frequently, such as daily. This will ensure you remain below any API throttling limits. - * If your use case requires higher rates of usage reporting, we recommend utilizing Events Based - * Components. + * See the following product documention articles for more information: * - * ## Create Usage for Subscription + * - [Create and Manage Components](https://maxio.zendesk.com/hc/en-us/articles/24261149711501-Create- + * Edit-and-Archive-Components). A + * - [Recording Metered Component Usage](https://maxio.zendesk.com/hc/en-us/articles/24251890500109- + * Reporting-Component-Allocations#reporting-metered-component-usage) + * - [Reporting Prepaid Component Status](https://maxio.zendesk.com/hc/en-us/articles/24251890500109- + * Reporting-Component-Allocations#reporting-prepaid-component-status) * - * This endpoint allows you to record an instance of metered or prepaid usage for a subscription. The - * `quantity` from usage for each component is accumulated to the `unit_balance` on the [Component Line - * Item](./b3A6MTQxMDgzNzQ-read-subscription-component) for the subscription. + * The `quantity` from usage for each component is accumulated to the `unit_balance` on the [Component + * Line Item]($e/Subscription%20Components/readSubscriptionComponent) for the subscription. * * ## Price Point ID usage * - * If you are using price points, for metered and prepaid usage components, Advanced Billing gives you + * If you are using price points, for metered and prepaid usage components Advanced Billing gives you * the option to specify a price point in your request. * * You do not need to specify a price point ID. If a price point is not included, the default price * point for the component will be used when the usage is recorded. * - * If an invalid `price_point_id` is submitted, the endpoint will return an error. - * * ## Deducting Usage * - * In the event that you need to reverse a previous usage report or otherwise deduct from the current - * usage balance, you may provide a negative quantity. + * If you need to reverse a previous usage report or otherwise deduct from the current usage balance, + * you can provide a negative quantity. * * Example: * - * Previously recorded: + * Previously recorded quantity was 5000: * * ```json * { @@ -724,8 +722,7 @@ export class SubscriptionComponentsController extends BaseController { * } * ``` * - * At this point, `unit_balance` would be `5000`. To reduce the balance to `0`, POST the following - * payload: + * To reduce the quantity to `0`, POST the following payload: * * ```json * { @@ -735,17 +732,9 @@ export class SubscriptionComponentsController extends BaseController { * } * } * ``` - * * The `unit_balance` has a floor of `0`; negative unit balances are never allowed. For example, if the * usage balance is 100 and you deduct 200 units, the unit balance would then be `0`, not `-100`. * - * ## FAQ - * - * Q. Is it possible to record metered usage for more than one component at a time? - * - * A. No. Usage should be reported as one API call per component on a single subscription. For example, - * to record that a subscriber has sent both an SMS Message and an Email, send an API call for each. - * * @param subscriptionIdOrReference Either the Advanced Billing * subscription ID (integer) or the * subscription reference (string). diff --git a/src/controllers/subscriptionGroupStatusController.ts b/src/controllers/subscriptionGroupStatusController.ts index 753b54b..fa9ffad 100644 --- a/src/controllers/subscriptionGroupStatusController.ts +++ b/src/controllers/subscriptionGroupStatusController.ts @@ -23,13 +23,12 @@ import { ErrorListResponseError } from '../errors/errorListResponseError.js'; export class SubscriptionGroupStatusController extends BaseController { /** - * This endpoint will immediately cancel all subscriptions within the specified group. The group is - * identified by it's `uid` passed in the URL. To successfully cancel the group, the primary - * subscription must be on automatic billing. The group members as well must be on automatic billing or - * they must be prepaid. + * Cancels all subscriptions within the specified group immediately. The group is identified by the + * `uid` that is passed in the URL. To successfully cancel the group, the primary subscription must be + * on automatic billing. The group members must be on automatic billing or prepaid. * - * In order to cancel a subscription group while also charging for any unbilled usage on metered or - * prepaid components, the `charge_unbilled_usage=true` parameter must be included in the request. + * To cancel a subscription group while also charging for any unbilled usage on metered or prepaid + * components, the `charge_unbilled_usage=true` parameter must be included in the request. * * @param uid The uid of the subscription group * @param body @@ -60,7 +59,7 @@ export class SubscriptionGroupStatusController extends BaseController { /** * This endpoint will schedule all subscriptions within the specified group to be canceled at the end - * of their billing period. The group is identified by it's uid passed in the URL. + * of their billing period. The group is identified by its uid passed in the URL. * * All subscriptions in the group must be on automatic billing in order to successfully cancel them, * and the group must not be in a "past_due" state. diff --git a/src/controllers/subscriptionGroupsController.ts b/src/controllers/subscriptionGroupsController.ts index 7e36abd..bf03f37 100644 --- a/src/controllers/subscriptionGroupsController.ts +++ b/src/controllers/subscriptionGroupsController.ts @@ -78,6 +78,10 @@ export class SubscriptionGroupsController extends BaseController { * * When passing product to a subscription you can use either `product_id` or `product_handle` or * `offer_id`. You can also use `custom_price` instead. + * The subscription request examples below will be split into two sections. + * The first section, "Subscription Customization", will focus on passing different information with a + * subscription, such as components, calendar billing, and custom fields. These examples will presume + * you are using a secure chargify_token generated by Chargify.js. * * @param body * @return Response from the API call @@ -303,8 +307,8 @@ export class SubscriptionGroupsController extends BaseController { * and the subscription will become part of the group with the specified target customer set as the * responsible payer for the group's subscriptions. * - * **Please Note:** In order to add an existing subscription to a subscription group, it must belong to - * either the same customer record as the target, or be within the same customer hierarchy. + * **Note:** In order to add an existing subscription to a subscription group, it must belong to either + * the same customer record as the target, or be within the same customer hierarchy. * * Rather than specifying a customer, the `target` parameter could instead simply have a value of * * `"self"` which indicates the subscription will be paid for not by some other customer, but by the @@ -314,7 +318,7 @@ export class SubscriptionGroupsController extends BaseController { * * `"eldest"` which indicates the subscription will be paid for by the root-level customer in the * subscribing customer's hierarchy. * - * To create a new subscription into a subscription group, please reference the following: + * To create a new subscription into a subscription group, reference the following: * [Create Subscription in a Subscription Group](https://developers.chargify.com/docs/api- * docs/d571659cf0f24-create-subscription#subscription-in-a-subscription-group) * diff --git a/src/controllers/subscriptionInvoiceAccountController.ts b/src/controllers/subscriptionInvoiceAccountController.ts index f691fe2..04d7300 100644 --- a/src/controllers/subscriptionInvoiceAccountController.ts +++ b/src/controllers/subscriptionInvoiceAccountController.ts @@ -87,7 +87,7 @@ export class SubscriptionInvoiceAccountController extends BaseController { * using the default credit card payment profile and applied to the prepayment account balance. This * is especially useful for manual replenishment of prepaid subscriptions. * - * Please note that you **can't** pass `amount_in_cents`. + * Note that passing `amount_in_cents` is now allowed. * * * @param subscriptionId The Chargify id of the subscription diff --git a/src/controllers/subscriptionProductsController.ts b/src/controllers/subscriptionProductsController.ts index 36110b8..30327a2 100644 --- a/src/controllers/subscriptionProductsController.ts +++ b/src/controllers/subscriptionProductsController.ts @@ -27,6 +27,7 @@ import { ErrorListResponseError } from '../errors/errorListResponseError.js'; export class SubscriptionProductsController extends BaseController { /** + * * In order to create a migration, you must pass the `product_id` or `product_handle` in the object * when you send a POST request. You may also pass either a `product_price_point_id` or * `product_price_point_handle` to choose which price point the subscription is moved to. If no price @@ -50,16 +51,16 @@ export class SubscriptionProductsController extends BaseController { * * ## Failed Migrations * - * One of the most common ways that a migration can fail is when the attempt is made to migrate a - * subscription to it's current product. Please be aware of this issue! + * Importaint note: One of the most common ways that a migration can fail is when the attempt is made + * to migrate a subscription to its current product. * * ## Migration 3D Secure - Stripe * - * It may happen that a payment needs 3D Secure Authentication when the subscription is migrated to a - * new product; this is referred to in our help docs as a [post-authentication flow](https://maxio. - * zendesk.com/hc/en-us/articles/24176278996493-Testing-Implementing-3D-Secure#psd2-flows-pre- - * authentication-and-post-authentication). The server returns `422 Unprocessable Entity` in this case - * with the following response: + * When a payment requires 3D Secure Authentication to adhear to Strong Customer Authentication (SCA) + * when the subscription is migrated to a new product, the request enters a [post-authentication + * flow](https://maxio.zendesk.com/hc/en-us/articles/24176278996493-Testing-Implementing-3D-Secure#psd2- + * flows-pre-authentication-and-post-authentication). The server returns `422 Unprocessable Entity` in + * this case with the following response: * * ```json * { @@ -104,7 +105,7 @@ export class SubscriptionProductsController extends BaseController { * * ### Example Redirect Flow * - * You may wish to redirect customers to different pages depending on whether their SCA was performed + * You may wish to redirect customers to different pages depending on whether SCA was performed * successfully. Here's an example flow to use as a reference: * * 1. Create a migration via API; it requires 3DS diff --git a/src/controllers/subscriptionStatusController.ts b/src/controllers/subscriptionStatusController.ts index 1ca6617..0af3841 100644 --- a/src/controllers/subscriptionStatusController.ts +++ b/src/controllers/subscriptionStatusController.ts @@ -151,7 +151,7 @@ export class SubscriptionStatusController extends BaseController { * * ## Limitations * - * You may not place a subscription on hold if the `next_billing` date is within 24 hours. + * You may not place a subscription on hold if the `next_billing_at` date is within 24 hours. * * @param subscriptionId The Chargify id of the subscription * @param body @@ -224,9 +224,8 @@ export class SubscriptionStatusController extends BaseController { * how the reactivation works, and how to reactivate subscriptions through the application, see * [reactivation](https://maxio.zendesk.com/hc/en-us/articles/24252109503629-Reactivating-and-Resuming). * - * **Please note: The term - * "resume" is used also during another process in Advanced Billing. This occurs when an on-hold - * subscription is "resumed". This returns the subscription to an active state.** + * **Note: The term "resume" is used also during another process in Advanced Billing. This occurs when + * an on-hold subscription is "resumed". This returns the subscription to an active state.** * * + The response returns the subscription object in the `active` or `trialing` state. * + The `canceled_at` and `cancellation_message` fields do not have values. @@ -513,8 +512,8 @@ export class SubscriptionStatusController extends BaseController { * snapshot of how much your customer will be charged on their next renewal. * * The "Next Billing" amount and "Next Billing" date are already represented in the UI on each - * Subscriber's Summary. For more information, please see our documentation [here](https://maxio. - * zendesk.com/hc/en-us/articles/24252493695757-Subscriber-Interface-Overview). + * Subscriber's Summary. For more information, see our documentation [here](https://maxio.zendesk. + * com/hc/en-us/articles/24252493695757-Subscriber-Interface-Overview). * * ## Optional Component Fields * diff --git a/src/controllers/subscriptionsController.ts b/src/controllers/subscriptionsController.ts index 678efeb..cf0caaa 100644 --- a/src/controllers/subscriptionsController.ts +++ b/src/controllers/subscriptionsController.ts @@ -86,813 +86,36 @@ import { SubscriptionResponseError } from '../errors/subscriptionResponseError.j export class SubscriptionsController extends BaseController { /** - * Full documentation on how subscriptions operate within Advanced Billing can be located under the - * following topics: + * + * Creates a Subscription for a customer and product * - * + [Subscriptions Reference](https://maxio.zendesk.com/hc/en-us/articles/24251526991757-Subscription- - * Overview) - * + [Subscriptions Actions](https://maxio.zendesk.com/hc/en-us/articles/24251983024653-Subscription- - * Actions-Overview) - * + [Subscription Cancellation](https://maxio.zendesk.com/hc/en-us/articles/24251957778829-Cancel- - * Subscriptions) - * + [Subscription Reactivation](https://maxio.zendesk.com/hc/en-us/articles/24252109503629- - * Reactivating-and-Resuming) - * + [Subscription Import](https://maxio.zendesk.com/hc/en-us/articles/24251489107213-Imports) + * Specify the product with `product_id` or `product_handle`. To set a specific product pricepPoint, + * use `product_price_point_handle` or `product_price_point_id`. * - * When creating a subscription, you must specify a product and a customer. Credit card details may be - * required, depending on the options for the Product being subscribed ([see Product Options](https: - * //maxio.zendesk.com/hc/en-us/articles/24261076617869-Product-Editing)). + * Identify an existing customer with `customer_id` or `customer_reference`. Optionally, include an + * existing payment profile using `payment_profile_id`. To create a new customer, pass + * customer_attributes. * - * The product may be specified by `product_id` or by `product_handle` (API Handle). In similar fashion, - * to pass a particular product price point, you may either use `product_price_point_handle` or - * `product_price_point_id`. + * Select an option from the **Request Examples** drop-down on the right side of the portal to see + * examples of common scenarios for creating subscriptions. * - * An existing customer may be specified by a `customer_id` (ID within Advanced Billing) or a - * `customer_reference` (unique value within your app that you have shared with Advanced Billing via - * the reference attribute on a customer). You may also pass in an existing payment profile for that - * customer with `payment_profile_id`. A new customer may be created by providing `customer_attributes`. + * Payment information may be required to create a subscription, depending on the options for the + * Product being subscribed. See [product options](https://docs.maxio.com/hc/en- + * us/articles/24261076617869-Edit-Products) for more information. See the [Payments + * Profile]($e/Payment%20Profiles/createPaymentProfile) endpoint for details on payment parameters. * - * Credit card details may be required, depending on the options for the product being subscribed. The - * product can be specified by `product_id` or by `product_handle` (API Handle). + * Do not use real card information for testing. See the Sites articles that cover [testing your site + * setup](https://docs.maxio.com/hc/en-us/articles/24250712113165-Testing-Overview#testing-overview-0- + * 0) for more details on testing in your sandbox. * - * If you are creating a subscription with a payment profile, the attribute to send will be - * `credit_card_attributes` or `bank_account_attributes` for ACH and Direct Debit. That said, when you - * read the subscription after creation, we return the profile details under `credit_card` or - * `bank_account`. + * Note that collecting and sending raw card details in production requires [PCI compliance](https: + * //docs.maxio.com/hc/en-us/articles/24183956938381-PCI-Compliance#pci-compliance-0-0) on your end. If + * your business is not PCI compliant, use [Chargify.js](https://docs.maxio.com/hc/en- + * us/articles/38163190843789-Chargify-js-Overview#chargify-js-overview-0-0) to collect credit card or + * bank account information. * - * ## Bulk creation of subscriptions - * - * Bulk creation of subscriptions is currently not supported. For scenarios where multiple - * subscriptions must be added, particularly when assigning to the same subscription group, it is - * essential to switch to a single-threaded approach. - * - * To avoid data conflicts or inaccuracies, incorporate a sleep interval between requests. - * - * While this single-threaded approach may impact performance, it ensures data consistency and accuracy - * in cases where concurrent creation attempts could otherwise lead to issues with subscription - * alignment and integrity. - * - * ## Taxable Subscriptions - * - * If your intent is to charge your subscribers tax via [Avalara Taxes](https://maxio.zendesk.com/hc/en- - * us/articles/24287043035661-Avalara-VAT-Tax) or [Custom Taxes](https://maxio.zendesk.com/hc/en- - * us/articles/24287044212749-Custom-Taxes), there are a few considerations to be made regarding - * collecting subscription data. - * For subscribers to be eligible to be taxed, the following information for the `customer` object or - * `payment_profile` object must by supplied: - * - * + A subscription to a [taxable product](https://maxio.zendesk.com/hc/en-us/articles/24261076617869- - * Product-Editing#tax-settings) - * + [Full valid billing or shipping address](https://maxio.zendesk.com/hc/en- - * us/articles/24287008131853-Advanced-Billing-Managed-Sales-Tax#full-address-required-for-taxable- - * subscriptions) to identify the tax locale - * + The portion of the address that houses the [state information](https://maxio.zendesk.com/hc/en- - * us/articles/24287008131853-Advanced-Billing-Managed-Sales-Tax#required-state-format-for-taxable- - * subscriptions) of either adddress must adhere to the ISO standard of a 2-3 character limit/format. - * + The portion of the address that houses the [country information](https://maxio.zendesk.com/hc/en- - * us/articles/24287008131853-Advanced-Billing-Managed-Sales-Tax#required-country-format-for-taxable- - * subscriptions) must adhere to the ISO standard of a 2 character limit/format. - * - * ## Subscription Request Examples - * - * The subscription examples below will be split into two sections. - * - * The first section, "Subscription Customization", will focus on passing different information with a - * subscription, such as components, calendar billing, and custom fields. These examples will presume - * you are using a secure `chargify_token` generated by Chargify.js. - * - * The second section, "Passing Payment Information", will focus on passing payment information into - * Advanced Billing. Please be aware that collecting and sending Advanced Billing raw card details - * requires PCI compliance on your end; these examples are provided as guidance. If your business - * is not PCI compliant, we recommend using Chargify.js to collect credit cards or bank accounts. - * - * # Subscription Customization - * - * ## With Components - * - * Different components require slightly different data. For example, quantity-based and on/off - * components accept `allocated_quantity`, while metered components accept `unit_balance`. - * - * When creating a subscription with a component, a `price_point_id` can be passed in along with the - * `component_id` to specify which price point to use. If not passed in, the default price point will - * be used. - * - * Note: if an invalid `price_point_id` is used, the subscription will still proceed but will use the - * component's default price point. - * - * Components and their price points may be added by ID or by handle. See the example request body - * labeled "Components By Handle (Quantity-Based)"; the format will be the same for other component - * types. - * - * ## With Coupon(s) - * - * Pass an array of `coupon_codes`. See the example request body "With Coupon". - * - * ## With Manual Invoice Collection - * - * The `invoice` collection method works only on legacy Statement Architecture. - * - * On Relationship Invoicing Architecture use the `remittance` collection method. - * - * ## Prepaid Subscription - * - * A prepaid subscription can be created with the usual subscription creation parameters, specifying - * `prepaid` as the `payment_collection_method` and including a nested `prepaid_configuration`. - * - * After a prepaid subscription has been created, additional funds can be manually added to the - * prepayment account through the [Create Prepayment Endpoint](https://developers.chargify.com/docs/api- - * docs/7ec482de77ba7-create-prepayment). - * - * Prepaid subscriptions do not work on legacy Statement Architecture. - * - * ## With Metafields - * - * Metafields can either attach to subscriptions or customers. Metafields are popuplated with the - * supplied metadata to the resource specified. - * - * If the metafield doesn't exist yet, it will be created on-the-fly. - * - * ## With Custom Pricing - * - * Custom pricing is pricing specific to the subscription in question. - * Create a subscription with custom pricing by passing pricing information instead of a price point. - * For a custom priced product, pass the custom_price object in place of `product_price_point_id`. For - * a custom priced component, pass the `custom_price` object within the component object. - * Custom prices and price points can exist in harmony on a subscription. - * - * # Passing Payment Information - * - * ## Subscription with Chargify.js token - * - * The `chargify_token` can be obtained using [Chargify.js](https://docs.maxio.com/hc/en- - * us/articles/38163190843789-Chargify-js-Overview#chargify-js-overview-0-0). The token represents - * payment profile attributes that were provided by the customer in their browser and stored at the - * payment gateway. - * - * The `payment_type` attribute may either be `credit_card` or `bank_account`, depending on the type of - * payment method being added. If a bank account is being passed, the payment attributes should be - * changed to `bank_account_attributes`. - * - * ```json - * { - * "subscription": { - * "product_handle": "pro-plan", - * "customer_attributes": { - * "first_name": "Joe", - * "last_name": "Smith", - * "email": "j.smith@example.com" - * }, - * "credit_card_attributes": { - * "chargify_token": "tok_cwhvpfcnbtgkd8nfkzf9dnjn", - * "payment_type": "credit_card" - * } - * } - * } - * ``` - * - * ## Subscription with vault token - * - * If you already have a customer and card stored in your payment gateway, you may create a - * subscription with a `vault_token`. Providing the last_four, card type and expiration date will - * allow the card to be displayed properly in the Advanced Billing UI. - * - * ```json - * { - * "subscription": { - * "product_handle": "pro-plan", - * "customer_attributes": { - * "first_name": "Joe", - * "last_name": "Smith", - * "email": "j.smith@example.com" - * }, - * "credit_card_attributes": { - * first_name: "Joe, - * last_name: "Smith", - * card_type: "visa", - * expiration_month: "05", - * expiration_year: "2025", - * last_four: "1234", - * vault_token: "12345abc", - * current_vault: "braintree_blue" - * } - * } - * ``` - * - * ## Subscription with ACH as Payment Profile - * - * ```json - * { - * "subscription": { - * "product_handle": "gold-product", - * "customer_attributes": { - * "first_name": "Joe", - * "last_name": "Blow", - * "email": "joe@example.com", - * "zip": "02120", - * "state": "MA", - * "reference": "XYZ", - * "phone": "(617) 111 - 0000", - * "organization": "Acme", - * "country": "US", - * "city": "Boston", - * "address_2": null, - * "address": "123 Mass Ave." - * }, - * "bank_account_attributes": { - * "bank_name": "Best Bank", - * "bank_routing_number": "021000089", - * "bank_account_number": "111111111111", - * "bank_account_type": "checking", - * "bank_account_holder_type": "business", - * "payment_type": "bank_account" - * } - * } - * } - * ``` - * - * ## Subscription with PayPal payment profile - * - * ### With the nonce from Braintree JS - * - * ```json - * { "subscription": { - * "product_handle":"test-product-b", - * "customer_attributes": { - * "first_name":"Amelia", - * "last_name":"Johnson", - * "email":"amelia@example.com", - * "organization":"My Awesome Company" - * }, - * "payment_profile_attributes":{ - * "paypal_email": "amelia@example.com", - * "current_vault": "braintree_blue", - * "payment_method_nonce":"abc123", - * "payment_type":"paypal_account" - * } - * } - * ``` - * - * - * ### With the Braintree Customer ID as the vault token: - * - * ```json - * { "subscription": { - * "product_handle":"test-product-b", - * "customer_attributes": { - * "first_name":"Amelia", - * "last_name":"Johnson", - * "email":"amelia@example.com", - * "organization":"My Awesome Company" - * }, - * "payment_profile_attributes":{ - * "paypal_email": "amelia@example.com", - * "current_vault": "braintree_blue", - * "vault_token":"58271347", - * "payment_type":"paypal_account" - * } - * } - * ``` - * - * ## Subscription using GoCardless Bank Number - * - * These examples creates a customer, bank account and mandate in GoCardless. - * - * For more information on GoCardless, please view the following two resources: - * - * + [Payment Profiles via API for GoCardless](https://developers.chargify.com/docs/api- - * docs/1f10a4f170405-create-payment-profile#gocardless) - * + [Full documentation on GoCardless](https://maxio.zendesk.com/hc/en-us/articles/24176159136909- - * GoCardless) - * - * + [Using Chargify.js with GoCardless - minimal example](https://docs.maxio.com/hc/en- - * us/articles/38206331271693-Examples#h_01K0PJ15QQZKCER8CFK40MR6XJ) - * - * + [Using Chargify.js with GoCardless - full example](https://docs.maxio.com/hc/en- - * us/articles/38206331271693-Examples#h_01K0PJ15QR09JVHWW0MCA7HVJV) - * - * ```json - * { - * "subscription": { - * "product_handle": "gold-product", - * "customer_attributes": { - * "first_name": "Jane", - * "last_name": "Doe", - * "email": "jd@chargify.test" - * }, - * "bank_account_attributes": { - * "bank_name": "Royal Bank of France", - * "bank_account_number": "0000000", - * "bank_routing_number": "0003", - * "bank_branch_code": "00006", - * "payment_type": "bank_account", - * "billing_address": "20 Place de la Gare", - * "billing_city": "Colombes", - * "billing_state": "Île-de-France", - * "billing_zip": "92700", - * "billing_country": "FR" - * } - * } - * } - * ``` - * - * ## Subscription using GoCardless IBAN Number - * - * ```json - * { - * "subscription": { - * "product_handle": "gold-product", - * "customer_attributes": { - * "first_name": "Jane", - * "last_name": "Doe", - * "email": "jd@chargify.test" - * }, - * "bank_account_attributes": { - * "bank_name": "French Bank", - * "bank_iban": "FR1420041010050500013M02606", - * "payment_type": "bank_account", - * "billing_address": "20 Place de la Gare", - * "billing_city": "Colombes", - * "billing_state": "Île-de-France", - * "billing_zip": "92700", - * "billing_country": "FR" - * } - * } - * } - * ``` - * - * ## Subscription using Stripe SEPA Direct Debit - * - * For more information on Stripe Direct Debit, please view the following two resources: - * - * + [Payment Profiles via API for Stripe SEPA Direct Debit](https://developers.chargify.com/docs/api- - * docs/1f10a4f170405-create-payment-profile#sepa-direct-debit) - * + [Full documentation on Stripe Direct Debit](https://maxio.zendesk.com/hc/en- - * us/articles/24176170430093-Stripe-SEPA-and-BECS-Direct-Debit) - * - * + [Using Chargify.js with Stripe SEPA or BECS Direct Debit - minimal example](https://docs.maxio. - * com/hc/en-us/articles/38206331271693-Examples#h_01K0PJ15QQFKKN8Z7B7DZ9AJS5) - * - * + [Using Chargify.js with Stripe SEPA Direct Debit - full example](https://docs.maxio.com/hc/en- - * us/articles/38206331271693-Examples#h_01K0PJ15QR09JVHWW0MCA7HVJV) - * - * - * ```json - * { - * "subscription": { - * "product_handle": "gold-product", - * "customer_attributes": { - * "first_name": "Jane", - * "last_name": "Doe", - * "email": "jd@chargify.test" - * }, - * "bank_account_attributes": { - * "bank_name": "Test Bank", - * "bank_iban": "DE89370400440532013000", - * "payment_type": "bank_account" - * } - * } - * } - * ``` - * - * ## Subscription using Stripe BECS Direct Debit - * - * For more information on Stripe Direct Debit, please view the following two resources: - * - * + [Payment Profiles via API for Stripe BECS Direct - * Debit]($e/Payment%20Profiles/createPaymentProfile) - * + [Full documentation on Stripe Direct Debit](https://maxio.zendesk.com/hc/en- - * us/articles/24176170430093-Stripe-SEPA-and-BECS-Direct-Debit) - * - * + [Using Chargify.js with Stripe SEPA, BECS or BACS Direct Debit - minimal example](https://docs. - * maxio.com/hc/en-us/articles/38206331271693-Examples#h_01K0PJ15QQFKKN8Z7B7DZ9AJS5) - * - * + [Using Chargify.js with Stripe BECS Direct Debit - full example](https://docs.maxio.com/hc/en- - * us/articles/38206331271693-Examples#h_01K0PJ15QRX4B1TYZKZD8ZND6D) - * - * - * ```json - * { - * "subscription": { - * "product_handle": "gold-product", - * "customer_attributes": { - * "first_name": "Jane", - * "last_name": "Doe", - * "email": "jd@chargify.test" - * }, - * "bank_account_attributes": { - * "bank_name": "Test Bank", - * "bank_branch_code": "000000", - * "bank_account_number": "000123456", - * "payment_type": "bank_account" - * } - * } - * } - * ``` - * - * ## Subscription using Stripe BACS Direct Debit - * - * For more information on Stripe Direct Debit, please view the following two resources: - * - * + [Payment Profiles via API for Stripe BACS Direct - * Debit]($e/Payment%20Profiles/createPaymentProfile) - * + [Full documentation on Stripe Direct Debit](https://maxio.zendesk.com/hc/en- - * us/articles/24176170430093-Stripe-SEPA-and-BECS-Direct-Debit) - * - * + [Using Chargify.js with Stripe SEPA, BECS or BACS Direct Debit - minimal example](https://docs. - * maxio.com/hc/en-us/articles/38206331271693-Examples#h_01K0PJ15QQFKKN8Z7B7DZ9AJS5) - * - * + [Using Chargify.js with Stripe BACS Direct Debit - full example](https://docs.maxio.com/hc/en- - * us/articles/38206331271693-Examples#h_01K0PJ15QR7PA1DJ3XE9MD05FM) - * - * ```json - * { - * "subscription": { - * "product_handle": "gold-product", - * "customer_attributes": { - * "first_name": "Jane", - * "last_name": "Doe", - * "email": "jd@chargify.test" - * }, - * "bank_account_attributes": { - * "bank_name": "Test Bank", - * "bank_branch_code": "108800", - * "bank_account_number": "00012345", - * "payment_type": "bank_account", - * "billing_address": "123 Main St.", - * "billing_city": "London", - * "billing_state": "LND", - * "billing_zip": "W1A 1AA", - * "billing_country": "GB" - * } - * } - * } - * ``` - * - * ## 3D Secure - Stripe - * - * It may happen that a payment needs 3D Secure Authentication when the subscription is created; this - * is referred to in our help docs as a [post-authentication flow](https://maxio.zendesk.com/hc/en- - * us/articles/24176278996493-Testing-Implementing-3D-Secure#psd2-flows-pre-authentication-and-post- - * authentication). The server returns `422 Unprocessable Entity` in this case with the following - * response: - * - * ```json - * { - * "errors": [ - * "Your card was declined. This transaction requires 3D secure authentication." - * ], - * "gateway_payment_id": "pi_1F0aGoJ2UDb3Q4av7zU3sHPh", - * "description": "This card requires 3D secure authentication. Redirect the customer to the URL from - * the action_link attribute to authenticate. Attach callback_url param to this URL if you want to be - * notified about the result of 3D Secure authentication. Attach redirect_url param to this URL if you - * want to redirect a customer back to your page after 3D Secure authentication. Example: https: - * //mysite.chargify.com/3d-secure/pi_1FCm4RKDeye4C0XfbqquXRYm?one_time_token_id=128&callback_url=https: - * //localhost:4000&redirect_url=https://yourpage.com will do a POST request to https://localhost:4000 - * after payment is authenticated and will redirect a customer to https://yourpage.com after 3DS - * authentication.", - * "action_link": "http://acme.chargify.com/3d-secure/pi_1F0aGoJ2UDb3Q4av7zU3sHPh? - * one_time_token_id=242" - * } - * ``` - * - * To let the customer go through 3D Secure Authentication, they need to be redirected to the URL - * specified in `action_link`. - * Optionally, you can specify `callback_url` parameter in the `action_link` URL if you’d like to be - * notified about the result of 3D Secure Authentication. The `callback_url` will return the following - * information: - * - * - whether the authentication was successful (`success`) - * - the gateway ID for the payment (`gateway_payment_id`) - * - the subscription ID (`subscription_id`) - * - * Lastly, you can also specify a `redirect_url` within the `action_link` URL if you’d like to redirect - * a customer back to your site. - * - * It is not possible to use `action_link` in an iframe inside a custom application. You have to - * redirect the customer directly to the `action_link`, then, to be notified about the result, use - * `redirect_url` or `callback_url`. - * - * The final URL that you send a customer to to complete 3D Secure may resemble the following, where - * the first half is the `action_link` and the second half contains a `redirect_url` and `callback_url`: - * `https://mysite.chargify.com/3d-secure/pi_1FCm4RKDeye4C0XfbqquXRYm? - * one_time_token_id=128&callback_url=https://localhost:4000&redirect_url=https://yourpage.com` - * - * ## 3D Secure - Checkout - * - * It may happen that a payment needs 3D Secure Authentication when the subscription is created; this - * is referred to in our help docs as a [post-authentication flow](https://maxio.zendesk.com/hc/en- - * us/articles/24176278996493-Testing-Implementing-3D-Secure#psd2-flows-pre-authentication-and-post- - * authentication). The server returns `422 Unprocessable Entity` in this case with the following - * response: - * - * ```json - * { - * "errors": [ - * "Your card was declined. This transaction requires 3D secure authentication." - * ], - * "gateway_payment_id": "pay_6gjofv7dlyrkpizlolsuspvtiu", - * "description": "This card requires 3D secure authentication. Redirect the customer to the URL from - * the action_link attribute to authenticate. Attach callback_url param to this URL if you want to be - * notified about the result of 3D Secure authentication. Attach redirect_url param to this URL if you - * want to redirect a customer back to your page after 3D Secure authentication. Example: https: - * //mysite.chargify.com/3d-secure/pay_6gjofv7dlyrkpizlolsuspvtiu? - * one_time_token_id=123&callback_url=https://localhost:4000&redirect_url=https://yourpage.com will do - * a POST request to https://localhost:4000 after payment is authenticated and will redirect a customer - * to https://yourpage.com after 3DS authentication.", - * "action_link": "http://mysite.chargify.com/3d-secure/pay_6gjofv7dlyrkpizlolsuspvtiu? - * one_time_token_id=123" - * } - * ``` - * - * To let the customer go through 3D Secure Authentication, they need to be redirected to the URL - * specified in `action_link`. - * Optionally, you can specify `callback_url` parameter in the `action_link` URL if you’d like to be - * notified about the result of 3D Secure Authentication. The `callback_url` will return the following - * information: - * - * - whether the authentication was successful (`success`) - * - the gateway ID for the payment (`gateway_payment_id`) - * - the subscription ID (`subscription_id`) - * - * Lastly, you can also specify a `redirect_url` parameter within the `action_link` URL if you’d like - * to redirect a customer back to your site. - * - * It is not possible to use `action_link` in an iframe inside a custom application. You have to - * redirect the customer directly to the `action_link`, then, to be notified about the result, use - * `redirect_url` or `callback_url`. - * - * The final URL that you send a customer to complete 3D Secure may resemble the following, where the - * first half is the `action_link` and the second half contains a `redirect_url` and `callback_url`: - * `https://mysite.chargify.com/3d-secure/pay_6gjofv7dlyrkpizlolsuspvtiu? - * one_time_token_id=123&callback_url=https://localhost:4000&redirect_url=https://yourpage.com` - * - * ### Example Redirect Flow - * - * You may wish to redirect customers to different pages depending on whether their SCA was performed - * successfully. Here's an example flow to use as a reference: - * - * 1. Create a subscription via API; it requires 3DS - * 2. You receive a `gateway_payment_id` in the `action_link` along other params in the response. - * 3. Use this `gateway_payment_id` to, for example, connect with your internal resources or generate a - * session_id - * 4. Include 1 of those attributes inside the `callback_url` and `redirect_url` to be aware which - * “session” this applies to - * 5. Redirect the customer to the `action_link` with `callback_url` and `redirect_url` applied - * 6. After the customer finishes 3DS authentication, we let you know the result by making a request to - * applied `callback_url`. - * 7. After that, we redirect the customer to the `redirect_url`; at this point the result of - * authentication is known - * 8. Optionally, you can use the applied "msg" param in the `redirect_url` to determine whether it was - * successful or not - * - * ## Subscriptions Import - * - * Subscriptions can be “imported” via the API to handle the following scenarios: - * - * + You already have existing subscriptions with specific start and renewal dates that you would like - * to import to Advanced Billing - * + You already have credit cards stored in your provider’s vault and you would like to create - * subscriptions using those tokens - * - * Before importing, you should have already set up your products to match your offerings. Then, you - * can create Subscriptions via the API just like you normally would, but using a few special - * attributes. - * - * Full documentation on how import Subscriptions using the **import tool** in the Advanced Billing UI - * can be located [here](https://maxio.zendesk.com/hc/en-us/articles/24251489107213-Imports). - * - * ### Important Notices and Disclaimers regarding Imports - * - * Before performing a bulk import of subscriptions via the API, we suggest reading the [Subscriptions - * Import](https://maxio.zendesk.com/hc/en-us/articles/24251489107213-Imports) instructions to - * understand the repurcussions of a large import. - * - * ### Subscription Input Attributes - * - * The following _additional_ attributes to the subscription input attributes make imports possible: - * `next_billing_at`, `previous_billing_at`, and `import_mrr`. - * - * ### Current Vault - * - * If you are using a Legacy gateway such as "eWAY Rapid (Legacy)" or "Stripe (Legacy)" then please - * contact Support for further instructions on subscription imports. - * - * ### Braintree Blue (Braintree v2) Imports - * - * Braintree Blue is Braintree’s newer (version 2) API. For this gateway, please provide the - * `vault_token` parameter with the value from Braintree’s “Customer ID” rather than the “Payment - * Profile Token”. At this time we do not use `current_vault_token` with the Braintree Blue gateway, - * and we only support a single payment profile per Braintree Customer. - * - * When importing PayPal type payment profiles, please set `payment_type` to `paypal_account`. - * - * ### Stripe ACH Imports - * - * If the bank account has already been verified, currently you will need to create the customer, - * create the payment profile in Advanced Billing - setting verified=true, then create a subscription - * using the customer_id and payment_profile_id. - * - * ### Webhooks During Import - * - * If no `next_billing_at` is provided, webhooks will be fired as normal. If you do set a future - * `next_billing_at`, only a subset of the webhooks are fired when the subscription is created. Keep - * reading for more information as to what webhooks will be fired under which scenarios. - * - * #### Successful creation with Billing Date - * - * Scenario: If `next_billing_at` provided - * - * + `signup_success` - * + `billing_date_change` - * - * #### Successful creation without Billing Date - * - * Scenario: If no `next_billing_at` provided - * - * + `signup_success` - * + `payment_success` - * - * #### Unsuccessful creation - * - * Scenario: If card can’t be charged, and no `next_billing_at` provided - * - * + signup_failure - * - * #### Webhooks fired when next_billing_at is reached: - * - * + `renewal_success or renewal_failure` - * + `payment_success or payment_failure` - * - * ### Date and Time Formats - * - * We will attempt to parse any string you send as the value of next_billing_at in to a date or time. - * For best results, use a known format like described in “Date and Time Specification” of RFC 2822 or - * ISO 8601 . - * - * The following are all equivalent and will work as input to `next_billing_at`: - * - * ``` - * Aug 06 2030 11:34:00 -0400 - * Aug 06 2030 11:34 -0400 - * 2030-08-06T11:34:00-04:00 - * 8/6/2030 11:34:00 EDT - * 8/6/2030 8:34:00 PDT - * 2030-08-06T15:34:00Z - * ``` - * You may also pass just a date, in which case we will assume the time to be noon - * - * ``` - * 2010-08-06 - * ``` - * - * ## Subscription Hierarchies & WhoPays - * - * When subscription groups were first added to our Relationship Invoicing architecture, to group - * together invoices for related subscriptions and allow for complex customer hierarchies and WhoPays - * scenarios, they were designed to consist of a primary and a collection of group members. The primary - * would control many aspects of the group, such as when the consolidated invoice is generated. As of - * today, groups still function this way. - * - * In the future, the concept of a "primary" will be removed in order to offer more flexibility into - * group management and reduce confusion concerning what actions must be done on a primary level, - * rather than a member level. - * - * We have introduced a two scheme system as a bridge between these two group organizations. Scheme 1, - * which is relevant to all subscription groups today, marks the group as being "ruled" by a primary. - * - * When reading a subscription via API, they will return a top-level attribute called `group`, which - * will denote which scheme is being used. At this time, the `scheme` attribute will always be 1. - * - * ### Subscription in a Customer Hierarchy - * - * For sites making use of the [Relationship Billing](https://maxio.zendesk.com/hc/en- - * us/articles/24252287829645-Advanced-Billing-Invoices-Overview) and [Customer Hierarchy](https: - * //maxio.zendesk.com/hc/en-us/articles/24252185211533-Customer-Hierarchies-WhoPays) features, it is - * possible to create subscriptions within a customer hierarchy. This can be achieved through the API - * by passing group parameters in the **Create Subscription** request. - * - * + The `group` parameters are optional and consist of the required `target` and optional `billing` - * parameters. - * - * When the `target` parameter specifies a customer that is already part of a hierarchy, the new - * subscription will become a member of the customer hierarchy as well. If the target customer is not - * part of a hierarchy, a new customer hierarchy will be created and both the target customer and the - * new subscription will become part of the hierarchy with the specified target customer set as the - * responsible payer for the hierarchy's subscriptions. - * - * Rather than specifying a customer, the `target` parameter could instead simply have a value of - * `self` which indicates the subscription will be paid for not by some other customer, but by the - * subscribing customer. This will be true whether the customer is being created new, is already part - * of a hierarchy, or already exists outside a hierarchy. A valid payment method must also be - * specified in the subscription parameters. - * - * Note that when creating subscriptions in a customer hierarchy, if the customer hierarchy does not - * already have a payment method, passing valid credit card attributes in the subscription parameters - * will also result in the payment method being established as the default payment method for the - * customer hierarchy irrespective of the responsible payer. - * - * The optional `billing` parameters specify how some aspects of the billing for the new subscription - * should be handled. Rather than capturing payment immediately, the `accrue` parameter can be - * included so that the new subscription charges accrue until the next assessment date. Regarding the - * date, the `align_date` parameter can be included so that the billing date of the new subscription - * matches up with the default subscription group in the customer hierarchy. When choosing to align - * the dates, the `prorate` parameter can also be specified so that the new subscription charges are - * prorated based on the billing period of the default subscription group in the customer hierarchy - * also. - * - * ### Subscription in a Subscription Group - * - * For sites making use of [Relationship Billing](https://maxio.zendesk.com/hc/en- - * us/articles/24252287829645-Advanced-Billing-Invoices-Overview) it may be desireable to create a - * subscription as part of a [subscription group](https://maxio.zendesk.com/hc/en- - * us/articles/24252172565005-Subscription-Groups-Overview) in order to rely on [invoice - * consolidation](https://maxio.zendesk.com/hc/en-us/articles/24252269909389-Invoice-Consolidation). - * This can be achieved through the API by passing group parameters in the Create Subscription request. - * The `group` parameters are optional and consist of the required `target` and optional `billing` - * parameters. - * - * The `target` parameters specify an existing subscription with which the newly created subscription - * should be grouped. If the target subscription is already part of a group, the new subscription will - * become a member of the group as well. If the target subscription is not part of a group, a new - * group will be created and both the target and the new subscription will become part of the group - * with the target as the group's primary subscription. - * - * The optional `billing` parameters specify how some aspects of the billing for the new subscription - * should be handled. Rather than capturing payment immediately, the `accrue` parameter can be - * included so that the new subscription charges accrue until the next assessment date. Regarding the - * date, the `align_date` parameter can be included so that the billing date of the new subscription - * matches up with the target subscription. When choosing to align the dates, the `prorate` parameter - * can also be specified so that the new subscription charges are prorated based on the billing period - * of the target subscription also. - * - * ## Providing Agreement Acceptance Params - * - * It is possible to provide a proof of customer's acceptance of terms and policies. - * We will be storing this proof in case it might be required (i.e. chargeback). - * Currently, we already keep it for subscriptions created via Public Signup Pages. - * In order to create a subscription with the proof of agreement acceptance, you must provide - * additional parameters `agreement acceptance` with `ip_address` and at least one url to the policy - * that was accepted: `terms_url` or `privacy_policy_url`. Additional urls that can be provided: - * `return_refund_policy_url`, `delivery_policy_url` and - * `secure_checkout_policy_url`. - * - * ```json - * "subscription": { - * "product_handle": "gold-product", - * "customer_attributes": { - * "first_name": "Jane", - * "last_name": "Doe", - * "email": "jd@chargify.test" - * }, - * "agreement_acceptance": { - * "ip_address": "1.2.3.4", - * "terms_url": "https://terms.url", - * "privacy_policy_url": "https://privacy_policy.url", - * "return_refund_policy_url": "https://return_refund_policy.url", - * "delivery_policy_url": "https://delivery_policy.url", - * "secure_checkout_policy_url": "https://secure_checkout_policy.url" - * } - * } - * } - * ``` - * - * **For Maxio Payments subscriptions, the agreement acceptance params are required, with at least - * terms_url provided.** - * - * ## Providing ACH Agreement params - * - * It is also possible to provide a proof that a customer authorized ACH agreement terms. - * The proof will be stored and the email will be sent to the customer with a copy of the terms (if - * enabled). - * In order to create a subscription with the proof of authorized ACH agreement terms, you must provide - * the additional parameter `ach_agreement` with the following nested parameters: `agreement_terms`, - * `authorizer_first_name`, `authorizer_last_name` and `ip_address`. - * Each of them is required. - * - * ```json - * "subscription": { - * "product_handle": "gold-product", - * "customer_attributes": { - * "first_name": "Jane", - * "last_name": "Doe", - * "email": "jd@chargify.test" - * }, - * "bank_account_attributes": { - * "bank_name": "Test Bank", - * "bank_routing_number": "021000089", - * "bank_account_number": "111111111111", - * "bank_account_type": "checking", - * "bank_account_holder_type": "business", - * "payment_type": "bank_account" - * }, - * "ach_agreement": { - * "agreement_terms": "ACH agreement terms", - * "authorizer_first_name": "Jane", - * "authorizer_last_name": "Doe", - * "ip_address": "1.2.3.4" - * } - * } - * ``` + * See the [Subscription Signups](page:introduction/basic-concepts/subscription-signup) article for + * more information on working with subscriptions in Advanced Billing. * * @param body * @return Response from the API call @@ -1077,32 +300,44 @@ export class SubscriptionsController extends BaseController { } /** - * The subscription endpoint allows you to instantly update one or many attributes about a subscription - * in a single call. + * Updates one or more attributes of a subscription. * * ## Update Subscription Payment Method * - * Change the card that your Subscriber uses for their subscription. You can also use this method to - * simply change the expiration date of the card **if your gateway allows**. + * Change the card that your subscriber uses for their subscription. You can also use this method to + * change the expiration date of the card **if your gateway allows**. + * + * Do not use real card information for testing. See the Sites articles that cover [testing your site + * setup](https://docs.maxio.com/hc/en-us/articles/24250712113165-Testing-Overview#testing-overview-0- + * 0) for more details on testing in your sandbox. * - * Note that partial card updates for **Authorize.Net** are not allowed via this endpoint. The existing + * Note that collecting and sending raw card details in production requires [PCI compliance](https: + * //docs.maxio.com/hc/en-us/articles/24183956938381-PCI-Compliance#pci-compliance-0-0) on your end. If + * your business is not PCI compliant, use [Chargify.js](https://docs.maxio.com/hc/en- + * us/articles/38163190843789-Chargify-js-Overview#chargify-js-overview-0-0) to collect credit card or + * bank account information. + * + * > Note: Partial card updates for **Authorize.Net** are not allowed via this endpoint. The existing * Payment Profile must be directly updated instead. * + * ## Update Product + * * You also use this method to change the subscription to a different product by setting a new value * for product_handle. A product change can be done in two different ways, **product change** or * **delayed product change**. * - * ## Product Change + * ### Product Change * - * This endpoint may be used to change a subscription's product. The new payment amount is calculated - * and charged at the normal start of the next period. If you desire complex product changes or - * prorated upgrades and downgrades instead, please see the documentation on Migrating Subscription - * Products. + * You can change a subscription's product. The new payment amount is calculated and charged at the + * normal start of the next period. If you require complex product changes or prorated upgrades and + * downgrades instead, please see the documentation on [Migrating Subscription Products](https://docs. + * maxio.com/hc/en-us/articles/24252069837581-Product-Changes-and-Migrations#product-changes-and- + * migrations-0-0). * - * To perform a product change, simply set either the `product_handle` or `product_id` attribute to - * that of a different product from the same site as the subscription. You can also change the price - * point by passing in either `product_price_point_id` or `product_price_point_handle` - otherwise the - * new product's default price point will be used. + * To perform a product change, set either the `product_handle` or `product_id` attribute to that of a + * different product from the same site as the subscription. You can also change the price point by + * passing in either `product_price_point_id` or `product_price_point_handle` - otherwise the new + * product's default price point is used. * * ### Delayed Product Change * @@ -1110,42 +345,42 @@ export class SubscriptionsController extends BaseController { * and charged at the normal start of the next period. * * This method schedules the product change to happen automatically at the subscription’s next renewal - * date. To perform a Delayed Product Change, set the `product_handle` attribute as you would in a + * date. To perform a delayed product change, set the `product_handle` attribute as you would in a * regular product change, but also set the `product_change_delayed` attribute to `true`. No proration * applies in this case. * * You can also perform a delayed change to the price point by passing in either * `product_price_point_id` or `product_price_point_handle` * - * **Note: To cancel a delayed product change, set `next_product_id` to an empty string.** + * > **Note:** To cancel a delayed product change, set `next_product_id` to an empty string. * * ## Billing Date Changes * + * You can update dates for a subscrption. + * * ### Regular Billing Date Changes * * Send the `next_billing_at` to set the next billing date for the subscription. After that date passes * and the subscription is processed, the following billing date will be set according to the * subscription's product period. * - * Note that if you pass an invalid date, we will automatically interpret and set the correct date. For - * example, when February 30 is entered, the next billing will be set to March 2nd in a non-leap year. + * > Note: If you pass an invalid date, the correct date is automatically set to he correct date. For + * example, if February 30 is passed, the next billing would be set to March 2nd in a non-leap year. * - * The server response will not return data under the key/value pair of `next_billing`. Please view the - * key/value pair of `current_period_ends_at` to verify that the `next_billing` date has been changed - * successfully. + * The server response will not return data under the key/value pair of `next_billing_at`. View the + * key/value pair of `current_period_ends_at` to verify that the `next_billing_at` date has been + * changed successfully. * - * ### Snap Day Changes + * ### Calendar Billing and Snap Day Changes * * For a subscription using Calendar Billing, setting the next billing date is a bit different. Send * the `snap_day` attribute to change the calendar billing date for **a subscription using a product * eligible for calendar billing**. * - * Note: If you change the product associated with a subscription that contains a `snap_date` and - * immediately `READ/GET` the subscription data, it will still contain evidence of the existing - * `snap_date`. This is due to the fact that a product change is instantanous and only affects the - * product associated with a subscription. After the `next_billing` date arrives, the `snap_day` - * associated with the subscription will return to `null.` Another way of looking at this is that you - * willl have to wait for the next billing cycle to arrive before the `snap_date` will reset to `null`. + * > Note: If you change the product associated with a subscription that contains a `snap_day` and + * immediately `READ/GET` the subscription data, it will still contain original `snap_day`. The + * `snap_day`will will reset to 'null on the next billing cycle. This is because a product change is + * instantanous and only affects the product associated with a subscription. * * @param subscriptionId The Chargify id of the subscription * @param body @@ -1293,8 +528,7 @@ export class SubscriptionsController extends BaseController { * `cascade` parameters. For example, to delete just the customer record, the query params would be: `? * ack={customer_id}&cascade[]=customer` * - * If you need to remove subscriptions from a live site, please contact support to discuss your use - * case. + * If you need to remove subscriptions from a live site, contact support to discuss your use case. * * ### Delete customer and payment profile * @@ -1369,7 +603,7 @@ export class SubscriptionsController extends BaseController { * * A subscription will not be created by utilizing this endpoint; it is meant to serve as a prediction. * - * For more information, please see our documentation [here](https://maxio.zendesk.com/hc/en- + * For more information, see our documentation [here](https://maxio.zendesk.com/hc/en- * us/articles/24252493695757-Subscriber-Interface-Overview). * * ## Taxable Subscriptions @@ -1382,13 +616,13 @@ export class SubscriptionsController extends BaseController { * + The subscription payload must contain a full billing or shipping address in order to calculate * tax * - * For more information about creating taxable previews, please see our documentation guide on how to - * create [taxable subscriptions.](https://maxio.zendesk.com/hc/en-us/sections/24287012349325-Taxes) + * For more information about creating taxable previews, see our documentation guide on how to create + * [taxable subscriptions.](https://maxio.zendesk.com/hc/en-us/sections/24287012349325-Taxes) * * You do **not** need to include a card number to generate tax information when you are previewing a - * subscription. However, please note that when you actually want to create the subscription, you must - * include the credit card information if you want the billing address to be stored in Advanced Billing. - * The billing address and the credit card information are stored together within the payment profile + * subscription. However, when you actually want to create the subscription, you must include the + * credit card information if you want the billing address to be stored in Advanced Billing. The + * billing address and the credit card information are stored together within the payment profile * object. Also, you may not send a billing address to Advanced Billing without payment profile * information, as the address is stored on the card. * @@ -1397,8 +631,8 @@ export class SubscriptionsController extends BaseController { * * ## Non-taxable Subscriptions * - * If you'd like to calculate subscriptions that do not include tax, please feel free to leave off the - * billing information. + * If you'd like to calculate subscriptions that do not include tax you may leave off the billing + * information. * * @param body * @return Response from the API call @@ -1466,8 +700,8 @@ export class SubscriptionsController extends BaseController { /** * Use this endpoint to remove a coupon from an existing subscription. * - * For more information on the expected behaviour of removing a coupon from a subscription, please see - * our documentation [here.](https://maxio.zendesk.com/hc/en-us/articles/24261259337101-Coupons-and- + * For more information on the expected behaviour of removing a coupon from a subscription, See our + * documentation [here.](https://maxio.zendesk.com/hc/en-us/articles/24261259337101-Coupons-and- * Subscriptions#removing-a-coupon) * * @param subscriptionId The Chargify id of the subscription diff --git a/src/index.ts b/src/index.ts index dc27ff2..461e05f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -603,6 +603,7 @@ export type { TaxConfiguration } from './models/taxConfiguration.js'; export { TaxConfigurationKind } from './models/taxConfigurationKind.js'; export { TaxDestinationAddress } from './models/taxDestinationAddress.js'; export type { TooManyManagementLinkRequests } from './models/tooManyManagementLinkRequests.js'; +export { TrialType } from './models/trialType.js'; export type { UpdateAllocationExpirationDate } from './models/updateAllocationExpirationDate.js'; export type { UpdateComponent } from './models/updateComponent.js'; export type { UpdateComponentPricePoint } from './models/updateComponentPricePoint.js'; @@ -739,6 +740,7 @@ export * from './models/containers/subscriptionGroupSignupComponentAllocatedQuan export * from './models/containers/subscriptionGroupSignupComponentComponentId.js'; export * from './models/containers/subscriptionGroupSignupComponentPricePointId.js'; export * from './models/containers/subscriptionGroupSignupComponentUnitBalance.js'; +export * from './models/containers/subscriptionSnapDay.js'; export * from './models/containers/updateComponentPricePointComponentId.js'; export * from './models/containers/updateComponentPricePointPricePointId.js'; export * from './models/containers/updateMetafieldsRequestMetafields.js'; diff --git a/src/models/accountBalances.ts b/src/models/accountBalances.ts index 03e3e4a..5800177 100644 --- a/src/models/accountBalances.ts +++ b/src/models/accountBalances.ts @@ -21,19 +21,12 @@ export interface AccountBalances { [key: string]: unknown; } -export const accountBalancesSchema: Schema = expandoObject({ - openInvoices: ['open_invoices', optional(lazy(() => accountBalanceSchema))], - pendingInvoices: [ - 'pending_invoices', - optional(lazy(() => accountBalanceSchema)), - ], - pendingDiscounts: [ - 'pending_discounts', - optional(lazy(() => accountBalanceSchema)), - ], - serviceCredits: [ - 'service_credits', - optional(lazy(() => accountBalanceSchema)), - ], - prepayments: ['prepayments', optional(lazy(() => accountBalanceSchema))], -}); +export const accountBalancesSchema: Schema = lazy(() => + expandoObject({ + openInvoices: ['open_invoices', optional(accountBalanceSchema)], + pendingInvoices: ['pending_invoices', optional(accountBalanceSchema)], + pendingDiscounts: ['pending_discounts', optional(accountBalanceSchema)], + serviceCredits: ['service_credits', optional(accountBalanceSchema)], + prepayments: ['prepayments', optional(accountBalanceSchema)], + }) +); diff --git a/src/models/activateEventBasedComponent.ts b/src/models/activateEventBasedComponent.ts index b901029..24b3abf 100644 --- a/src/models/activateEventBasedComponent.ts +++ b/src/models/activateEventBasedComponent.ts @@ -14,23 +14,18 @@ import { export interface ActivateEventBasedComponent { /** The Chargify id of the price point */ pricePointId?: number; - /** This attribute is particularly useful when you need to align billing events for different components on distinct schedules within a subscription. Please note this only works for site with Multifrequency enabled */ + /** This attribute is particularly useful when you need to align billing events for different components on distinct schedules within a subscription. This only works for site with Multifrequency enabled. */ billingSchedule?: BillingSchedule; /** Create or update custom pricing unique to the subscription. Used in place of `price_point_id`. */ customPrice?: ComponentCustomPrice; [key: string]: unknown; } -export const activateEventBasedComponentSchema: Schema = expandoObject( - { - pricePointId: ['price_point_id', optional(number())], - billingSchedule: [ - 'billing_schedule', - optional(lazy(() => billingScheduleSchema)), - ], - customPrice: [ - 'custom_price', - optional(lazy(() => componentCustomPriceSchema)), - ], - } +export const activateEventBasedComponentSchema: Schema = lazy( + () => + expandoObject({ + pricePointId: ['price_point_id', optional(number())], + billingSchedule: ['billing_schedule', optional(billingScheduleSchema)], + customPrice: ['custom_price', optional(componentCustomPriceSchema)], + }) ); diff --git a/src/models/addSubscriptionToAGroup.ts b/src/models/addSubscriptionToAGroup.ts index fd0a9e9..562e175 100644 --- a/src/models/addSubscriptionToAGroup.ts +++ b/src/models/addSubscriptionToAGroup.ts @@ -12,6 +12,6 @@ export interface AddSubscriptionToAGroup { [key: string]: unknown; } -export const addSubscriptionToAGroupSchema: Schema = expandoObject( - { group: ['group', optional(lazy(() => groupSettingsSchema))] } +export const addSubscriptionToAGroupSchema: Schema = lazy( + () => expandoObject({ group: ['group', optional(groupSettingsSchema)] }) ); diff --git a/src/models/addressChange.ts b/src/models/addressChange.ts index ae13630..32d0102 100644 --- a/src/models/addressChange.ts +++ b/src/models/addressChange.ts @@ -13,7 +13,9 @@ export interface AddressChange { [key: string]: unknown; } -export const addressChangeSchema: Schema = expandoObject({ - before: ['before', lazy(() => invoiceAddressSchema)], - after: ['after', lazy(() => invoiceAddressSchema)], -}); +export const addressChangeSchema: Schema = lazy(() => + expandoObject({ + before: ['before', invoiceAddressSchema], + after: ['after', invoiceAddressSchema], + }) +); diff --git a/src/models/allocateComponents.ts b/src/models/allocateComponents.ts index 11b16f2..79d0d2c 100644 --- a/src/models/allocateComponents.ts +++ b/src/models/allocateComponents.ts @@ -49,17 +49,14 @@ export interface AllocateComponents { [key: string]: unknown; } -export const allocateComponentsSchema: Schema = expandoObject( - { +export const allocateComponentsSchema: Schema = lazy(() => + expandoObject({ prorationUpgradeScheme: ['proration_upgrade_scheme', optional(string())], prorationDowngradeScheme: [ 'proration_downgrade_scheme', optional(string()), ], - allocations: [ - 'allocations', - optional(array(lazy(() => createAllocationSchema))), - ], + allocations: ['allocations', optional(array(createAllocationSchema))], accrueCharge: ['accrue_charge', optional(boolean())], upgradeCharge: ['upgrade_charge', optional(nullable(creditTypeSchema))], downgradeCredit: ['downgrade_credit', optional(nullable(creditTypeSchema))], @@ -68,5 +65,5 @@ export const allocateComponentsSchema: Schema = expandoObjec optional(collectionMethodSchema), ], initiateDunning: ['initiate_dunning', optional(boolean())], - } + }) ); diff --git a/src/models/allocation.ts b/src/models/allocation.ts index 6958ad6..3f8ce13 100644 --- a/src/models/allocation.ts +++ b/src/models/allocation.ts @@ -85,36 +85,38 @@ export interface Allocation { [key: string]: unknown; } -export const allocationSchema: Schema = expandoObject({ - allocationId: ['allocation_id', optional(number())], - componentId: ['component_id', optional(number())], - componentHandle: ['component_handle', optional(nullable(string()))], - subscriptionId: ['subscription_id', optional(number())], - quantity: ['quantity', optional(allocationQuantitySchema)], - previousQuantity: [ - 'previous_quantity', - optional(allocationPreviousQuantitySchema), - ], - memo: ['memo', optional(nullable(string()))], - timestamp: ['timestamp', optional(string())], - createdAt: ['created_at', optional(string())], - prorationUpgradeScheme: ['proration_upgrade_scheme', optional(string())], - prorationDowngradeScheme: ['proration_downgrade_scheme', optional(string())], - pricePointId: ['price_point_id', optional(number())], - pricePointName: ['price_point_name', optional(string())], - pricePointHandle: ['price_point_handle', optional(string())], - interval: ['interval', optional(number())], - intervalUnit: ['interval_unit', optional(nullable(intervalUnitSchema))], - previousPricePointId: ['previous_price_point_id', optional(number())], - accrueCharge: ['accrue_charge', optional(boolean())], - initiateDunning: ['initiate_dunning', optional(boolean())], - upgradeCharge: ['upgrade_charge', optional(nullable(creditTypeSchema))], - downgradeCredit: ['downgrade_credit', optional(nullable(creditTypeSchema))], - payment: [ - 'payment', - optional(nullable(lazy(() => paymentForAllocationSchema))), - ], - expiresAt: ['expires_at', optional(string())], - usedQuantity: ['used_quantity', optional(bigint())], - chargeId: ['charge_id', optional(bigint())], -}); +export const allocationSchema: Schema = lazy(() => + expandoObject({ + allocationId: ['allocation_id', optional(number())], + componentId: ['component_id', optional(number())], + componentHandle: ['component_handle', optional(nullable(string()))], + subscriptionId: ['subscription_id', optional(number())], + quantity: ['quantity', optional(allocationQuantitySchema)], + previousQuantity: [ + 'previous_quantity', + optional(allocationPreviousQuantitySchema), + ], + memo: ['memo', optional(nullable(string()))], + timestamp: ['timestamp', optional(string())], + createdAt: ['created_at', optional(string())], + prorationUpgradeScheme: ['proration_upgrade_scheme', optional(string())], + prorationDowngradeScheme: [ + 'proration_downgrade_scheme', + optional(string()), + ], + pricePointId: ['price_point_id', optional(number())], + pricePointName: ['price_point_name', optional(string())], + pricePointHandle: ['price_point_handle', optional(string())], + interval: ['interval', optional(number())], + intervalUnit: ['interval_unit', optional(nullable(intervalUnitSchema))], + previousPricePointId: ['previous_price_point_id', optional(number())], + accrueCharge: ['accrue_charge', optional(boolean())], + initiateDunning: ['initiate_dunning', optional(boolean())], + upgradeCharge: ['upgrade_charge', optional(nullable(creditTypeSchema))], + downgradeCredit: ['downgrade_credit', optional(nullable(creditTypeSchema))], + payment: ['payment', optional(nullable(paymentForAllocationSchema))], + expiresAt: ['expires_at', optional(string())], + usedQuantity: ['used_quantity', optional(bigint())], + chargeId: ['charge_id', optional(bigint())], + }) +); diff --git a/src/models/allocationPreview.ts b/src/models/allocationPreview.ts index a241712..43dcf4c 100644 --- a/src/models/allocationPreview.ts +++ b/src/models/allocationPreview.ts @@ -45,8 +45,8 @@ export interface AllocationPreview { [key: string]: unknown; } -export const allocationPreviewSchema: Schema = expandoObject( - { +export const allocationPreviewSchema: Schema = lazy(() => + expandoObject({ startDate: ['start_date', optional(string())], endDate: ['end_date', optional(string())], subtotalInCents: ['subtotal_in_cents', optional(bigint())], @@ -55,16 +55,10 @@ export const allocationPreviewSchema: Schema = expandoObject( totalInCents: ['total_in_cents', optional(bigint())], direction: ['direction', optional(allocationPreviewDirectionSchema)], prorationScheme: ['proration_scheme', optional(string())], - lineItems: [ - 'line_items', - optional(array(lazy(() => allocationPreviewLineItemSchema))), - ], + lineItems: ['line_items', optional(array(allocationPreviewLineItemSchema))], accrueCharge: ['accrue_charge', optional(boolean())], - allocations: [ - 'allocations', - optional(array(lazy(() => allocationPreviewItemSchema))), - ], + allocations: ['allocations', optional(array(allocationPreviewItemSchema))], periodType: ['period_type', optional(string())], existingBalanceInCents: ['existing_balance_in_cents', optional(bigint())], - } + }) ); diff --git a/src/models/allocationPreviewItem.ts b/src/models/allocationPreviewItem.ts index c1439db..4ffb44b 100644 --- a/src/models/allocationPreviewItem.ts +++ b/src/models/allocationPreviewItem.ts @@ -7,6 +7,7 @@ import { boolean, expandoObject, + lazy, nullable, number, optional, @@ -56,31 +57,35 @@ export interface AllocationPreviewItem { [key: string]: unknown; } -export const allocationPreviewItemSchema: Schema = expandoObject( - { - componentId: ['component_id', optional(number())], - subscriptionId: ['subscription_id', optional(number())], - quantity: ['quantity', optional(allocationPreviewItemQuantitySchema)], - previousQuantity: [ - 'previous_quantity', - optional(allocationPreviewItemPreviousQuantitySchema), - ], - memo: ['memo', optional(nullable(string()))], - timestamp: ['timestamp', optional(nullable(string()))], - prorationUpgradeScheme: ['proration_upgrade_scheme', optional(string())], - prorationDowngradeScheme: [ - 'proration_downgrade_scheme', - optional(string()), - ], - accrueCharge: ['accrue_charge', optional(boolean())], - upgradeCharge: ['upgrade_charge', optional(nullable(creditTypeSchema))], - downgradeCredit: ['downgrade_credit', optional(nullable(creditTypeSchema))], - pricePointId: ['price_point_id', optional(number())], - interval: ['interval', optional(number())], - intervalUnit: ['interval_unit', optional(nullable(intervalUnitSchema))], - previousPricePointId: ['previous_price_point_id', optional(number())], - pricePointHandle: ['price_point_handle', optional(string())], - pricePointName: ['price_point_name', optional(string())], - componentHandle: ['component_handle', optional(nullable(string()))], - } +export const allocationPreviewItemSchema: Schema = lazy( + () => + expandoObject({ + componentId: ['component_id', optional(number())], + subscriptionId: ['subscription_id', optional(number())], + quantity: ['quantity', optional(allocationPreviewItemQuantitySchema)], + previousQuantity: [ + 'previous_quantity', + optional(allocationPreviewItemPreviousQuantitySchema), + ], + memo: ['memo', optional(nullable(string()))], + timestamp: ['timestamp', optional(nullable(string()))], + prorationUpgradeScheme: ['proration_upgrade_scheme', optional(string())], + prorationDowngradeScheme: [ + 'proration_downgrade_scheme', + optional(string()), + ], + accrueCharge: ['accrue_charge', optional(boolean())], + upgradeCharge: ['upgrade_charge', optional(nullable(creditTypeSchema))], + downgradeCredit: [ + 'downgrade_credit', + optional(nullable(creditTypeSchema)), + ], + pricePointId: ['price_point_id', optional(number())], + interval: ['interval', optional(number())], + intervalUnit: ['interval_unit', optional(nullable(intervalUnitSchema))], + previousPricePointId: ['previous_price_point_id', optional(number())], + pricePointHandle: ['price_point_handle', optional(string())], + pricePointName: ['price_point_name', optional(string())], + componentHandle: ['component_handle', optional(nullable(string()))], + }) ); diff --git a/src/models/allocationPreviewResponse.ts b/src/models/allocationPreviewResponse.ts index 660a0d4..a35c22f 100644 --- a/src/models/allocationPreviewResponse.ts +++ b/src/models/allocationPreviewResponse.ts @@ -15,11 +15,9 @@ export interface AllocationPreviewResponse { [key: string]: unknown; } -export const allocationPreviewResponseSchema: Schema = expandoObject( - { - allocationPreview: [ - 'allocation_preview', - lazy(() => allocationPreviewSchema), - ], - } +export const allocationPreviewResponseSchema: Schema = lazy( + () => + expandoObject({ + allocationPreview: ['allocation_preview', allocationPreviewSchema], + }) ); diff --git a/src/models/allocationResponse.ts b/src/models/allocationResponse.ts index 23514c1..9cab10a 100644 --- a/src/models/allocationResponse.ts +++ b/src/models/allocationResponse.ts @@ -12,6 +12,6 @@ export interface AllocationResponse { [key: string]: unknown; } -export const allocationResponseSchema: Schema = expandoObject( - { allocation: ['allocation', optional(lazy(() => allocationSchema))] } +export const allocationResponseSchema: Schema = lazy(() => + expandoObject({ allocation: ['allocation', optional(allocationSchema)] }) ); diff --git a/src/models/applyCreditNoteEvent.ts b/src/models/applyCreditNoteEvent.ts index 943e1b8..678a707 100644 --- a/src/models/applyCreditNoteEvent.ts +++ b/src/models/applyCreditNoteEvent.ts @@ -25,12 +25,13 @@ export interface ApplyCreditNoteEvent { [key: string]: unknown; } -export const applyCreditNoteEventSchema: Schema = expandoObject( - { - id: ['id', bigint()], - timestamp: ['timestamp', string()], - invoice: ['invoice', lazy(() => invoiceSchema)], - eventType: ['event_type', invoiceEventTypeSchema], - eventData: ['event_data', lazy(() => applyCreditNoteEventDataSchema)], - } +export const applyCreditNoteEventSchema: Schema = lazy( + () => + expandoObject({ + id: ['id', bigint()], + timestamp: ['timestamp', string()], + invoice: ['invoice', invoiceSchema], + eventType: ['event_type', invoiceEventTypeSchema], + eventData: ['event_data', applyCreditNoteEventDataSchema], + }) ); diff --git a/src/models/applyCreditNoteEventData.ts b/src/models/applyCreditNoteEventData.ts index 9530841..03696ab 100644 --- a/src/models/applyCreditNoteEventData.ts +++ b/src/models/applyCreditNoteEventData.ts @@ -44,20 +44,21 @@ export interface ApplyCreditNoteEventData { [key: string]: unknown; } -export const applyCreditNoteEventDataSchema: Schema = expandoObject( - { - uid: ['uid', string()], - creditNoteNumber: ['credit_note_number', string()], - creditNoteUid: ['credit_note_uid', string()], - originalAmount: ['original_amount', string()], - appliedAmount: ['applied_amount', string()], - transactionTime: ['transaction_time', optional(string())], - memo: ['memo', optional(nullable(string()))], - role: ['role', optional(string())], - consolidatedInvoice: ['consolidated_invoice', optional(boolean())], - appliedCreditNotes: [ - 'applied_credit_notes', - optional(array(lazy(() => appliedCreditNoteDataSchema))), - ], - } +export const applyCreditNoteEventDataSchema: Schema = lazy( + () => + expandoObject({ + uid: ['uid', string()], + creditNoteNumber: ['credit_note_number', string()], + creditNoteUid: ['credit_note_uid', string()], + originalAmount: ['original_amount', string()], + appliedAmount: ['applied_amount', string()], + transactionTime: ['transaction_time', optional(string())], + memo: ['memo', optional(nullable(string()))], + role: ['role', optional(string())], + consolidatedInvoice: ['consolidated_invoice', optional(boolean())], + appliedCreditNotes: [ + 'applied_credit_notes', + optional(array(appliedCreditNoteDataSchema)), + ], + }) ); diff --git a/src/models/applyDebitNoteEvent.ts b/src/models/applyDebitNoteEvent.ts index 7e8c3d9..4f982a9 100644 --- a/src/models/applyDebitNoteEvent.ts +++ b/src/models/applyDebitNoteEvent.ts @@ -25,12 +25,12 @@ export interface ApplyDebitNoteEvent { [key: string]: unknown; } -export const applyDebitNoteEventSchema: Schema = expandoObject( - { +export const applyDebitNoteEventSchema: Schema = lazy(() => + expandoObject({ id: ['id', bigint()], timestamp: ['timestamp', string()], - invoice: ['invoice', lazy(() => invoiceSchema)], + invoice: ['invoice', invoiceSchema], eventType: ['event_type', invoiceEventTypeSchema], - eventData: ['event_data', lazy(() => applyDebitNoteEventDataSchema)], - } + eventData: ['event_data', applyDebitNoteEventDataSchema], + }) ); diff --git a/src/models/applyPaymentEvent.ts b/src/models/applyPaymentEvent.ts index 6e1be5d..0123985 100644 --- a/src/models/applyPaymentEvent.ts +++ b/src/models/applyPaymentEvent.ts @@ -25,12 +25,12 @@ export interface ApplyPaymentEvent { [key: string]: unknown; } -export const applyPaymentEventSchema: Schema = expandoObject( - { +export const applyPaymentEventSchema: Schema = lazy(() => + expandoObject({ id: ['id', bigint()], timestamp: ['timestamp', string()], - invoice: ['invoice', lazy(() => invoiceSchema)], + invoice: ['invoice', invoiceSchema], eventType: ['event_type', invoiceEventTypeSchema], - eventData: ['event_data', lazy(() => applyPaymentEventDataSchema)], - } + eventData: ['event_data', applyPaymentEventDataSchema], + }) ); diff --git a/src/models/applyPaymentEventData.ts b/src/models/applyPaymentEventData.ts index 8051f75..8e37fa7 100644 --- a/src/models/applyPaymentEventData.ts +++ b/src/models/applyPaymentEventData.ts @@ -7,6 +7,7 @@ import { boolean, expandoObject, + lazy, nullable, number, optional, @@ -44,27 +45,28 @@ export interface ApplyPaymentEventData { [key: string]: unknown; } -export const applyPaymentEventDataSchema: Schema = expandoObject( - { - consolidationLevel: [ - 'consolidation_level', - invoiceConsolidationLevelSchema, - ], - memo: ['memo', string()], - originalAmount: ['original_amount', string()], - appliedAmount: ['applied_amount', string()], - transactionTime: ['transaction_time', string()], - paymentMethod: ['payment_method', invoiceEventPaymentSchema], - transactionId: ['transaction_id', optional(number())], - parentInvoiceNumber: [ - 'parent_invoice_number', - optional(nullable(number())), - ], - remainingPrepaymentAmount: [ - 'remaining_prepayment_amount', - optional(nullable(string())), - ], - prepayment: ['prepayment', optional(boolean())], - external: ['external', optional(boolean())], - } +export const applyPaymentEventDataSchema: Schema = lazy( + () => + expandoObject({ + consolidationLevel: [ + 'consolidation_level', + invoiceConsolidationLevelSchema, + ], + memo: ['memo', string()], + originalAmount: ['original_amount', string()], + appliedAmount: ['applied_amount', string()], + transactionTime: ['transaction_time', string()], + paymentMethod: ['payment_method', invoiceEventPaymentSchema], + transactionId: ['transaction_id', optional(number())], + parentInvoiceNumber: [ + 'parent_invoice_number', + optional(nullable(number())), + ], + remainingPrepaymentAmount: [ + 'remaining_prepayment_amount', + optional(nullable(string())), + ], + prepayment: ['prepayment', optional(boolean())], + external: ['external', optional(boolean())], + }) ); diff --git a/src/models/backportInvoiceEvent.ts b/src/models/backportInvoiceEvent.ts index de4932d..b28e4b4 100644 --- a/src/models/backportInvoiceEvent.ts +++ b/src/models/backportInvoiceEvent.ts @@ -21,12 +21,13 @@ export interface BackportInvoiceEvent { [key: string]: unknown; } -export const backportInvoiceEventSchema: Schema = expandoObject( - { - id: ['id', bigint()], - timestamp: ['timestamp', string()], - invoice: ['invoice', lazy(() => invoiceSchema)], - eventType: ['event_type', invoiceEventTypeSchema], - eventData: ['event_data', lazy(() => invoiceSchema)], - } +export const backportInvoiceEventSchema: Schema = lazy( + () => + expandoObject({ + id: ['id', bigint()], + timestamp: ['timestamp', string()], + invoice: ['invoice', invoiceSchema], + eventType: ['event_type', invoiceEventTypeSchema], + eventData: ['event_data', invoiceSchema], + }) ); diff --git a/src/models/bankAccountResponse.ts b/src/models/bankAccountResponse.ts index d3c02ff..e5720e1 100644 --- a/src/models/bankAccountResponse.ts +++ b/src/models/bankAccountResponse.ts @@ -15,11 +15,8 @@ export interface BankAccountResponse { [key: string]: unknown; } -export const bankAccountResponseSchema: Schema = expandoObject( - { - paymentProfile: [ - 'payment_profile', - lazy(() => bankAccountPaymentProfileSchema), - ], - } +export const bankAccountResponseSchema: Schema = lazy(() => + expandoObject({ + paymentProfile: ['payment_profile', bankAccountPaymentProfileSchema], + }) ); diff --git a/src/models/bankAccountVerificationRequest.ts b/src/models/bankAccountVerificationRequest.ts index 98c8ab7..199a99f 100644 --- a/src/models/bankAccountVerificationRequest.ts +++ b/src/models/bankAccountVerificationRequest.ts @@ -15,11 +15,12 @@ export interface BankAccountVerificationRequest { [key: string]: unknown; } -export const bankAccountVerificationRequestSchema: Schema = expandoObject( - { - bankAccountVerification: [ - 'bank_account_verification', - lazy(() => bankAccountVerificationSchema), - ], - } +export const bankAccountVerificationRequestSchema: Schema = lazy( + () => + expandoObject({ + bankAccountVerification: [ + 'bank_account_verification', + bankAccountVerificationSchema, + ], + }) ); diff --git a/src/models/batchJobResponse.ts b/src/models/batchJobResponse.ts index ed8eca1..db1b26b 100644 --- a/src/models/batchJobResponse.ts +++ b/src/models/batchJobResponse.ts @@ -12,6 +12,6 @@ export interface BatchJobResponse { [key: string]: unknown; } -export const batchJobResponseSchema: Schema = expandoObject({ - batchjob: ['batchjob', lazy(() => batchJobSchema)], -}); +export const batchJobResponseSchema: Schema = lazy(() => + expandoObject({ batchjob: ['batchjob', batchJobSchema] }) +); diff --git a/src/models/billingManifest.ts b/src/models/billingManifest.ts index f00ac80..7ae92c9 100644 --- a/src/models/billingManifest.ts +++ b/src/models/billingManifest.ts @@ -32,17 +32,16 @@ export interface BillingManifest { [key: string]: unknown; } -export const billingManifestSchema: Schema = expandoObject({ - lineItems: [ - 'line_items', - optional(array(lazy(() => billingManifestItemSchema))), - ], - totalInCents: ['total_in_cents', optional(bigint())], - totalDiscountInCents: ['total_discount_in_cents', optional(bigint())], - totalTaxInCents: ['total_tax_in_cents', optional(bigint())], - subtotalInCents: ['subtotal_in_cents', optional(bigint())], - startDate: ['start_date', optional(nullable(string()))], - endDate: ['end_date', optional(nullable(string()))], - periodType: ['period_type', optional(nullable(string()))], - existingBalanceInCents: ['existing_balance_in_cents', optional(bigint())], -}); +export const billingManifestSchema: Schema = lazy(() => + expandoObject({ + lineItems: ['line_items', optional(array(billingManifestItemSchema))], + totalInCents: ['total_in_cents', optional(bigint())], + totalDiscountInCents: ['total_discount_in_cents', optional(bigint())], + totalTaxInCents: ['total_tax_in_cents', optional(bigint())], + subtotalInCents: ['subtotal_in_cents', optional(bigint())], + startDate: ['start_date', optional(nullable(string()))], + endDate: ['end_date', optional(nullable(string()))], + periodType: ['period_type', optional(nullable(string()))], + existingBalanceInCents: ['existing_balance_in_cents', optional(bigint())], + }) +); diff --git a/src/models/billingSchedule.ts b/src/models/billingSchedule.ts index 61764b4..b74a962 100644 --- a/src/models/billingSchedule.ts +++ b/src/models/billingSchedule.ts @@ -6,7 +6,7 @@ import { expandoObject, optional, Schema, string } from '../schema.js'; -/** This attribute is particularly useful when you need to align billing events for different components on distinct schedules within a subscription. Please note this only works for site with Multifrequency enabled */ +/** This attribute is particularly useful when you need to align billing events for different components on distinct schedules within a subscription. This only works for site with Multifrequency enabled. */ export interface BillingSchedule { /** The initial_billing_at attribute in Maxio allows you to specify a custom starting date for billing cycles associated with components that have their own billing frequency set. Only ISO8601 format is supported. */ initialBillingAt?: string; diff --git a/src/models/bulkComponentsPricePointAssignment.ts b/src/models/bulkComponentsPricePointAssignment.ts index 2718af1..a8c80b4 100644 --- a/src/models/bulkComponentsPricePointAssignment.ts +++ b/src/models/bulkComponentsPricePointAssignment.ts @@ -15,11 +15,12 @@ export interface BulkComponentsPricePointAssignment { [key: string]: unknown; } -export const bulkComponentsPricePointAssignmentSchema: Schema = expandoObject( - { - components: [ - 'components', - optional(array(lazy(() => componentPricePointAssignmentSchema))), - ], - } +export const bulkComponentsPricePointAssignmentSchema: Schema = lazy( + () => + expandoObject({ + components: [ + 'components', + optional(array(componentPricePointAssignmentSchema)), + ], + }) ); diff --git a/src/models/bulkCreateProductPricePointsRequest.ts b/src/models/bulkCreateProductPricePointsRequest.ts index 1e16b05..decca7c 100644 --- a/src/models/bulkCreateProductPricePointsRequest.ts +++ b/src/models/bulkCreateProductPricePointsRequest.ts @@ -15,11 +15,9 @@ export interface BulkCreateProductPricePointsRequest { [key: string]: unknown; } -export const bulkCreateProductPricePointsRequestSchema: Schema = expandoObject( - { - pricePoints: [ - 'price_points', - array(lazy(() => createProductPricePointSchema)), - ], - } +export const bulkCreateProductPricePointsRequestSchema: Schema = lazy( + () => + expandoObject({ + pricePoints: ['price_points', array(createProductPricePointSchema)], + }) ); diff --git a/src/models/bulkCreateProductPricePointsResponse.ts b/src/models/bulkCreateProductPricePointsResponse.ts index 9146167..6832048 100644 --- a/src/models/bulkCreateProductPricePointsResponse.ts +++ b/src/models/bulkCreateProductPricePointsResponse.ts @@ -15,11 +15,9 @@ export interface BulkCreateProductPricePointsResponse { [key: string]: unknown; } -export const bulkCreateProductPricePointsResponseSchema: Schema = expandoObject( - { - pricePoints: [ - 'price_points', - optional(array(lazy(() => productPricePointSchema))), - ], - } +export const bulkCreateProductPricePointsResponseSchema: Schema = lazy( + () => + expandoObject({ + pricePoints: ['price_points', optional(array(productPricePointSchema))], + }) ); diff --git a/src/models/bulkCreateSegments.ts b/src/models/bulkCreateSegments.ts index d7c00a5..5fefe25 100644 --- a/src/models/bulkCreateSegments.ts +++ b/src/models/bulkCreateSegments.ts @@ -12,6 +12,8 @@ export interface BulkCreateSegments { [key: string]: unknown; } -export const bulkCreateSegmentsSchema: Schema = expandoObject( - { segments: ['segments', optional(array(lazy(() => createSegmentSchema)))] } +export const bulkCreateSegmentsSchema: Schema = lazy(() => + expandoObject({ + segments: ['segments', optional(array(createSegmentSchema))], + }) ); diff --git a/src/models/bulkUpdateSegments.ts b/src/models/bulkUpdateSegments.ts index 19a00a7..60673e8 100644 --- a/src/models/bulkUpdateSegments.ts +++ b/src/models/bulkUpdateSegments.ts @@ -15,11 +15,8 @@ export interface BulkUpdateSegments { [key: string]: unknown; } -export const bulkUpdateSegmentsSchema: Schema = expandoObject( - { - segments: [ - 'segments', - optional(array(lazy(() => bulkUpdateSegmentsItemSchema))), - ], - } +export const bulkUpdateSegmentsSchema: Schema = lazy(() => + expandoObject({ + segments: ['segments', optional(array(bulkUpdateSegmentsItemSchema))], + }) ); diff --git a/src/models/bulkUpdateSegmentsItem.ts b/src/models/bulkUpdateSegmentsItem.ts index 4a23756..a100277 100644 --- a/src/models/bulkUpdateSegmentsItem.ts +++ b/src/models/bulkUpdateSegmentsItem.ts @@ -20,10 +20,11 @@ export interface BulkUpdateSegmentsItem { [key: string]: unknown; } -export const bulkUpdateSegmentsItemSchema: Schema = expandoObject( - { - id: ['id', number()], - pricingScheme: ['pricing_scheme', pricingSchemeSchema], - prices: ['prices', array(lazy(() => createOrUpdateSegmentPriceSchema))], - } +export const bulkUpdateSegmentsItemSchema: Schema = lazy( + () => + expandoObject({ + id: ['id', number()], + pricingScheme: ['pricing_scheme', pricingSchemeSchema], + prices: ['prices', array(createOrUpdateSegmentPriceSchema)], + }) ); diff --git a/src/models/calendarBilling.ts b/src/models/calendarBilling.ts index 88b396f..f3a6d8f 100644 --- a/src/models/calendarBilling.ts +++ b/src/models/calendarBilling.ts @@ -4,7 +4,7 @@ * This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ). */ -import { expandoObject, optional, Schema } from '../schema.js'; +import { expandoObject, lazy, nullable, optional, Schema } from '../schema.js'; import { CalendarBillingSnapDay, calendarBillingSnapDaySchema, @@ -14,15 +14,17 @@ import { FirstChargeType, firstChargeTypeSchema } from './firstChargeType.js'; /** (Optional). Cannot be used when also specifying next_billing_at */ export interface CalendarBilling { /** A day of month that subscription will be processed on. Can be 1 up to 28 or 'end'. */ - snapDay?: CalendarBillingSnapDay; + snapDay?: CalendarBillingSnapDay | null; calendarBillingFirstCharge?: FirstChargeType; [key: string]: unknown; } -export const calendarBillingSchema: Schema = expandoObject({ - snapDay: ['snap_day', optional(calendarBillingSnapDaySchema)], - calendarBillingFirstCharge: [ - 'calendar_billing_first_charge', - optional(firstChargeTypeSchema), - ], -}); +export const calendarBillingSchema: Schema = lazy(() => + expandoObject({ + snapDay: ['snap_day', optional(nullable(calendarBillingSnapDaySchema))], + calendarBillingFirstCharge: [ + 'calendar_billing_first_charge', + optional(firstChargeTypeSchema), + ], + }) +); diff --git a/src/models/cancellationRequest.ts b/src/models/cancellationRequest.ts index 64ff1da..ad96929 100644 --- a/src/models/cancellationRequest.ts +++ b/src/models/cancellationRequest.ts @@ -15,6 +15,6 @@ export interface CancellationRequest { [key: string]: unknown; } -export const cancellationRequestSchema: Schema = expandoObject( - { subscription: ['subscription', lazy(() => cancellationOptionsSchema)] } +export const cancellationRequestSchema: Schema = lazy(() => + expandoObject({ subscription: ['subscription', cancellationOptionsSchema] }) ); diff --git a/src/models/changeChargebackStatusEvent.ts b/src/models/changeChargebackStatusEvent.ts index c13e411..1e65576 100644 --- a/src/models/changeChargebackStatusEvent.ts +++ b/src/models/changeChargebackStatusEvent.ts @@ -25,15 +25,13 @@ export interface ChangeChargebackStatusEvent { [key: string]: unknown; } -export const changeChargebackStatusEventSchema: Schema = expandoObject( - { - id: ['id', bigint()], - timestamp: ['timestamp', string()], - invoice: ['invoice', lazy(() => invoiceSchema)], - eventType: ['event_type', invoiceEventTypeSchema], - eventData: [ - 'event_data', - lazy(() => changeChargebackStatusEventDataSchema), - ], - } +export const changeChargebackStatusEventSchema: Schema = lazy( + () => + expandoObject({ + id: ['id', bigint()], + timestamp: ['timestamp', string()], + invoice: ['invoice', invoiceSchema], + eventType: ['event_type', invoiceEventTypeSchema], + eventData: ['event_data', changeChargebackStatusEventDataSchema], + }) ); diff --git a/src/models/changeInvoiceCollectionMethodEvent.ts b/src/models/changeInvoiceCollectionMethodEvent.ts index 25aaaa7..c578b6d 100644 --- a/src/models/changeInvoiceCollectionMethodEvent.ts +++ b/src/models/changeInvoiceCollectionMethodEvent.ts @@ -25,15 +25,13 @@ export interface ChangeInvoiceCollectionMethodEvent { [key: string]: unknown; } -export const changeInvoiceCollectionMethodEventSchema: Schema = expandoObject( - { - id: ['id', bigint()], - timestamp: ['timestamp', string()], - invoice: ['invoice', lazy(() => invoiceSchema)], - eventType: ['event_type', invoiceEventTypeSchema], - eventData: [ - 'event_data', - lazy(() => changeInvoiceCollectionMethodEventDataSchema), - ], - } +export const changeInvoiceCollectionMethodEventSchema: Schema = lazy( + () => + expandoObject({ + id: ['id', bigint()], + timestamp: ['timestamp', string()], + invoice: ['invoice', invoiceSchema], + eventType: ['event_type', invoiceEventTypeSchema], + eventData: ['event_data', changeInvoiceCollectionMethodEventDataSchema], + }) ); diff --git a/src/models/changeInvoiceStatusEvent.ts b/src/models/changeInvoiceStatusEvent.ts index ca286f2..6c63a78 100644 --- a/src/models/changeInvoiceStatusEvent.ts +++ b/src/models/changeInvoiceStatusEvent.ts @@ -25,12 +25,13 @@ export interface ChangeInvoiceStatusEvent { [key: string]: unknown; } -export const changeInvoiceStatusEventSchema: Schema = expandoObject( - { - id: ['id', bigint()], - timestamp: ['timestamp', string()], - invoice: ['invoice', lazy(() => invoiceSchema)], - eventType: ['event_type', invoiceEventTypeSchema], - eventData: ['event_data', lazy(() => changeInvoiceStatusEventDataSchema)], - } +export const changeInvoiceStatusEventSchema: Schema = lazy( + () => + expandoObject({ + id: ['id', bigint()], + timestamp: ['timestamp', string()], + invoice: ['invoice', invoiceSchema], + eventType: ['event_type', invoiceEventTypeSchema], + eventData: ['event_data', changeInvoiceStatusEventDataSchema], + }) ); diff --git a/src/models/chargifyEBB.ts b/src/models/chargifyEBB.ts index 2e99afc..a5e0046 100644 --- a/src/models/chargifyEBB.ts +++ b/src/models/chargifyEBB.ts @@ -9,9 +9,9 @@ import { expandoObject, number, optional, Schema, string } from '../schema.js'; export interface ChargifyEBB { /** This timestamp determines what billing period the event will be billed in. If your request payload does not include it, Chargify will add `chargify.timestamp` to the event payload and set the value to `now`. */ timestamp?: string; - /** A unique ID set by Chargify. Please note that this field is reserved. If `chargify.id` is present in the request payload, it will be overwritten. */ + /** A unique ID set by Chargify. This field is reserved. If `chargify.id` is present in the request payload, it will be overwritten. */ id?: string; - /** An ISO-8601 timestamp, set by Chargify at the time each event is recorded. Please note that this field is reserved. If `chargify.created_at` is present in the request payload, it will be overwritten. */ + /** An ISO-8601 timestamp, set by Chargify at the time each event is recorded. This field is reserved. If `chargify.created_at` is present in the request payload, it will be overwritten. */ createdAt?: string; /** User-defined string scoped per-stream. Duplicate events within a stream will be silently ignored. Tokens expire after 31 days. */ uniquenessToken?: string; diff --git a/src/models/component.ts b/src/models/component.ts index b9be382..73fccc4 100644 --- a/src/models/component.ts +++ b/src/models/component.ts @@ -47,8 +47,6 @@ export interface Component { kind?: ComponentKind; /** Boolean flag describing whether a component is archived or not. */ archived?: boolean; - /** Boolean flag describing whether a component is taxable or not. */ - taxable?: boolean; /** The description of the component. */ description?: string | null; defaultPricePointId?: number | null; @@ -61,7 +59,9 @@ export interface Component { /** URL that points to the location to read the existing price points via GET request */ pricePointsUrl?: string | null; defaultPricePointName?: string; - /** A string representing the tax code related to the component type. This is especially important when using the Avalara service to tax based on locale. This attribute has a max length of 10 characters. */ + /** Boolean flag describing whether a component is taxable or not. */ + taxable?: boolean; + /** A string representing the tax code related to the component type. This is especially important when using AvaTax to tax based on locale. This attribute has a max length of 25 characters. */ taxCode?: string | null; recurring?: boolean; /** @@ -97,58 +97,60 @@ export interface Component { [key: string]: unknown; } -export const componentSchema: Schema = expandoObject({ - id: ['id', optional(number())], - name: ['name', optional(string())], - handle: ['handle', optional(nullable(string()))], - pricingScheme: ['pricing_scheme', optional(nullable(pricingSchemeSchema))], - unitName: ['unit_name', optional(string())], - unitPrice: ['unit_price', optional(nullable(string()))], - productFamilyId: ['product_family_id', optional(number())], - productFamilyName: ['product_family_name', optional(string())], - productFamilyHandle: ['product_family_handle', optional(string())], - pricePerUnitInCents: [ - 'price_per_unit_in_cents', - optional(nullable(bigint())), - ], - kind: ['kind', optional(componentKindSchema)], - archived: ['archived', optional(boolean())], - taxable: ['taxable', optional(boolean())], - description: ['description', optional(nullable(string()))], - defaultPricePointId: ['default_price_point_id', optional(nullable(number()))], - overagePrices: [ - 'overage_prices', - optional(nullable(array(lazy(() => componentPriceSchema)))), - ], - prices: [ - 'prices', - optional(nullable(array(lazy(() => componentPriceSchema)))), - ], - pricePointCount: ['price_point_count', optional(number())], - pricePointsUrl: ['price_points_url', optional(nullable(string()))], - defaultPricePointName: ['default_price_point_name', optional(string())], - taxCode: ['tax_code', optional(nullable(string()))], - recurring: ['recurring', optional(boolean())], - upgradeCharge: ['upgrade_charge', optional(nullable(creditTypeSchema))], - downgradeCredit: ['downgrade_credit', optional(nullable(creditTypeSchema))], - createdAt: ['created_at', optional(string())], - updatedAt: ['updated_at', optional(string())], - archivedAt: ['archived_at', optional(nullable(string()))], - hideDateRangeOnInvoice: ['hide_date_range_on_invoice', optional(boolean())], - allowFractionalQuantities: [ - 'allow_fractional_quantities', - optional(boolean()), - ], - itemCategory: ['item_category', optional(nullable(itemCategorySchema))], - useSiteExchangeRate: [ - 'use_site_exchange_rate', - optional(nullable(boolean())), - ], - accountingCode: ['accounting_code', optional(nullable(string()))], - eventBasedBillingMetricId: [ - 'event_based_billing_metric_id', - optional(number()), - ], - interval: ['interval', optional(number())], - intervalUnit: ['interval_unit', optional(nullable(intervalUnitSchema))], -}); +export const componentSchema: Schema = lazy(() => + expandoObject({ + id: ['id', optional(number())], + name: ['name', optional(string())], + handle: ['handle', optional(nullable(string()))], + pricingScheme: ['pricing_scheme', optional(nullable(pricingSchemeSchema))], + unitName: ['unit_name', optional(string())], + unitPrice: ['unit_price', optional(nullable(string()))], + productFamilyId: ['product_family_id', optional(number())], + productFamilyName: ['product_family_name', optional(string())], + productFamilyHandle: ['product_family_handle', optional(string())], + pricePerUnitInCents: [ + 'price_per_unit_in_cents', + optional(nullable(bigint())), + ], + kind: ['kind', optional(componentKindSchema)], + archived: ['archived', optional(boolean())], + description: ['description', optional(nullable(string()))], + defaultPricePointId: [ + 'default_price_point_id', + optional(nullable(number())), + ], + overagePrices: [ + 'overage_prices', + optional(nullable(array(componentPriceSchema))), + ], + prices: ['prices', optional(nullable(array(componentPriceSchema)))], + pricePointCount: ['price_point_count', optional(number())], + pricePointsUrl: ['price_points_url', optional(nullable(string()))], + defaultPricePointName: ['default_price_point_name', optional(string())], + taxable: ['taxable', optional(boolean())], + taxCode: ['tax_code', optional(nullable(string()))], + recurring: ['recurring', optional(boolean())], + upgradeCharge: ['upgrade_charge', optional(nullable(creditTypeSchema))], + downgradeCredit: ['downgrade_credit', optional(nullable(creditTypeSchema))], + createdAt: ['created_at', optional(string())], + updatedAt: ['updated_at', optional(string())], + archivedAt: ['archived_at', optional(nullable(string()))], + hideDateRangeOnInvoice: ['hide_date_range_on_invoice', optional(boolean())], + allowFractionalQuantities: [ + 'allow_fractional_quantities', + optional(boolean()), + ], + itemCategory: ['item_category', optional(nullable(itemCategorySchema))], + useSiteExchangeRate: [ + 'use_site_exchange_rate', + optional(nullable(boolean())), + ], + accountingCode: ['accounting_code', optional(nullable(string()))], + eventBasedBillingMetricId: [ + 'event_based_billing_metric_id', + optional(number()), + ], + interval: ['interval', optional(number())], + intervalUnit: ['interval_unit', optional(nullable(intervalUnitSchema))], + }) +); diff --git a/src/models/componentAllocationChange.ts b/src/models/componentAllocationChange.ts index ba5cb47..f4d491d 100644 --- a/src/models/componentAllocationChange.ts +++ b/src/models/componentAllocationChange.ts @@ -4,7 +4,14 @@ * This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ). */ -import { expandoObject, number, optional, Schema, string } from '../schema.js'; +import { + expandoObject, + lazy, + number, + optional, + Schema, + string, +} from '../schema.js'; import { ComponentAllocationChangeAllocatedQuantity, componentAllocationChangeAllocatedQuantitySchema, @@ -21,17 +28,18 @@ export interface ComponentAllocationChange { [key: string]: unknown; } -export const componentAllocationChangeSchema: Schema = expandoObject( - { - previousAllocation: ['previous_allocation', number()], - newAllocation: ['new_allocation', number()], - componentId: ['component_id', number()], - componentHandle: ['component_handle', string()], - memo: ['memo', string()], - allocationId: ['allocation_id', number()], - allocatedQuantity: [ - 'allocated_quantity', - optional(componentAllocationChangeAllocatedQuantitySchema), - ], - } +export const componentAllocationChangeSchema: Schema = lazy( + () => + expandoObject({ + previousAllocation: ['previous_allocation', number()], + newAllocation: ['new_allocation', number()], + componentId: ['component_id', number()], + componentHandle: ['component_handle', string()], + memo: ['memo', string()], + allocationId: ['allocation_id', number()], + allocatedQuantity: [ + 'allocated_quantity', + optional(componentAllocationChangeAllocatedQuantitySchema), + ], + }) ); diff --git a/src/models/componentCostData.ts b/src/models/componentCostData.ts index fee27f5..8a7090b 100644 --- a/src/models/componentCostData.ts +++ b/src/models/componentCostData.ts @@ -32,17 +32,14 @@ export interface ComponentCostData { [key: string]: unknown; } -export const componentCostDataSchema: Schema = expandoObject( - { +export const componentCostDataSchema: Schema = lazy(() => + expandoObject({ componentCodeId: ['component_code_id', optional(nullable(number()))], pricePointId: ['price_point_id', optional(number())], productId: ['product_id', optional(number())], quantity: ['quantity', optional(string())], amount: ['amount', optional(string())], pricingScheme: ['pricing_scheme', optional(pricingSchemeSchema)], - tiers: [ - 'tiers', - optional(array(lazy(() => componentCostDataRateTierSchema))), - ], - } + tiers: ['tiers', optional(array(componentCostDataRateTierSchema))], + }) ); diff --git a/src/models/componentCurrencyPricesResponse.ts b/src/models/componentCurrencyPricesResponse.ts index 477c72d..f44e9dd 100644 --- a/src/models/componentCurrencyPricesResponse.ts +++ b/src/models/componentCurrencyPricesResponse.ts @@ -15,11 +15,9 @@ export interface ComponentCurrencyPricesResponse { [key: string]: unknown; } -export const componentCurrencyPricesResponseSchema: Schema = expandoObject( - { - currencyPrices: [ - 'currency_prices', - array(lazy(() => componentCurrencyPriceSchema)), - ], - } +export const componentCurrencyPricesResponseSchema: Schema = lazy( + () => + expandoObject({ + currencyPrices: ['currency_prices', array(componentCurrencyPriceSchema)], + }) ); diff --git a/src/models/componentCustomPrice.ts b/src/models/componentCustomPrice.ts index 28cf942..0cd390f 100644 --- a/src/models/componentCustomPrice.ts +++ b/src/models/componentCustomPrice.ts @@ -14,6 +14,10 @@ import { optional, Schema, } from '../schema.js'; +import { + ExpirationIntervalUnit, + expirationIntervalUnitSchema, +} from './expirationIntervalUnit.js'; import { IntervalUnit, intervalUnitSchema } from './intervalUnit.js'; import { Price, priceSchema } from './price.js'; import { PricingScheme, pricingSchemeSchema } from './pricingScheme.js'; @@ -30,15 +34,34 @@ export interface ComponentCustomPrice { intervalUnit?: IntervalUnit | null; /** On/off components only need one price bracket starting at 1 */ prices: Price[]; + /** Applicable only to prepaid usage components. Controls whether the allocated quantity renews each period. */ + renewPrepaidAllocation?: boolean; + /** Applicable only to prepaid usage components. Controls whether remaining units roll over to the next period. */ + rolloverPrepaidRemainder?: boolean; + /** Applicable only when rollover is enabled. Number of `expiration_interval_unit`s after which rollover amounts expire. */ + expirationInterval?: number | null; + /** Applicable only when rollover is enabled. Interval unit for rollover expiration (month or day). */ + expirationIntervalUnit?: ExpirationIntervalUnit | null; [key: string]: unknown; } -export const componentCustomPriceSchema: Schema = expandoObject( - { - taxIncluded: ['tax_included', optional(boolean())], - pricingScheme: ['pricing_scheme', optional(pricingSchemeSchema)], - interval: ['interval', optional(number())], - intervalUnit: ['interval_unit', optional(nullable(intervalUnitSchema))], - prices: ['prices', array(lazy(() => priceSchema))], - } +export const componentCustomPriceSchema: Schema = lazy( + () => + expandoObject({ + taxIncluded: ['tax_included', optional(boolean())], + pricingScheme: ['pricing_scheme', optional(pricingSchemeSchema)], + interval: ['interval', optional(number())], + intervalUnit: ['interval_unit', optional(nullable(intervalUnitSchema))], + prices: ['prices', array(priceSchema)], + renewPrepaidAllocation: ['renew_prepaid_allocation', optional(boolean())], + rolloverPrepaidRemainder: [ + 'rollover_prepaid_remainder', + optional(boolean()), + ], + expirationInterval: ['expiration_interval', optional(nullable(number()))], + expirationIntervalUnit: [ + 'expiration_interval_unit', + optional(nullable(expirationIntervalUnitSchema)), + ], + }) ); diff --git a/src/models/componentPricePoint.ts b/src/models/componentPricePoint.ts index c37aa66..c405387 100644 --- a/src/models/componentPricePoint.ts +++ b/src/models/componentPricePoint.ts @@ -74,8 +74,8 @@ export interface ComponentPricePoint { [key: string]: unknown; } -export const componentPricePointSchema: Schema = expandoObject( - { +export const componentPricePointSchema: Schema = lazy(() => + expandoObject({ id: ['id', optional(number())], type: ['type', optional(pricePointTypeSchema)], mDefault: ['default', optional(boolean())], @@ -86,7 +86,7 @@ export const componentPricePointSchema: Schema = expandoObj archivedAt: ['archived_at', optional(nullable(string()))], createdAt: ['created_at', optional(string())], updatedAt: ['updated_at', optional(string())], - prices: ['prices', optional(array(lazy(() => componentPriceSchema)))], + prices: ['prices', optional(array(componentPriceSchema))], useSiteExchangeRate: ['use_site_exchange_rate', optional(boolean())], subscriptionId: ['subscription_id', optional(number())], taxIncluded: ['tax_included', optional(boolean())], @@ -94,12 +94,9 @@ export const componentPricePointSchema: Schema = expandoObj intervalUnit: ['interval_unit', optional(nullable(intervalUnitSchema))], currencyPrices: [ 'currency_prices', - optional(array(lazy(() => componentCurrencyPriceSchema))), - ], - overagePrices: [ - 'overage_prices', - optional(array(lazy(() => componentPriceSchema))), + optional(array(componentCurrencyPriceSchema)), ], + overagePrices: ['overage_prices', optional(array(componentPriceSchema))], overagePricingScheme: [ 'overage_pricing_scheme', optional(pricingSchemeSchema), @@ -114,5 +111,5 @@ export const componentPricePointSchema: Schema = expandoObj 'expiration_interval_unit', optional(nullable(expirationIntervalUnitSchema)), ], - } + }) ); diff --git a/src/models/componentPricePointAssignment.ts b/src/models/componentPricePointAssignment.ts index 854e991..c758b23 100644 --- a/src/models/componentPricePointAssignment.ts +++ b/src/models/componentPricePointAssignment.ts @@ -4,7 +4,7 @@ * This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ). */ -import { expandoObject, number, optional, Schema } from '../schema.js'; +import { expandoObject, lazy, number, optional, Schema } from '../schema.js'; import { ComponentPricePointAssignmentPricePoint, componentPricePointAssignmentPricePointSchema, @@ -16,12 +16,13 @@ export interface ComponentPricePointAssignment { [key: string]: unknown; } -export const componentPricePointAssignmentSchema: Schema = expandoObject( - { - componentId: ['component_id', optional(number())], - pricePoint: [ - 'price_point', - optional(componentPricePointAssignmentPricePointSchema), - ], - } +export const componentPricePointAssignmentSchema: Schema = lazy( + () => + expandoObject({ + componentId: ['component_id', optional(number())], + pricePoint: [ + 'price_point', + optional(componentPricePointAssignmentPricePointSchema), + ], + }) ); diff --git a/src/models/componentPricePointItem.ts b/src/models/componentPricePointItem.ts index bbfa31b..faa09ef 100644 --- a/src/models/componentPricePointItem.ts +++ b/src/models/componentPricePointItem.ts @@ -31,13 +31,14 @@ export interface ComponentPricePointItem { [key: string]: unknown; } -export const componentPricePointItemSchema: Schema = expandoObject( - { - name: ['name', optional(string())], - handle: ['handle', optional(string())], - pricingScheme: ['pricing_scheme', optional(pricingSchemeSchema)], - interval: ['interval', optional(number())], - intervalUnit: ['interval_unit', optional(nullable(intervalUnitSchema))], - prices: ['prices', optional(array(lazy(() => priceSchema)))], - } +export const componentPricePointItemSchema: Schema = lazy( + () => + expandoObject({ + name: ['name', optional(string())], + handle: ['handle', optional(string())], + pricingScheme: ['pricing_scheme', optional(pricingSchemeSchema)], + interval: ['interval', optional(number())], + intervalUnit: ['interval_unit', optional(nullable(intervalUnitSchema))], + prices: ['prices', optional(array(priceSchema))], + }) ); diff --git a/src/models/componentPricePointResponse.ts b/src/models/componentPricePointResponse.ts index ffdc4bf..c7d4c7e 100644 --- a/src/models/componentPricePointResponse.ts +++ b/src/models/componentPricePointResponse.ts @@ -15,6 +15,7 @@ export interface ComponentPricePointResponse { [key: string]: unknown; } -export const componentPricePointResponseSchema: Schema = expandoObject( - { pricePoint: ['price_point', lazy(() => componentPricePointSchema)] } +export const componentPricePointResponseSchema: Schema = lazy( + () => + expandoObject({ pricePoint: ['price_point', componentPricePointSchema] }) ); diff --git a/src/models/componentPricePointsResponse.ts b/src/models/componentPricePointsResponse.ts index a3e8ecd..8ec22c8 100644 --- a/src/models/componentPricePointsResponse.ts +++ b/src/models/componentPricePointsResponse.ts @@ -20,12 +20,10 @@ export interface ComponentPricePointsResponse { [key: string]: unknown; } -export const componentPricePointsResponseSchema: Schema = expandoObject( - { - pricePoints: [ - 'price_points', - optional(array(lazy(() => componentPricePointSchema))), - ], - meta: ['meta', optional(lazy(() => listPublicKeysMetaSchema))], - } +export const componentPricePointsResponseSchema: Schema = lazy( + () => + expandoObject({ + pricePoints: ['price_points', optional(array(componentPricePointSchema))], + meta: ['meta', optional(listPublicKeysMetaSchema)], + }) ); diff --git a/src/models/componentResponse.ts b/src/models/componentResponse.ts index f24eb8d..5b679c6 100644 --- a/src/models/componentResponse.ts +++ b/src/models/componentResponse.ts @@ -12,6 +12,6 @@ export interface ComponentResponse { [key: string]: unknown; } -export const componentResponseSchema: Schema = expandoObject( - { component: ['component', lazy(() => componentSchema)] } +export const componentResponseSchema: Schema = lazy(() => + expandoObject({ component: ['component', componentSchema] }) ); diff --git a/src/models/consolidatedInvoice.ts b/src/models/consolidatedInvoice.ts index 2cfcabd..225fb32 100644 --- a/src/models/consolidatedInvoice.ts +++ b/src/models/consolidatedInvoice.ts @@ -12,6 +12,6 @@ export interface ConsolidatedInvoice { [key: string]: unknown; } -export const consolidatedInvoiceSchema: Schema = expandoObject( - { invoices: ['invoices', optional(array(lazy(() => invoiceSchema)))] } +export const consolidatedInvoiceSchema: Schema = lazy(() => + expandoObject({ invoices: ['invoices', optional(array(invoiceSchema))] }) ); diff --git a/src/models/containers/calendarBillingSnapDay.ts b/src/models/containers/calendarBillingSnapDay.ts index 04f4f20..783bd0a 100644 --- a/src/models/containers/calendarBillingSnapDay.ts +++ b/src/models/containers/calendarBillingSnapDay.ts @@ -4,13 +4,19 @@ * This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ). */ -import { number, oneOf, Schema, string } from '../../schema.js'; +import { + isMappedValueValidForSchema, + number, + oneOf, + Schema, +} from '../../schema.js'; +import { SnapDay, snapDaySchema } from '../snapDay.js'; /** This is a container type for one-of types. */ -export type CalendarBillingSnapDay = number | string; +export type CalendarBillingSnapDay = number | SnapDay; export const calendarBillingSnapDaySchema: Schema = oneOf( - [number(), string()] + [number(), snapDaySchema] ); export namespace CalendarBillingSnapDay { @@ -24,11 +30,11 @@ export namespace CalendarBillingSnapDay { } /** - * Validation method to narrow down union type to string type case. + * Validation method to narrow down union type to SnapDay type case. * - * This is String case. + * This is SnapDay case. */ - export function isString(value: unknown): value is string { - return typeof value === 'string'; + export function isSnapDay(value: unknown): value is SnapDay { + return isMappedValueValidForSchema(value, snapDaySchema); } } diff --git a/src/models/containers/createComponentPricePointRequestPricePoint.ts b/src/models/containers/createComponentPricePointRequestPricePoint.ts index ee2ed0f..4054916 100644 --- a/src/models/containers/createComponentPricePointRequestPricePoint.ts +++ b/src/models/containers/createComponentPricePointRequestPricePoint.ts @@ -4,7 +4,12 @@ * This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ). */ -import { anyOf, isMappedValueValidForSchema, Schema } from '../../schema.js'; +import { + anyOf, + isMappedValueValidForSchema, + lazy, + Schema, +} from '../../schema.js'; import { CreateComponentPricePoint, createComponentPricePointSchema, @@ -19,8 +24,12 @@ export type CreateComponentPricePointRequestPricePoint = | CreateComponentPricePoint | CreatePrepaidUsageComponentPricePoint; -export const createComponentPricePointRequestPricePointSchema: Schema = anyOf( - [createComponentPricePointSchema, createPrepaidUsageComponentPricePointSchema] +export const createComponentPricePointRequestPricePointSchema: Schema = lazy( + () => + anyOf([ + createComponentPricePointSchema, + createPrepaidUsageComponentPricePointSchema, + ]) ); export namespace CreateComponentPricePointRequestPricePoint { diff --git a/src/models/containers/createComponentPricePointsRequestPricePoints.ts b/src/models/containers/createComponentPricePointsRequestPricePoints.ts index 095c08a..7dc4b86 100644 --- a/src/models/containers/createComponentPricePointsRequestPricePoints.ts +++ b/src/models/containers/createComponentPricePointsRequestPricePoints.ts @@ -4,7 +4,12 @@ * This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ). */ -import { anyOf, isMappedValueValidForSchema, Schema } from '../../schema.js'; +import { + anyOf, + isMappedValueValidForSchema, + lazy, + Schema, +} from '../../schema.js'; import { CreateComponentPricePoint, createComponentPricePointSchema, @@ -19,8 +24,12 @@ export type CreateComponentPricePointsRequestPricePoints = | CreateComponentPricePoint | CreatePrepaidUsageComponentPricePoint; -export const createComponentPricePointsRequestPricePointsSchema: Schema = anyOf( - [createComponentPricePointSchema, createPrepaidUsageComponentPricePointSchema] +export const createComponentPricePointsRequestPricePointsSchema: Schema = lazy( + () => + anyOf([ + createComponentPricePointSchema, + createPrepaidUsageComponentPricePointSchema, + ]) ); export namespace CreateComponentPricePointsRequestPricePoints { diff --git a/src/models/containers/createMetafieldsRequestMetafields.ts b/src/models/containers/createMetafieldsRequestMetafields.ts index 1443048..e384f06 100644 --- a/src/models/containers/createMetafieldsRequestMetafields.ts +++ b/src/models/containers/createMetafieldsRequestMetafields.ts @@ -7,6 +7,7 @@ import { array, isMappedValueValidForSchema, + lazy, oneOf, Schema, } from '../../schema.js'; @@ -17,8 +18,8 @@ export type CreateMetafieldsRequestMetafields = | CreateMetafield | CreateMetafield[]; -export const createMetafieldsRequestMetafieldsSchema: Schema = oneOf( - [createMetafieldSchema, array(createMetafieldSchema)] +export const createMetafieldsRequestMetafieldsSchema: Schema = lazy( + () => oneOf([createMetafieldSchema, array(createMetafieldSchema)]) ); export namespace CreateMetafieldsRequestMetafields { diff --git a/src/models/containers/customerErrorResponseErrors.ts b/src/models/containers/customerErrorResponseErrors.ts index 0110c3b..7fe8d83 100644 --- a/src/models/containers/customerErrorResponseErrors.ts +++ b/src/models/containers/customerErrorResponseErrors.ts @@ -7,6 +7,7 @@ import { array, isMappedValueValidForSchema, + lazy, oneOf, Schema, string, @@ -16,8 +17,8 @@ import { CustomerError, customerErrorSchema } from '../customerError.js'; /** This is a container type for one-of types. */ export type CustomerErrorResponseErrors = CustomerError | string[]; -export const customerErrorResponseErrorsSchema: Schema = oneOf( - [customerErrorSchema, array(string())] +export const customerErrorResponseErrorsSchema: Schema = lazy( + () => oneOf([customerErrorSchema, array(string())]) ); export namespace CustomerErrorResponseErrors { diff --git a/src/models/containers/eventEventSpecificData.ts b/src/models/containers/eventEventSpecificData.ts index 375f639..011ffe1 100644 --- a/src/models/containers/eventEventSpecificData.ts +++ b/src/models/containers/eventEventSpecificData.ts @@ -4,7 +4,12 @@ * This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ). */ -import { isMappedValueValidForSchema, oneOf, Schema } from '../../schema.js'; +import { + isMappedValueValidForSchema, + lazy, + oneOf, + Schema, +} from '../../schema.js'; import { ComponentAllocationChange, componentAllocationChangeSchema, @@ -87,27 +92,28 @@ export type EventEventSpecificData = | ItemPricePointChanged | CustomFieldValueChange; -export const eventEventSpecificDataSchema: Schema = oneOf( - [ - subscriptionProductChangeSchema, - subscriptionStateChangeSchema, - paymentRelatedEventsSchema, - refundSuccessSchema, - componentAllocationChangeSchema, - meteredUsageSchema, - prepaidUsageSchema, - dunningStepReachedSchema, - invoiceIssuedSchema, - pendingCancellationChangeSchema, - prepaidSubscriptionBalanceChangedSchema, - proformaInvoiceIssuedSchema, - subscriptionGroupSignupEventDataSchema, - creditAccountBalanceChangedSchema, - prepaymentAccountBalanceChangedSchema, - paymentCollectionMethodChangedSchema, - itemPricePointChangedSchema, - customFieldValueChangeSchema, - ] +export const eventEventSpecificDataSchema: Schema = lazy( + () => + oneOf([ + subscriptionProductChangeSchema, + subscriptionStateChangeSchema, + paymentRelatedEventsSchema, + refundSuccessSchema, + componentAllocationChangeSchema, + meteredUsageSchema, + prepaidUsageSchema, + dunningStepReachedSchema, + invoiceIssuedSchema, + pendingCancellationChangeSchema, + prepaidSubscriptionBalanceChangedSchema, + proformaInvoiceIssuedSchema, + subscriptionGroupSignupEventDataSchema, + creditAccountBalanceChangedSchema, + prepaymentAccountBalanceChangedSchema, + paymentCollectionMethodChangedSchema, + itemPricePointChangedSchema, + customFieldValueChangeSchema, + ]) ); export namespace EventEventSpecificData { diff --git a/src/models/containers/invoiceEvent.ts b/src/models/containers/invoiceEvent.ts index 1447aba..61ab055 100644 --- a/src/models/containers/invoiceEvent.ts +++ b/src/models/containers/invoiceEvent.ts @@ -4,7 +4,12 @@ * This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ). */ -import { anyOf, isMappedValueValidForSchema, Schema } from '../../schema.js'; +import { + anyOf, + isMappedValueValidForSchema, + lazy, + Schema, +} from '../../schema.js'; import { ApplyCreditNoteEvent, applyCreditNoteEventSchema, @@ -102,26 +107,28 @@ const discriminatorMap = { 'void_remainder': voidRemainderEventSchema, }; -export const invoiceEventSchema: Schema = anyOf( - [ - applyCreditNoteEventSchema, - applyDebitNoteEventSchema, - applyPaymentEventSchema, - backportInvoiceEventSchema, - changeChargebackStatusEventSchema, - changeInvoiceCollectionMethodEventSchema, - changeInvoiceStatusEventSchema, - createCreditNoteEventSchema, - createDebitNoteEventSchema, - failedPaymentEventSchema, - issueInvoiceEventSchema, - refundInvoiceEventSchema, - removePaymentEventSchema, - voidInvoiceEventSchema, - voidRemainderEventSchema, - ], - discriminatorMap, - 'event_type' +export const invoiceEventSchema: Schema = lazy(() => + anyOf( + [ + applyCreditNoteEventSchema, + applyDebitNoteEventSchema, + applyPaymentEventSchema, + backportInvoiceEventSchema, + changeChargebackStatusEventSchema, + changeInvoiceCollectionMethodEventSchema, + changeInvoiceStatusEventSchema, + createCreditNoteEventSchema, + createDebitNoteEventSchema, + failedPaymentEventSchema, + issueInvoiceEventSchema, + refundInvoiceEventSchema, + removePaymentEventSchema, + voidInvoiceEventSchema, + voidRemainderEventSchema, + ], + discriminatorMap, + 'event_type' + ) ); export namespace InvoiceEvent { diff --git a/src/models/containers/invoiceEventPayment.ts b/src/models/containers/invoiceEventPayment.ts index 6b1cd58..0db57c1 100644 --- a/src/models/containers/invoiceEventPayment.ts +++ b/src/models/containers/invoiceEventPayment.ts @@ -4,7 +4,12 @@ * This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ). */ -import { anyOf, isMappedValueValidForSchema, Schema } from '../../schema.js'; +import { + anyOf, + isMappedValueValidForSchema, + lazy, + Schema, +} from '../../schema.js'; import { PaymentMethodApplePay, paymentMethodApplePaySchema, @@ -42,16 +47,18 @@ const discriminatorMap = { 'paypal_account': paymentMethodPaypalSchema, }; -export const invoiceEventPaymentSchema: Schema = anyOf( - [ - paymentMethodApplePaySchema, - paymentMethodBankAccountSchema, - paymentMethodCreditCardSchema, - paymentMethodExternalSchema, - paymentMethodPaypalSchema, - ], - discriminatorMap, - 'type' +export const invoiceEventPaymentSchema: Schema = lazy(() => + anyOf( + [ + paymentMethodApplePaySchema, + paymentMethodBankAccountSchema, + paymentMethodCreditCardSchema, + paymentMethodExternalSchema, + paymentMethodPaypalSchema, + ], + discriminatorMap, + 'type' + ) ); export namespace InvoiceEventPayment { diff --git a/src/models/containers/paymentProfile.ts b/src/models/containers/paymentProfile.ts index ec424d9..86abdf4 100644 --- a/src/models/containers/paymentProfile.ts +++ b/src/models/containers/paymentProfile.ts @@ -4,7 +4,12 @@ * This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ). */ -import { anyOf, isMappedValueValidForSchema, Schema } from '../../schema.js'; +import { + anyOf, + isMappedValueValidForSchema, + lazy, + Schema, +} from '../../schema.js'; import { ApplePayPaymentProfile, applePayPaymentProfileSchema, @@ -36,15 +41,17 @@ const discriminatorMap = { 'paypal_account': paypalPaymentProfileSchema, }; -export const paymentProfileSchema: Schema = anyOf( - [ - applePayPaymentProfileSchema, - bankAccountPaymentProfileSchema, - creditCardPaymentProfileSchema, - paypalPaymentProfileSchema, - ], - discriminatorMap, - 'payment_type' +export const paymentProfileSchema: Schema = lazy(() => + anyOf( + [ + applePayPaymentProfileSchema, + bankAccountPaymentProfileSchema, + creditCardPaymentProfileSchema, + paypalPaymentProfileSchema, + ], + discriminatorMap, + 'payment_type' + ) ); export namespace PaymentProfile { diff --git a/src/models/containers/reactivateSubscriptionRequestResume.ts b/src/models/containers/reactivateSubscriptionRequestResume.ts index a5b8fb5..fb76b4b 100644 --- a/src/models/containers/reactivateSubscriptionRequestResume.ts +++ b/src/models/containers/reactivateSubscriptionRequestResume.ts @@ -7,6 +7,7 @@ import { boolean, isMappedValueValidForSchema, + lazy, oneOf, Schema, } from '../../schema.js'; @@ -15,8 +16,8 @@ import { ResumeOptions, resumeOptionsSchema } from '../resumeOptions.js'; /** This is a container type for one-of types. */ export type ReactivateSubscriptionRequestResume = boolean | ResumeOptions; -export const reactivateSubscriptionRequestResumeSchema: Schema = oneOf( - [boolean(), resumeOptionsSchema] +export const reactivateSubscriptionRequestResumeSchema: Schema = lazy( + () => oneOf([boolean(), resumeOptionsSchema]) ); export namespace ReactivateSubscriptionRequestResume { diff --git a/src/models/containers/refundInvoiceRequestRefund.ts b/src/models/containers/refundInvoiceRequestRefund.ts index 7690507..2d12758 100644 --- a/src/models/containers/refundInvoiceRequestRefund.ts +++ b/src/models/containers/refundInvoiceRequestRefund.ts @@ -4,7 +4,12 @@ * This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ). */ -import { anyOf, isMappedValueValidForSchema, Schema } from '../../schema.js'; +import { + anyOf, + isMappedValueValidForSchema, + lazy, + Schema, +} from '../../schema.js'; import { RefundConsolidatedInvoice, refundConsolidatedInvoiceSchema, @@ -16,8 +21,8 @@ export type RefundInvoiceRequestRefund = | RefundInvoice | RefundConsolidatedInvoice; -export const refundInvoiceRequestRefundSchema: Schema = anyOf( - [refundInvoiceSchema, refundConsolidatedInvoiceSchema] +export const refundInvoiceRequestRefundSchema: Schema = lazy( + () => anyOf([refundInvoiceSchema, refundConsolidatedInvoiceSchema]) ); export namespace RefundInvoiceRequestRefund { diff --git a/src/models/containers/subscriptionGroupCreateErrorResponseErrors.ts b/src/models/containers/subscriptionGroupCreateErrorResponseErrors.ts index e0e0ad0..ffc43ee 100644 --- a/src/models/containers/subscriptionGroupCreateErrorResponseErrors.ts +++ b/src/models/containers/subscriptionGroupCreateErrorResponseErrors.ts @@ -6,6 +6,7 @@ import { isMappedValueValidForSchema, + lazy, oneOf, Schema, string, @@ -25,12 +26,13 @@ export type SubscriptionGroupCreateErrorResponseErrors = | SubscriptionGroupSingleError | string; -export const subscriptionGroupCreateErrorResponseErrorsSchema: Schema = oneOf( - [ - subscriptionGroupMembersArrayErrorSchema, - subscriptionGroupSingleErrorSchema, - string(), - ] +export const subscriptionGroupCreateErrorResponseErrorsSchema: Schema = lazy( + () => + oneOf([ + subscriptionGroupMembersArrayErrorSchema, + subscriptionGroupSingleErrorSchema, + string(), + ]) ); export namespace SubscriptionGroupCreateErrorResponseErrors { diff --git a/src/models/containers/subscriptionSnapDay.ts b/src/models/containers/subscriptionSnapDay.ts new file mode 100644 index 0000000..2404b22 --- /dev/null +++ b/src/models/containers/subscriptionSnapDay.ts @@ -0,0 +1,41 @@ +/** + * AdvancedBilling + * + * This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ). + */ + +import { + isMappedValueValidForSchema, + number, + oneOf, + Schema, +} from '../../schema.js'; +import { SnapDay, snapDaySchema } from '../snapDay.js'; + +/** This is a container type for one-of types. */ +export type SubscriptionSnapDay = number | SnapDay; + +export const subscriptionSnapDaySchema: Schema = oneOf([ + number(), + snapDaySchema, +]); + +export namespace SubscriptionSnapDay { + /** + * Validation method to narrow down union type to number type case. + * + * This is Number case. + */ + export function isNumber(value: unknown): value is number { + return typeof value === 'number'; + } + + /** + * Validation method to narrow down union type to SnapDay type case. + * + * This is SnapDay case. + */ + export function isSnapDay(value: unknown): value is SnapDay { + return isMappedValueValidForSchema(value, snapDaySchema); + } +} diff --git a/src/models/containers/updateMetafieldsRequestMetafields.ts b/src/models/containers/updateMetafieldsRequestMetafields.ts index 3a1a05c..b5c8477 100644 --- a/src/models/containers/updateMetafieldsRequestMetafields.ts +++ b/src/models/containers/updateMetafieldsRequestMetafields.ts @@ -7,6 +7,7 @@ import { array, isMappedValueValidForSchema, + lazy, oneOf, Schema, } from '../../schema.js'; @@ -17,8 +18,8 @@ export type UpdateMetafieldsRequestMetafields = | UpdateMetafield | UpdateMetafield[]; -export const updateMetafieldsRequestMetafieldsSchema: Schema = oneOf( - [updateMetafieldSchema, array(updateMetafieldSchema)] +export const updateMetafieldsRequestMetafieldsSchema: Schema = lazy( + () => oneOf([updateMetafieldSchema, array(updateMetafieldSchema)]) ); export namespace UpdateMetafieldsRequestMetafields { diff --git a/src/models/containers/updateSubscriptionSnapDay.ts b/src/models/containers/updateSubscriptionSnapDay.ts index 756c45e..2d7aa7b 100644 --- a/src/models/containers/updateSubscriptionSnapDay.ts +++ b/src/models/containers/updateSubscriptionSnapDay.ts @@ -13,28 +13,28 @@ import { import { SnapDay, snapDaySchema } from '../snapDay.js'; /** This is a container type for one-of types. */ -export type UpdateSubscriptionSnapDay = SnapDay | number; +export type UpdateSubscriptionSnapDay = number | SnapDay; export const updateSubscriptionSnapDaySchema: Schema = oneOf( - [snapDaySchema, number()] + [number(), snapDaySchema] ); export namespace UpdateSubscriptionSnapDay { /** - * Validation method to narrow down union type to SnapDay type case. + * Validation method to narrow down union type to number type case. * - * This is SnapDay case. + * This is Number case. */ - export function isSnapDay(value: unknown): value is SnapDay { - return isMappedValueValidForSchema(value, snapDaySchema); + export function isNumber(value: unknown): value is number { + return typeof value === 'number'; } /** - * Validation method to narrow down union type to number type case. + * Validation method to narrow down union type to SnapDay type case. * - * This is Number case. + * This is SnapDay case. */ - export function isNumber(value: unknown): value is number { - return typeof value === 'number'; + export function isSnapDay(value: unknown): value is SnapDay { + return isMappedValueValidForSchema(value, snapDaySchema); } } diff --git a/src/models/coupon.ts b/src/models/coupon.ts index 57cd7f9..ed011ad 100644 --- a/src/models/coupon.ts +++ b/src/models/coupon.ts @@ -68,60 +68,62 @@ export interface Coupon { [key: string]: unknown; } -export const couponSchema: Schema = expandoObject({ - id: ['id', optional(number())], - name: ['name', optional(string())], - code: ['code', optional(string())], - description: ['description', optional(string())], - amount: ['amount', optional(nullable(number()))], - amountInCents: ['amount_in_cents', optional(nullable(bigint()))], - productFamilyId: ['product_family_id', optional(number())], - productFamilyName: ['product_family_name', optional(nullable(string()))], - startDate: ['start_date', optional(string())], - endDate: ['end_date', optional(nullable(string()))], - percentage: ['percentage', optional(nullable(string()))], - recurring: ['recurring', optional(boolean())], - recurringScheme: ['recurring_scheme', optional(recurringSchemeSchema)], - durationPeriodCount: ['duration_period_count', optional(nullable(number()))], - durationInterval: ['duration_interval', optional(nullable(number()))], - durationIntervalUnit: [ - 'duration_interval_unit', - optional(nullable(string())), - ], - durationIntervalSpan: [ - 'duration_interval_span', - optional(nullable(string())), - ], - allowNegativeBalance: ['allow_negative_balance', optional(boolean())], - archivedAt: ['archived_at', optional(nullable(string()))], - conversionLimit: ['conversion_limit', optional(nullable(string()))], - stackable: ['stackable', optional(boolean())], - compoundingStrategy: [ - 'compounding_strategy', - optional(nullable(compoundingStrategySchema)), - ], - useSiteExchangeRate: ['use_site_exchange_rate', optional(boolean())], - createdAt: ['created_at', optional(string())], - updatedAt: ['updated_at', optional(string())], - discountType: ['discount_type', optional(discountTypeSchema)], - excludeMidPeriodAllocations: [ - 'exclude_mid_period_allocations', - optional(boolean()), - ], - applyOnCancelAtEndOfPeriod: [ - 'apply_on_cancel_at_end_of_period', - optional(boolean()), - ], - applyOnSubscriptionExpiration: [ - 'apply_on_subscription_expiration', - optional(boolean()), - ], - couponRestrictions: [ - 'coupon_restrictions', - optional(array(lazy(() => couponRestrictionSchema))), - ], - currencyPrices: [ - 'currency_prices', - optional(array(lazy(() => couponCurrencySchema))), - ], -}); +export const couponSchema: Schema = lazy(() => + expandoObject({ + id: ['id', optional(number())], + name: ['name', optional(string())], + code: ['code', optional(string())], + description: ['description', optional(string())], + amount: ['amount', optional(nullable(number()))], + amountInCents: ['amount_in_cents', optional(nullable(bigint()))], + productFamilyId: ['product_family_id', optional(number())], + productFamilyName: ['product_family_name', optional(nullable(string()))], + startDate: ['start_date', optional(string())], + endDate: ['end_date', optional(nullable(string()))], + percentage: ['percentage', optional(nullable(string()))], + recurring: ['recurring', optional(boolean())], + recurringScheme: ['recurring_scheme', optional(recurringSchemeSchema)], + durationPeriodCount: [ + 'duration_period_count', + optional(nullable(number())), + ], + durationInterval: ['duration_interval', optional(nullable(number()))], + durationIntervalUnit: [ + 'duration_interval_unit', + optional(nullable(string())), + ], + durationIntervalSpan: [ + 'duration_interval_span', + optional(nullable(string())), + ], + allowNegativeBalance: ['allow_negative_balance', optional(boolean())], + archivedAt: ['archived_at', optional(nullable(string()))], + conversionLimit: ['conversion_limit', optional(nullable(string()))], + stackable: ['stackable', optional(boolean())], + compoundingStrategy: [ + 'compounding_strategy', + optional(nullable(compoundingStrategySchema)), + ], + useSiteExchangeRate: ['use_site_exchange_rate', optional(boolean())], + createdAt: ['created_at', optional(string())], + updatedAt: ['updated_at', optional(string())], + discountType: ['discount_type', optional(discountTypeSchema)], + excludeMidPeriodAllocations: [ + 'exclude_mid_period_allocations', + optional(boolean()), + ], + applyOnCancelAtEndOfPeriod: [ + 'apply_on_cancel_at_end_of_period', + optional(boolean()), + ], + applyOnSubscriptionExpiration: [ + 'apply_on_subscription_expiration', + optional(boolean()), + ], + couponRestrictions: [ + 'coupon_restrictions', + optional(array(couponRestrictionSchema)), + ], + currencyPrices: ['currency_prices', optional(array(couponCurrencySchema))], + }) +); diff --git a/src/models/couponCurrencyRequest.ts b/src/models/couponCurrencyRequest.ts index cb581a6..6e36024 100644 --- a/src/models/couponCurrencyRequest.ts +++ b/src/models/couponCurrencyRequest.ts @@ -15,11 +15,9 @@ export interface CouponCurrencyRequest { [key: string]: unknown; } -export const couponCurrencyRequestSchema: Schema = expandoObject( - { - currencyPrices: [ - 'currency_prices', - array(lazy(() => updateCouponCurrencySchema)), - ], - } +export const couponCurrencyRequestSchema: Schema = lazy( + () => + expandoObject({ + currencyPrices: ['currency_prices', array(updateCouponCurrencySchema)], + }) ); diff --git a/src/models/couponCurrencyResponse.ts b/src/models/couponCurrencyResponse.ts index e171157..f3c1d67 100644 --- a/src/models/couponCurrencyResponse.ts +++ b/src/models/couponCurrencyResponse.ts @@ -12,11 +12,12 @@ export interface CouponCurrencyResponse { [key: string]: unknown; } -export const couponCurrencyResponseSchema: Schema = expandoObject( - { - currencyPrices: [ - 'currency_prices', - optional(array(lazy(() => couponCurrencySchema))), - ], - } +export const couponCurrencyResponseSchema: Schema = lazy( + () => + expandoObject({ + currencyPrices: [ + 'currency_prices', + optional(array(couponCurrencySchema)), + ], + }) ); diff --git a/src/models/couponPayload.ts b/src/models/couponPayload.ts index 1c08c91..27a7c14 100644 --- a/src/models/couponPayload.ts +++ b/src/models/couponPayload.ts @@ -8,6 +8,7 @@ import { bigint, boolean, expandoObject, + lazy, optional, Schema, string, @@ -48,31 +49,33 @@ export interface CouponPayload { [key: string]: unknown; } -export const couponPayloadSchema: Schema = expandoObject({ - name: ['name', optional(string())], - code: ['code', optional(string())], - description: ['description', optional(string())], - percentage: ['percentage', optional(couponPayloadPercentageSchema)], - amountInCents: ['amount_in_cents', optional(bigint())], - allowNegativeBalance: ['allow_negative_balance', optional(boolean())], - recurring: ['recurring', optional(boolean())], - endDate: ['end_date', optional(string())], - productFamilyId: ['product_family_id', optional(string())], - stackable: ['stackable', optional(boolean())], - compoundingStrategy: [ - 'compounding_strategy', - optional(compoundingStrategySchema), - ], - excludeMidPeriodAllocations: [ - 'exclude_mid_period_allocations', - optional(boolean()), - ], - applyOnCancelAtEndOfPeriod: [ - 'apply_on_cancel_at_end_of_period', - optional(boolean()), - ], - applyOnSubscriptionExpiration: [ - 'apply_on_subscription_expiration', - optional(boolean()), - ], -}); +export const couponPayloadSchema: Schema = lazy(() => + expandoObject({ + name: ['name', optional(string())], + code: ['code', optional(string())], + description: ['description', optional(string())], + percentage: ['percentage', optional(couponPayloadPercentageSchema)], + amountInCents: ['amount_in_cents', optional(bigint())], + allowNegativeBalance: ['allow_negative_balance', optional(boolean())], + recurring: ['recurring', optional(boolean())], + endDate: ['end_date', optional(string())], + productFamilyId: ['product_family_id', optional(string())], + stackable: ['stackable', optional(boolean())], + compoundingStrategy: [ + 'compounding_strategy', + optional(compoundingStrategySchema), + ], + excludeMidPeriodAllocations: [ + 'exclude_mid_period_allocations', + optional(boolean()), + ], + applyOnCancelAtEndOfPeriod: [ + 'apply_on_cancel_at_end_of_period', + optional(boolean()), + ], + applyOnSubscriptionExpiration: [ + 'apply_on_subscription_expiration', + optional(boolean()), + ], + }) +); diff --git a/src/models/couponRequest.ts b/src/models/couponRequest.ts index 9313f4c..b9e52b6 100644 --- a/src/models/couponRequest.ts +++ b/src/models/couponRequest.ts @@ -23,8 +23,10 @@ export interface CouponRequest { [key: string]: unknown; } -export const couponRequestSchema: Schema = expandoObject({ - coupon: ['coupon', optional(lazy(() => couponPayloadSchema))], - restrictedProducts: ['restricted_products', optional(dict(boolean()))], - restrictedComponents: ['restricted_components', optional(dict(boolean()))], -}); +export const couponRequestSchema: Schema = lazy(() => + expandoObject({ + coupon: ['coupon', optional(couponPayloadSchema)], + restrictedProducts: ['restricted_products', optional(dict(boolean()))], + restrictedComponents: ['restricted_components', optional(dict(boolean()))], + }) +); diff --git a/src/models/couponResponse.ts b/src/models/couponResponse.ts index 5289d56..7f0ee72 100644 --- a/src/models/couponResponse.ts +++ b/src/models/couponResponse.ts @@ -12,6 +12,6 @@ export interface CouponResponse { [key: string]: unknown; } -export const couponResponseSchema: Schema = expandoObject({ - coupon: ['coupon', optional(lazy(() => couponSchema))], -}); +export const couponResponseSchema: Schema = lazy(() => + expandoObject({ coupon: ['coupon', optional(couponSchema)] }) +); diff --git a/src/models/createAllocation.ts b/src/models/createAllocation.ts index cf1f011..4e47a0f 100644 --- a/src/models/createAllocation.ts +++ b/src/models/createAllocation.ts @@ -51,27 +51,29 @@ export interface CreateAllocation { initiateDunning?: boolean; /** Price point that the allocation should be charged at. Accepts either the price point's id (integer) or handle (string). When not specified, the default price point will be used. */ pricePointId?: CreateAllocationPricePointId | null; - /** This attribute is particularly useful when you need to align billing events for different components on distinct schedules within a subscription. Please note this only works for site with Multifrequency enabled */ + /** This attribute is particularly useful when you need to align billing events for different components on distinct schedules within a subscription. This only works for site with Multifrequency enabled. */ billingSchedule?: BillingSchedule; [key: string]: unknown; } -export const createAllocationSchema: Schema = expandoObject({ - quantity: ['quantity', number()], - componentId: ['component_id', optional(number())], - memo: ['memo', optional(string())], - prorationDowngradeScheme: ['proration_downgrade_scheme', optional(string())], - prorationUpgradeScheme: ['proration_upgrade_scheme', optional(string())], - accrueCharge: ['accrue_charge', optional(boolean())], - downgradeCredit: ['downgrade_credit', optional(nullable(creditTypeSchema))], - upgradeCharge: ['upgrade_charge', optional(nullable(creditTypeSchema))], - initiateDunning: ['initiate_dunning', optional(boolean())], - pricePointId: [ - 'price_point_id', - optional(nullable(createAllocationPricePointIdSchema)), - ], - billingSchedule: [ - 'billing_schedule', - optional(lazy(() => billingScheduleSchema)), - ], -}); +export const createAllocationSchema: Schema = lazy(() => + expandoObject({ + quantity: ['quantity', number()], + componentId: ['component_id', optional(number())], + memo: ['memo', optional(string())], + prorationDowngradeScheme: [ + 'proration_downgrade_scheme', + optional(string()), + ], + prorationUpgradeScheme: ['proration_upgrade_scheme', optional(string())], + accrueCharge: ['accrue_charge', optional(boolean())], + downgradeCredit: ['downgrade_credit', optional(nullable(creditTypeSchema))], + upgradeCharge: ['upgrade_charge', optional(nullable(creditTypeSchema))], + initiateDunning: ['initiate_dunning', optional(boolean())], + pricePointId: [ + 'price_point_id', + optional(nullable(createAllocationPricePointIdSchema)), + ], + billingSchedule: ['billing_schedule', optional(billingScheduleSchema)], + }) +); diff --git a/src/models/createAllocationRequest.ts b/src/models/createAllocationRequest.ts index c3fa0b8..90a7cdc 100644 --- a/src/models/createAllocationRequest.ts +++ b/src/models/createAllocationRequest.ts @@ -15,6 +15,6 @@ export interface CreateAllocationRequest { [key: string]: unknown; } -export const createAllocationRequestSchema: Schema = expandoObject( - { allocation: ['allocation', lazy(() => createAllocationSchema)] } +export const createAllocationRequestSchema: Schema = lazy( + () => expandoObject({ allocation: ['allocation', createAllocationSchema] }) ); diff --git a/src/models/createComponentPricePoint.ts b/src/models/createComponentPricePoint.ts index 04f0fa2..6eb40e2 100644 --- a/src/models/createComponentPricePoint.ts +++ b/src/models/createComponentPricePoint.ts @@ -36,15 +36,16 @@ export interface CreateComponentPricePoint { [key: string]: unknown; } -export const createComponentPricePointSchema: Schema = expandoObject( - { - name: ['name', string()], - handle: ['handle', optional(string())], - pricingScheme: ['pricing_scheme', pricingSchemeSchema], - prices: ['prices', array(lazy(() => priceSchema))], - useSiteExchangeRate: ['use_site_exchange_rate', optional(boolean())], - taxIncluded: ['tax_included', optional(boolean())], - interval: ['interval', optional(number())], - intervalUnit: ['interval_unit', optional(nullable(intervalUnitSchema))], - } +export const createComponentPricePointSchema: Schema = lazy( + () => + expandoObject({ + name: ['name', string()], + handle: ['handle', optional(string())], + pricingScheme: ['pricing_scheme', pricingSchemeSchema], + prices: ['prices', array(priceSchema)], + useSiteExchangeRate: ['use_site_exchange_rate', optional(boolean())], + taxIncluded: ['tax_included', optional(boolean())], + interval: ['interval', optional(number())], + intervalUnit: ['interval_unit', optional(nullable(intervalUnitSchema))], + }) ); diff --git a/src/models/createComponentPricePointRequest.ts b/src/models/createComponentPricePointRequest.ts index f04312a..a066287 100644 --- a/src/models/createComponentPricePointRequest.ts +++ b/src/models/createComponentPricePointRequest.ts @@ -4,7 +4,7 @@ * This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ). */ -import { expandoObject, Schema } from '../schema.js'; +import { expandoObject, lazy, Schema } from '../schema.js'; import { CreateComponentPricePointRequestPricePoint, createComponentPricePointRequestPricePointSchema, @@ -15,11 +15,12 @@ export interface CreateComponentPricePointRequest { [key: string]: unknown; } -export const createComponentPricePointRequestSchema: Schema = expandoObject( - { - pricePoint: [ - 'price_point', - createComponentPricePointRequestPricePointSchema, - ], - } +export const createComponentPricePointRequestSchema: Schema = lazy( + () => + expandoObject({ + pricePoint: [ + 'price_point', + createComponentPricePointRequestPricePointSchema, + ], + }) ); diff --git a/src/models/createComponentPricePointsRequest.ts b/src/models/createComponentPricePointsRequest.ts index 1c96fbf..4b0aa55 100644 --- a/src/models/createComponentPricePointsRequest.ts +++ b/src/models/createComponentPricePointsRequest.ts @@ -4,7 +4,7 @@ * This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ). */ -import { array, expandoObject, Schema } from '../schema.js'; +import { array, expandoObject, lazy, Schema } from '../schema.js'; import { CreateComponentPricePointsRequestPricePoints, createComponentPricePointsRequestPricePointsSchema, @@ -15,11 +15,12 @@ export interface CreateComponentPricePointsRequest { [key: string]: unknown; } -export const createComponentPricePointsRequestSchema: Schema = expandoObject( - { - pricePoints: [ - 'price_points', - array(createComponentPricePointsRequestPricePointsSchema), - ], - } +export const createComponentPricePointsRequestSchema: Schema = lazy( + () => + expandoObject({ + pricePoints: [ + 'price_points', + array(createComponentPricePointsRequestPricePointsSchema), + ], + }) ); diff --git a/src/models/createCreditNoteEvent.ts b/src/models/createCreditNoteEvent.ts index 1eec25e..303501e 100644 --- a/src/models/createCreditNoteEvent.ts +++ b/src/models/createCreditNoteEvent.ts @@ -22,12 +22,13 @@ export interface CreateCreditNoteEvent { [key: string]: unknown; } -export const createCreditNoteEventSchema: Schema = expandoObject( - { - id: ['id', bigint()], - timestamp: ['timestamp', string()], - invoice: ['invoice', lazy(() => invoiceSchema)], - eventType: ['event_type', invoiceEventTypeSchema], - eventData: ['event_data', lazy(() => creditNoteSchema)], - } +export const createCreditNoteEventSchema: Schema = lazy( + () => + expandoObject({ + id: ['id', bigint()], + timestamp: ['timestamp', string()], + invoice: ['invoice', invoiceSchema], + eventType: ['event_type', invoiceEventTypeSchema], + eventData: ['event_data', creditNoteSchema], + }) ); diff --git a/src/models/createCurrencyPricesRequest.ts b/src/models/createCurrencyPricesRequest.ts index 3c74f9c..19d32c4 100644 --- a/src/models/createCurrencyPricesRequest.ts +++ b/src/models/createCurrencyPricesRequest.ts @@ -15,11 +15,9 @@ export interface CreateCurrencyPricesRequest { [key: string]: unknown; } -export const createCurrencyPricesRequestSchema: Schema = expandoObject( - { - currencyPrices: [ - 'currency_prices', - array(lazy(() => createCurrencyPriceSchema)), - ], - } +export const createCurrencyPricesRequestSchema: Schema = lazy( + () => + expandoObject({ + currencyPrices: ['currency_prices', array(createCurrencyPriceSchema)], + }) ); diff --git a/src/models/createCustomerRequest.ts b/src/models/createCustomerRequest.ts index 737f021..defb55e 100644 --- a/src/models/createCustomerRequest.ts +++ b/src/models/createCustomerRequest.ts @@ -12,6 +12,6 @@ export interface CreateCustomerRequest { [key: string]: unknown; } -export const createCustomerRequestSchema: Schema = expandoObject( - { customer: ['customer', lazy(() => createCustomerSchema)] } +export const createCustomerRequestSchema: Schema = lazy( + () => expandoObject({ customer: ['customer', createCustomerSchema] }) ); diff --git a/src/models/createDebitNoteEvent.ts b/src/models/createDebitNoteEvent.ts index 9f3d508..1bce225 100644 --- a/src/models/createDebitNoteEvent.ts +++ b/src/models/createDebitNoteEvent.ts @@ -22,12 +22,13 @@ export interface CreateDebitNoteEvent { [key: string]: unknown; } -export const createDebitNoteEventSchema: Schema = expandoObject( - { - id: ['id', bigint()], - timestamp: ['timestamp', string()], - invoice: ['invoice', lazy(() => invoiceSchema)], - eventType: ['event_type', invoiceEventTypeSchema], - eventData: ['event_data', lazy(() => debitNoteSchema)], - } +export const createDebitNoteEventSchema: Schema = lazy( + () => + expandoObject({ + id: ['id', bigint()], + timestamp: ['timestamp', string()], + invoice: ['invoice', invoiceSchema], + eventType: ['event_type', invoiceEventTypeSchema], + eventData: ['event_data', debitNoteSchema], + }) ); diff --git a/src/models/createEBBComponent.ts b/src/models/createEBBComponent.ts index 9b778b8..4d45192 100644 --- a/src/models/createEBBComponent.ts +++ b/src/models/createEBBComponent.ts @@ -12,11 +12,8 @@ export interface CreateEBBComponent { [key: string]: unknown; } -export const createEBBComponentSchema: Schema = expandoObject( - { - eventBasedComponent: [ - 'event_based_component', - lazy(() => eBBComponentSchema), - ], - } +export const createEBBComponentSchema: Schema = lazy(() => + expandoObject({ + eventBasedComponent: ['event_based_component', eBBComponentSchema], + }) ); diff --git a/src/models/createInvoice.ts b/src/models/createInvoice.ts index 0e6a030..ac7da9e 100644 --- a/src/models/createInvoice.ts +++ b/src/models/createInvoice.ts @@ -49,27 +49,17 @@ export interface CreateInvoice { [key: string]: unknown; } -export const createInvoiceSchema: Schema = expandoObject({ - lineItems: [ - 'line_items', - optional(array(lazy(() => createInvoiceItemSchema))), - ], - issueDate: ['issue_date', optional(string())], - netTerms: ['net_terms', optional(number())], - paymentInstructions: ['payment_instructions', optional(string())], - memo: ['memo', optional(string())], - sellerAddress: [ - 'seller_address', - optional(lazy(() => createInvoiceAddressSchema)), - ], - billingAddress: [ - 'billing_address', - optional(lazy(() => createInvoiceAddressSchema)), - ], - shippingAddress: [ - 'shipping_address', - optional(lazy(() => createInvoiceAddressSchema)), - ], - coupons: ['coupons', optional(array(lazy(() => createInvoiceCouponSchema)))], - status: ['status', optional(createInvoiceStatusSchema)], -}); +export const createInvoiceSchema: Schema = lazy(() => + expandoObject({ + lineItems: ['line_items', optional(array(createInvoiceItemSchema))], + issueDate: ['issue_date', optional(string())], + netTerms: ['net_terms', optional(number())], + paymentInstructions: ['payment_instructions', optional(string())], + memo: ['memo', optional(string())], + sellerAddress: ['seller_address', optional(createInvoiceAddressSchema)], + billingAddress: ['billing_address', optional(createInvoiceAddressSchema)], + shippingAddress: ['shipping_address', optional(createInvoiceAddressSchema)], + coupons: ['coupons', optional(array(createInvoiceCouponSchema))], + status: ['status', optional(createInvoiceStatusSchema)], + }) +); diff --git a/src/models/createInvoiceCoupon.ts b/src/models/createInvoiceCoupon.ts index 878a5e3..b28812f 100644 --- a/src/models/createInvoiceCoupon.ts +++ b/src/models/createInvoiceCoupon.ts @@ -4,7 +4,7 @@ * This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ). */ -import { expandoObject, optional, Schema, string } from '../schema.js'; +import { expandoObject, lazy, optional, Schema, string } from '../schema.js'; import { CompoundingStrategy, compoundingStrategySchema, @@ -24,6 +24,7 @@ import { export interface CreateInvoiceCoupon { code?: string; + subcode?: string; percentage?: CreateInvoiceCouponPercentage; amount?: CreateInvoiceCouponAmount; description?: string; @@ -33,9 +34,10 @@ export interface CreateInvoiceCoupon { [key: string]: unknown; } -export const createInvoiceCouponSchema: Schema = expandoObject( - { +export const createInvoiceCouponSchema: Schema = lazy(() => + expandoObject({ code: ['code', optional(string())], + subcode: ['subcode', optional(string())], percentage: ['percentage', optional(createInvoiceCouponPercentageSchema)], amount: ['amount', optional(createInvoiceCouponAmountSchema)], description: ['description', optional(string())], @@ -47,5 +49,5 @@ export const createInvoiceCouponSchema: Schema = expandoObj 'compounding_strategy', optional(compoundingStrategySchema), ], - } + }) ); diff --git a/src/models/createInvoiceItem.ts b/src/models/createInvoiceItem.ts index 492a4e6..b25311e 100644 --- a/src/models/createInvoiceItem.ts +++ b/src/models/createInvoiceItem.ts @@ -4,7 +4,14 @@ * This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ). */ -import { boolean, expandoObject, optional, Schema, string } from '../schema.js'; +import { + boolean, + expandoObject, + lazy, + optional, + Schema, + string, +} from '../schema.js'; import { CreateInvoiceItemComponentId, createInvoiceItemComponentIdSchema, @@ -36,11 +43,9 @@ export interface CreateInvoiceItem { quantity?: CreateInvoiceItemQuantity; /** The unit_price can contain up to 8 decimal places. i.e. 1.00 or 0.0012 or 0.00000065. If you submit a value with more than 8 decimal places, we will round it down to the 8th decimal place. */ unitPrice?: CreateInvoiceItemUnitPrice; - /** - * Set to true to automatically calculate taxes. Site must be configured to use and calculate taxes. - * If using Avalara, a tax_code parameter must also be sent. - */ + /** Set to true to automatically calculate taxes. Site must be configured to use and calculate taxes. If using AvaTax, a tax_code parameter must also be sent. */ taxable?: boolean; + /** A string representing the tax code related to the product type. This is especially important when using AvaTax to tax based on locale. This attribute has a max length of 25 characters. */ taxCode?: string; /** YYYY-MM-DD */ periodRangeStart?: string; @@ -57,8 +62,8 @@ export interface CreateInvoiceItem { [key: string]: unknown; } -export const createInvoiceItemSchema: Schema = expandoObject( - { +export const createInvoiceItemSchema: Schema = lazy(() => + expandoObject({ title: ['title', optional(string())], quantity: ['quantity', optional(createInvoiceItemQuantitySchema)], unitPrice: ['unit_price', optional(createInvoiceItemUnitPriceSchema)], @@ -77,5 +82,5 @@ export const createInvoiceItemSchema: Schema = expandoObject( optional(createInvoiceItemProductPricePointIdSchema), ], description: ['description', optional(string())], - } + }) ); diff --git a/src/models/createInvoicePayment.ts b/src/models/createInvoicePayment.ts index 533e689..4dd673d 100644 --- a/src/models/createInvoicePayment.ts +++ b/src/models/createInvoicePayment.ts @@ -4,7 +4,14 @@ * This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ). */ -import { expandoObject, number, optional, Schema, string } from '../schema.js'; +import { + expandoObject, + lazy, + number, + optional, + Schema, + string, +} from '../schema.js'; import { CreateInvoicePaymentAmount, createInvoicePaymentAmountSchema, @@ -33,13 +40,14 @@ export interface CreateInvoicePayment { [key: string]: unknown; } -export const createInvoicePaymentSchema: Schema = expandoObject( - { - amount: ['amount', optional(createInvoicePaymentAmountSchema)], - memo: ['memo', optional(string())], - method: ['method', optional(invoicePaymentMethodTypeSchema)], - details: ['details', optional(string())], - paymentProfileId: ['payment_profile_id', optional(number())], - receivedOn: ['received_on', optional(string())], - } +export const createInvoicePaymentSchema: Schema = lazy( + () => + expandoObject({ + amount: ['amount', optional(createInvoicePaymentAmountSchema)], + memo: ['memo', optional(string())], + method: ['method', optional(invoicePaymentMethodTypeSchema)], + details: ['details', optional(string())], + paymentProfileId: ['payment_profile_id', optional(number())], + receivedOn: ['received_on', optional(string())], + }) ); diff --git a/src/models/createInvoicePaymentRequest.ts b/src/models/createInvoicePaymentRequest.ts index 06937d3..26a8f8f 100644 --- a/src/models/createInvoicePaymentRequest.ts +++ b/src/models/createInvoicePaymentRequest.ts @@ -21,9 +21,10 @@ export interface CreateInvoicePaymentRequest { [key: string]: unknown; } -export const createInvoicePaymentRequestSchema: Schema = expandoObject( - { - payment: ['payment', lazy(() => createInvoicePaymentSchema)], - type: ['type', optional(invoicePaymentTypeSchema)], - } +export const createInvoicePaymentRequestSchema: Schema = lazy( + () => + expandoObject({ + payment: ['payment', createInvoicePaymentSchema], + type: ['type', optional(invoicePaymentTypeSchema)], + }) ); diff --git a/src/models/createInvoiceRequest.ts b/src/models/createInvoiceRequest.ts index 85e0d49..f2ccbb6 100644 --- a/src/models/createInvoiceRequest.ts +++ b/src/models/createInvoiceRequest.ts @@ -12,6 +12,6 @@ export interface CreateInvoiceRequest { [key: string]: unknown; } -export const createInvoiceRequestSchema: Schema = expandoObject( - { invoice: ['invoice', lazy(() => createInvoiceSchema)] } +export const createInvoiceRequestSchema: Schema = lazy( + () => expandoObject({ invoice: ['invoice', createInvoiceSchema] }) ); diff --git a/src/models/createMetadataRequest.ts b/src/models/createMetadataRequest.ts index d9563c1..ad83e80 100644 --- a/src/models/createMetadataRequest.ts +++ b/src/models/createMetadataRequest.ts @@ -12,6 +12,6 @@ export interface CreateMetadataRequest { [key: string]: unknown; } -export const createMetadataRequestSchema: Schema = expandoObject( - { metadata: ['metadata', array(lazy(() => createMetadataSchema))] } +export const createMetadataRequestSchema: Schema = lazy( + () => expandoObject({ metadata: ['metadata', array(createMetadataSchema)] }) ); diff --git a/src/models/createMetafield.ts b/src/models/createMetafield.ts index e4c284e..b3e5413 100644 --- a/src/models/createMetafield.ts +++ b/src/models/createMetafield.ts @@ -19,16 +19,18 @@ export interface CreateMetafield { name?: string; /** Warning: When updating a metafield's scope attribute, all scope attributes must be passed. Partially complete scope attributes will override the existing settings. */ scope?: MetafieldScope; - /** Indicates how data should be added to the metafield. For example, a text type is just a string, so a given metafield of this type can have any value attached. On the other hand, dropdown and radio have a set of allowed values that can be input, and appear differently on a Public Signup Page. Defaults to 'text' */ + /** Indicates the type of metafield. A text metafield allows any string value. Dropdown and radio metafields have a set of values that can be selected. Defaults to 'text'. */ inputType?: MetafieldInput; /** Only applicable when input_type is radio or dropdown. Empty strings will not be submitted. */ mEnum?: string[]; [key: string]: unknown; } -export const createMetafieldSchema: Schema = expandoObject({ - name: ['name', optional(string())], - scope: ['scope', optional(lazy(() => metafieldScopeSchema))], - inputType: ['input_type', optional(metafieldInputSchema)], - mEnum: ['enum', optional(array(string()))], -}); +export const createMetafieldSchema: Schema = lazy(() => + expandoObject({ + name: ['name', optional(string())], + scope: ['scope', optional(metafieldScopeSchema)], + inputType: ['input_type', optional(metafieldInputSchema)], + mEnum: ['enum', optional(array(string()))], + }) +); diff --git a/src/models/createMetafieldsRequest.ts b/src/models/createMetafieldsRequest.ts index 369825e..769e63b 100644 --- a/src/models/createMetafieldsRequest.ts +++ b/src/models/createMetafieldsRequest.ts @@ -4,7 +4,7 @@ * This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ). */ -import { expandoObject, Schema } from '../schema.js'; +import { expandoObject, lazy, Schema } from '../schema.js'; import { CreateMetafieldsRequestMetafields, createMetafieldsRequestMetafieldsSchema, @@ -15,6 +15,9 @@ export interface CreateMetafieldsRequest { [key: string]: unknown; } -export const createMetafieldsRequestSchema: Schema = expandoObject( - { metafields: ['metafields', createMetafieldsRequestMetafieldsSchema] } +export const createMetafieldsRequestSchema: Schema = lazy( + () => + expandoObject({ + metafields: ['metafields', createMetafieldsRequestMetafieldsSchema], + }) ); diff --git a/src/models/createMeteredComponent.ts b/src/models/createMeteredComponent.ts index 86fc050..4d849bf 100644 --- a/src/models/createMeteredComponent.ts +++ b/src/models/createMeteredComponent.ts @@ -15,8 +15,9 @@ export interface CreateMeteredComponent { [key: string]: unknown; } -export const createMeteredComponentSchema: Schema = expandoObject( - { - meteredComponent: ['metered_component', lazy(() => meteredComponentSchema)], - } +export const createMeteredComponentSchema: Schema = lazy( + () => + expandoObject({ + meteredComponent: ['metered_component', meteredComponentSchema], + }) ); diff --git a/src/models/createMultiInvoicePayment.ts b/src/models/createMultiInvoicePayment.ts index 1aca0cb..49edd22 100644 --- a/src/models/createMultiInvoicePayment.ts +++ b/src/models/createMultiInvoicePayment.ts @@ -40,16 +40,17 @@ export interface CreateMultiInvoicePayment { [key: string]: unknown; } -export const createMultiInvoicePaymentSchema: Schema = expandoObject( - { - memo: ['memo', optional(string())], - details: ['details', optional(string())], - method: ['method', optional(invoicePaymentMethodTypeSchema)], - amount: ['amount', createMultiInvoicePaymentAmountSchema], - receivedOn: ['received_on', optional(string())], - applications: [ - 'applications', - array(lazy(() => createInvoicePaymentApplicationSchema)), - ], - } +export const createMultiInvoicePaymentSchema: Schema = lazy( + () => + expandoObject({ + memo: ['memo', optional(string())], + details: ['details', optional(string())], + method: ['method', optional(invoicePaymentMethodTypeSchema)], + amount: ['amount', createMultiInvoicePaymentAmountSchema], + receivedOn: ['received_on', optional(string())], + applications: [ + 'applications', + array(createInvoicePaymentApplicationSchema), + ], + }) ); diff --git a/src/models/createMultiInvoicePaymentRequest.ts b/src/models/createMultiInvoicePaymentRequest.ts index 874e30b..4e6f908 100644 --- a/src/models/createMultiInvoicePaymentRequest.ts +++ b/src/models/createMultiInvoicePaymentRequest.ts @@ -15,6 +15,6 @@ export interface CreateMultiInvoicePaymentRequest { [key: string]: unknown; } -export const createMultiInvoicePaymentRequestSchema: Schema = expandoObject( - { payment: ['payment', lazy(() => createMultiInvoicePaymentSchema)] } +export const createMultiInvoicePaymentRequestSchema: Schema = lazy( + () => expandoObject({ payment: ['payment', createMultiInvoicePaymentSchema] }) ); diff --git a/src/models/createOffer.ts b/src/models/createOffer.ts index 5a7ab31..ae3fee5 100644 --- a/src/models/createOffer.ts +++ b/src/models/createOffer.ts @@ -29,15 +29,14 @@ export interface CreateOffer { [key: string]: unknown; } -export const createOfferSchema: Schema = expandoObject({ - name: ['name', string()], - handle: ['handle', string()], - description: ['description', optional(string())], - productId: ['product_id', number()], - productPricePointId: ['product_price_point_id', optional(number())], - components: [ - 'components', - optional(array(lazy(() => createOfferComponentSchema))), - ], - coupons: ['coupons', optional(array(string()))], -}); +export const createOfferSchema: Schema = lazy(() => + expandoObject({ + name: ['name', string()], + handle: ['handle', string()], + description: ['description', optional(string())], + productId: ['product_id', number()], + productPricePointId: ['product_price_point_id', optional(number())], + components: ['components', optional(array(createOfferComponentSchema))], + coupons: ['coupons', optional(array(string()))], + }) +); diff --git a/src/models/createOfferRequest.ts b/src/models/createOfferRequest.ts index 12b5add..4ccdd35 100644 --- a/src/models/createOfferRequest.ts +++ b/src/models/createOfferRequest.ts @@ -12,6 +12,6 @@ export interface CreateOfferRequest { [key: string]: unknown; } -export const createOfferRequestSchema: Schema = expandoObject( - { offer: ['offer', lazy(() => createOfferSchema)] } +export const createOfferRequestSchema: Schema = lazy(() => + expandoObject({ offer: ['offer', createOfferSchema] }) ); diff --git a/src/models/createOnOffComponent.ts b/src/models/createOnOffComponent.ts index a8ceeeb..0f82079 100644 --- a/src/models/createOnOffComponent.ts +++ b/src/models/createOnOffComponent.ts @@ -12,6 +12,9 @@ export interface CreateOnOffComponent { [key: string]: unknown; } -export const createOnOffComponentSchema: Schema = expandoObject( - { onOffComponent: ['on_off_component', lazy(() => onOffComponentSchema)] } +export const createOnOffComponentSchema: Schema = lazy( + () => + expandoObject({ + onOffComponent: ['on_off_component', onOffComponentSchema], + }) ); diff --git a/src/models/createOrUpdateEndpointRequest.ts b/src/models/createOrUpdateEndpointRequest.ts index 67f4b65..ac755d8 100644 --- a/src/models/createOrUpdateEndpointRequest.ts +++ b/src/models/createOrUpdateEndpointRequest.ts @@ -17,6 +17,6 @@ export interface CreateOrUpdateEndpointRequest { [key: string]: unknown; } -export const createOrUpdateEndpointRequestSchema: Schema = expandoObject( - { endpoint: ['endpoint', lazy(() => createOrUpdateEndpointSchema)] } +export const createOrUpdateEndpointRequestSchema: Schema = lazy( + () => expandoObject({ endpoint: ['endpoint', createOrUpdateEndpointSchema] }) ); diff --git a/src/models/createOrUpdateProduct.ts b/src/models/createOrUpdateProduct.ts index 3fa96ad..585a5d3 100644 --- a/src/models/createOrUpdateProduct.ts +++ b/src/models/createOrUpdateProduct.ts @@ -19,6 +19,7 @@ import { expirationIntervalUnitSchema, } from './expirationIntervalUnit.js'; import { IntervalUnit, intervalUnitSchema } from './intervalUnit.js'; +import { TrialType, trialTypeSchema } from './trialType.js'; export interface CreateOrUpdateProduct { /** The product name */ @@ -29,7 +30,7 @@ export interface CreateOrUpdateProduct { description: string; /** E.g. Internal ID or SKU Number */ accountingCode?: string; - /** Deprecated value that can be ignored unless you have legacy hosted pages. For Public Signup Page users, please read this attribute from under the signup page. */ + /** Deprecated value that can be ignored unless you have legacy hosted pages. For Public Signup Page users, read this attribute from under the signup page. */ requireCreditCard?: boolean; /** The product price, in integer cents */ priceInCents: bigint; @@ -43,13 +44,14 @@ export interface CreateOrUpdateProduct { trialInterval?: number; /** A string representing the trial interval unit for this product, either month or day */ trialIntervalUnit?: IntervalUnit | null; - trialType?: string; + /** Indicates how a trial is handled when the trail period ends and there is no credit card on file. For `no_obligation`, the subscription transitions to a Trial Ended state. Maxio will not send any emails or statements. For `payment_expected`, the subscription transitions to a Past Due state. Maxio will send normal dunning emails and statements according to your other settings. */ + trialType?: TrialType | null; /** The numerical expiration interval. i.e. an expiration_interval of ‘30’ coupled with an expiration_interval_unit of day would mean this product would expire after 30 days. */ expirationInterval?: number; /** A string representing the expiration interval unit for this product, either month, day or never */ expirationIntervalUnit?: ExpirationIntervalUnit | null; autoCreateSignupPage?: boolean; - /** A string representing the tax code related to the product type. This is especially important when using the Avalara service to tax based on locale. This attribute has a max length of 10 characters. */ + /** A string representing the tax code related to the product type. This is especially important when using AvaTax to tax based on locale. This attribute has a max length of 25 characters. */ taxCode?: string; [key: string]: unknown; } @@ -70,7 +72,7 @@ export const createOrUpdateProductSchema: Schema = expand 'trial_interval_unit', optional(nullable(intervalUnitSchema)), ], - trialType: ['trial_type', optional(string())], + trialType: ['trial_type', optional(nullable(trialTypeSchema))], expirationInterval: ['expiration_interval', optional(number())], expirationIntervalUnit: [ 'expiration_interval_unit', diff --git a/src/models/createOrUpdateProductRequest.ts b/src/models/createOrUpdateProductRequest.ts index a6670ee..d5d2859 100644 --- a/src/models/createOrUpdateProductRequest.ts +++ b/src/models/createOrUpdateProductRequest.ts @@ -15,6 +15,6 @@ export interface CreateOrUpdateProductRequest { [key: string]: unknown; } -export const createOrUpdateProductRequestSchema: Schema = expandoObject( - { product: ['product', lazy(() => createOrUpdateProductSchema)] } +export const createOrUpdateProductRequestSchema: Schema = lazy( + () => expandoObject({ product: ['product', createOrUpdateProductSchema] }) ); diff --git a/src/models/createOrUpdateSegmentPrice.ts b/src/models/createOrUpdateSegmentPrice.ts index f4b5fb8..1e7c4ac 100644 --- a/src/models/createOrUpdateSegmentPrice.ts +++ b/src/models/createOrUpdateSegmentPrice.ts @@ -4,7 +4,7 @@ * This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ). */ -import { expandoObject, number, optional, Schema } from '../schema.js'; +import { expandoObject, lazy, number, optional, Schema } from '../schema.js'; import { CreateOrUpdateSegmentPriceUnitPrice, createOrUpdateSegmentPriceUnitPriceSchema, @@ -18,10 +18,11 @@ export interface CreateOrUpdateSegmentPrice { [key: string]: unknown; } -export const createOrUpdateSegmentPriceSchema: Schema = expandoObject( - { - startingQuantity: ['starting_quantity', optional(number())], - endingQuantity: ['ending_quantity', optional(number())], - unitPrice: ['unit_price', createOrUpdateSegmentPriceUnitPriceSchema], - } +export const createOrUpdateSegmentPriceSchema: Schema = lazy( + () => + expandoObject({ + startingQuantity: ['starting_quantity', optional(number())], + endingQuantity: ['ending_quantity', optional(number())], + unitPrice: ['unit_price', createOrUpdateSegmentPriceUnitPriceSchema], + }) ); diff --git a/src/models/createPaymentProfile.ts b/src/models/createPaymentProfile.ts index bea27d5..0449c85 100644 --- a/src/models/createPaymentProfile.ts +++ b/src/models/createPaymentProfile.ts @@ -6,6 +6,7 @@ import { expandoObject, + lazy, nullable, number, optional, @@ -30,7 +31,7 @@ import { import { PaymentType, paymentTypeSchema } from './paymentType.js'; export interface CreatePaymentProfile { - /** Token received after sending billing informations using chargify.js. */ + /** Token received after sending billing information using chargify.js. */ chargifyToken?: string; id?: number; paymentType?: PaymentType; @@ -55,7 +56,7 @@ export interface CreatePaymentProfile { billingCity?: string; /** The credit card or bank account billing address state (i.e. MA). This value is merely passed through to the payment gateway. This must conform to the [ISO_3166-1](https://en.wikipedia.org/wiki/ISO_3166-1#Current_codes) in order to be valid for tax locale purposes. */ billingState?: string; - /** The credit card or bank account billing address country, required in [ISO_3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) format (i.e. “US”). This value is merely passed through to the payment gateway. Some gateways require country codes in a specific format. Please check your gateway’s documentation. If creating an ACH subscription, only US is supported at this time. */ + /** The credit card or bank account billing address country, required in [ISO_3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) format (i.e. “US”). This value is merely passed through to the payment gateway. Some gateways require country codes in a specific format. Check your gateway’s documentation. If creating an ACH subscription, only US is supported at this time. */ billingCountry?: string; /** The credit card or bank account billing address zip code (i.e. 12345). This value is merely passed through to the payment gateway. */ billingZip?: string; @@ -94,48 +95,49 @@ export interface CreatePaymentProfile { [key: string]: unknown; } -export const createPaymentProfileSchema: Schema = expandoObject( - { - chargifyToken: ['chargify_token', optional(string())], - id: ['id', optional(number())], - paymentType: ['payment_type', optional(paymentTypeSchema)], - firstName: ['first_name', optional(string())], - lastName: ['last_name', optional(string())], - maskedCardNumber: ['masked_card_number', optional(string())], - fullNumber: ['full_number', optional(string())], - cardType: ['card_type', optional(cardTypeSchema)], - expirationMonth: [ - 'expiration_month', - optional(createPaymentProfileExpirationMonthSchema), - ], - expirationYear: [ - 'expiration_year', - optional(createPaymentProfileExpirationYearSchema), - ], - billingAddress: ['billing_address', optional(string())], - billingAddress2: ['billing_address_2', optional(nullable(string()))], - billingCity: ['billing_city', optional(string())], - billingState: ['billing_state', optional(string())], - billingCountry: ['billing_country', optional(string())], - billingZip: ['billing_zip', optional(string())], - currentVault: ['current_vault', optional(allVaultsSchema)], - vaultToken: ['vault_token', optional(string())], - customerVaultToken: ['customer_vault_token', optional(string())], - customerId: ['customer_id', optional(number())], - paypalEmail: ['paypal_email', optional(string())], - paymentMethodNonce: ['payment_method_nonce', optional(string())], - gatewayHandle: ['gateway_handle', optional(string())], - cvv: ['cvv', optional(string())], - bankName: ['bank_name', optional(string())], - bankIban: ['bank_iban', optional(string())], - bankRoutingNumber: ['bank_routing_number', optional(string())], - bankAccountNumber: ['bank_account_number', optional(string())], - bankBranchCode: ['bank_branch_code', optional(string())], - bankAccountType: ['bank_account_type', optional(bankAccountTypeSchema)], - bankAccountHolderType: [ - 'bank_account_holder_type', - optional(bankAccountHolderTypeSchema), - ], - lastFour: ['last_four', optional(string())], - } +export const createPaymentProfileSchema: Schema = lazy( + () => + expandoObject({ + chargifyToken: ['chargify_token', optional(string())], + id: ['id', optional(number())], + paymentType: ['payment_type', optional(paymentTypeSchema)], + firstName: ['first_name', optional(string())], + lastName: ['last_name', optional(string())], + maskedCardNumber: ['masked_card_number', optional(string())], + fullNumber: ['full_number', optional(string())], + cardType: ['card_type', optional(cardTypeSchema)], + expirationMonth: [ + 'expiration_month', + optional(createPaymentProfileExpirationMonthSchema), + ], + expirationYear: [ + 'expiration_year', + optional(createPaymentProfileExpirationYearSchema), + ], + billingAddress: ['billing_address', optional(string())], + billingAddress2: ['billing_address_2', optional(nullable(string()))], + billingCity: ['billing_city', optional(string())], + billingState: ['billing_state', optional(string())], + billingCountry: ['billing_country', optional(string())], + billingZip: ['billing_zip', optional(string())], + currentVault: ['current_vault', optional(allVaultsSchema)], + vaultToken: ['vault_token', optional(string())], + customerVaultToken: ['customer_vault_token', optional(string())], + customerId: ['customer_id', optional(number())], + paypalEmail: ['paypal_email', optional(string())], + paymentMethodNonce: ['payment_method_nonce', optional(string())], + gatewayHandle: ['gateway_handle', optional(string())], + cvv: ['cvv', optional(string())], + bankName: ['bank_name', optional(string())], + bankIban: ['bank_iban', optional(string())], + bankRoutingNumber: ['bank_routing_number', optional(string())], + bankAccountNumber: ['bank_account_number', optional(string())], + bankBranchCode: ['bank_branch_code', optional(string())], + bankAccountType: ['bank_account_type', optional(bankAccountTypeSchema)], + bankAccountHolderType: [ + 'bank_account_holder_type', + optional(bankAccountHolderTypeSchema), + ], + lastFour: ['last_four', optional(string())], + }) ); diff --git a/src/models/createPaymentProfileRequest.ts b/src/models/createPaymentProfileRequest.ts index 72de9dd..b30e749 100644 --- a/src/models/createPaymentProfileRequest.ts +++ b/src/models/createPaymentProfileRequest.ts @@ -15,8 +15,9 @@ export interface CreatePaymentProfileRequest { [key: string]: unknown; } -export const createPaymentProfileRequestSchema: Schema = expandoObject( - { - paymentProfile: ['payment_profile', lazy(() => createPaymentProfileSchema)], - } +export const createPaymentProfileRequestSchema: Schema = lazy( + () => + expandoObject({ + paymentProfile: ['payment_profile', createPaymentProfileSchema], + }) ); diff --git a/src/models/createPrepaidComponent.ts b/src/models/createPrepaidComponent.ts index d2d85c4..2479c8f 100644 --- a/src/models/createPrepaidComponent.ts +++ b/src/models/createPrepaidComponent.ts @@ -15,11 +15,12 @@ export interface CreatePrepaidComponent { [key: string]: unknown; } -export const createPrepaidComponentSchema: Schema = expandoObject( - { - prepaidUsageComponent: [ - 'prepaid_usage_component', - lazy(() => prepaidUsageComponentSchema), - ], - } +export const createPrepaidComponentSchema: Schema = lazy( + () => + expandoObject({ + prepaidUsageComponent: [ + 'prepaid_usage_component', + prepaidUsageComponentSchema, + ], + }) ); diff --git a/src/models/createPrepaidUsageComponentPricePoint.ts b/src/models/createPrepaidUsageComponentPricePoint.ts index 9026016..3d58030 100644 --- a/src/models/createPrepaidUsageComponentPricePoint.ts +++ b/src/models/createPrepaidUsageComponentPricePoint.ts @@ -43,23 +43,24 @@ export interface CreatePrepaidUsageComponentPricePoint { [key: string]: unknown; } -export const createPrepaidUsageComponentPricePointSchema: Schema = expandoObject( - { - name: ['name', string()], - handle: ['handle', optional(string())], - pricingScheme: ['pricing_scheme', pricingSchemeSchema], - prices: ['prices', array(lazy(() => priceSchema))], - overagePricing: ['overage_pricing', lazy(() => overagePricingSchema)], - useSiteExchangeRate: ['use_site_exchange_rate', optional(boolean())], - rolloverPrepaidRemainder: [ - 'rollover_prepaid_remainder', - optional(boolean()), - ], - renewPrepaidAllocation: ['renew_prepaid_allocation', optional(boolean())], - expirationInterval: ['expiration_interval', optional(number())], - expirationIntervalUnit: [ - 'expiration_interval_unit', - optional(nullable(expirationIntervalUnitSchema)), - ], - } +export const createPrepaidUsageComponentPricePointSchema: Schema = lazy( + () => + expandoObject({ + name: ['name', string()], + handle: ['handle', optional(string())], + pricingScheme: ['pricing_scheme', pricingSchemeSchema], + prices: ['prices', array(priceSchema)], + overagePricing: ['overage_pricing', overagePricingSchema], + useSiteExchangeRate: ['use_site_exchange_rate', optional(boolean())], + rolloverPrepaidRemainder: [ + 'rollover_prepaid_remainder', + optional(boolean()), + ], + renewPrepaidAllocation: ['renew_prepaid_allocation', optional(boolean())], + expirationInterval: ['expiration_interval', optional(number())], + expirationIntervalUnit: [ + 'expiration_interval_unit', + optional(nullable(expirationIntervalUnitSchema)), + ], + }) ); diff --git a/src/models/createPrepaymentRequest.ts b/src/models/createPrepaymentRequest.ts index 8247d75..2443ade 100644 --- a/src/models/createPrepaymentRequest.ts +++ b/src/models/createPrepaymentRequest.ts @@ -15,6 +15,6 @@ export interface CreatePrepaymentRequest { [key: string]: unknown; } -export const createPrepaymentRequestSchema: Schema = expandoObject( - { prepayment: ['prepayment', lazy(() => createPrepaymentSchema)] } +export const createPrepaymentRequestSchema: Schema = lazy( + () => expandoObject({ prepayment: ['prepayment', createPrepaymentSchema] }) ); diff --git a/src/models/createPrepaymentResponse.ts b/src/models/createPrepaymentResponse.ts index 297a93f..d6fccd7 100644 --- a/src/models/createPrepaymentResponse.ts +++ b/src/models/createPrepaymentResponse.ts @@ -15,6 +15,6 @@ export interface CreatePrepaymentResponse { [key: string]: unknown; } -export const createPrepaymentResponseSchema: Schema = expandoObject( - { prepayment: ['prepayment', lazy(() => createdPrepaymentSchema)] } +export const createPrepaymentResponseSchema: Schema = lazy( + () => expandoObject({ prepayment: ['prepayment', createdPrepaymentSchema] }) ); diff --git a/src/models/createProductCurrencyPricesRequest.ts b/src/models/createProductCurrencyPricesRequest.ts index 28e2266..a2c6661 100644 --- a/src/models/createProductCurrencyPricesRequest.ts +++ b/src/models/createProductCurrencyPricesRequest.ts @@ -15,11 +15,12 @@ export interface CreateProductCurrencyPricesRequest { [key: string]: unknown; } -export const createProductCurrencyPricesRequestSchema: Schema = expandoObject( - { - currencyPrices: [ - 'currency_prices', - array(lazy(() => createProductCurrencyPriceSchema)), - ], - } +export const createProductCurrencyPricesRequestSchema: Schema = lazy( + () => + expandoObject({ + currencyPrices: [ + 'currency_prices', + array(createProductCurrencyPriceSchema), + ], + }) ); diff --git a/src/models/createProductFamilyRequest.ts b/src/models/createProductFamilyRequest.ts index d6fad23..4fe92f4 100644 --- a/src/models/createProductFamilyRequest.ts +++ b/src/models/createProductFamilyRequest.ts @@ -15,6 +15,9 @@ export interface CreateProductFamilyRequest { [key: string]: unknown; } -export const createProductFamilyRequestSchema: Schema = expandoObject( - { productFamily: ['product_family', lazy(() => createProductFamilySchema)] } +export const createProductFamilyRequestSchema: Schema = lazy( + () => + expandoObject({ + productFamily: ['product_family', createProductFamilySchema], + }) ); diff --git a/src/models/createProductPricePoint.ts b/src/models/createProductPricePoint.ts index 2f73443..40ae0e6 100644 --- a/src/models/createProductPricePoint.ts +++ b/src/models/createProductPricePoint.ts @@ -19,6 +19,7 @@ import { expirationIntervalUnitSchema, } from './expirationIntervalUnit.js'; import { IntervalUnit, intervalUnitSchema } from './intervalUnit.js'; +import { TrialType, trialTypeSchema } from './trialType.js'; export interface CreateProductPricePoint { /** The product price point name */ @@ -37,7 +38,8 @@ export interface CreateProductPricePoint { trialInterval?: number; /** A string representing the trial interval unit for this product price point, either month or day */ trialIntervalUnit?: IntervalUnit; - trialType?: string; + /** Indicates how a trial is handled when the trail period ends and there is no credit card on file. For `no_obligation`, the subscription transitions to a Trial Ended state. Maxio will not send any emails or statements. For `payment_expected`, the subscription transitions to a Past Due state. Maxio will send normal dunning emails and statements according to your other settings. */ + trialType?: TrialType | null; /** The product price point initial charge, in integer cents */ initialChargeInCents?: bigint; initialChargeAfterTrial?: boolean; @@ -60,7 +62,7 @@ export const createProductPricePointSchema: Schema = ex trialPriceInCents: ['trial_price_in_cents', optional(bigint())], trialInterval: ['trial_interval', optional(number())], trialIntervalUnit: ['trial_interval_unit', optional(intervalUnitSchema)], - trialType: ['trial_type', optional(string())], + trialType: ['trial_type', optional(nullable(trialTypeSchema))], initialChargeInCents: ['initial_charge_in_cents', optional(bigint())], initialChargeAfterTrial: [ 'initial_charge_after_trial', diff --git a/src/models/createProductPricePointRequest.ts b/src/models/createProductPricePointRequest.ts index d893bc8..7176211 100644 --- a/src/models/createProductPricePointRequest.ts +++ b/src/models/createProductPricePointRequest.ts @@ -15,6 +15,9 @@ export interface CreateProductPricePointRequest { [key: string]: unknown; } -export const createProductPricePointRequestSchema: Schema = expandoObject( - { pricePoint: ['price_point', lazy(() => createProductPricePointSchema)] } +export const createProductPricePointRequestSchema: Schema = lazy( + () => + expandoObject({ + pricePoint: ['price_point', createProductPricePointSchema], + }) ); diff --git a/src/models/createQuantityBasedComponent.ts b/src/models/createQuantityBasedComponent.ts index 4b051e0..cee56f2 100644 --- a/src/models/createQuantityBasedComponent.ts +++ b/src/models/createQuantityBasedComponent.ts @@ -15,11 +15,12 @@ export interface CreateQuantityBasedComponent { [key: string]: unknown; } -export const createQuantityBasedComponentSchema: Schema = expandoObject( - { - quantityBasedComponent: [ - 'quantity_based_component', - lazy(() => quantityBasedComponentSchema), - ], - } +export const createQuantityBasedComponentSchema: Schema = lazy( + () => + expandoObject({ + quantityBasedComponent: [ + 'quantity_based_component', + quantityBasedComponentSchema, + ], + }) ); diff --git a/src/models/createReasonCodeRequest.ts b/src/models/createReasonCodeRequest.ts index b3ed7db..cede7be 100644 --- a/src/models/createReasonCodeRequest.ts +++ b/src/models/createReasonCodeRequest.ts @@ -15,6 +15,6 @@ export interface CreateReasonCodeRequest { [key: string]: unknown; } -export const createReasonCodeRequestSchema: Schema = expandoObject( - { reasonCode: ['reason_code', lazy(() => createReasonCodeSchema)] } +export const createReasonCodeRequestSchema: Schema = lazy( + () => expandoObject({ reasonCode: ['reason_code', createReasonCodeSchema] }) ); diff --git a/src/models/createSegment.ts b/src/models/createSegment.ts index ec437d8..48dd69e 100644 --- a/src/models/createSegment.ts +++ b/src/models/createSegment.ts @@ -42,26 +42,25 @@ export interface CreateSegment { [key: string]: unknown; } -export const createSegmentSchema: Schema = expandoObject({ - segmentProperty1Value: [ - 'segment_property_1_value', - optional(createSegmentSegmentProperty1ValueSchema), - ], - segmentProperty2Value: [ - 'segment_property_2_value', - optional(createSegmentSegmentProperty2ValueSchema), - ], - segmentProperty3Value: [ - 'segment_property_3_value', - optional(createSegmentSegmentProperty3ValueSchema), - ], - segmentProperty4Value: [ - 'segment_property_4_value', - optional(createSegmentSegmentProperty4ValueSchema), - ], - pricingScheme: ['pricing_scheme', pricingSchemeSchema], - prices: [ - 'prices', - optional(array(lazy(() => createOrUpdateSegmentPriceSchema))), - ], -}); +export const createSegmentSchema: Schema = lazy(() => + expandoObject({ + segmentProperty1Value: [ + 'segment_property_1_value', + optional(createSegmentSegmentProperty1ValueSchema), + ], + segmentProperty2Value: [ + 'segment_property_2_value', + optional(createSegmentSegmentProperty2ValueSchema), + ], + segmentProperty3Value: [ + 'segment_property_3_value', + optional(createSegmentSegmentProperty3ValueSchema), + ], + segmentProperty4Value: [ + 'segment_property_4_value', + optional(createSegmentSegmentProperty4ValueSchema), + ], + pricingScheme: ['pricing_scheme', pricingSchemeSchema], + prices: ['prices', optional(array(createOrUpdateSegmentPriceSchema))], + }) +); diff --git a/src/models/createSegmentRequest.ts b/src/models/createSegmentRequest.ts index 9ecb2c5..4bacdcd 100644 --- a/src/models/createSegmentRequest.ts +++ b/src/models/createSegmentRequest.ts @@ -12,6 +12,6 @@ export interface CreateSegmentRequest { [key: string]: unknown; } -export const createSegmentRequestSchema: Schema = expandoObject( - { segment: ['segment', lazy(() => createSegmentSchema)] } +export const createSegmentRequestSchema: Schema = lazy( + () => expandoObject({ segment: ['segment', createSegmentSchema] }) ); diff --git a/src/models/createSubscription.ts b/src/models/createSubscription.ts index 15bb4ce..7b54ff4 100644 --- a/src/models/createSubscription.ts +++ b/src/models/createSubscription.ts @@ -153,16 +153,13 @@ export interface CreateSubscription { [key: string]: unknown; } -export const createSubscriptionSchema: Schema = expandoObject( - { +export const createSubscriptionSchema: Schema = lazy(() => + expandoObject({ productHandle: ['product_handle', optional(string())], productId: ['product_id', optional(number())], productPricePointHandle: ['product_price_point_handle', optional(string())], productPricePointId: ['product_price_point_id', optional(number())], - customPrice: [ - 'custom_price', - optional(lazy(() => subscriptionCustomPriceSchema)), - ], + customPrice: ['custom_price', optional(subscriptionCustomPriceSchema)], couponCode: ['coupon_code', optional(string())], couponCodes: ['coupon_codes', optional(array(string()))], paymentCollectionMethod: [ @@ -184,31 +181,28 @@ export const createSubscriptionSchema: Schema = expandoObjec reference: ['reference', optional(string())], customerAttributes: [ 'customer_attributes', - optional(lazy(() => customerAttributesSchema)), + optional(customerAttributesSchema), ], paymentProfileAttributes: [ 'payment_profile_attributes', - optional(lazy(() => paymentProfileAttributesSchema)), + optional(paymentProfileAttributesSchema), ], creditCardAttributes: [ 'credit_card_attributes', - optional(lazy(() => paymentProfileAttributesSchema)), + optional(paymentProfileAttributesSchema), ], bankAccountAttributes: [ 'bank_account_attributes', - optional(lazy(() => bankAccountAttributesSchema)), + optional(bankAccountAttributesSchema), ], components: [ 'components', - optional(array(lazy(() => createSubscriptionComponentSchema))), - ], - calendarBilling: [ - 'calendar_billing', - optional(lazy(() => calendarBillingSchema)), + optional(array(createSubscriptionComponentSchema)), ], + calendarBilling: ['calendar_billing', optional(calendarBillingSchema)], metafields: ['metafields', optional(dict(string()))], customerReference: ['customer_reference', optional(string())], - group: ['group', optional(lazy(() => groupSettingsSchema))], + group: ['group', optional(groupSettingsSchema)], ref: ['ref', optional(string())], cancellationMessage: ['cancellation_message', optional(string())], cancellationMethod: ['cancellation_method', optional(string())], @@ -230,7 +224,7 @@ export const createSubscriptionSchema: Schema = expandoObjec offerId: ['offer_id', optional(createSubscriptionOfferIdSchema)], prepaidConfiguration: [ 'prepaid_configuration', - optional(lazy(() => upsertPrepaidConfigurationSchema)), + optional(upsertPrepaidConfigurationSchema), ], previousBillingAt: ['previous_billing_at', optional(string())], importMrr: ['import_mrr', optional(boolean())], @@ -238,9 +232,9 @@ export const createSubscriptionSchema: Schema = expandoObjec activatedAt: ['activated_at', optional(string())], agreementAcceptance: [ 'agreement_acceptance', - optional(lazy(() => agreementAcceptanceSchema)), + optional(agreementAcceptanceSchema), ], - achAgreement: ['ach_agreement', optional(lazy(() => aCHAgreementSchema))], + achAgreement: ['ach_agreement', optional(aCHAgreementSchema)], dunningCommunicationDelayEnabled: [ 'dunning_communication_delay_enabled', optional(boolean()), @@ -253,5 +247,5 @@ export const createSubscriptionSchema: Schema = expandoObjec 'skip_billing_manifest_taxes', optional(boolean()), ], - } + }) ); diff --git a/src/models/createSubscriptionComponent.ts b/src/models/createSubscriptionComponent.ts index eaa514e..424ac93 100644 --- a/src/models/createSubscriptionComponent.ts +++ b/src/models/createSubscriptionComponent.ts @@ -45,26 +45,24 @@ export interface CreateSubscriptionComponent { [key: string]: unknown; } -export const createSubscriptionComponentSchema: Schema = expandoObject( - { - componentId: [ - 'component_id', - optional(createSubscriptionComponentComponentIdSchema), - ], - enabled: ['enabled', optional(boolean())], - unitBalance: ['unit_balance', optional(number())], - allocatedQuantity: [ - 'allocated_quantity', - optional(createSubscriptionComponentAllocatedQuantitySchema), - ], - quantity: ['quantity', optional(number())], - pricePointId: [ - 'price_point_id', - optional(createSubscriptionComponentPricePointIdSchema), - ], - customPrice: [ - 'custom_price', - optional(lazy(() => componentCustomPriceSchema)), - ], - } +export const createSubscriptionComponentSchema: Schema = lazy( + () => + expandoObject({ + componentId: [ + 'component_id', + optional(createSubscriptionComponentComponentIdSchema), + ], + enabled: ['enabled', optional(boolean())], + unitBalance: ['unit_balance', optional(number())], + allocatedQuantity: [ + 'allocated_quantity', + optional(createSubscriptionComponentAllocatedQuantitySchema), + ], + quantity: ['quantity', optional(number())], + pricePointId: [ + 'price_point_id', + optional(createSubscriptionComponentPricePointIdSchema), + ], + customPrice: ['custom_price', optional(componentCustomPriceSchema)], + }) ); diff --git a/src/models/createSubscriptionGroupRequest.ts b/src/models/createSubscriptionGroupRequest.ts index 52fe303..bf3c2b8 100644 --- a/src/models/createSubscriptionGroupRequest.ts +++ b/src/models/createSubscriptionGroupRequest.ts @@ -15,11 +15,9 @@ export interface CreateSubscriptionGroupRequest { [key: string]: unknown; } -export const createSubscriptionGroupRequestSchema: Schema = expandoObject( - { - subscriptionGroup: [ - 'subscription_group', - lazy(() => createSubscriptionGroupSchema), - ], - } +export const createSubscriptionGroupRequestSchema: Schema = lazy( + () => + expandoObject({ + subscriptionGroup: ['subscription_group', createSubscriptionGroupSchema], + }) ); diff --git a/src/models/createSubscriptionRequest.ts b/src/models/createSubscriptionRequest.ts index 33dd693..8f5788b 100644 --- a/src/models/createSubscriptionRequest.ts +++ b/src/models/createSubscriptionRequest.ts @@ -15,6 +15,7 @@ export interface CreateSubscriptionRequest { [key: string]: unknown; } -export const createSubscriptionRequestSchema: Schema = expandoObject( - { subscription: ['subscription', lazy(() => createSubscriptionSchema)] } +export const createSubscriptionRequestSchema: Schema = lazy( + () => + expandoObject({ subscription: ['subscription', createSubscriptionSchema] }) ); diff --git a/src/models/createUsage.ts b/src/models/createUsage.ts index 451fb3f..c8ece67 100644 --- a/src/models/createUsage.ts +++ b/src/models/createUsage.ts @@ -13,23 +13,29 @@ import { string, } from '../schema.js'; import { BillingSchedule, billingScheduleSchema } from './billingSchedule.js'; +import { + ComponentCustomPrice, + componentCustomPriceSchema, +} from './componentCustomPrice.js'; export interface CreateUsage { /** integer by default or decimal number if fractional quantities are enabled for the component */ quantity?: number; pricePointId?: string; memo?: string; - /** This attribute is particularly useful when you need to align billing events for different components on distinct schedules within a subscription. Please note this only works for site with Multifrequency enabled */ + /** This attribute is particularly useful when you need to align billing events for different components on distinct schedules within a subscription. This only works for site with Multifrequency enabled. */ billingSchedule?: BillingSchedule; + /** Create or update custom pricing unique to the subscription. Used in place of `price_point_id`. */ + customPrice?: ComponentCustomPrice; [key: string]: unknown; } -export const createUsageSchema: Schema = expandoObject({ - quantity: ['quantity', optional(number())], - pricePointId: ['price_point_id', optional(string())], - memo: ['memo', optional(string())], - billingSchedule: [ - 'billing_schedule', - optional(lazy(() => billingScheduleSchema)), - ], -}); +export const createUsageSchema: Schema = lazy(() => + expandoObject({ + quantity: ['quantity', optional(number())], + pricePointId: ['price_point_id', optional(string())], + memo: ['memo', optional(string())], + billingSchedule: ['billing_schedule', optional(billingScheduleSchema)], + customPrice: ['custom_price', optional(componentCustomPriceSchema)], + }) +); diff --git a/src/models/createUsageRequest.ts b/src/models/createUsageRequest.ts index 39785b5..0e87ca4 100644 --- a/src/models/createUsageRequest.ts +++ b/src/models/createUsageRequest.ts @@ -12,6 +12,6 @@ export interface CreateUsageRequest { [key: string]: unknown; } -export const createUsageRequestSchema: Schema = expandoObject( - { usage: ['usage', lazy(() => createUsageSchema)] } +export const createUsageRequestSchema: Schema = lazy(() => + expandoObject({ usage: ['usage', createUsageSchema] }) ); diff --git a/src/models/creditNote.ts b/src/models/creditNote.ts index f3a04ff..a86c716 100644 --- a/src/models/creditNote.ts +++ b/src/models/creditNote.ts @@ -97,47 +97,37 @@ export interface CreditNote { [key: string]: unknown; } -export const creditNoteSchema: Schema = expandoObject({ - uid: ['uid', optional(string())], - siteId: ['site_id', optional(number())], - customerId: ['customer_id', optional(number())], - subscriptionId: ['subscription_id', optional(number())], - number: ['number', optional(string())], - sequenceNumber: ['sequence_number', optional(number())], - issueDate: ['issue_date', optional(string())], - appliedDate: ['applied_date', optional(string())], - status: ['status', optional(creditNoteStatusSchema)], - currency: ['currency', optional(string())], - memo: ['memo', optional(string())], - seller: ['seller', optional(lazy(() => invoiceSellerSchema))], - customer: ['customer', optional(lazy(() => invoiceCustomerSchema))], - billingAddress: [ - 'billing_address', - optional(lazy(() => invoiceAddressSchema)), - ], - shippingAddress: [ - 'shipping_address', - optional(lazy(() => invoiceAddressSchema)), - ], - subtotalAmount: ['subtotal_amount', optional(string())], - discountAmount: ['discount_amount', optional(string())], - taxAmount: ['tax_amount', optional(string())], - totalAmount: ['total_amount', optional(string())], - appliedAmount: ['applied_amount', optional(string())], - remainingAmount: ['remaining_amount', optional(string())], - lineItems: [ - 'line_items', - optional(array(lazy(() => creditNoteLineItemSchema))), - ], - discounts: ['discounts', optional(array(lazy(() => invoiceDiscountSchema)))], - taxes: ['taxes', optional(array(lazy(() => invoiceTaxSchema)))], - applications: [ - 'applications', - optional(array(lazy(() => creditNoteApplicationSchema))), - ], - refunds: ['refunds', optional(array(lazy(() => invoiceRefundSchema)))], - originInvoices: [ - 'origin_invoices', - optional(array(lazy(() => originInvoiceSchema))), - ], -}); +export const creditNoteSchema: Schema = lazy(() => + expandoObject({ + uid: ['uid', optional(string())], + siteId: ['site_id', optional(number())], + customerId: ['customer_id', optional(number())], + subscriptionId: ['subscription_id', optional(number())], + number: ['number', optional(string())], + sequenceNumber: ['sequence_number', optional(number())], + issueDate: ['issue_date', optional(string())], + appliedDate: ['applied_date', optional(string())], + status: ['status', optional(creditNoteStatusSchema)], + currency: ['currency', optional(string())], + memo: ['memo', optional(string())], + seller: ['seller', optional(invoiceSellerSchema)], + customer: ['customer', optional(invoiceCustomerSchema)], + billingAddress: ['billing_address', optional(invoiceAddressSchema)], + shippingAddress: ['shipping_address', optional(invoiceAddressSchema)], + subtotalAmount: ['subtotal_amount', optional(string())], + discountAmount: ['discount_amount', optional(string())], + taxAmount: ['tax_amount', optional(string())], + totalAmount: ['total_amount', optional(string())], + appliedAmount: ['applied_amount', optional(string())], + remainingAmount: ['remaining_amount', optional(string())], + lineItems: ['line_items', optional(array(creditNoteLineItemSchema))], + discounts: ['discounts', optional(array(invoiceDiscountSchema))], + taxes: ['taxes', optional(array(invoiceTaxSchema))], + applications: [ + 'applications', + optional(array(creditNoteApplicationSchema)), + ], + refunds: ['refunds', optional(array(invoiceRefundSchema))], + originInvoices: ['origin_invoices', optional(array(originInvoiceSchema))], + }) +); diff --git a/src/models/currencyPricesResponse.ts b/src/models/currencyPricesResponse.ts index 265f60a..48de6dd 100644 --- a/src/models/currencyPricesResponse.ts +++ b/src/models/currencyPricesResponse.ts @@ -12,8 +12,9 @@ export interface CurrencyPricesResponse { [key: string]: unknown; } -export const currencyPricesResponseSchema: Schema = expandoObject( - { - currencyPrices: ['currency_prices', array(lazy(() => currencyPriceSchema))], - } +export const currencyPricesResponseSchema: Schema = lazy( + () => + expandoObject({ + currencyPrices: ['currency_prices', array(currencyPriceSchema)], + }) ); diff --git a/src/models/customerChange.ts b/src/models/customerChange.ts index b1a336a..7c91660 100644 --- a/src/models/customerChange.ts +++ b/src/models/customerChange.ts @@ -23,18 +23,20 @@ export interface CustomerChange { [key: string]: unknown; } -export const customerChangeSchema: Schema = expandoObject({ - payer: ['payer', optional(nullable(lazy(() => customerPayerChangeSchema)))], - shippingAddress: [ - 'shipping_address', - optional(nullable(lazy(() => addressChangeSchema))), - ], - billingAddress: [ - 'billing_address', - optional(nullable(lazy(() => addressChangeSchema))), - ], - customFields: [ - 'custom_fields', - optional(nullable(lazy(() => customerCustomFieldsChangeSchema))), - ], -}); +export const customerChangeSchema: Schema = lazy(() => + expandoObject({ + payer: ['payer', optional(nullable(customerPayerChangeSchema))], + shippingAddress: [ + 'shipping_address', + optional(nullable(addressChangeSchema)), + ], + billingAddress: [ + 'billing_address', + optional(nullable(addressChangeSchema)), + ], + customFields: [ + 'custom_fields', + optional(nullable(customerCustomFieldsChangeSchema)), + ], + }) +); diff --git a/src/models/customerChangesPreviewResponse.ts b/src/models/customerChangesPreviewResponse.ts index cc324d1..f84d79a 100644 --- a/src/models/customerChangesPreviewResponse.ts +++ b/src/models/customerChangesPreviewResponse.ts @@ -12,6 +12,6 @@ export interface CustomerChangesPreviewResponse { [key: string]: unknown; } -export const customerChangesPreviewResponseSchema: Schema = expandoObject( - { changes: ['changes', lazy(() => customerChangeSchema)] } +export const customerChangesPreviewResponseSchema: Schema = lazy( + () => expandoObject({ changes: ['changes', customerChangeSchema] }) ); diff --git a/src/models/customerCustomFieldsChange.ts b/src/models/customerCustomFieldsChange.ts index 3c572f4..b848868 100644 --- a/src/models/customerCustomFieldsChange.ts +++ b/src/models/customerCustomFieldsChange.ts @@ -16,9 +16,10 @@ export interface CustomerCustomFieldsChange { [key: string]: unknown; } -export const customerCustomFieldsChangeSchema: Schema = expandoObject( - { - before: ['before', array(lazy(() => invoiceCustomFieldSchema))], - after: ['after', array(lazy(() => invoiceCustomFieldSchema))], - } +export const customerCustomFieldsChangeSchema: Schema = lazy( + () => + expandoObject({ + before: ['before', array(invoiceCustomFieldSchema)], + after: ['after', array(invoiceCustomFieldSchema)], + }) ); diff --git a/src/models/customerPayerChange.ts b/src/models/customerPayerChange.ts index b85feda..e6ded39 100644 --- a/src/models/customerPayerChange.ts +++ b/src/models/customerPayerChange.ts @@ -16,9 +16,9 @@ export interface CustomerPayerChange { [key: string]: unknown; } -export const customerPayerChangeSchema: Schema = expandoObject( - { - before: ['before', lazy(() => invoicePayerChangeSchema)], - after: ['after', lazy(() => invoicePayerChangeSchema)], - } +export const customerPayerChangeSchema: Schema = lazy(() => + expandoObject({ + before: ['before', invoicePayerChangeSchema], + after: ['after', invoicePayerChangeSchema], + }) ); diff --git a/src/models/customerResponse.ts b/src/models/customerResponse.ts index b5fd287..7f4b9c4 100644 --- a/src/models/customerResponse.ts +++ b/src/models/customerResponse.ts @@ -12,6 +12,6 @@ export interface CustomerResponse { [key: string]: unknown; } -export const customerResponseSchema: Schema = expandoObject({ - customer: ['customer', lazy(() => customerSchema)], -}); +export const customerResponseSchema: Schema = lazy(() => + expandoObject({ customer: ['customer', customerSchema] }) +); diff --git a/src/models/debitNote.ts b/src/models/debitNote.ts index c3007d9..6a8acee 100644 --- a/src/models/debitNote.ts +++ b/src/models/debitNote.ts @@ -82,37 +82,30 @@ export interface DebitNote { [key: string]: unknown; } -export const debitNoteSchema: Schema = expandoObject({ - uid: ['uid', optional(string())], - siteId: ['site_id', optional(number())], - customerId: ['customer_id', optional(number())], - subscriptionId: ['subscription_id', optional(number())], - number: ['number', optional(number())], - sequenceNumber: ['sequence_number', optional(number())], - originCreditNoteUid: ['origin_credit_note_uid', optional(string())], - originCreditNoteNumber: ['origin_credit_note_number', optional(string())], - issueDate: ['issue_date', optional(string())], - appliedDate: ['applied_date', optional(string())], - dueDate: ['due_date', optional(string())], - status: ['status', optional(debitNoteStatusSchema)], - memo: ['memo', optional(string())], - role: ['role', optional(debitNoteRoleSchema)], - currency: ['currency', optional(string())], - seller: ['seller', optional(lazy(() => invoiceSellerSchema))], - customer: ['customer', optional(lazy(() => invoiceCustomerSchema))], - billingAddress: [ - 'billing_address', - optional(lazy(() => invoiceAddressSchema)), - ], - shippingAddress: [ - 'shipping_address', - optional(lazy(() => invoiceAddressSchema)), - ], - lineItems: [ - 'line_items', - optional(array(lazy(() => creditNoteLineItemSchema))), - ], - discounts: ['discounts', optional(array(lazy(() => invoiceDiscountSchema)))], - taxes: ['taxes', optional(array(lazy(() => invoiceTaxSchema)))], - refunds: ['refunds', optional(array(lazy(() => invoiceRefundSchema)))], -}); +export const debitNoteSchema: Schema = lazy(() => + expandoObject({ + uid: ['uid', optional(string())], + siteId: ['site_id', optional(number())], + customerId: ['customer_id', optional(number())], + subscriptionId: ['subscription_id', optional(number())], + number: ['number', optional(number())], + sequenceNumber: ['sequence_number', optional(number())], + originCreditNoteUid: ['origin_credit_note_uid', optional(string())], + originCreditNoteNumber: ['origin_credit_note_number', optional(string())], + issueDate: ['issue_date', optional(string())], + appliedDate: ['applied_date', optional(string())], + dueDate: ['due_date', optional(string())], + status: ['status', optional(debitNoteStatusSchema)], + memo: ['memo', optional(string())], + role: ['role', optional(debitNoteRoleSchema)], + currency: ['currency', optional(string())], + seller: ['seller', optional(invoiceSellerSchema)], + customer: ['customer', optional(invoiceCustomerSchema)], + billingAddress: ['billing_address', optional(invoiceAddressSchema)], + shippingAddress: ['shipping_address', optional(invoiceAddressSchema)], + lineItems: ['line_items', optional(array(creditNoteLineItemSchema))], + discounts: ['discounts', optional(array(invoiceDiscountSchema))], + taxes: ['taxes', optional(array(invoiceTaxSchema))], + refunds: ['refunds', optional(array(invoiceRefundSchema))], + }) +); diff --git a/src/models/deductServiceCredit.ts b/src/models/deductServiceCredit.ts index 7be11a2..608243e 100644 --- a/src/models/deductServiceCredit.ts +++ b/src/models/deductServiceCredit.ts @@ -4,7 +4,7 @@ * This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ). */ -import { expandoObject, optional, Schema, string } from '../schema.js'; +import { expandoObject, lazy, optional, Schema, string } from '../schema.js'; import { DeductServiceCreditAmount, deductServiceCreditAmountSchema, @@ -16,9 +16,9 @@ export interface DeductServiceCredit { [key: string]: unknown; } -export const deductServiceCreditSchema: Schema = expandoObject( - { +export const deductServiceCreditSchema: Schema = lazy(() => + expandoObject({ amount: ['amount', deductServiceCreditAmountSchema], memo: ['memo', optional(string())], - } + }) ); diff --git a/src/models/deductServiceCreditRequest.ts b/src/models/deductServiceCreditRequest.ts index a6df1d5..8234096 100644 --- a/src/models/deductServiceCreditRequest.ts +++ b/src/models/deductServiceCreditRequest.ts @@ -15,6 +15,6 @@ export interface DeductServiceCreditRequest { [key: string]: unknown; } -export const deductServiceCreditRequestSchema: Schema = expandoObject( - { deduction: ['deduction', lazy(() => deductServiceCreditSchema)] } +export const deductServiceCreditRequestSchema: Schema = lazy( + () => expandoObject({ deduction: ['deduction', deductServiceCreditSchema] }) ); diff --git a/src/models/dunningStepReached.ts b/src/models/dunningStepReached.ts index cef8d53..364d9be 100644 --- a/src/models/dunningStepReached.ts +++ b/src/models/dunningStepReached.ts @@ -15,10 +15,10 @@ export interface DunningStepReached { [key: string]: unknown; } -export const dunningStepReachedSchema: Schema = expandoObject( - { - dunner: ['dunner', lazy(() => dunnerDataSchema)], - currentStep: ['current_step', lazy(() => dunningStepDataSchema)], - nextStep: ['next_step', lazy(() => dunningStepDataSchema)], - } +export const dunningStepReachedSchema: Schema = lazy(() => + expandoObject({ + dunner: ['dunner', dunnerDataSchema], + currentStep: ['current_step', dunningStepDataSchema], + nextStep: ['next_step', dunningStepDataSchema], + }) ); diff --git a/src/models/eBBComponent.ts b/src/models/eBBComponent.ts index 9e87599..91a6e84 100644 --- a/src/models/eBBComponent.ts +++ b/src/models/eBBComponent.ts @@ -45,7 +45,7 @@ export interface EBBComponent { pricePoints?: ComponentPricePointItem[]; /** The amount the customer will be charged per unit when the pricing scheme is “per_unit”. The price can contain up to 8 decimal places. i.e. 1.00 or 0.0012 or 0.00000065 */ unitPrice?: EBBComponentUnitPrice; - /** A string representing the tax code related to the component type. This is especially important when using the Avalara service to tax based on locale. This attribute has a max length of 10 characters. */ + /** A string representing the tax code related to the component type. This is especially important when using AvaTax to tax based on locale. This attribute has a max length of 25 characters. */ taxCode?: string; /** (Only available on Relationship Invoicing sites) Boolean flag describing if the service date range should show for the component on generated invoices. */ hideDateRangeOnInvoice?: boolean; @@ -58,22 +58,24 @@ export interface EBBComponent { [key: string]: unknown; } -export const eBBComponentSchema: Schema = expandoObject({ - name: ['name', string()], - unitName: ['unit_name', string()], - description: ['description', optional(string())], - handle: ['handle', optional(string())], - taxable: ['taxable', optional(boolean())], - pricingScheme: ['pricing_scheme', pricingSchemeSchema], - prices: ['prices', optional(array(lazy(() => priceSchema)))], - pricePoints: [ - 'price_points', - optional(array(lazy(() => componentPricePointItemSchema))), - ], - unitPrice: ['unit_price', optional(eBBComponentUnitPriceSchema)], - taxCode: ['tax_code', optional(string())], - hideDateRangeOnInvoice: ['hide_date_range_on_invoice', optional(boolean())], - eventBasedBillingMetricId: ['event_based_billing_metric_id', number()], - interval: ['interval', optional(number())], - intervalUnit: ['interval_unit', optional(nullable(intervalUnitSchema))], -}); +export const eBBComponentSchema: Schema = lazy(() => + expandoObject({ + name: ['name', string()], + unitName: ['unit_name', string()], + description: ['description', optional(string())], + handle: ['handle', optional(string())], + taxable: ['taxable', optional(boolean())], + pricingScheme: ['pricing_scheme', pricingSchemeSchema], + prices: ['prices', optional(array(priceSchema))], + pricePoints: [ + 'price_points', + optional(array(componentPricePointItemSchema)), + ], + unitPrice: ['unit_price', optional(eBBComponentUnitPriceSchema)], + taxCode: ['tax_code', optional(string())], + hideDateRangeOnInvoice: ['hide_date_range_on_invoice', optional(boolean())], + eventBasedBillingMetricId: ['event_based_billing_metric_id', number()], + interval: ['interval', optional(number())], + intervalUnit: ['interval_unit', optional(nullable(intervalUnitSchema))], + }) +); diff --git a/src/models/eBBEvent.ts b/src/models/eBBEvent.ts index 6b3072f..2f883c9 100644 --- a/src/models/eBBEvent.ts +++ b/src/models/eBBEvent.ts @@ -12,6 +12,6 @@ export interface EBBEvent { [key: string]: unknown; } -export const eBBEventSchema: Schema = expandoObject({ - chargify: ['chargify', optional(lazy(() => chargifyEBBSchema))], -}); +export const eBBEventSchema: Schema = lazy(() => + expandoObject({ chargify: ['chargify', optional(chargifyEBBSchema)] }) +); diff --git a/src/models/endpointResponse.ts b/src/models/endpointResponse.ts index 9f92259..0d60ed6 100644 --- a/src/models/endpointResponse.ts +++ b/src/models/endpointResponse.ts @@ -12,6 +12,6 @@ export interface EndpointResponse { [key: string]: unknown; } -export const endpointResponseSchema: Schema = expandoObject({ - endpoint: ['endpoint', optional(lazy(() => endpointSchema))], -}); +export const endpointResponseSchema: Schema = lazy(() => + expandoObject({ endpoint: ['endpoint', optional(endpointSchema)] }) +); diff --git a/src/models/event.ts b/src/models/event.ts index d1d7725..bc9beff 100644 --- a/src/models/event.ts +++ b/src/models/event.ts @@ -7,6 +7,7 @@ import { bigint, expandoObject, + lazy, nullable, number, Schema, @@ -65,15 +66,17 @@ export interface Event { [key: string]: unknown; } -export const eventSchema: Schema = expandoObject({ - id: ['id', bigint()], - key: ['key', eventKeySchema], - message: ['message', string()], - subscriptionId: ['subscription_id', nullable(number())], - customerId: ['customer_id', nullable(number())], - createdAt: ['created_at', string()], - eventSpecificData: [ - 'event_specific_data', - nullable(eventEventSpecificDataSchema), - ], -}); +export const eventSchema: Schema = lazy(() => + expandoObject({ + id: ['id', bigint()], + key: ['key', eventKeySchema], + message: ['message', string()], + subscriptionId: ['subscription_id', nullable(number())], + customerId: ['customer_id', nullable(number())], + createdAt: ['created_at', string()], + eventSpecificData: [ + 'event_specific_data', + nullable(eventEventSpecificDataSchema), + ], + }) +); diff --git a/src/models/eventResponse.ts b/src/models/eventResponse.ts index 5a91a26..9b1dbc6 100644 --- a/src/models/eventResponse.ts +++ b/src/models/eventResponse.ts @@ -12,6 +12,6 @@ export interface EventResponse { [key: string]: unknown; } -export const eventResponseSchema: Schema = expandoObject({ - event: ['event', lazy(() => eventSchema)], -}); +export const eventResponseSchema: Schema = lazy(() => + expandoObject({ event: ['event', eventSchema] }) +); diff --git a/src/models/failedPaymentEvent.ts b/src/models/failedPaymentEvent.ts index aab3d67..2102c4b 100644 --- a/src/models/failedPaymentEvent.ts +++ b/src/models/failedPaymentEvent.ts @@ -25,12 +25,12 @@ export interface FailedPaymentEvent { [key: string]: unknown; } -export const failedPaymentEventSchema: Schema = expandoObject( - { +export const failedPaymentEventSchema: Schema = lazy(() => + expandoObject({ id: ['id', bigint()], timestamp: ['timestamp', string()], - invoice: ['invoice', lazy(() => invoiceSchema)], + invoice: ['invoice', invoiceSchema], eventType: ['event_type', invoiceEventTypeSchema], - eventData: ['event_data', lazy(() => failedPaymentEventDataSchema)], - } + eventData: ['event_data', failedPaymentEventDataSchema], + }) ); diff --git a/src/models/fullSubscriptionGroupResponse.ts b/src/models/fullSubscriptionGroupResponse.ts index 5405502..e36d9cf 100644 --- a/src/models/fullSubscriptionGroupResponse.ts +++ b/src/models/fullSubscriptionGroupResponse.ts @@ -66,28 +66,26 @@ export interface FullSubscriptionGroupResponse { [key: string]: unknown; } -export const fullSubscriptionGroupResponseSchema: Schema = expandoObject( - { - uid: ['uid', optional(string())], - scheme: ['scheme', optional(number())], - customerId: ['customer_id', optional(number())], - paymentProfileId: ['payment_profile_id', optional(number())], - subscriptionIds: ['subscription_ids', optional(array(number()))], - primarySubscriptionId: ['primary_subscription_id', optional(number())], - nextAssessmentAt: ['next_assessment_at', optional(string())], - state: ['state', optional(subscriptionStateSchema)], - cancelAtEndOfPeriod: ['cancel_at_end_of_period', optional(boolean())], - currentBillingAmountInCents: [ - 'current_billing_amount_in_cents', - optional(bigint()), - ], - customer: [ - 'customer', - optional(lazy(() => subscriptionGroupCustomerSchema)), - ], - accountBalances: [ - 'account_balances', - optional(lazy(() => subscriptionGroupBalancesSchema)), - ], - } +export const fullSubscriptionGroupResponseSchema: Schema = lazy( + () => + expandoObject({ + uid: ['uid', optional(string())], + scheme: ['scheme', optional(number())], + customerId: ['customer_id', optional(number())], + paymentProfileId: ['payment_profile_id', optional(number())], + subscriptionIds: ['subscription_ids', optional(array(number()))], + primarySubscriptionId: ['primary_subscription_id', optional(number())], + nextAssessmentAt: ['next_assessment_at', optional(string())], + state: ['state', optional(subscriptionStateSchema)], + cancelAtEndOfPeriod: ['cancel_at_end_of_period', optional(boolean())], + currentBillingAmountInCents: [ + 'current_billing_amount_in_cents', + optional(bigint()), + ], + customer: ['customer', optional(subscriptionGroupCustomerSchema)], + accountBalances: [ + 'account_balances', + optional(subscriptionGroupBalancesSchema), + ], + }) ); diff --git a/src/models/getOneTimeTokenRequest.ts b/src/models/getOneTimeTokenRequest.ts index 8dab39c..bf4ffaa 100644 --- a/src/models/getOneTimeTokenRequest.ts +++ b/src/models/getOneTimeTokenRequest.ts @@ -15,11 +15,9 @@ export interface GetOneTimeTokenRequest { [key: string]: unknown; } -export const getOneTimeTokenRequestSchema: Schema = expandoObject( - { - paymentProfile: [ - 'payment_profile', - lazy(() => getOneTimeTokenPaymentProfileSchema), - ], - } +export const getOneTimeTokenRequestSchema: Schema = lazy( + () => + expandoObject({ + paymentProfile: ['payment_profile', getOneTimeTokenPaymentProfileSchema], + }) ); diff --git a/src/models/groupSettings.ts b/src/models/groupSettings.ts index 4758fdc..4976277 100644 --- a/src/models/groupSettings.ts +++ b/src/models/groupSettings.ts @@ -16,7 +16,9 @@ export interface GroupSettings { [key: string]: unknown; } -export const groupSettingsSchema: Schema = expandoObject({ - target: ['target', lazy(() => groupTargetSchema)], - billing: ['billing', optional(lazy(() => groupBillingSchema))], -}); +export const groupSettingsSchema: Schema = lazy(() => + expandoObject({ + target: ['target', groupTargetSchema], + billing: ['billing', optional(groupBillingSchema)], + }) +); diff --git a/src/models/invoice.ts b/src/models/invoice.ts index 12a5291..8a2ab49 100644 --- a/src/models/invoice.ts +++ b/src/models/invoice.ts @@ -170,85 +170,81 @@ export interface Invoice { [key: string]: unknown; } -export const invoiceSchema: Schema = expandoObject({ - id: ['id', optional(bigint())], - uid: ['uid', optional(string())], - siteId: ['site_id', optional(number())], - customerId: ['customer_id', optional(number())], - subscriptionId: ['subscription_id', optional(number())], - number: ['number', optional(string())], - sequenceNumber: ['sequence_number', optional(number())], - transactionTime: ['transaction_time', optional(string())], - createdAt: ['created_at', optional(string())], - updatedAt: ['updated_at', optional(string())], - issueDate: ['issue_date', optional(string())], - dueDate: ['due_date', optional(string())], - paidDate: ['paid_date', optional(nullable(string()))], - status: ['status', optional(invoiceStatusSchema)], - role: ['role', optional(invoiceRoleSchema)], - parentInvoiceId: ['parent_invoice_id', optional(nullable(number()))], - collectionMethod: ['collection_method', optional(collectionMethodSchema)], - paymentInstructions: ['payment_instructions', optional(string())], - currency: ['currency', optional(string())], - consolidationLevel: [ - 'consolidation_level', - optional(invoiceConsolidationLevelSchema), - ], - parentInvoiceUid: ['parent_invoice_uid', optional(nullable(string()))], - subscriptionGroupId: ['subscription_group_id', optional(nullable(number()))], - parentInvoiceNumber: ['parent_invoice_number', optional(nullable(number()))], - groupPrimarySubscriptionId: [ - 'group_primary_subscription_id', - optional(nullable(number())), - ], - productName: ['product_name', optional(string())], - productFamilyName: ['product_family_name', optional(string())], - seller: ['seller', optional(lazy(() => invoiceSellerSchema))], - customer: ['customer', optional(lazy(() => invoiceCustomerSchema))], - payer: ['payer', optional(lazy(() => invoicePayerSchema))], - recipientEmails: ['recipient_emails', optional(array(string()))], - netTerms: ['net_terms', optional(number())], - memo: ['memo', optional(string())], - billingAddress: [ - 'billing_address', - optional(lazy(() => invoiceAddressSchema)), - ], - shippingAddress: [ - 'shipping_address', - optional(lazy(() => invoiceAddressSchema)), - ], - subtotalAmount: ['subtotal_amount', optional(string())], - discountAmount: ['discount_amount', optional(string())], - taxAmount: ['tax_amount', optional(string())], - totalAmount: ['total_amount', optional(string())], - creditAmount: ['credit_amount', optional(string())], - debitAmount: ['debit_amount', optional(string())], - refundAmount: ['refund_amount', optional(string())], - paidAmount: ['paid_amount', optional(string())], - dueAmount: ['due_amount', optional(string())], - lineItems: ['line_items', optional(array(lazy(() => invoiceLineItemSchema)))], - discounts: ['discounts', optional(array(lazy(() => invoiceDiscountSchema)))], - taxes: ['taxes', optional(array(lazy(() => invoiceTaxSchema)))], - credits: ['credits', optional(array(lazy(() => invoiceCreditSchema)))], - debits: ['debits', optional(array(lazy(() => invoiceDebitSchema)))], - refunds: ['refunds', optional(array(lazy(() => invoiceRefundSchema)))], - payments: ['payments', optional(array(lazy(() => invoicePaymentSchema)))], - customFields: [ - 'custom_fields', - optional(array(lazy(() => invoiceCustomFieldSchema))), - ], - displaySettings: [ - 'display_settings', - optional(lazy(() => invoiceDisplaySettingsSchema)), - ], - avataxDetails: [ - 'avatax_details', - optional(lazy(() => invoiceAvataxDetailsSchema)), - ], - publicUrl: ['public_url', optional(string())], - previousBalanceData: [ - 'previous_balance_data', - optional(lazy(() => invoicePreviousBalanceSchema)), - ], - publicUrlExpiresOn: ['public_url_expires_on', optional(string())], -}); +export const invoiceSchema: Schema = lazy(() => + expandoObject({ + id: ['id', optional(bigint())], + uid: ['uid', optional(string())], + siteId: ['site_id', optional(number())], + customerId: ['customer_id', optional(number())], + subscriptionId: ['subscription_id', optional(number())], + number: ['number', optional(string())], + sequenceNumber: ['sequence_number', optional(number())], + transactionTime: ['transaction_time', optional(string())], + createdAt: ['created_at', optional(string())], + updatedAt: ['updated_at', optional(string())], + issueDate: ['issue_date', optional(string())], + dueDate: ['due_date', optional(string())], + paidDate: ['paid_date', optional(nullable(string()))], + status: ['status', optional(invoiceStatusSchema)], + role: ['role', optional(invoiceRoleSchema)], + parentInvoiceId: ['parent_invoice_id', optional(nullable(number()))], + collectionMethod: ['collection_method', optional(collectionMethodSchema)], + paymentInstructions: ['payment_instructions', optional(string())], + currency: ['currency', optional(string())], + consolidationLevel: [ + 'consolidation_level', + optional(invoiceConsolidationLevelSchema), + ], + parentInvoiceUid: ['parent_invoice_uid', optional(nullable(string()))], + subscriptionGroupId: [ + 'subscription_group_id', + optional(nullable(number())), + ], + parentInvoiceNumber: [ + 'parent_invoice_number', + optional(nullable(number())), + ], + groupPrimarySubscriptionId: [ + 'group_primary_subscription_id', + optional(nullable(number())), + ], + productName: ['product_name', optional(string())], + productFamilyName: ['product_family_name', optional(string())], + seller: ['seller', optional(invoiceSellerSchema)], + customer: ['customer', optional(invoiceCustomerSchema)], + payer: ['payer', optional(invoicePayerSchema)], + recipientEmails: ['recipient_emails', optional(array(string()))], + netTerms: ['net_terms', optional(number())], + memo: ['memo', optional(string())], + billingAddress: ['billing_address', optional(invoiceAddressSchema)], + shippingAddress: ['shipping_address', optional(invoiceAddressSchema)], + subtotalAmount: ['subtotal_amount', optional(string())], + discountAmount: ['discount_amount', optional(string())], + taxAmount: ['tax_amount', optional(string())], + totalAmount: ['total_amount', optional(string())], + creditAmount: ['credit_amount', optional(string())], + debitAmount: ['debit_amount', optional(string())], + refundAmount: ['refund_amount', optional(string())], + paidAmount: ['paid_amount', optional(string())], + dueAmount: ['due_amount', optional(string())], + lineItems: ['line_items', optional(array(invoiceLineItemSchema))], + discounts: ['discounts', optional(array(invoiceDiscountSchema))], + taxes: ['taxes', optional(array(invoiceTaxSchema))], + credits: ['credits', optional(array(invoiceCreditSchema))], + debits: ['debits', optional(array(invoiceDebitSchema))], + refunds: ['refunds', optional(array(invoiceRefundSchema))], + payments: ['payments', optional(array(invoicePaymentSchema))], + customFields: ['custom_fields', optional(array(invoiceCustomFieldSchema))], + displaySettings: [ + 'display_settings', + optional(invoiceDisplaySettingsSchema), + ], + avataxDetails: ['avatax_details', optional(invoiceAvataxDetailsSchema)], + publicUrl: ['public_url', optional(string())], + previousBalanceData: [ + 'previous_balance_data', + optional(invoicePreviousBalanceSchema), + ], + publicUrlExpiresOn: ['public_url_expires_on', optional(string())], + }) +); diff --git a/src/models/invoiceDiscount.ts b/src/models/invoiceDiscount.ts index efc1316..fd52ec5 100644 --- a/src/models/invoiceDiscount.ts +++ b/src/models/invoiceDiscount.ts @@ -43,20 +43,22 @@ export interface InvoiceDiscount { [key: string]: unknown; } -export const invoiceDiscountSchema: Schema = expandoObject({ - uid: ['uid', optional(string())], - title: ['title', optional(string())], - description: ['description', optional(nullable(string()))], - code: ['code', optional(string())], - sourceType: ['source_type', optional(invoiceDiscountSourceTypeSchema)], - sourceId: ['source_id', optional(number())], - discountType: ['discount_type', optional(invoiceDiscountTypeSchema)], - percentage: ['percentage', optional(string())], - eligibleAmount: ['eligible_amount', optional(string())], - discountAmount: ['discount_amount', optional(string())], - transactionId: ['transaction_id', optional(number())], - lineItemBreakouts: [ - 'line_item_breakouts', - optional(array(lazy(() => invoiceDiscountBreakoutSchema))), - ], -}); +export const invoiceDiscountSchema: Schema = lazy(() => + expandoObject({ + uid: ['uid', optional(string())], + title: ['title', optional(string())], + description: ['description', optional(nullable(string()))], + code: ['code', optional(string())], + sourceType: ['source_type', optional(invoiceDiscountSourceTypeSchema)], + sourceId: ['source_id', optional(number())], + discountType: ['discount_type', optional(invoiceDiscountTypeSchema)], + percentage: ['percentage', optional(string())], + eligibleAmount: ['eligible_amount', optional(string())], + discountAmount: ['discount_amount', optional(string())], + transactionId: ['transaction_id', optional(number())], + lineItemBreakouts: [ + 'line_item_breakouts', + optional(array(invoiceDiscountBreakoutSchema)), + ], + }) +); diff --git a/src/models/invoiceIssued.ts b/src/models/invoiceIssued.ts index 4cf52b9..92d7a58 100644 --- a/src/models/invoiceIssued.ts +++ b/src/models/invoiceIssued.ts @@ -38,20 +38,22 @@ export interface InvoiceIssued { [key: string]: unknown; } -export const invoiceIssuedSchema: Schema = expandoObject({ - uid: ['uid', string()], - number: ['number', string()], - role: ['role', string()], - dueDate: ['due_date', nullable(string())], - issueDate: ['issue_date', string()], - paidDate: ['paid_date', string()], - dueAmount: ['due_amount', string()], - paidAmount: ['paid_amount', string()], - taxAmount: ['tax_amount', string()], - refundAmount: ['refund_amount', string()], - totalAmount: ['total_amount', string()], - statusAmount: ['status_amount', string()], - productName: ['product_name', string()], - consolidationLevel: ['consolidation_level', string()], - lineItems: ['line_items', array(lazy(() => invoiceLineItemEventDataSchema))], -}); +export const invoiceIssuedSchema: Schema = lazy(() => + expandoObject({ + uid: ['uid', string()], + number: ['number', string()], + role: ['role', string()], + dueDate: ['due_date', nullable(string())], + issueDate: ['issue_date', string()], + paidDate: ['paid_date', string()], + dueAmount: ['due_amount', string()], + paidAmount: ['paid_amount', string()], + taxAmount: ['tax_amount', string()], + refundAmount: ['refund_amount', string()], + totalAmount: ['total_amount', string()], + statusAmount: ['status_amount', string()], + productName: ['product_name', string()], + consolidationLevel: ['consolidation_level', string()], + lineItems: ['line_items', array(invoiceLineItemEventDataSchema)], + }) +); diff --git a/src/models/invoiceLineItem.ts b/src/models/invoiceLineItem.ts index 755414c..c3a52d3 100644 --- a/src/models/invoiceLineItem.ts +++ b/src/models/invoiceLineItem.ts @@ -94,34 +94,39 @@ export interface InvoiceLineItem { [key: string]: unknown; } -export const invoiceLineItemSchema: Schema = expandoObject({ - uid: ['uid', optional(string())], - title: ['title', optional(string())], - description: ['description', optional(string())], - quantity: ['quantity', optional(string())], - unitPrice: ['unit_price', optional(string())], - subtotalAmount: ['subtotal_amount', optional(string())], - discountAmount: ['discount_amount', optional(string())], - taxAmount: ['tax_amount', optional(string())], - totalAmount: ['total_amount', optional(string())], - tieredUnitPrice: ['tiered_unit_price', optional(boolean())], - periodRangeStart: ['period_range_start', optional(string())], - periodRangeEnd: ['period_range_end', optional(string())], - transactionId: ['transaction_id', optional(number())], - productId: ['product_id', optional(nullable(number()))], - productVersion: ['product_version', optional(nullable(number()))], - componentId: ['component_id', optional(nullable(number()))], - pricePointId: ['price_point_id', optional(nullable(number()))], - billingScheduleItemId: [ - 'billing_schedule_item_id', - optional(nullable(number())), - ], - hide: ['hide', optional(boolean())], - componentCostData: [ - 'component_cost_data', - optional(nullable(lazy(() => invoiceLineItemComponentCostDataSchema))), - ], - productPricePointId: ['product_price_point_id', optional(nullable(number()))], - customItem: ['custom_item', optional(boolean())], - kind: ['kind', optional(string())], -}); +export const invoiceLineItemSchema: Schema = lazy(() => + expandoObject({ + uid: ['uid', optional(string())], + title: ['title', optional(string())], + description: ['description', optional(string())], + quantity: ['quantity', optional(string())], + unitPrice: ['unit_price', optional(string())], + subtotalAmount: ['subtotal_amount', optional(string())], + discountAmount: ['discount_amount', optional(string())], + taxAmount: ['tax_amount', optional(string())], + totalAmount: ['total_amount', optional(string())], + tieredUnitPrice: ['tiered_unit_price', optional(boolean())], + periodRangeStart: ['period_range_start', optional(string())], + periodRangeEnd: ['period_range_end', optional(string())], + transactionId: ['transaction_id', optional(number())], + productId: ['product_id', optional(nullable(number()))], + productVersion: ['product_version', optional(nullable(number()))], + componentId: ['component_id', optional(nullable(number()))], + pricePointId: ['price_point_id', optional(nullable(number()))], + billingScheduleItemId: [ + 'billing_schedule_item_id', + optional(nullable(number())), + ], + hide: ['hide', optional(boolean())], + componentCostData: [ + 'component_cost_data', + optional(nullable(invoiceLineItemComponentCostDataSchema)), + ], + productPricePointId: [ + 'product_price_point_id', + optional(nullable(number())), + ], + customItem: ['custom_item', optional(boolean())], + kind: ['kind', optional(string())], + }) +); diff --git a/src/models/invoiceLineItemComponentCostData.ts b/src/models/invoiceLineItemComponentCostData.ts index 74ff5f1..aa2706a 100644 --- a/src/models/invoiceLineItemComponentCostData.ts +++ b/src/models/invoiceLineItemComponentCostData.ts @@ -15,6 +15,9 @@ export interface InvoiceLineItemComponentCostData { [key: string]: unknown; } -export const invoiceLineItemComponentCostDataSchema: Schema = expandoObject( - { rates: ['rates', optional(array(lazy(() => componentCostDataSchema)))] } +export const invoiceLineItemComponentCostDataSchema: Schema = lazy( + () => + expandoObject({ + rates: ['rates', optional(array(componentCostDataSchema))], + }) ); diff --git a/src/models/invoiceLineItemEventData.ts b/src/models/invoiceLineItemEventData.ts index cae70dd..9142820 100644 --- a/src/models/invoiceLineItemEventData.ts +++ b/src/models/invoiceLineItemEventData.ts @@ -44,39 +44,40 @@ export interface InvoiceLineItemEventData { [key: string]: unknown; } -export const invoiceLineItemEventDataSchema: Schema = expandoObject( - { - uid: ['uid', optional(string())], - title: ['title', optional(string())], - description: ['description', optional(string())], - quantity: ['quantity', optional(number())], - quantityDelta: ['quantity_delta', optional(nullable(number()))], - unitPrice: ['unit_price', optional(string())], - periodRangeStart: ['period_range_start', optional(string())], - periodRangeEnd: ['period_range_end', optional(string())], - amount: ['amount', optional(string())], - lineReferences: ['line_references', optional(string())], - pricingDetailsIndex: [ - 'pricing_details_index', - optional(nullable(number())), - ], - pricingDetails: [ - 'pricing_details', - optional(array(lazy(() => invoiceLineItemPricingDetailSchema))), - ], - taxCode: ['tax_code', optional(nullable(string()))], - taxAmount: ['tax_amount', optional(string())], - productId: ['product_id', optional(number())], - productPricePointId: [ - 'product_price_point_id', - optional(nullable(number())), - ], - pricePointId: ['price_point_id', optional(nullable(number()))], - componentId: ['component_id', optional(nullable(number()))], - billingScheduleItemId: [ - 'billing_schedule_item_id', - optional(nullable(number())), - ], - customItem: ['custom_item', optional(nullable(boolean()))], - } +export const invoiceLineItemEventDataSchema: Schema = lazy( + () => + expandoObject({ + uid: ['uid', optional(string())], + title: ['title', optional(string())], + description: ['description', optional(string())], + quantity: ['quantity', optional(number())], + quantityDelta: ['quantity_delta', optional(nullable(number()))], + unitPrice: ['unit_price', optional(string())], + periodRangeStart: ['period_range_start', optional(string())], + periodRangeEnd: ['period_range_end', optional(string())], + amount: ['amount', optional(string())], + lineReferences: ['line_references', optional(string())], + pricingDetailsIndex: [ + 'pricing_details_index', + optional(nullable(number())), + ], + pricingDetails: [ + 'pricing_details', + optional(array(invoiceLineItemPricingDetailSchema)), + ], + taxCode: ['tax_code', optional(nullable(string()))], + taxAmount: ['tax_amount', optional(string())], + productId: ['product_id', optional(number())], + productPricePointId: [ + 'product_price_point_id', + optional(nullable(number())), + ], + pricePointId: ['price_point_id', optional(nullable(number()))], + componentId: ['component_id', optional(nullable(number()))], + billingScheduleItemId: [ + 'billing_schedule_item_id', + optional(nullable(number())), + ], + customItem: ['custom_item', optional(nullable(boolean()))], + }) ); diff --git a/src/models/invoicePayment.ts b/src/models/invoicePayment.ts index da85f8a..902ef60 100644 --- a/src/models/invoicePayment.ts +++ b/src/models/invoicePayment.ts @@ -40,23 +40,22 @@ export interface InvoicePayment { [key: string]: unknown; } -export const invoicePaymentSchema: Schema = expandoObject({ - transactionTime: ['transaction_time', optional(string())], - memo: ['memo', optional(string())], - originalAmount: ['original_amount', optional(string())], - appliedAmount: ['applied_amount', optional(string())], - paymentMethod: [ - 'payment_method', - optional(lazy(() => invoicePaymentMethodSchema)), - ], - transactionId: ['transaction_id', optional(number())], - prepayment: ['prepayment', optional(boolean())], - gatewayHandle: ['gateway_handle', optional(nullable(string()))], - gatewayUsed: ['gateway_used', optional(string())], - gatewayTransactionId: [ - 'gateway_transaction_id', - optional(nullable(string())), - ], - receivedOn: ['received_on', optional(nullable(string()))], - uid: ['uid', optional(string())], -}); +export const invoicePaymentSchema: Schema = lazy(() => + expandoObject({ + transactionTime: ['transaction_time', optional(string())], + memo: ['memo', optional(string())], + originalAmount: ['original_amount', optional(string())], + appliedAmount: ['applied_amount', optional(string())], + paymentMethod: ['payment_method', optional(invoicePaymentMethodSchema)], + transactionId: ['transaction_id', optional(number())], + prepayment: ['prepayment', optional(boolean())], + gatewayHandle: ['gateway_handle', optional(nullable(string()))], + gatewayUsed: ['gateway_used', optional(string())], + gatewayTransactionId: [ + 'gateway_transaction_id', + optional(nullable(string())), + ], + receivedOn: ['received_on', optional(nullable(string()))], + uid: ['uid', optional(string())], + }) +); diff --git a/src/models/invoicePreviousBalance.ts b/src/models/invoicePreviousBalance.ts index ed453d3..2abd362 100644 --- a/src/models/invoicePreviousBalance.ts +++ b/src/models/invoicePreviousBalance.ts @@ -23,12 +23,10 @@ export interface InvoicePreviousBalance { [key: string]: unknown; } -export const invoicePreviousBalanceSchema: Schema = expandoObject( - { - capturedAt: ['captured_at', optional(string())], - invoices: [ - 'invoices', - optional(array(lazy(() => invoiceBalanceItemSchema))), - ], - } +export const invoicePreviousBalanceSchema: Schema = lazy( + () => + expandoObject({ + capturedAt: ['captured_at', optional(string())], + invoices: ['invoices', optional(array(invoiceBalanceItemSchema))], + }) ); diff --git a/src/models/invoiceResponse.ts b/src/models/invoiceResponse.ts index 11eee14..857c28d 100644 --- a/src/models/invoiceResponse.ts +++ b/src/models/invoiceResponse.ts @@ -12,6 +12,6 @@ export interface InvoiceResponse { [key: string]: unknown; } -export const invoiceResponseSchema: Schema = expandoObject({ - invoice: ['invoice', lazy(() => invoiceSchema)], -}); +export const invoiceResponseSchema: Schema = lazy(() => + expandoObject({ invoice: ['invoice', invoiceSchema] }) +); diff --git a/src/models/invoiceSeller.ts b/src/models/invoiceSeller.ts index ac45ee1..c6cf09a 100644 --- a/src/models/invoiceSeller.ts +++ b/src/models/invoiceSeller.ts @@ -23,9 +23,11 @@ export interface InvoiceSeller { [key: string]: unknown; } -export const invoiceSellerSchema: Schema = expandoObject({ - name: ['name', optional(string())], - address: ['address', optional(lazy(() => invoiceAddressSchema))], - phone: ['phone', optional(string())], - logoUrl: ['logo_url', optional(nullable(string()))], -}); +export const invoiceSellerSchema: Schema = lazy(() => + expandoObject({ + name: ['name', optional(string())], + address: ['address', optional(invoiceAddressSchema)], + phone: ['phone', optional(string())], + logoUrl: ['logo_url', optional(nullable(string()))], + }) +); diff --git a/src/models/invoiceTax.ts b/src/models/invoiceTax.ts index abd6f9a..30eb606 100644 --- a/src/models/invoiceTax.ts +++ b/src/models/invoiceTax.ts @@ -46,25 +46,27 @@ export interface InvoiceTax { [key: string]: unknown; } -export const invoiceTaxSchema: Schema = expandoObject({ - uid: ['uid', optional(string())], - title: ['title', optional(string())], - description: ['description', optional(nullable(string()))], - sourceType: ['source_type', optional(proformaInvoiceTaxSourceTypeSchema)], - sourceId: ['source_id', optional(number())], - percentage: ['percentage', optional(string())], - taxableAmount: ['taxable_amount', optional(string())], - taxAmount: ['tax_amount', optional(string())], - transactionId: ['transaction_id', optional(number())], - lineItemBreakouts: [ - 'line_item_breakouts', - optional(array(lazy(() => invoiceTaxBreakoutSchema))), - ], - taxComponentBreakouts: [ - 'tax_component_breakouts', - optional(array(lazy(() => invoiceTaxComponentBreakoutSchema))), - ], - euVat: ['eu_vat', optional(boolean())], - type: ['type', optional(string())], - taxExemptAmount: ['tax_exempt_amount', optional(string())], -}); +export const invoiceTaxSchema: Schema = lazy(() => + expandoObject({ + uid: ['uid', optional(string())], + title: ['title', optional(string())], + description: ['description', optional(nullable(string()))], + sourceType: ['source_type', optional(proformaInvoiceTaxSourceTypeSchema)], + sourceId: ['source_id', optional(number())], + percentage: ['percentage', optional(string())], + taxableAmount: ['taxable_amount', optional(string())], + taxAmount: ['tax_amount', optional(string())], + transactionId: ['transaction_id', optional(number())], + lineItemBreakouts: [ + 'line_item_breakouts', + optional(array(invoiceTaxBreakoutSchema)), + ], + taxComponentBreakouts: [ + 'tax_component_breakouts', + optional(array(invoiceTaxComponentBreakoutSchema)), + ], + euVat: ['eu_vat', optional(boolean())], + type: ['type', optional(string())], + taxExemptAmount: ['tax_exempt_amount', optional(string())], + }) +); diff --git a/src/models/issueInvoiceEvent.ts b/src/models/issueInvoiceEvent.ts index 48534ac..be9bd85 100644 --- a/src/models/issueInvoiceEvent.ts +++ b/src/models/issueInvoiceEvent.ts @@ -25,12 +25,12 @@ export interface IssueInvoiceEvent { [key: string]: unknown; } -export const issueInvoiceEventSchema: Schema = expandoObject( - { +export const issueInvoiceEventSchema: Schema = lazy(() => + expandoObject({ id: ['id', bigint()], timestamp: ['timestamp', string()], - invoice: ['invoice', lazy(() => invoiceSchema)], + invoice: ['invoice', invoiceSchema], eventType: ['event_type', invoiceEventTypeSchema], - eventData: ['event_data', lazy(() => issueInvoiceEventDataSchema)], - } + eventData: ['event_data', issueInvoiceEventDataSchema], + }) ); diff --git a/src/models/issueServiceCredit.ts b/src/models/issueServiceCredit.ts index 73a6c3e..151d324 100644 --- a/src/models/issueServiceCredit.ts +++ b/src/models/issueServiceCredit.ts @@ -4,7 +4,7 @@ * This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ). */ -import { expandoObject, optional, Schema, string } from '../schema.js'; +import { expandoObject, lazy, optional, Schema, string } from '../schema.js'; import { IssueServiceCreditAmount, issueServiceCreditAmountSchema, @@ -16,9 +16,9 @@ export interface IssueServiceCredit { [key: string]: unknown; } -export const issueServiceCreditSchema: Schema = expandoObject( - { +export const issueServiceCreditSchema: Schema = lazy(() => + expandoObject({ amount: ['amount', issueServiceCreditAmountSchema], memo: ['memo', optional(string())], - } + }) ); diff --git a/src/models/issueServiceCreditRequest.ts b/src/models/issueServiceCreditRequest.ts index 69f3277..afabd82 100644 --- a/src/models/issueServiceCreditRequest.ts +++ b/src/models/issueServiceCreditRequest.ts @@ -15,6 +15,9 @@ export interface IssueServiceCreditRequest { [key: string]: unknown; } -export const issueServiceCreditRequestSchema: Schema = expandoObject( - { serviceCredit: ['service_credit', lazy(() => issueServiceCreditSchema)] } +export const issueServiceCreditRequestSchema: Schema = lazy( + () => + expandoObject({ + serviceCredit: ['service_credit', issueServiceCreditSchema], + }) ); diff --git a/src/models/itemPricePointChanged.ts b/src/models/itemPricePointChanged.ts index ac67a56..1a17b58 100644 --- a/src/models/itemPricePointChanged.ts +++ b/src/models/itemPricePointChanged.ts @@ -20,19 +20,14 @@ export interface ItemPricePointChanged { [key: string]: unknown; } -export const itemPricePointChangedSchema: Schema = expandoObject( - { - itemId: ['item_id', number()], - itemType: ['item_type', string()], - itemHandle: ['item_handle', string()], - itemName: ['item_name', string()], - previousPricePoint: [ - 'previous_price_point', - lazy(() => itemPricePointDataSchema), - ], - currentPricePoint: [ - 'current_price_point', - lazy(() => itemPricePointDataSchema), - ], - } +export const itemPricePointChangedSchema: Schema = lazy( + () => + expandoObject({ + itemId: ['item_id', number()], + itemType: ['item_type', string()], + itemHandle: ['item_handle', string()], + itemName: ['item_name', string()], + previousPricePoint: ['previous_price_point', itemPricePointDataSchema], + currentPricePoint: ['current_price_point', itemPricePointDataSchema], + }) ); diff --git a/src/models/listComponentsPricePointsResponse.ts b/src/models/listComponentsPricePointsResponse.ts index db31328..3bceefb 100644 --- a/src/models/listComponentsPricePointsResponse.ts +++ b/src/models/listComponentsPricePointsResponse.ts @@ -15,8 +15,9 @@ export interface ListComponentsPricePointsResponse { [key: string]: unknown; } -export const listComponentsPricePointsResponseSchema: Schema = expandoObject( - { - pricePoints: ['price_points', array(lazy(() => componentPricePointSchema))], - } +export const listComponentsPricePointsResponseSchema: Schema = lazy( + () => + expandoObject({ + pricePoints: ['price_points', array(componentPricePointSchema)], + }) ); diff --git a/src/models/listCouponsFilter.ts b/src/models/listCouponsFilter.ts index 1cf1c70..513bf23 100644 --- a/src/models/listCouponsFilter.ts +++ b/src/models/listCouponsFilter.ts @@ -30,8 +30,10 @@ export interface ListCouponsFilter { ids?: number[]; /** Allows fetching coupons with matching codes based on provided values. Use in query `filter[codes]=free,free_trial`. */ codes?: string[]; - /** Allows fetching coupons with matching use_site_exchange_rate based on provided value. Use in query `filter[use_site_exchange_rate]=true`. */ + /** If true, restricts the list to coupons whose pricing is recalculated from the site’s current exchange rates, so their currency_prices array contains on-the-fly conversions rather than stored price records. If false, restricts the list to coupons that have manually defined amounts for each currency, ensuring the response includes the saved currency_prices entries instead of exchange-rate-derived values. Use in query `filter[use_site_exchange_rate]=true`. */ useSiteExchangeRate?: boolean; + /** Controls returning archived coupons. */ + includeArchived?: boolean; [key: string]: unknown; } @@ -45,5 +47,6 @@ export const listCouponsFilterSchema: Schema = expandoObject( ids: ['ids', optional(array(number()))], codes: ['codes', optional(array(string()))], useSiteExchangeRate: ['use_site_exchange_rate', optional(boolean())], + includeArchived: ['include_archived', optional(boolean())], } ); diff --git a/src/models/listCreditNotesResponse.ts b/src/models/listCreditNotesResponse.ts index df0b4e3..bd1a257 100644 --- a/src/models/listCreditNotesResponse.ts +++ b/src/models/listCreditNotesResponse.ts @@ -12,6 +12,7 @@ export interface ListCreditNotesResponse { [key: string]: unknown; } -export const listCreditNotesResponseSchema: Schema = expandoObject( - { creditNotes: ['credit_notes', array(lazy(() => creditNoteSchema))] } +export const listCreditNotesResponseSchema: Schema = lazy( + () => + expandoObject({ creditNotes: ['credit_notes', array(creditNoteSchema)] }) ); diff --git a/src/models/listInvoiceEventsResponse.ts b/src/models/listInvoiceEventsResponse.ts index c1c556c..47e0829 100644 --- a/src/models/listInvoiceEventsResponse.ts +++ b/src/models/listInvoiceEventsResponse.ts @@ -4,7 +4,14 @@ * This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ). */ -import { array, expandoObject, number, optional, Schema } from '../schema.js'; +import { + array, + expandoObject, + lazy, + number, + optional, + Schema, +} from '../schema.js'; import { InvoiceEvent, invoiceEventSchema } from './containers/invoiceEvent.js'; export interface ListInvoiceEventsResponse { @@ -15,11 +22,12 @@ export interface ListInvoiceEventsResponse { [key: string]: unknown; } -export const listInvoiceEventsResponseSchema: Schema = expandoObject( - { - events: ['events', optional(array(invoiceEventSchema))], - page: ['page', optional(number())], - perPage: ['per_page', optional(number())], - totalPages: ['total_pages', optional(number())], - } +export const listInvoiceEventsResponseSchema: Schema = lazy( + () => + expandoObject({ + events: ['events', optional(array(invoiceEventSchema))], + page: ['page', optional(number())], + perPage: ['per_page', optional(number())], + totalPages: ['total_pages', optional(number())], + }) ); diff --git a/src/models/listInvoicesResponse.ts b/src/models/listInvoicesResponse.ts index 6cebf3c..b88f434 100644 --- a/src/models/listInvoicesResponse.ts +++ b/src/models/listInvoicesResponse.ts @@ -12,6 +12,6 @@ export interface ListInvoicesResponse { [key: string]: unknown; } -export const listInvoicesResponseSchema: Schema = expandoObject( - { invoices: ['invoices', array(lazy(() => invoiceSchema))] } +export const listInvoicesResponseSchema: Schema = lazy( + () => expandoObject({ invoices: ['invoices', array(invoiceSchema)] }) ); diff --git a/src/models/listMRRResponse.ts b/src/models/listMRRResponse.ts index 10ca8c8..e325215 100644 --- a/src/models/listMRRResponse.ts +++ b/src/models/listMRRResponse.ts @@ -15,6 +15,6 @@ export interface ListMRRResponse { [key: string]: unknown; } -export const listMRRResponseSchema: Schema = expandoObject({ - mrr: ['mrr', lazy(() => listMRRResponseResultSchema)], -}); +export const listMRRResponseSchema: Schema = lazy(() => + expandoObject({ mrr: ['mrr', listMRRResponseResultSchema] }) +); diff --git a/src/models/listMRRResponseResult.ts b/src/models/listMRRResponseResult.ts index 7bfdb9b..c4bfc8c 100644 --- a/src/models/listMRRResponseResult.ts +++ b/src/models/listMRRResponseResult.ts @@ -26,14 +26,15 @@ export interface ListMRRResponseResult { [key: string]: unknown; } -export const listMRRResponseResultSchema: Schema = expandoObject( - { - page: ['page', optional(number())], - perPage: ['per_page', optional(number())], - totalPages: ['total_pages', optional(number())], - totalEntries: ['total_entries', optional(number())], - currency: ['currency', optional(string())], - currencySymbol: ['currency_symbol', optional(string())], - movements: ['movements', optional(array(lazy(() => movementSchema)))], - } +export const listMRRResponseResultSchema: Schema = lazy( + () => + expandoObject({ + page: ['page', optional(number())], + perPage: ['per_page', optional(number())], + totalPages: ['total_pages', optional(number())], + totalEntries: ['total_entries', optional(number())], + currency: ['currency', optional(string())], + currencySymbol: ['currency_symbol', optional(string())], + movements: ['movements', optional(array(movementSchema))], + }) ); diff --git a/src/models/listMetafieldsResponse.ts b/src/models/listMetafieldsResponse.ts index 726a670..724eafe 100644 --- a/src/models/listMetafieldsResponse.ts +++ b/src/models/listMetafieldsResponse.ts @@ -23,12 +23,13 @@ export interface ListMetafieldsResponse { [key: string]: unknown; } -export const listMetafieldsResponseSchema: Schema = expandoObject( - { - totalCount: ['total_count', optional(number())], - currentPage: ['current_page', optional(number())], - totalPages: ['total_pages', optional(number())], - perPage: ['per_page', optional(number())], - metafields: ['metafields', optional(array(lazy(() => metafieldSchema)))], - } +export const listMetafieldsResponseSchema: Schema = lazy( + () => + expandoObject({ + totalCount: ['total_count', optional(number())], + currentPage: ['current_page', optional(number())], + totalPages: ['total_pages', optional(number())], + perPage: ['per_page', optional(number())], + metafields: ['metafields', optional(array(metafieldSchema))], + }) ); diff --git a/src/models/listOffersResponse.ts b/src/models/listOffersResponse.ts index 1d011c5..4d617d1 100644 --- a/src/models/listOffersResponse.ts +++ b/src/models/listOffersResponse.ts @@ -12,6 +12,6 @@ export interface ListOffersResponse { [key: string]: unknown; } -export const listOffersResponseSchema: Schema = expandoObject( - { offers: ['offers', optional(array(lazy(() => offerSchema)))] } +export const listOffersResponseSchema: Schema = lazy(() => + expandoObject({ offers: ['offers', optional(array(offerSchema))] }) ); diff --git a/src/models/listProductPricePointsResponse.ts b/src/models/listProductPricePointsResponse.ts index 33613d0..87f7276 100644 --- a/src/models/listProductPricePointsResponse.ts +++ b/src/models/listProductPricePointsResponse.ts @@ -15,6 +15,9 @@ export interface ListProductPricePointsResponse { [key: string]: unknown; } -export const listProductPricePointsResponseSchema: Schema = expandoObject( - { pricePoints: ['price_points', array(lazy(() => productPricePointSchema))] } +export const listProductPricePointsResponseSchema: Schema = lazy( + () => + expandoObject({ + pricePoints: ['price_points', array(productPricePointSchema)], + }) ); diff --git a/src/models/listProductsFilter.ts b/src/models/listProductsFilter.ts index 49ad00a..7cf3b1c 100644 --- a/src/models/listProductsFilter.ts +++ b/src/models/listProductsFilter.ts @@ -28,13 +28,13 @@ export interface ListProductsFilter { [key: string]: unknown; } -export const listProductsFilterSchema: Schema = expandoObject( - { +export const listProductsFilterSchema: Schema = lazy(() => + expandoObject({ ids: ['ids', optional(array(number()))], prepaidProductPricePoint: [ 'prepaid_product_price_point', - optional(lazy(() => prepaidProductPricePointFilterSchema)), + optional(prepaidProductPricePointFilterSchema), ], useSiteExchangeRate: ['use_site_exchange_rate', optional(boolean())], - } + }) ); diff --git a/src/models/listProformaInvoicesResponse.ts b/src/models/listProformaInvoicesResponse.ts index 0ff2368..11501fa 100644 --- a/src/models/listProformaInvoicesResponse.ts +++ b/src/models/listProformaInvoicesResponse.ts @@ -17,12 +17,13 @@ export interface ListProformaInvoicesResponse { [key: string]: unknown; } -export const listProformaInvoicesResponseSchema: Schema = expandoObject( - { - proformaInvoices: [ - 'proforma_invoices', - optional(array(lazy(() => proformaInvoiceSchema))), - ], - meta: ['meta', optional(lazy(() => listProformaInvoicesMetaSchema))], - } +export const listProformaInvoicesResponseSchema: Schema = lazy( + () => + expandoObject({ + proformaInvoices: [ + 'proforma_invoices', + optional(array(proformaInvoiceSchema)), + ], + meta: ['meta', optional(listProformaInvoicesMetaSchema)], + }) ); diff --git a/src/models/listPublicKeysResponse.ts b/src/models/listPublicKeysResponse.ts index 9d82db2..b04b3b6 100644 --- a/src/models/listPublicKeysResponse.ts +++ b/src/models/listPublicKeysResponse.ts @@ -17,12 +17,10 @@ export interface ListPublicKeysResponse { [key: string]: unknown; } -export const listPublicKeysResponseSchema: Schema = expandoObject( - { - chargifyJsKeys: [ - 'chargify_js_keys', - optional(array(lazy(() => publicKeySchema))), - ], - meta: ['meta', optional(lazy(() => listPublicKeysMetaSchema))], - } +export const listPublicKeysResponseSchema: Schema = lazy( + () => + expandoObject({ + chargifyJsKeys: ['chargify_js_keys', optional(array(publicKeySchema))], + meta: ['meta', optional(listPublicKeysMetaSchema)], + }) ); diff --git a/src/models/listSaleRepItem.ts b/src/models/listSaleRepItem.ts index b483aec..8ce1d6f 100644 --- a/src/models/listSaleRepItem.ts +++ b/src/models/listSaleRepItem.ts @@ -25,10 +25,12 @@ export interface ListSaleRepItem { [key: string]: unknown; } -export const listSaleRepItemSchema: Schema = expandoObject({ - id: ['id', optional(number())], - fullName: ['full_name', optional(string())], - subscriptionsCount: ['subscriptions_count', optional(number())], - mrrData: ['mrr_data', optional(dict(lazy(() => saleRepItemMrrSchema)))], - testMode: ['test_mode', optional(boolean())], -}); +export const listSaleRepItemSchema: Schema = lazy(() => + expandoObject({ + id: ['id', optional(number())], + fullName: ['full_name', optional(string())], + subscriptionsCount: ['subscriptions_count', optional(number())], + mrrData: ['mrr_data', optional(dict(saleRepItemMrrSchema))], + testMode: ['test_mode', optional(boolean())], + }) +); diff --git a/src/models/listSegmentsResponse.ts b/src/models/listSegmentsResponse.ts index 9deb6a0..ce0900d 100644 --- a/src/models/listSegmentsResponse.ts +++ b/src/models/listSegmentsResponse.ts @@ -12,6 +12,7 @@ export interface ListSegmentsResponse { [key: string]: unknown; } -export const listSegmentsResponseSchema: Schema = expandoObject( - { segments: ['segments', optional(array(lazy(() => segmentSchema)))] } +export const listSegmentsResponseSchema: Schema = lazy( + () => + expandoObject({ segments: ['segments', optional(array(segmentSchema))] }) ); diff --git a/src/models/listServiceCreditsResponse.ts b/src/models/listServiceCreditsResponse.ts index 0ea44a7..5fc3734 100644 --- a/src/models/listServiceCreditsResponse.ts +++ b/src/models/listServiceCreditsResponse.ts @@ -12,11 +12,12 @@ export interface ListServiceCreditsResponse { [key: string]: unknown; } -export const listServiceCreditsResponseSchema: Schema = expandoObject( - { - serviceCredits: [ - 'service_credits', - optional(array(lazy(() => serviceCredit1Schema))), - ], - } +export const listServiceCreditsResponseSchema: Schema = lazy( + () => + expandoObject({ + serviceCredits: [ + 'service_credits', + optional(array(serviceCredit1Schema)), + ], + }) ); diff --git a/src/models/listSubscriptionComponentsForSiteFilter.ts b/src/models/listSubscriptionComponentsForSiteFilter.ts index b4d1e37..c0adce7 100644 --- a/src/models/listSubscriptionComponentsForSiteFilter.ts +++ b/src/models/listSubscriptionComponentsForSiteFilter.ts @@ -28,13 +28,11 @@ export interface ListSubscriptionComponentsForSiteFilter { [key: string]: unknown; } -export const listSubscriptionComponentsForSiteFilterSchema: Schema = expandoObject( - { - currencies: ['currencies', optional(array(string()))], - useSiteExchangeRate: ['use_site_exchange_rate', optional(boolean())], - subscription: [ - 'subscription', - optional(lazy(() => subscriptionFilterSchema)), - ], - } +export const listSubscriptionComponentsForSiteFilterSchema: Schema = lazy( + () => + expandoObject({ + currencies: ['currencies', optional(array(string()))], + useSiteExchangeRate: ['use_site_exchange_rate', optional(boolean())], + subscription: ['subscription', optional(subscriptionFilterSchema)], + }) ); diff --git a/src/models/listSubscriptionComponentsResponse.ts b/src/models/listSubscriptionComponentsResponse.ts index 702c2ab..db62017 100644 --- a/src/models/listSubscriptionComponentsResponse.ts +++ b/src/models/listSubscriptionComponentsResponse.ts @@ -15,11 +15,12 @@ export interface ListSubscriptionComponentsResponse { [key: string]: unknown; } -export const listSubscriptionComponentsResponseSchema: Schema = expandoObject( - { - subscriptionsComponents: [ - 'subscriptions_components', - array(lazy(() => subscriptionComponentSchema)), - ], - } +export const listSubscriptionComponentsResponseSchema: Schema = lazy( + () => + expandoObject({ + subscriptionsComponents: [ + 'subscriptions_components', + array(subscriptionComponentSchema), + ], + }) ); diff --git a/src/models/listSubscriptionGroupPrepayment.ts b/src/models/listSubscriptionGroupPrepayment.ts index 88f7298..81e0314 100644 --- a/src/models/listSubscriptionGroupPrepayment.ts +++ b/src/models/listSubscriptionGroupPrepayment.ts @@ -15,11 +15,9 @@ export interface ListSubscriptionGroupPrepayment { [key: string]: unknown; } -export const listSubscriptionGroupPrepaymentSchema: Schema = expandoObject( - { - prepayment: [ - 'prepayment', - lazy(() => listSubcriptionGroupPrepaymentItemSchema), - ], - } +export const listSubscriptionGroupPrepaymentSchema: Schema = lazy( + () => + expandoObject({ + prepayment: ['prepayment', listSubcriptionGroupPrepaymentItemSchema], + }) ); diff --git a/src/models/listSubscriptionGroupPrepaymentResponse.ts b/src/models/listSubscriptionGroupPrepaymentResponse.ts index 481c4f5..9234af1 100644 --- a/src/models/listSubscriptionGroupPrepaymentResponse.ts +++ b/src/models/listSubscriptionGroupPrepaymentResponse.ts @@ -15,11 +15,12 @@ export interface ListSubscriptionGroupPrepaymentResponse { [key: string]: unknown; } -export const listSubscriptionGroupPrepaymentResponseSchema: Schema = expandoObject( - { - prepayments: [ - 'prepayments', - array(lazy(() => listSubscriptionGroupPrepaymentSchema)), - ], - } +export const listSubscriptionGroupPrepaymentResponseSchema: Schema = lazy( + () => + expandoObject({ + prepayments: [ + 'prepayments', + array(listSubscriptionGroupPrepaymentSchema), + ], + }) ); diff --git a/src/models/listSubscriptionGroupsItem.ts b/src/models/listSubscriptionGroupsItem.ts index 78bdf47..921ea15 100644 --- a/src/models/listSubscriptionGroupsItem.ts +++ b/src/models/listSubscriptionGroupsItem.ts @@ -35,21 +35,22 @@ export interface ListSubscriptionGroupsItem { [key: string]: unknown; } -export const listSubscriptionGroupsItemSchema: Schema = expandoObject( - { - uid: ['uid', optional(string())], - scheme: ['scheme', optional(number())], - customerId: ['customer_id', optional(number())], - paymentProfileId: ['payment_profile_id', optional(number())], - subscriptionIds: ['subscription_ids', optional(array(number()))], - primarySubscriptionId: ['primary_subscription_id', optional(number())], - nextAssessmentAt: ['next_assessment_at', optional(string())], - state: ['state', optional(string())], - cancelAtEndOfPeriod: ['cancel_at_end_of_period', optional(boolean())], - accountBalances: [ - 'account_balances', - optional(lazy(() => subscriptionGroupBalancesSchema)), - ], - groupType: ['group_type', optional(groupTypeSchema)], - } +export const listSubscriptionGroupsItemSchema: Schema = lazy( + () => + expandoObject({ + uid: ['uid', optional(string())], + scheme: ['scheme', optional(number())], + customerId: ['customer_id', optional(number())], + paymentProfileId: ['payment_profile_id', optional(number())], + subscriptionIds: ['subscription_ids', optional(array(number()))], + primarySubscriptionId: ['primary_subscription_id', optional(number())], + nextAssessmentAt: ['next_assessment_at', optional(string())], + state: ['state', optional(string())], + cancelAtEndOfPeriod: ['cancel_at_end_of_period', optional(boolean())], + accountBalances: [ + 'account_balances', + optional(subscriptionGroupBalancesSchema), + ], + groupType: ['group_type', optional(groupTypeSchema)], + }) ); diff --git a/src/models/listSubscriptionGroupsResponse.ts b/src/models/listSubscriptionGroupsResponse.ts index fce3523..787c2e5 100644 --- a/src/models/listSubscriptionGroupsResponse.ts +++ b/src/models/listSubscriptionGroupsResponse.ts @@ -20,12 +20,13 @@ export interface ListSubscriptionGroupsResponse { [key: string]: unknown; } -export const listSubscriptionGroupsResponseSchema: Schema = expandoObject( - { - subscriptionGroups: [ - 'subscription_groups', - optional(array(lazy(() => listSubscriptionGroupsItemSchema))), - ], - meta: ['meta', optional(lazy(() => listSubscriptionGroupsMetaSchema))], - } +export const listSubscriptionGroupsResponseSchema: Schema = lazy( + () => + expandoObject({ + subscriptionGroups: [ + 'subscription_groups', + optional(array(listSubscriptionGroupsItemSchema)), + ], + meta: ['meta', optional(listSubscriptionGroupsMetaSchema)], + }) ); diff --git a/src/models/mRR.ts b/src/models/mRR.ts index 032c6bd..89691b2 100644 --- a/src/models/mRR.ts +++ b/src/models/mRR.ts @@ -25,11 +25,13 @@ export interface MRR { [key: string]: unknown; } -export const mRRSchema: Schema = expandoObject({ - amountInCents: ['amount_in_cents', optional(bigint())], - amountFormatted: ['amount_formatted', optional(string())], - currency: ['currency', optional(string())], - currencySymbol: ['currency_symbol', optional(string())], - breakouts: ['breakouts', optional(lazy(() => breakoutsSchema))], - atTime: ['at_time', optional(string())], -}); +export const mRRSchema: Schema = lazy(() => + expandoObject({ + amountInCents: ['amount_in_cents', optional(bigint())], + amountFormatted: ['amount_formatted', optional(string())], + currency: ['currency', optional(string())], + currencySymbol: ['currency_symbol', optional(string())], + breakouts: ['breakouts', optional(breakoutsSchema)], + atTime: ['at_time', optional(string())], + }) +); diff --git a/src/models/mRRResponse.ts b/src/models/mRRResponse.ts index bbde6fb..b6d7ed1 100644 --- a/src/models/mRRResponse.ts +++ b/src/models/mRRResponse.ts @@ -12,6 +12,6 @@ export interface MRRResponse { [key: string]: unknown; } -export const mRRResponseSchema: Schema = expandoObject({ - mrr: ['mrr', lazy(() => mRRSchema)], -}); +export const mRRResponseSchema: Schema = lazy(() => + expandoObject({ mrr: ['mrr', mRRSchema] }) +); diff --git a/src/models/metafield.ts b/src/models/metafield.ts index 7d76981..478b1df 100644 --- a/src/models/metafield.ts +++ b/src/models/metafield.ts @@ -25,19 +25,21 @@ export interface Metafield { name?: string; /** Warning: When updating a metafield's scope attribute, all scope attributes must be passed. Partially complete scope attributes will override the existing settings. */ scope?: MetafieldScope; - /** the amount of subscriptions this metafield has been applied to in Chargify */ + /** The amount of subscriptions this metafield has been applied to in Advanced Billing. */ dataCount?: number; - /** Indicates how data should be added to the metafield. For example, a text type is just a string, so a given metafield of this type can have any value attached. On the other hand, dropdown and radio have a set of allowed values that can be input, and appear differently on a Public Signup Page. Defaults to 'text' */ + /** Indicates the type of metafield. A text metafield allows any string value. Dropdown and radio metafields have a set of values that can be selected. Defaults to 'text'. */ inputType?: MetafieldInput; mEnum?: MetafieldEnum | null; [key: string]: unknown; } -export const metafieldSchema: Schema = expandoObject({ - id: ['id', optional(number())], - name: ['name', optional(string())], - scope: ['scope', optional(lazy(() => metafieldScopeSchema))], - dataCount: ['data_count', optional(number())], - inputType: ['input_type', optional(metafieldInputSchema)], - mEnum: ['enum', optional(nullable(metafieldEnumSchema))], -}); +export const metafieldSchema: Schema = lazy(() => + expandoObject({ + id: ['id', optional(number())], + name: ['name', optional(string())], + scope: ['scope', optional(metafieldScopeSchema)], + dataCount: ['data_count', optional(number())], + inputType: ['input_type', optional(metafieldInputSchema)], + mEnum: ['enum', optional(nullable(metafieldEnumSchema))], + }) +); diff --git a/src/models/metafieldScope.ts b/src/models/metafieldScope.ts index 08fd50b..c44d5ab 100644 --- a/src/models/metafieldScope.ts +++ b/src/models/metafieldScope.ts @@ -17,9 +17,9 @@ export interface MetafieldScope { statements?: IncludeOption; /** Include (1) or exclude (0) metafields from the portal. */ portal?: IncludeOption; - /** Include (1) or exclude (0) metafields from being viewable by your ecosystem. */ + /** Include (1) or exclude (0) metafields used in [Embeddable Components](page:development-tools/embeddable-components/overview) from being viewable by your ecosystem. */ publicShow?: IncludeOption; - /** Include (1) or exclude (0) metafields from being edited by your ecosystem. */ + /** Include (1) or exclude (0) metafields used in [Embeddable Components](page:development-tools/embeddable-components/overview) from being editable by your ecosystem. */ publicEdit?: IncludeOption; hosted?: string[]; [key: string]: unknown; diff --git a/src/models/meteredComponent.ts b/src/models/meteredComponent.ts index e3b36eb..3227497 100644 --- a/src/models/meteredComponent.ts +++ b/src/models/meteredComponent.ts @@ -45,7 +45,7 @@ export interface MeteredComponent { pricePoints?: ComponentPricePointItem[]; /** The amount the customer will be charged per unit when the pricing scheme is “per_unit”. For On/Off Components, this is the amount that the customer will be charged when they turn the component on for the subscription. The price can contain up to 8 decimal places. i.e. 1.00 or 0.0012 or 0.00000065 */ unitPrice?: MeteredComponentUnitPrice; - /** A string representing the tax code related to the component type. This is especially important when using the Avalara service to tax based on locale. This attribute has a max length of 10 characters. */ + /** A string representing the tax code related to the component type. This is especially important when using AvaTax to tax based on locale. This attribute has a max length of 25 characters. */ taxCode?: string; /** (Only available on Relationship Invoicing sites) Boolean flag describing if the service date range should show for the component on generated invoices. */ hideDateRangeOnInvoice?: boolean; @@ -59,27 +59,29 @@ export interface MeteredComponent { [key: string]: unknown; } -export const meteredComponentSchema: Schema = expandoObject({ - name: ['name', string()], - unitName: ['unit_name', string()], - description: ['description', optional(string())], - handle: ['handle', optional(string())], - taxable: ['taxable', optional(boolean())], - pricingScheme: ['pricing_scheme', pricingSchemeSchema], - prices: ['prices', optional(array(lazy(() => priceSchema)))], - pricePoints: [ - 'price_points', - optional(array(lazy(() => componentPricePointItemSchema))), - ], - unitPrice: ['unit_price', optional(meteredComponentUnitPriceSchema)], - taxCode: ['tax_code', optional(string())], - hideDateRangeOnInvoice: ['hide_date_range_on_invoice', optional(boolean())], - displayOnHostedPage: ['display_on_hosted_page', optional(boolean())], - allowFractionalQuantities: [ - 'allow_fractional_quantities', - optional(boolean()), - ], - publicSignupPageIds: ['public_signup_page_ids', optional(array(number()))], - interval: ['interval', optional(number())], - intervalUnit: ['interval_unit', optional(nullable(intervalUnitSchema))], -}); +export const meteredComponentSchema: Schema = lazy(() => + expandoObject({ + name: ['name', string()], + unitName: ['unit_name', string()], + description: ['description', optional(string())], + handle: ['handle', optional(string())], + taxable: ['taxable', optional(boolean())], + pricingScheme: ['pricing_scheme', pricingSchemeSchema], + prices: ['prices', optional(array(priceSchema))], + pricePoints: [ + 'price_points', + optional(array(componentPricePointItemSchema)), + ], + unitPrice: ['unit_price', optional(meteredComponentUnitPriceSchema)], + taxCode: ['tax_code', optional(string())], + hideDateRangeOnInvoice: ['hide_date_range_on_invoice', optional(boolean())], + displayOnHostedPage: ['display_on_hosted_page', optional(boolean())], + allowFractionalQuantities: [ + 'allow_fractional_quantities', + optional(boolean()), + ], + publicSignupPageIds: ['public_signup_page_ids', optional(array(number()))], + interval: ['interval', optional(number())], + intervalUnit: ['interval_unit', optional(nullable(intervalUnitSchema))], + }) +); diff --git a/src/models/movement.ts b/src/models/movement.ts index ae807b1..bd68a26 100644 --- a/src/models/movement.ts +++ b/src/models/movement.ts @@ -33,17 +33,16 @@ export interface Movement { [key: string]: unknown; } -export const movementSchema: Schema = expandoObject({ - timestamp: ['timestamp', optional(string())], - amountInCents: ['amount_in_cents', optional(bigint())], - amountFormatted: ['amount_formatted', optional(string())], - description: ['description', optional(string())], - category: ['category', optional(string())], - breakouts: ['breakouts', optional(lazy(() => breakoutsSchema))], - lineItems: [ - 'line_items', - optional(array(lazy(() => movementLineItemSchema))), - ], - subscriptionId: ['subscription_id', optional(number())], - subscriberName: ['subscriber_name', optional(string())], -}); +export const movementSchema: Schema = lazy(() => + expandoObject({ + timestamp: ['timestamp', optional(string())], + amountInCents: ['amount_in_cents', optional(bigint())], + amountFormatted: ['amount_formatted', optional(string())], + description: ['description', optional(string())], + category: ['category', optional(string())], + breakouts: ['breakouts', optional(breakoutsSchema)], + lineItems: ['line_items', optional(array(movementLineItemSchema))], + subscriptionId: ['subscription_id', optional(number())], + subscriberName: ['subscriber_name', optional(string())], + }) +); diff --git a/src/models/movementLineItem.ts b/src/models/movementLineItem.ts index 4eb4c0a..bd8def1 100644 --- a/src/models/movementLineItem.ts +++ b/src/models/movementLineItem.ts @@ -31,17 +31,16 @@ export interface MovementLineItem { [key: string]: unknown; } -export const movementLineItemSchema: Schema = expandoObject({ - productId: ['product_id', optional(number())], - componentId: ['component_id', optional(number())], - pricePointId: ['price_point_id', optional(number())], - name: ['name', optional(string())], - mrr: ['mrr', optional(number())], - mrrMovements: [ - 'mrr_movements', - optional(array(lazy(() => mRRMovementSchema))), - ], - quantity: ['quantity', optional(number())], - prevQuantity: ['prev_quantity', optional(number())], - recurring: ['recurring', optional(boolean())], -}); +export const movementLineItemSchema: Schema = lazy(() => + expandoObject({ + productId: ['product_id', optional(number())], + componentId: ['component_id', optional(number())], + pricePointId: ['price_point_id', optional(number())], + name: ['name', optional(string())], + mrr: ['mrr', optional(number())], + mrrMovements: ['mrr_movements', optional(array(mRRMovementSchema))], + quantity: ['quantity', optional(number())], + prevQuantity: ['prev_quantity', optional(number())], + recurring: ['recurring', optional(boolean())], + }) +); diff --git a/src/models/multiInvoicePayment.ts b/src/models/multiInvoicePayment.ts index dca4576..f0ba6fc 100644 --- a/src/models/multiInvoicePayment.ts +++ b/src/models/multiInvoicePayment.ts @@ -29,14 +29,14 @@ export interface MultiInvoicePayment { [key: string]: unknown; } -export const multiInvoicePaymentSchema: Schema = expandoObject( - { +export const multiInvoicePaymentSchema: Schema = lazy(() => + expandoObject({ transactionId: ['transaction_id', optional(number())], totalAmount: ['total_amount', optional(string())], currencyCode: ['currency_code', optional(string())], applications: [ 'applications', - optional(array(lazy(() => invoicePaymentApplicationSchema))), + optional(array(invoicePaymentApplicationSchema)), ], - } + }) ); diff --git a/src/models/multiInvoicePaymentResponse.ts b/src/models/multiInvoicePaymentResponse.ts index f5e5175..e3773bf 100644 --- a/src/models/multiInvoicePaymentResponse.ts +++ b/src/models/multiInvoicePaymentResponse.ts @@ -15,6 +15,6 @@ export interface MultiInvoicePaymentResponse { [key: string]: unknown; } -export const multiInvoicePaymentResponseSchema: Schema = expandoObject( - { payment: ['payment', lazy(() => multiInvoicePaymentSchema)] } +export const multiInvoicePaymentResponseSchema: Schema = lazy( + () => expandoObject({ payment: ['payment', multiInvoicePaymentSchema] }) ); diff --git a/src/models/offer.ts b/src/models/offer.ts index 20d1b25..55a2e33 100644 --- a/src/models/offer.ts +++ b/src/models/offer.ts @@ -42,30 +42,29 @@ export interface Offer { [key: string]: unknown; } -export const offerSchema: Schema = expandoObject({ - id: ['id', optional(number())], - siteId: ['site_id', optional(number())], - productFamilyId: ['product_family_id', optional(number())], - productId: ['product_id', optional(number())], - productPricePointId: ['product_price_point_id', optional(number())], - productRevisableNumber: ['product_revisable_number', optional(number())], - name: ['name', optional(string())], - handle: ['handle', optional(string())], - description: ['description', optional(nullable(string()))], - createdAt: ['created_at', optional(string())], - updatedAt: ['updated_at', optional(string())], - archivedAt: ['archived_at', optional(nullable(string()))], - offerItems: ['offer_items', optional(array(lazy(() => offerItemSchema)))], - offerDiscounts: [ - 'offer_discounts', - optional(array(lazy(() => offerDiscountSchema))), - ], - productFamilyName: ['product_family_name', optional(string())], - productName: ['product_name', optional(string())], - productPricePointName: ['product_price_point_name', optional(string())], - productPriceInCents: ['product_price_in_cents', optional(bigint())], - offerSignupPages: [ - 'offer_signup_pages', - optional(array(lazy(() => offerSignupPageSchema))), - ], -}); +export const offerSchema: Schema = lazy(() => + expandoObject({ + id: ['id', optional(number())], + siteId: ['site_id', optional(number())], + productFamilyId: ['product_family_id', optional(number())], + productId: ['product_id', optional(number())], + productPricePointId: ['product_price_point_id', optional(number())], + productRevisableNumber: ['product_revisable_number', optional(number())], + name: ['name', optional(string())], + handle: ['handle', optional(string())], + description: ['description', optional(nullable(string()))], + createdAt: ['created_at', optional(string())], + updatedAt: ['updated_at', optional(string())], + archivedAt: ['archived_at', optional(nullable(string()))], + offerItems: ['offer_items', optional(array(offerItemSchema))], + offerDiscounts: ['offer_discounts', optional(array(offerDiscountSchema))], + productFamilyName: ['product_family_name', optional(string())], + productName: ['product_name', optional(string())], + productPricePointName: ['product_price_point_name', optional(string())], + productPriceInCents: ['product_price_in_cents', optional(bigint())], + offerSignupPages: [ + 'offer_signup_pages', + optional(array(offerSignupPageSchema)), + ], + }) +); diff --git a/src/models/offerItem.ts b/src/models/offerItem.ts index 6d4c57e..a4012d6 100644 --- a/src/models/offerItem.ts +++ b/src/models/offerItem.ts @@ -34,18 +34,17 @@ export interface OfferItem { [key: string]: unknown; } -export const offerItemSchema: Schema = expandoObject({ - componentId: ['component_id', optional(number())], - pricePointId: ['price_point_id', optional(number())], - startingQuantity: ['starting_quantity', optional(string())], - editable: ['editable', optional(boolean())], - componentUnitPrice: ['component_unit_price', optional(string())], - componentName: ['component_name', optional(string())], - pricePointName: ['price_point_name', optional(string())], - currencyPrices: [ - 'currency_prices', - optional(array(lazy(() => currencyPriceSchema))), - ], - interval: ['interval', optional(number())], - intervalUnit: ['interval_unit', optional(nullable(intervalUnitSchema))], -}); +export const offerItemSchema: Schema = lazy(() => + expandoObject({ + componentId: ['component_id', optional(number())], + pricePointId: ['price_point_id', optional(number())], + startingQuantity: ['starting_quantity', optional(string())], + editable: ['editable', optional(boolean())], + componentUnitPrice: ['component_unit_price', optional(string())], + componentName: ['component_name', optional(string())], + pricePointName: ['price_point_name', optional(string())], + currencyPrices: ['currency_prices', optional(array(currencyPriceSchema))], + interval: ['interval', optional(number())], + intervalUnit: ['interval_unit', optional(nullable(intervalUnitSchema))], + }) +); diff --git a/src/models/offerResponse.ts b/src/models/offerResponse.ts index 4aa73f7..eb92cc2 100644 --- a/src/models/offerResponse.ts +++ b/src/models/offerResponse.ts @@ -12,6 +12,6 @@ export interface OfferResponse { [key: string]: unknown; } -export const offerResponseSchema: Schema = expandoObject({ - offer: ['offer', optional(lazy(() => offerSchema))], -}); +export const offerResponseSchema: Schema = lazy(() => + expandoObject({ offer: ['offer', optional(offerSchema)] }) +); diff --git a/src/models/onOffComponent.ts b/src/models/onOffComponent.ts index 22b6bb2..43539b9 100644 --- a/src/models/onOffComponent.ts +++ b/src/models/onOffComponent.ts @@ -48,7 +48,7 @@ export interface OnOffComponent { pricePoints?: ComponentPricePointItem[]; /** This is the amount that the customer will be charged when they turn the component on for the subscription. The price can contain up to 8 decimal places. i.e. 1.00 or 0.0012 or 0.00000065 */ unitPrice: OnOffComponentUnitPrice; - /** A string representing the tax code related to the component type. This is especially important when using the Avalara service to tax based on locale. This attribute has a max length of 10 characters. */ + /** A string representing the tax code related to the component type. This is especially important when using AvaTax to tax based on locale. This attribute has a max length of 25 characters. */ taxCode?: string; /** (Only available on Relationship Invoicing sites) Boolean flag describing if the service date range should show for the component on generated invoices. */ hideDateRangeOnInvoice?: boolean; @@ -62,26 +62,28 @@ export interface OnOffComponent { [key: string]: unknown; } -export const onOffComponentSchema: Schema = expandoObject({ - name: ['name', string()], - description: ['description', optional(string())], - handle: ['handle', optional(string())], - taxable: ['taxable', optional(boolean())], - upgradeCharge: ['upgrade_charge', optional(nullable(creditTypeSchema))], - downgradeCredit: ['downgrade_credit', optional(nullable(creditTypeSchema))], - pricePoints: [ - 'price_points', - optional(array(lazy(() => componentPricePointItemSchema))), - ], - unitPrice: ['unit_price', onOffComponentUnitPriceSchema], - taxCode: ['tax_code', optional(string())], - hideDateRangeOnInvoice: ['hide_date_range_on_invoice', optional(boolean())], - displayOnHostedPage: ['display_on_hosted_page', optional(boolean())], - allowFractionalQuantities: [ - 'allow_fractional_quantities', - optional(boolean()), - ], - publicSignupPageIds: ['public_signup_page_ids', optional(array(number()))], - interval: ['interval', optional(number())], - intervalUnit: ['interval_unit', optional(nullable(intervalUnitSchema))], -}); +export const onOffComponentSchema: Schema = lazy(() => + expandoObject({ + name: ['name', string()], + description: ['description', optional(string())], + handle: ['handle', optional(string())], + taxable: ['taxable', optional(boolean())], + upgradeCharge: ['upgrade_charge', optional(nullable(creditTypeSchema))], + downgradeCredit: ['downgrade_credit', optional(nullable(creditTypeSchema))], + pricePoints: [ + 'price_points', + optional(array(componentPricePointItemSchema)), + ], + unitPrice: ['unit_price', onOffComponentUnitPriceSchema], + taxCode: ['tax_code', optional(string())], + hideDateRangeOnInvoice: ['hide_date_range_on_invoice', optional(boolean())], + displayOnHostedPage: ['display_on_hosted_page', optional(boolean())], + allowFractionalQuantities: [ + 'allow_fractional_quantities', + optional(boolean()), + ], + publicSignupPageIds: ['public_signup_page_ids', optional(array(number()))], + interval: ['interval', optional(number())], + intervalUnit: ['interval_unit', optional(nullable(intervalUnitSchema))], + }) +); diff --git a/src/models/overagePricing.ts b/src/models/overagePricing.ts index a24ac9c..38849b7 100644 --- a/src/models/overagePricing.ts +++ b/src/models/overagePricing.ts @@ -15,7 +15,9 @@ export interface OveragePricing { [key: string]: unknown; } -export const overagePricingSchema: Schema = expandoObject({ - pricingScheme: ['pricing_scheme', pricingSchemeSchema], - prices: ['prices', optional(array(lazy(() => priceSchema)))], -}); +export const overagePricingSchema: Schema = lazy(() => + expandoObject({ + pricingScheme: ['pricing_scheme', pricingSchemeSchema], + prices: ['prices', optional(array(priceSchema))], + }) +); diff --git a/src/models/overrideSubscriptionRequest.ts b/src/models/overrideSubscriptionRequest.ts index 6c7aad1..481c065 100644 --- a/src/models/overrideSubscriptionRequest.ts +++ b/src/models/overrideSubscriptionRequest.ts @@ -15,6 +15,9 @@ export interface OverrideSubscriptionRequest { [key: string]: unknown; } -export const overrideSubscriptionRequestSchema: Schema = expandoObject( - { subscription: ['subscription', lazy(() => overrideSubscriptionSchema)] } +export const overrideSubscriptionRequestSchema: Schema = lazy( + () => + expandoObject({ + subscription: ['subscription', overrideSubscriptionSchema], + }) ); diff --git a/src/models/paginatedMetadata.ts b/src/models/paginatedMetadata.ts index a9db361..1d9aaa4 100644 --- a/src/models/paginatedMetadata.ts +++ b/src/models/paginatedMetadata.ts @@ -23,12 +23,12 @@ export interface PaginatedMetadata { [key: string]: unknown; } -export const paginatedMetadataSchema: Schema = expandoObject( - { +export const paginatedMetadataSchema: Schema = lazy(() => + expandoObject({ totalCount: ['total_count', optional(number())], currentPage: ['current_page', optional(number())], totalPages: ['total_pages', optional(number())], perPage: ['per_page', optional(number())], - metadata: ['metadata', optional(array(lazy(() => metadataSchema)))], - } + metadata: ['metadata', optional(array(metadataSchema))], + }) ); diff --git a/src/models/pauseRequest.ts b/src/models/pauseRequest.ts index 1986c29..9bc6544 100644 --- a/src/models/pauseRequest.ts +++ b/src/models/pauseRequest.ts @@ -13,6 +13,6 @@ export interface PauseRequest { [key: string]: unknown; } -export const pauseRequestSchema: Schema = expandoObject({ - hold: ['hold', optional(lazy(() => autoResumeSchema))], -}); +export const pauseRequestSchema: Schema = lazy(() => + expandoObject({ hold: ['hold', optional(autoResumeSchema)] }) +); diff --git a/src/models/paymentProfileAttributes.ts b/src/models/paymentProfileAttributes.ts index cd3e370..a1df2bb 100644 --- a/src/models/paymentProfileAttributes.ts +++ b/src/models/paymentProfileAttributes.ts @@ -6,6 +6,7 @@ import { expandoObject, + lazy, nullable, number, optional, @@ -51,7 +52,7 @@ export interface PaymentProfileAttributes { billingCity?: string; /** (Optional, may be required by your product configuration or gateway settings) The credit card or bank account billing address state (i.e. MA). This value is merely passed through to the payment gateway. This must conform to the [ISO_3166-1](https://en.wikipedia.org/wiki/ISO_3166-1#Current_codes) in order to be valid for tax locale purposes. */ billingState?: string; - /** (Optional, may be required by your product configuration or gateway settings) The credit card or bank account billing address country, required in [ISO_3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) format (i.e. “US”). This value is merely passed through to the payment gateway. Some gateways require country codes in a specific format. Please check your gateway’s documentation. If creating an ACH subscription, only US is supported at this time. */ + /** (Optional, may be required by your product configuration or gateway settings) The credit card or bank account billing address country, required in [ISO_3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) format (i.e. “US”). This value is merely passed through to the payment gateway. Some gateways require country codes in a specific format. Check your gateway’s documentation. If creating an ACH subscription, only US is supported at this time. */ billingCountry?: string; /** (Optional, may be required by your product configuration or gateway settings) The credit card or bank account billing address zip code (i.e. 12345). This value is merely passed through to the payment gateway. */ billingZip?: string; @@ -74,38 +75,39 @@ export interface PaymentProfileAttributes { [key: string]: unknown; } -export const paymentProfileAttributesSchema: Schema = expandoObject( - { - chargifyToken: ['chargify_token', optional(string())], - id: ['id', optional(number())], - paymentType: ['payment_type', optional(paymentTypeSchema)], - firstName: ['first_name', optional(string())], - lastName: ['last_name', optional(string())], - maskedCardNumber: ['masked_card_number', optional(string())], - fullNumber: ['full_number', optional(string())], - cardType: ['card_type', optional(cardTypeSchema)], - expirationMonth: [ - 'expiration_month', - optional(paymentProfileAttributesExpirationMonthSchema), - ], - expirationYear: [ - 'expiration_year', - optional(paymentProfileAttributesExpirationYearSchema), - ], - billingAddress: ['billing_address', optional(string())], - billingAddress2: ['billing_address_2', optional(nullable(string()))], - billingCity: ['billing_city', optional(string())], - billingState: ['billing_state', optional(string())], - billingCountry: ['billing_country', optional(string())], - billingZip: ['billing_zip', optional(string())], - currentVault: ['current_vault', optional(allVaultsSchema)], - vaultToken: ['vault_token', optional(string())], - customerVaultToken: ['customer_vault_token', optional(string())], - customerId: ['customer_id', optional(number())], - paypalEmail: ['paypal_email', optional(string())], - paymentMethodNonce: ['payment_method_nonce', optional(string())], - gatewayHandle: ['gateway_handle', optional(string())], - cvv: ['cvv', optional(string())], - lastFour: ['last_four', optional(string())], - } +export const paymentProfileAttributesSchema: Schema = lazy( + () => + expandoObject({ + chargifyToken: ['chargify_token', optional(string())], + id: ['id', optional(number())], + paymentType: ['payment_type', optional(paymentTypeSchema)], + firstName: ['first_name', optional(string())], + lastName: ['last_name', optional(string())], + maskedCardNumber: ['masked_card_number', optional(string())], + fullNumber: ['full_number', optional(string())], + cardType: ['card_type', optional(cardTypeSchema)], + expirationMonth: [ + 'expiration_month', + optional(paymentProfileAttributesExpirationMonthSchema), + ], + expirationYear: [ + 'expiration_year', + optional(paymentProfileAttributesExpirationYearSchema), + ], + billingAddress: ['billing_address', optional(string())], + billingAddress2: ['billing_address_2', optional(nullable(string()))], + billingCity: ['billing_city', optional(string())], + billingState: ['billing_state', optional(string())], + billingCountry: ['billing_country', optional(string())], + billingZip: ['billing_zip', optional(string())], + currentVault: ['current_vault', optional(allVaultsSchema)], + vaultToken: ['vault_token', optional(string())], + customerVaultToken: ['customer_vault_token', optional(string())], + customerId: ['customer_id', optional(number())], + paypalEmail: ['paypal_email', optional(string())], + paymentMethodNonce: ['payment_method_nonce', optional(string())], + gatewayHandle: ['gateway_handle', optional(string())], + cvv: ['cvv', optional(string())], + lastFour: ['last_four', optional(string())], + }) ); diff --git a/src/models/paymentProfileResponse.ts b/src/models/paymentProfileResponse.ts index 15417c7..b351c51 100644 --- a/src/models/paymentProfileResponse.ts +++ b/src/models/paymentProfileResponse.ts @@ -4,7 +4,7 @@ * This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ). */ -import { expandoObject, Schema } from '../schema.js'; +import { expandoObject, lazy, Schema } from '../schema.js'; import { PaymentProfile, paymentProfileSchema, @@ -15,6 +15,7 @@ export interface PaymentProfileResponse { [key: string]: unknown; } -export const paymentProfileResponseSchema: Schema = expandoObject( - { paymentProfile: ['payment_profile', paymentProfileSchema] } +export const paymentProfileResponseSchema: Schema = lazy( + () => + expandoObject({ paymentProfile: ['payment_profile', paymentProfileSchema] }) ); diff --git a/src/models/prepaidConfigurationResponse.ts b/src/models/prepaidConfigurationResponse.ts index a4443ac..61dd340 100644 --- a/src/models/prepaidConfigurationResponse.ts +++ b/src/models/prepaidConfigurationResponse.ts @@ -15,11 +15,12 @@ export interface PrepaidConfigurationResponse { [key: string]: unknown; } -export const prepaidConfigurationResponseSchema: Schema = expandoObject( - { - prepaidConfiguration: [ - 'prepaid_configuration', - lazy(() => prepaidConfigurationSchema), - ], - } +export const prepaidConfigurationResponseSchema: Schema = lazy( + () => + expandoObject({ + prepaidConfiguration: [ + 'prepaid_configuration', + prepaidConfigurationSchema, + ], + }) ); diff --git a/src/models/prepaidUsage.ts b/src/models/prepaidUsage.ts index 7ffe50c..dc68351 100644 --- a/src/models/prepaidUsage.ts +++ b/src/models/prepaidUsage.ts @@ -31,18 +31,20 @@ export interface PrepaidUsage { [key: string]: unknown; } -export const prepaidUsageSchema: Schema = expandoObject({ - previousUnitBalance: ['previous_unit_balance', string()], - previousOverageUnitBalance: ['previous_overage_unit_balance', string()], - newUnitBalance: ['new_unit_balance', number()], - newOverageUnitBalance: ['new_overage_unit_balance', number()], - usageQuantity: ['usage_quantity', number()], - overageUsageQuantity: ['overage_usage_quantity', number()], - componentId: ['component_id', number()], - componentHandle: ['component_handle', string()], - memo: ['memo', string()], - allocationDetails: [ - 'allocation_details', - array(lazy(() => prepaidUsageAllocationDetailSchema)), - ], -}); +export const prepaidUsageSchema: Schema = lazy(() => + expandoObject({ + previousUnitBalance: ['previous_unit_balance', string()], + previousOverageUnitBalance: ['previous_overage_unit_balance', string()], + newUnitBalance: ['new_unit_balance', number()], + newOverageUnitBalance: ['new_overage_unit_balance', number()], + usageQuantity: ['usage_quantity', number()], + overageUsageQuantity: ['overage_usage_quantity', number()], + componentId: ['component_id', number()], + componentHandle: ['component_handle', string()], + memo: ['memo', string()], + allocationDetails: [ + 'allocation_details', + array(prepaidUsageAllocationDetailSchema), + ], + }) +); diff --git a/src/models/prepaidUsageComponent.ts b/src/models/prepaidUsageComponent.ts index dfd5905..fddaefc 100644 --- a/src/models/prepaidUsageComponent.ts +++ b/src/models/prepaidUsageComponent.ts @@ -60,7 +60,7 @@ export interface PrepaidUsageComponent { pricePoints?: CreatePrepaidUsageComponentPricePoint[]; /** The amount the customer will be charged per unit when the pricing scheme is “per_unit”. For On/Off Components, this is the amount that the customer will be charged when they turn the component on for the subscription. The price can contain up to 8 decimal places. i.e. 1.00 or 0.0012 or 0.00000065 */ unitPrice?: PrepaidUsageComponentUnitPrice; - /** A string representing the tax code related to the component type. This is especially important when using the Avalara service to tax based on locale. This attribute has a max length of 10 characters. */ + /** A string representing the tax code related to the component type. This is especially important when using AvaTax to tax based on locale. This attribute has a max length of 25 characters. */ taxCode?: string; /** (Only available on Relationship Invoicing sites) Boolean flag describing if the service date range should show for the component on generated invoices. */ hideDateRangeOnInvoice?: boolean; @@ -78,40 +78,50 @@ export interface PrepaidUsageComponent { [key: string]: unknown; } -export const prepaidUsageComponentSchema: Schema = expandoObject( - { - name: ['name', string()], - unitName: ['unit_name', string()], - description: ['description', optional(string())], - handle: ['handle', optional(string())], - taxable: ['taxable', optional(boolean())], - pricingScheme: ['pricing_scheme', pricingSchemeSchema], - prices: ['prices', optional(array(lazy(() => priceSchema)))], - upgradeCharge: ['upgrade_charge', optional(nullable(creditTypeSchema))], - downgradeCredit: ['downgrade_credit', optional(nullable(creditTypeSchema))], - pricePoints: [ - 'price_points', - optional(array(lazy(() => createPrepaidUsageComponentPricePointSchema))), - ], - unitPrice: ['unit_price', optional(prepaidUsageComponentUnitPriceSchema)], - taxCode: ['tax_code', optional(string())], - hideDateRangeOnInvoice: ['hide_date_range_on_invoice', optional(boolean())], - overagePricing: ['overage_pricing', lazy(() => overagePricingSchema)], - rolloverPrepaidRemainder: [ - 'rollover_prepaid_remainder', - optional(boolean()), - ], - renewPrepaidAllocation: ['renew_prepaid_allocation', optional(boolean())], - expirationInterval: ['expiration_interval', optional(number())], - expirationIntervalUnit: [ - 'expiration_interval_unit', - optional(nullable(expirationIntervalUnitSchema)), - ], - displayOnHostedPage: ['display_on_hosted_page', optional(boolean())], - allowFractionalQuantities: [ - 'allow_fractional_quantities', - optional(boolean()), - ], - publicSignupPageIds: ['public_signup_page_ids', optional(array(number()))], - } +export const prepaidUsageComponentSchema: Schema = lazy( + () => + expandoObject({ + name: ['name', string()], + unitName: ['unit_name', string()], + description: ['description', optional(string())], + handle: ['handle', optional(string())], + taxable: ['taxable', optional(boolean())], + pricingScheme: ['pricing_scheme', pricingSchemeSchema], + prices: ['prices', optional(array(priceSchema))], + upgradeCharge: ['upgrade_charge', optional(nullable(creditTypeSchema))], + downgradeCredit: [ + 'downgrade_credit', + optional(nullable(creditTypeSchema)), + ], + pricePoints: [ + 'price_points', + optional(array(createPrepaidUsageComponentPricePointSchema)), + ], + unitPrice: ['unit_price', optional(prepaidUsageComponentUnitPriceSchema)], + taxCode: ['tax_code', optional(string())], + hideDateRangeOnInvoice: [ + 'hide_date_range_on_invoice', + optional(boolean()), + ], + overagePricing: ['overage_pricing', overagePricingSchema], + rolloverPrepaidRemainder: [ + 'rollover_prepaid_remainder', + optional(boolean()), + ], + renewPrepaidAllocation: ['renew_prepaid_allocation', optional(boolean())], + expirationInterval: ['expiration_interval', optional(number())], + expirationIntervalUnit: [ + 'expiration_interval_unit', + optional(nullable(expirationIntervalUnitSchema)), + ], + displayOnHostedPage: ['display_on_hosted_page', optional(boolean())], + allowFractionalQuantities: [ + 'allow_fractional_quantities', + optional(boolean()), + ], + publicSignupPageIds: [ + 'public_signup_page_ids', + optional(array(number())), + ], + }) ); diff --git a/src/models/prepaymentResponse.ts b/src/models/prepaymentResponse.ts index 63886e1..bd78c76 100644 --- a/src/models/prepaymentResponse.ts +++ b/src/models/prepaymentResponse.ts @@ -12,6 +12,6 @@ export interface PrepaymentResponse { [key: string]: unknown; } -export const prepaymentResponseSchema: Schema = expandoObject( - { prepayment: ['prepayment', lazy(() => prepaymentSchema)] } +export const prepaymentResponseSchema: Schema = lazy(() => + expandoObject({ prepayment: ['prepayment', prepaymentSchema] }) ); diff --git a/src/models/prepaymentsResponse.ts b/src/models/prepaymentsResponse.ts index c76fd9b..95919ee 100644 --- a/src/models/prepaymentsResponse.ts +++ b/src/models/prepaymentsResponse.ts @@ -12,8 +12,8 @@ export interface PrepaymentsResponse { [key: string]: unknown; } -export const prepaymentsResponseSchema: Schema = expandoObject( - { - prepayments: ['prepayments', optional(array(lazy(() => prepaymentSchema)))], - } +export const prepaymentsResponseSchema: Schema = lazy(() => + expandoObject({ + prepayments: ['prepayments', optional(array(prepaymentSchema))], + }) ); diff --git a/src/models/previewAllocationsRequest.ts b/src/models/previewAllocationsRequest.ts index 77c2205..6cb80a8 100644 --- a/src/models/previewAllocationsRequest.ts +++ b/src/models/previewAllocationsRequest.ts @@ -36,11 +36,15 @@ export interface PreviewAllocationsRequest { [key: string]: unknown; } -export const previewAllocationsRequestSchema: Schema = expandoObject( - { - allocations: ['allocations', array(lazy(() => createAllocationSchema))], - effectiveProrationDate: ['effective_proration_date', optional(string())], - upgradeCharge: ['upgrade_charge', optional(nullable(creditTypeSchema))], - downgradeCredit: ['downgrade_credit', optional(nullable(creditTypeSchema))], - } +export const previewAllocationsRequestSchema: Schema = lazy( + () => + expandoObject({ + allocations: ['allocations', array(createAllocationSchema)], + effectiveProrationDate: ['effective_proration_date', optional(string())], + upgradeCharge: ['upgrade_charge', optional(nullable(creditTypeSchema))], + downgradeCredit: [ + 'downgrade_credit', + optional(nullable(creditTypeSchema)), + ], + }) ); diff --git a/src/models/price.ts b/src/models/price.ts index e38c540..3011321 100644 --- a/src/models/price.ts +++ b/src/models/price.ts @@ -4,7 +4,7 @@ * This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ). */ -import { expandoObject, nullable, optional, Schema } from '../schema.js'; +import { expandoObject, lazy, nullable, optional, Schema } from '../schema.js'; import { PriceEndingQuantity, priceEndingQuantitySchema, @@ -26,11 +26,13 @@ export interface Price { [key: string]: unknown; } -export const priceSchema: Schema = expandoObject({ - startingQuantity: ['starting_quantity', priceStartingQuantitySchema], - endingQuantity: [ - 'ending_quantity', - optional(nullable(priceEndingQuantitySchema)), - ], - unitPrice: ['unit_price', priceUnitPriceSchema], -}); +export const priceSchema: Schema = lazy(() => + expandoObject({ + startingQuantity: ['starting_quantity', priceStartingQuantitySchema], + endingQuantity: [ + 'ending_quantity', + optional(nullable(priceEndingQuantitySchema)), + ], + unitPrice: ['unit_price', priceUnitPriceSchema], + }) +); diff --git a/src/models/product.ts b/src/models/product.ts index 2aaa62d..084b3ce 100644 --- a/src/models/product.ts +++ b/src/models/product.ts @@ -37,7 +37,7 @@ export interface Product { description?: string | null; /** E.g. Internal ID or SKU Number */ accountingCode?: string | null; - /** Deprecated value that can be ignored unless you have legacy hosted pages. For Public Signup Page users, please read this attribute from under the signup page. */ + /** Deprecated value that can be ignored unless you have legacy hosted pages. For Public Signup Page users, read this attribute from under the signup page. */ requestCreditCard?: boolean; /** A numerical interval for the length a subscription to this product will run before it expires. See the description of interval for a description of how this value is coupled with an interval unit to calculate the full interval */ expirationInterval?: number | null; @@ -83,7 +83,7 @@ export interface Product { requireBillingAddress?: boolean; /** A boolean indicating whether a shipping address is required for the customer, especially at signup. */ requireShippingAddress?: boolean; - /** A string representing the tax code related to the product type. This is especially important when using the Avalara service to tax based on locale. This attribute has a max length of 10 characters. */ + /** A string representing the tax code related to the product type. This is especially important when using AvaTax to tax based on locale. This attribute has a max length of 25 characters. */ taxCode?: string | null; defaultProductPricePointId?: number; useSiteExchangeRate?: boolean | null; @@ -94,66 +94,68 @@ export interface Product { [key: string]: unknown; } -export const productSchema: Schema = expandoObject({ - id: ['id', optional(number())], - name: ['name', optional(string())], - handle: ['handle', optional(nullable(string()))], - description: ['description', optional(nullable(string()))], - accountingCode: ['accounting_code', optional(nullable(string()))], - requestCreditCard: ['request_credit_card', optional(boolean())], - expirationInterval: ['expiration_interval', optional(nullable(number()))], - expirationIntervalUnit: [ - 'expiration_interval_unit', - optional(nullable(expirationIntervalUnitSchema)), - ], - createdAt: ['created_at', optional(string())], - updatedAt: ['updated_at', optional(string())], - priceInCents: ['price_in_cents', optional(bigint())], - interval: ['interval', optional(number())], - intervalUnit: ['interval_unit', optional(intervalUnitSchema)], - initialChargeInCents: [ - 'initial_charge_in_cents', - optional(nullable(bigint())), - ], - trialPriceInCents: ['trial_price_in_cents', optional(nullable(bigint()))], - trialInterval: ['trial_interval', optional(nullable(number()))], - trialIntervalUnit: [ - 'trial_interval_unit', - optional(nullable(intervalUnitSchema)), - ], - archivedAt: ['archived_at', optional(nullable(string()))], - requireCreditCard: ['require_credit_card', optional(boolean())], - returnParams: ['return_params', optional(nullable(string()))], - taxable: ['taxable', optional(boolean())], - updateReturnUrl: ['update_return_url', optional(nullable(string()))], - initialChargeAfterTrial: [ - 'initial_charge_after_trial', - optional(nullable(boolean())), - ], - versionNumber: ['version_number', optional(number())], - updateReturnParams: ['update_return_params', optional(nullable(string()))], - productFamily: ['product_family', optional(lazy(() => productFamilySchema))], - publicSignupPages: [ - 'public_signup_pages', - optional(array(lazy(() => publicSignupPageSchema))), - ], - productPricePointName: ['product_price_point_name', optional(string())], - requestBillingAddress: ['request_billing_address', optional(boolean())], - requireBillingAddress: ['require_billing_address', optional(boolean())], - requireShippingAddress: ['require_shipping_address', optional(boolean())], - taxCode: ['tax_code', optional(nullable(string()))], - defaultProductPricePointId: [ - 'default_product_price_point_id', - optional(number()), - ], - useSiteExchangeRate: [ - 'use_site_exchange_rate', - optional(nullable(boolean())), - ], - itemCategory: ['item_category', optional(nullable(string()))], - productPricePointId: ['product_price_point_id', optional(number())], - productPricePointHandle: [ - 'product_price_point_handle', - optional(nullable(string())), - ], -}); +export const productSchema: Schema = lazy(() => + expandoObject({ + id: ['id', optional(number())], + name: ['name', optional(string())], + handle: ['handle', optional(nullable(string()))], + description: ['description', optional(nullable(string()))], + accountingCode: ['accounting_code', optional(nullable(string()))], + requestCreditCard: ['request_credit_card', optional(boolean())], + expirationInterval: ['expiration_interval', optional(nullable(number()))], + expirationIntervalUnit: [ + 'expiration_interval_unit', + optional(nullable(expirationIntervalUnitSchema)), + ], + createdAt: ['created_at', optional(string())], + updatedAt: ['updated_at', optional(string())], + priceInCents: ['price_in_cents', optional(bigint())], + interval: ['interval', optional(number())], + intervalUnit: ['interval_unit', optional(intervalUnitSchema)], + initialChargeInCents: [ + 'initial_charge_in_cents', + optional(nullable(bigint())), + ], + trialPriceInCents: ['trial_price_in_cents', optional(nullable(bigint()))], + trialInterval: ['trial_interval', optional(nullable(number()))], + trialIntervalUnit: [ + 'trial_interval_unit', + optional(nullable(intervalUnitSchema)), + ], + archivedAt: ['archived_at', optional(nullable(string()))], + requireCreditCard: ['require_credit_card', optional(boolean())], + returnParams: ['return_params', optional(nullable(string()))], + taxable: ['taxable', optional(boolean())], + updateReturnUrl: ['update_return_url', optional(nullable(string()))], + initialChargeAfterTrial: [ + 'initial_charge_after_trial', + optional(nullable(boolean())), + ], + versionNumber: ['version_number', optional(number())], + updateReturnParams: ['update_return_params', optional(nullable(string()))], + productFamily: ['product_family', optional(productFamilySchema)], + publicSignupPages: [ + 'public_signup_pages', + optional(array(publicSignupPageSchema)), + ], + productPricePointName: ['product_price_point_name', optional(string())], + requestBillingAddress: ['request_billing_address', optional(boolean())], + requireBillingAddress: ['require_billing_address', optional(boolean())], + requireShippingAddress: ['require_shipping_address', optional(boolean())], + taxCode: ['tax_code', optional(nullable(string()))], + defaultProductPricePointId: [ + 'default_product_price_point_id', + optional(number()), + ], + useSiteExchangeRate: [ + 'use_site_exchange_rate', + optional(nullable(boolean())), + ], + itemCategory: ['item_category', optional(nullable(string()))], + productPricePointId: ['product_price_point_id', optional(number())], + productPricePointHandle: [ + 'product_price_point_handle', + optional(nullable(string())), + ], + }) +); diff --git a/src/models/productFamilyResponse.ts b/src/models/productFamilyResponse.ts index 7846703..adaa0ed 100644 --- a/src/models/productFamilyResponse.ts +++ b/src/models/productFamilyResponse.ts @@ -12,11 +12,9 @@ export interface ProductFamilyResponse { [key: string]: unknown; } -export const productFamilyResponseSchema: Schema = expandoObject( - { - productFamily: [ - 'product_family', - optional(lazy(() => productFamilySchema)), - ], - } +export const productFamilyResponseSchema: Schema = lazy( + () => + expandoObject({ + productFamily: ['product_family', optional(productFamilySchema)], + }) ); diff --git a/src/models/productPricePoint.ts b/src/models/productPricePoint.ts index 2e68bf2..7ffca18 100644 --- a/src/models/productPricePoint.ts +++ b/src/models/productPricePoint.ts @@ -23,6 +23,7 @@ import { } from './expirationIntervalUnit.js'; import { IntervalUnit, intervalUnitSchema } from './intervalUnit.js'; import { PricePointType, pricePointTypeSchema } from './pricePointType.js'; +import { TrialType, trialTypeSchema } from './trialType.js'; export interface ProductPricePoint { id?: number; @@ -42,7 +43,8 @@ export interface ProductPricePoint { trialInterval?: number | null; /** A string representing the trial interval unit for this product price point, either month or day */ trialIntervalUnit?: IntervalUnit | null; - trialType?: string; + /** Indicates how a trial is handled when the trail period ends and there is no credit card on file. For `no_obligation`, the subscription transitions to a Trial Ended state. Maxio will not send any emails or statements. For `payment_expected`, the subscription transitions to a Past Due state. Maxio will send normal dunning emails and statements according to your other settings. */ + trialType?: TrialType | null; /** reserved for future use */ introductoryOffer?: boolean | null; /** The product price point initial charge, in integer cents */ @@ -73,8 +75,8 @@ export interface ProductPricePoint { [key: string]: unknown; } -export const productPricePointSchema: Schema = expandoObject( - { +export const productPricePointSchema: Schema = lazy(() => + expandoObject({ id: ['id', optional(number())], name: ['name', optional(string())], handle: ['handle', optional(nullable(string()))], @@ -87,7 +89,7 @@ export const productPricePointSchema: Schema = expandoObject( 'trial_interval_unit', optional(nullable(intervalUnitSchema)), ], - trialType: ['trial_type', optional(string())], + trialType: ['trial_type', optional(nullable(trialTypeSchema))], introductoryOffer: ['introductory_offer', optional(nullable(boolean()))], initialChargeInCents: [ 'initial_charge_in_cents', @@ -110,9 +112,6 @@ export const productPricePointSchema: Schema = expandoObject( type: ['type', optional(pricePointTypeSchema)], taxIncluded: ['tax_included', optional(boolean())], subscriptionId: ['subscription_id', optional(nullable(number()))], - currencyPrices: [ - 'currency_prices', - optional(array(lazy(() => currencyPriceSchema))), - ], - } + currencyPrices: ['currency_prices', optional(array(currencyPriceSchema))], + }) ); diff --git a/src/models/productPricePointResponse.ts b/src/models/productPricePointResponse.ts index c105bd4..16bf630 100644 --- a/src/models/productPricePointResponse.ts +++ b/src/models/productPricePointResponse.ts @@ -15,6 +15,6 @@ export interface ProductPricePointResponse { [key: string]: unknown; } -export const productPricePointResponseSchema: Schema = expandoObject( - { pricePoint: ['price_point', lazy(() => productPricePointSchema)] } +export const productPricePointResponseSchema: Schema = lazy( + () => expandoObject({ pricePoint: ['price_point', productPricePointSchema] }) ); diff --git a/src/models/productResponse.ts b/src/models/productResponse.ts index c46602a..f32f155 100644 --- a/src/models/productResponse.ts +++ b/src/models/productResponse.ts @@ -12,6 +12,6 @@ export interface ProductResponse { [key: string]: unknown; } -export const productResponseSchema: Schema = expandoObject({ - product: ['product', lazy(() => productSchema)], -}); +export const productResponseSchema: Schema = lazy(() => + expandoObject({ product: ['product', productSchema] }) +); diff --git a/src/models/proformaError.ts b/src/models/proformaError.ts index 47c29bd..17512b0 100644 --- a/src/models/proformaError.ts +++ b/src/models/proformaError.ts @@ -13,6 +13,8 @@ export interface ProformaError { [key: string]: unknown; } -export const proformaErrorSchema: Schema = expandoObject({ - subscription: ['subscription', optional(lazy(() => baseStringErrorSchema))], -}); +export const proformaErrorSchema: Schema = lazy(() => + expandoObject({ + subscription: ['subscription', optional(baseStringErrorSchema)], + }) +); diff --git a/src/models/proformaInvoice.ts b/src/models/proformaInvoice.ts index e6768aa..0b486e7 100644 --- a/src/models/proformaInvoice.ts +++ b/src/models/proformaInvoice.ts @@ -107,62 +107,46 @@ export interface ProformaInvoice { [key: string]: unknown; } -export const proformaInvoiceSchema: Schema = expandoObject({ - uid: ['uid', optional(string())], - siteId: ['site_id', optional(number())], - customerId: ['customer_id', optional(nullable(number()))], - subscriptionId: ['subscription_id', optional(nullable(number()))], - number: ['number', optional(nullable(number()))], - sequenceNumber: ['sequence_number', optional(nullable(number()))], - createdAt: ['created_at', optional(string())], - deliveryDate: ['delivery_date', optional(string())], - status: ['status', optional(proformaInvoiceStatusSchema)], - collectionMethod: ['collection_method', optional(collectionMethodSchema)], - paymentInstructions: ['payment_instructions', optional(string())], - currency: ['currency', optional(string())], - consolidationLevel: [ - 'consolidation_level', - optional(invoiceConsolidationLevelSchema), - ], - productName: ['product_name', optional(string())], - productFamilyName: ['product_family_name', optional(string())], - role: ['role', optional(proformaInvoiceRoleSchema)], - seller: ['seller', optional(lazy(() => invoiceSellerSchema))], - customer: ['customer', optional(lazy(() => invoiceCustomerSchema))], - memo: ['memo', optional(string())], - billingAddress: [ - 'billing_address', - optional(lazy(() => invoiceAddressSchema)), - ], - shippingAddress: [ - 'shipping_address', - optional(lazy(() => invoiceAddressSchema)), - ], - subtotalAmount: ['subtotal_amount', optional(string())], - discountAmount: ['discount_amount', optional(string())], - taxAmount: ['tax_amount', optional(string())], - totalAmount: ['total_amount', optional(string())], - creditAmount: ['credit_amount', optional(string())], - paidAmount: ['paid_amount', optional(string())], - refundAmount: ['refund_amount', optional(string())], - dueAmount: ['due_amount', optional(string())], - lineItems: ['line_items', optional(array(lazy(() => invoiceLineItemSchema)))], - discounts: [ - 'discounts', - optional(array(lazy(() => proformaInvoiceDiscountSchema))), - ], - taxes: ['taxes', optional(array(lazy(() => proformaInvoiceTaxSchema)))], - credits: [ - 'credits', - optional(array(lazy(() => proformaInvoiceCreditSchema))), - ], - payments: [ - 'payments', - optional(array(lazy(() => proformaInvoicePaymentSchema))), - ], - customFields: [ - 'custom_fields', - optional(array(lazy(() => invoiceCustomFieldSchema))), - ], - publicUrl: ['public_url', optional(nullable(string()))], -}); +export const proformaInvoiceSchema: Schema = lazy(() => + expandoObject({ + uid: ['uid', optional(string())], + siteId: ['site_id', optional(number())], + customerId: ['customer_id', optional(nullable(number()))], + subscriptionId: ['subscription_id', optional(nullable(number()))], + number: ['number', optional(nullable(number()))], + sequenceNumber: ['sequence_number', optional(nullable(number()))], + createdAt: ['created_at', optional(string())], + deliveryDate: ['delivery_date', optional(string())], + status: ['status', optional(proformaInvoiceStatusSchema)], + collectionMethod: ['collection_method', optional(collectionMethodSchema)], + paymentInstructions: ['payment_instructions', optional(string())], + currency: ['currency', optional(string())], + consolidationLevel: [ + 'consolidation_level', + optional(invoiceConsolidationLevelSchema), + ], + productName: ['product_name', optional(string())], + productFamilyName: ['product_family_name', optional(string())], + role: ['role', optional(proformaInvoiceRoleSchema)], + seller: ['seller', optional(invoiceSellerSchema)], + customer: ['customer', optional(invoiceCustomerSchema)], + memo: ['memo', optional(string())], + billingAddress: ['billing_address', optional(invoiceAddressSchema)], + shippingAddress: ['shipping_address', optional(invoiceAddressSchema)], + subtotalAmount: ['subtotal_amount', optional(string())], + discountAmount: ['discount_amount', optional(string())], + taxAmount: ['tax_amount', optional(string())], + totalAmount: ['total_amount', optional(string())], + creditAmount: ['credit_amount', optional(string())], + paidAmount: ['paid_amount', optional(string())], + refundAmount: ['refund_amount', optional(string())], + dueAmount: ['due_amount', optional(string())], + lineItems: ['line_items', optional(array(invoiceLineItemSchema))], + discounts: ['discounts', optional(array(proformaInvoiceDiscountSchema))], + taxes: ['taxes', optional(array(proformaInvoiceTaxSchema))], + credits: ['credits', optional(array(proformaInvoiceCreditSchema))], + payments: ['payments', optional(array(proformaInvoicePaymentSchema))], + customFields: ['custom_fields', optional(array(invoiceCustomFieldSchema))], + publicUrl: ['public_url', optional(nullable(string()))], + }) +); diff --git a/src/models/proformaInvoiceDiscount.ts b/src/models/proformaInvoiceDiscount.ts index c60edbe..2755ef7 100644 --- a/src/models/proformaInvoiceDiscount.ts +++ b/src/models/proformaInvoiceDiscount.ts @@ -37,21 +37,22 @@ export interface ProformaInvoiceDiscount { [key: string]: unknown; } -export const proformaInvoiceDiscountSchema: Schema = expandoObject( - { - uid: ['uid', optional(string())], - title: ['title', optional(string())], - code: ['code', optional(string())], - sourceType: [ - 'source_type', - optional(proformaInvoiceDiscountSourceTypeSchema), - ], - discountType: ['discount_type', optional(invoiceDiscountTypeSchema)], - eligibleAmount: ['eligible_amount', optional(string())], - discountAmount: ['discount_amount', optional(string())], - lineItemBreakouts: [ - 'line_item_breakouts', - optional(array(lazy(() => invoiceDiscountBreakoutSchema))), - ], - } +export const proformaInvoiceDiscountSchema: Schema = lazy( + () => + expandoObject({ + uid: ['uid', optional(string())], + title: ['title', optional(string())], + code: ['code', optional(string())], + sourceType: [ + 'source_type', + optional(proformaInvoiceDiscountSourceTypeSchema), + ], + discountType: ['discount_type', optional(invoiceDiscountTypeSchema)], + eligibleAmount: ['eligible_amount', optional(string())], + discountAmount: ['discount_amount', optional(string())], + lineItemBreakouts: [ + 'line_item_breakouts', + optional(array(invoiceDiscountBreakoutSchema)), + ], + }) ); diff --git a/src/models/proformaInvoiceIssued.ts b/src/models/proformaInvoiceIssued.ts index 313385b..5c5c075 100644 --- a/src/models/proformaInvoiceIssued.ts +++ b/src/models/proformaInvoiceIssued.ts @@ -25,21 +25,19 @@ export interface ProformaInvoiceIssued { [key: string]: unknown; } -export const proformaInvoiceIssuedSchema: Schema = expandoObject( - { - uid: ['uid', string()], - number: ['number', string()], - role: ['role', string()], - deliveryDate: ['delivery_date', string()], - createdAt: ['created_at', string()], - dueAmount: ['due_amount', string()], - paidAmount: ['paid_amount', string()], - taxAmount: ['tax_amount', string()], - totalAmount: ['total_amount', string()], - productName: ['product_name', string()], - lineItems: [ - 'line_items', - array(lazy(() => invoiceLineItemEventDataSchema)), - ], - } +export const proformaInvoiceIssuedSchema: Schema = lazy( + () => + expandoObject({ + uid: ['uid', string()], + number: ['number', string()], + role: ['role', string()], + deliveryDate: ['delivery_date', string()], + createdAt: ['created_at', string()], + dueAmount: ['due_amount', string()], + paidAmount: ['paid_amount', string()], + taxAmount: ['tax_amount', string()], + totalAmount: ['total_amount', string()], + productName: ['product_name', string()], + lineItems: ['line_items', array(invoiceLineItemEventDataSchema)], + }) ); diff --git a/src/models/proformaInvoiceTax.ts b/src/models/proformaInvoiceTax.ts index e67300d..58370fd 100644 --- a/src/models/proformaInvoiceTax.ts +++ b/src/models/proformaInvoiceTax.ts @@ -32,8 +32,8 @@ export interface ProformaInvoiceTax { [key: string]: unknown; } -export const proformaInvoiceTaxSchema: Schema = expandoObject( - { +export const proformaInvoiceTaxSchema: Schema = lazy(() => + expandoObject({ uid: ['uid', optional(string())], title: ['title', optional(string())], sourceType: ['source_type', optional(proformaInvoiceTaxSourceTypeSchema)], @@ -42,7 +42,7 @@ export const proformaInvoiceTaxSchema: Schema = expandoObjec taxAmount: ['tax_amount', optional(string())], lineItemBreakouts: [ 'line_item_breakouts', - optional(array(lazy(() => invoiceTaxBreakoutSchema))), + optional(array(invoiceTaxBreakoutSchema)), ], - } + }) ); diff --git a/src/models/quantityBasedComponent.ts b/src/models/quantityBasedComponent.ts index 2e25275..9fa488b 100644 --- a/src/models/quantityBasedComponent.ts +++ b/src/models/quantityBasedComponent.ts @@ -56,7 +56,7 @@ export interface QuantityBasedComponent { pricePoints?: ComponentPricePointItem[]; /** The amount the customer will be charged per unit when the pricing scheme is “per_unit”. For On/Off Components, this is the amount that the customer will be charged when they turn the component on for the subscription. The price can contain up to 8 decimal places. i.e. 1.00 or 0.0012 or 0.00000065 */ unitPrice?: QuantityBasedComponentUnitPrice; - /** A string representing the tax code related to the component type. This is especially important when using the Avalara service to tax based on locale. This attribute has a max length of 10 characters. */ + /** A string representing the tax code related to the component type. This is especially important when using AvaTax to tax based on locale. This attribute has a max length of 25 characters. */ taxCode?: string; /** (Only available on Relationship Invoicing sites) Boolean flag describing if the service date range should show for the component on generated invoices. */ hideDateRangeOnInvoice?: boolean; @@ -71,32 +71,45 @@ export interface QuantityBasedComponent { [key: string]: unknown; } -export const quantityBasedComponentSchema: Schema = expandoObject( - { - name: ['name', string()], - unitName: ['unit_name', string()], - description: ['description', optional(string())], - handle: ['handle', optional(string())], - taxable: ['taxable', optional(boolean())], - pricingScheme: ['pricing_scheme', pricingSchemeSchema], - prices: ['prices', optional(array(lazy(() => priceSchema)))], - upgradeCharge: ['upgrade_charge', optional(nullable(creditTypeSchema))], - downgradeCredit: ['downgrade_credit', optional(nullable(creditTypeSchema))], - pricePoints: [ - 'price_points', - optional(array(lazy(() => componentPricePointItemSchema))), - ], - unitPrice: ['unit_price', optional(quantityBasedComponentUnitPriceSchema)], - taxCode: ['tax_code', optional(string())], - hideDateRangeOnInvoice: ['hide_date_range_on_invoice', optional(boolean())], - recurring: ['recurring', optional(boolean())], - displayOnHostedPage: ['display_on_hosted_page', optional(boolean())], - allowFractionalQuantities: [ - 'allow_fractional_quantities', - optional(boolean()), - ], - publicSignupPageIds: ['public_signup_page_ids', optional(array(number()))], - interval: ['interval', optional(number())], - intervalUnit: ['interval_unit', optional(nullable(intervalUnitSchema))], - } +export const quantityBasedComponentSchema: Schema = lazy( + () => + expandoObject({ + name: ['name', string()], + unitName: ['unit_name', string()], + description: ['description', optional(string())], + handle: ['handle', optional(string())], + taxable: ['taxable', optional(boolean())], + pricingScheme: ['pricing_scheme', pricingSchemeSchema], + prices: ['prices', optional(array(priceSchema))], + upgradeCharge: ['upgrade_charge', optional(nullable(creditTypeSchema))], + downgradeCredit: [ + 'downgrade_credit', + optional(nullable(creditTypeSchema)), + ], + pricePoints: [ + 'price_points', + optional(array(componentPricePointItemSchema)), + ], + unitPrice: [ + 'unit_price', + optional(quantityBasedComponentUnitPriceSchema), + ], + taxCode: ['tax_code', optional(string())], + hideDateRangeOnInvoice: [ + 'hide_date_range_on_invoice', + optional(boolean()), + ], + recurring: ['recurring', optional(boolean())], + displayOnHostedPage: ['display_on_hosted_page', optional(boolean())], + allowFractionalQuantities: [ + 'allow_fractional_quantities', + optional(boolean()), + ], + publicSignupPageIds: [ + 'public_signup_page_ids', + optional(array(number())), + ], + interval: ['interval', optional(number())], + intervalUnit: ['interval_unit', optional(nullable(intervalUnitSchema))], + }) ); diff --git a/src/models/reactivateSubscriptionRequest.ts b/src/models/reactivateSubscriptionRequest.ts index 1baa60a..1aac50c 100644 --- a/src/models/reactivateSubscriptionRequest.ts +++ b/src/models/reactivateSubscriptionRequest.ts @@ -37,19 +37,20 @@ export interface ReactivateSubscriptionRequest { [key: string]: unknown; } -export const reactivateSubscriptionRequestSchema: Schema = expandoObject( - { - calendarBilling: [ - 'calendar_billing', - optional(lazy(() => reactivationBillingSchema)), - ], - includeTrial: ['include_trial', optional(boolean())], - preserveBalance: ['preserve_balance', optional(boolean())], - couponCode: ['coupon_code', optional(string())], - useCreditsAndPrepayments: [ - 'use_credits_and_prepayments', - optional(boolean()), - ], - resume: ['resume', optional(reactivateSubscriptionRequestResumeSchema)], - } +export const reactivateSubscriptionRequestSchema: Schema = lazy( + () => + expandoObject({ + calendarBilling: [ + 'calendar_billing', + optional(reactivationBillingSchema), + ], + includeTrial: ['include_trial', optional(boolean())], + preserveBalance: ['preserve_balance', optional(boolean())], + couponCode: ['coupon_code', optional(string())], + useCreditsAndPrepayments: [ + 'use_credits_and_prepayments', + optional(boolean()), + ], + resume: ['resume', optional(reactivateSubscriptionRequestResumeSchema)], + }) ); diff --git a/src/models/reasonCodeResponse.ts b/src/models/reasonCodeResponse.ts index 6b51f49..a1126a4 100644 --- a/src/models/reasonCodeResponse.ts +++ b/src/models/reasonCodeResponse.ts @@ -12,6 +12,6 @@ export interface ReasonCodeResponse { [key: string]: unknown; } -export const reasonCodeResponseSchema: Schema = expandoObject( - { reasonCode: ['reason_code', lazy(() => reasonCodeSchema)] } +export const reasonCodeResponseSchema: Schema = lazy(() => + expandoObject({ reasonCode: ['reason_code', reasonCodeSchema] }) ); diff --git a/src/models/recordPaymentRequest.ts b/src/models/recordPaymentRequest.ts index cac96e6..7caf68b 100644 --- a/src/models/recordPaymentRequest.ts +++ b/src/models/recordPaymentRequest.ts @@ -12,6 +12,6 @@ export interface RecordPaymentRequest { [key: string]: unknown; } -export const recordPaymentRequestSchema: Schema = expandoObject( - { payment: ['payment', lazy(() => createPaymentSchema)] } +export const recordPaymentRequestSchema: Schema = lazy( + () => expandoObject({ payment: ['payment', createPaymentSchema] }) ); diff --git a/src/models/recordPaymentResponse.ts b/src/models/recordPaymentResponse.ts index cd2df6d..5e3cb1f 100644 --- a/src/models/recordPaymentResponse.ts +++ b/src/models/recordPaymentResponse.ts @@ -24,15 +24,10 @@ export interface RecordPaymentResponse { [key: string]: unknown; } -export const recordPaymentResponseSchema: Schema = expandoObject( - { - paidInvoices: [ - 'paid_invoices', - optional(array(lazy(() => paidInvoiceSchema))), - ], - prepayment: [ - 'prepayment', - optional(nullable(lazy(() => invoicePrePaymentSchema))), - ], - } +export const recordPaymentResponseSchema: Schema = lazy( + () => + expandoObject({ + paidInvoices: ['paid_invoices', optional(array(paidInvoiceSchema))], + prepayment: ['prepayment', optional(nullable(invoicePrePaymentSchema))], + }) ); diff --git a/src/models/referralValidationResponse.ts b/src/models/referralValidationResponse.ts index 4a1b761..e9d65fc 100644 --- a/src/models/referralValidationResponse.ts +++ b/src/models/referralValidationResponse.ts @@ -12,6 +12,9 @@ export interface ReferralValidationResponse { [key: string]: unknown; } -export const referralValidationResponseSchema: Schema = expandoObject( - { referralCode: ['referral_code', optional(lazy(() => referralCodeSchema))] } +export const referralValidationResponseSchema: Schema = lazy( + () => + expandoObject({ + referralCode: ['referral_code', optional(referralCodeSchema)], + }) ); diff --git a/src/models/refundConsolidatedInvoice.ts b/src/models/refundConsolidatedInvoice.ts index 85b6f7d..26556b8 100644 --- a/src/models/refundConsolidatedInvoice.ts +++ b/src/models/refundConsolidatedInvoice.ts @@ -7,6 +7,7 @@ import { boolean, expandoObject, + lazy, number, optional, Schema, @@ -34,13 +35,14 @@ export interface RefundConsolidatedInvoice { [key: string]: unknown; } -export const refundConsolidatedInvoiceSchema: Schema = expandoObject( - { - memo: ['memo', string()], - paymentId: ['payment_id', number()], - segmentUids: ['segment_uids', refundConsolidatedInvoiceSegmentUidsSchema], - external: ['external', optional(boolean())], - applyCredit: ['apply_credit', optional(boolean())], - amount: ['amount', optional(string())], - } +export const refundConsolidatedInvoiceSchema: Schema = lazy( + () => + expandoObject({ + memo: ['memo', string()], + paymentId: ['payment_id', number()], + segmentUids: ['segment_uids', refundConsolidatedInvoiceSegmentUidsSchema], + external: ['external', optional(boolean())], + applyCredit: ['apply_credit', optional(boolean())], + amount: ['amount', optional(string())], + }) ); diff --git a/src/models/refundInvoiceEvent.ts b/src/models/refundInvoiceEvent.ts index 9615ee7..b5db965 100644 --- a/src/models/refundInvoiceEvent.ts +++ b/src/models/refundInvoiceEvent.ts @@ -25,12 +25,12 @@ export interface RefundInvoiceEvent { [key: string]: unknown; } -export const refundInvoiceEventSchema: Schema = expandoObject( - { +export const refundInvoiceEventSchema: Schema = lazy(() => + expandoObject({ id: ['id', bigint()], timestamp: ['timestamp', string()], - invoice: ['invoice', lazy(() => invoiceSchema)], + invoice: ['invoice', invoiceSchema], eventType: ['event_type', invoiceEventTypeSchema], - eventData: ['event_data', lazy(() => refundInvoiceEventDataSchema)], - } + eventData: ['event_data', refundInvoiceEventDataSchema], + }) ); diff --git a/src/models/refundInvoiceEventData.ts b/src/models/refundInvoiceEventData.ts index 71c8e71..0d22ddd 100644 --- a/src/models/refundInvoiceEventData.ts +++ b/src/models/refundInvoiceEventData.ts @@ -48,22 +48,20 @@ export interface RefundInvoiceEventData { [key: string]: unknown; } -export const refundInvoiceEventDataSchema: Schema = expandoObject( - { - applyCredit: ['apply_credit', boolean()], - consolidationLevel: [ - 'consolidation_level', - optional(invoiceConsolidationLevelSchema), - ], - creditNoteAttributes: [ - 'credit_note_attributes', - lazy(() => creditNoteSchema), - ], - memo: ['memo', optional(string())], - originalAmount: ['original_amount', optional(string())], - paymentId: ['payment_id', number()], - refundAmount: ['refund_amount', string()], - refundId: ['refund_id', number()], - transactionTime: ['transaction_time', string()], - } +export const refundInvoiceEventDataSchema: Schema = lazy( + () => + expandoObject({ + applyCredit: ['apply_credit', boolean()], + consolidationLevel: [ + 'consolidation_level', + optional(invoiceConsolidationLevelSchema), + ], + creditNoteAttributes: ['credit_note_attributes', creditNoteSchema], + memo: ['memo', optional(string())], + originalAmount: ['original_amount', optional(string())], + paymentId: ['payment_id', number()], + refundAmount: ['refund_amount', string()], + refundId: ['refund_id', number()], + transactionTime: ['transaction_time', string()], + }) ); diff --git a/src/models/refundInvoiceRequest.ts b/src/models/refundInvoiceRequest.ts index 51a125d..5eefcaf 100644 --- a/src/models/refundInvoiceRequest.ts +++ b/src/models/refundInvoiceRequest.ts @@ -4,7 +4,7 @@ * This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ). */ -import { expandoObject, Schema } from '../schema.js'; +import { expandoObject, lazy, Schema } from '../schema.js'; import { RefundInvoiceRequestRefund, refundInvoiceRequestRefundSchema, @@ -15,6 +15,6 @@ export interface RefundInvoiceRequest { [key: string]: unknown; } -export const refundInvoiceRequestSchema: Schema = expandoObject( - { refund: ['refund', refundInvoiceRequestRefundSchema] } +export const refundInvoiceRequestSchema: Schema = lazy( + () => expandoObject({ refund: ['refund', refundInvoiceRequestRefundSchema] }) ); diff --git a/src/models/refundPrepayment.ts b/src/models/refundPrepayment.ts index 83402d8..b3894a3 100644 --- a/src/models/refundPrepayment.ts +++ b/src/models/refundPrepayment.ts @@ -8,6 +8,7 @@ import { bigint, boolean, expandoObject, + lazy, nullable, optional, Schema, @@ -29,9 +30,11 @@ export interface RefundPrepayment { [key: string]: unknown; } -export const refundPrepaymentSchema: Schema = expandoObject({ - amountInCents: ['amount_in_cents', nullable(bigint())], - amount: ['amount', refundPrepaymentAmountSchema], - memo: ['memo', string()], - external: ['external', optional(boolean())], -}); +export const refundPrepaymentSchema: Schema = lazy(() => + expandoObject({ + amountInCents: ['amount_in_cents', nullable(bigint())], + amount: ['amount', refundPrepaymentAmountSchema], + memo: ['memo', string()], + external: ['external', optional(boolean())], + }) +); diff --git a/src/models/refundPrepaymentBaseRefundError.ts b/src/models/refundPrepaymentBaseRefundError.ts index e2008d2..22a8b49 100644 --- a/src/models/refundPrepaymentBaseRefundError.ts +++ b/src/models/refundPrepaymentBaseRefundError.ts @@ -12,6 +12,6 @@ export interface RefundPrepaymentBaseRefundError { [key: string]: unknown; } -export const refundPrepaymentBaseRefundErrorSchema: Schema = expandoObject( - { refund: ['refund', optional(lazy(() => baseRefundErrorSchema))] } +export const refundPrepaymentBaseRefundErrorSchema: Schema = lazy( + () => expandoObject({ refund: ['refund', optional(baseRefundErrorSchema)] }) ); diff --git a/src/models/refundPrepaymentRequest.ts b/src/models/refundPrepaymentRequest.ts index 812d796..2cbbb28 100644 --- a/src/models/refundPrepaymentRequest.ts +++ b/src/models/refundPrepaymentRequest.ts @@ -15,6 +15,6 @@ export interface RefundPrepaymentRequest { [key: string]: unknown; } -export const refundPrepaymentRequestSchema: Schema = expandoObject( - { refund: ['refund', lazy(() => refundPrepaymentSchema)] } +export const refundPrepaymentRequestSchema: Schema = lazy( + () => expandoObject({ refund: ['refund', refundPrepaymentSchema] }) ); diff --git a/src/models/removePaymentEvent.ts b/src/models/removePaymentEvent.ts index 8f43057..5cd1ffb 100644 --- a/src/models/removePaymentEvent.ts +++ b/src/models/removePaymentEvent.ts @@ -25,12 +25,12 @@ export interface RemovePaymentEvent { [key: string]: unknown; } -export const removePaymentEventSchema: Schema = expandoObject( - { +export const removePaymentEventSchema: Schema = lazy(() => + expandoObject({ id: ['id', bigint()], timestamp: ['timestamp', string()], - invoice: ['invoice', lazy(() => invoiceSchema)], + invoice: ['invoice', invoiceSchema], eventType: ['event_type', invoiceEventTypeSchema], - eventData: ['event_data', lazy(() => removePaymentEventDataSchema)], - } + eventData: ['event_data', removePaymentEventDataSchema], + }) ); diff --git a/src/models/removePaymentEventData.ts b/src/models/removePaymentEventData.ts index 1d7cd03..0ee305d 100644 --- a/src/models/removePaymentEventData.ts +++ b/src/models/removePaymentEventData.ts @@ -7,6 +7,7 @@ import { boolean, expandoObject, + lazy, number, optional, Schema, @@ -36,14 +37,15 @@ export interface RemovePaymentEventData { [key: string]: unknown; } -export const removePaymentEventDataSchema: Schema = expandoObject( - { - transactionId: ['transaction_id', number()], - memo: ['memo', string()], - originalAmount: ['original_amount', optional(string())], - appliedAmount: ['applied_amount', string()], - transactionTime: ['transaction_time', string()], - paymentMethod: ['payment_method', invoiceEventPaymentSchema], - prepayment: ['prepayment', boolean()], - } +export const removePaymentEventDataSchema: Schema = lazy( + () => + expandoObject({ + transactionId: ['transaction_id', number()], + memo: ['memo', string()], + originalAmount: ['original_amount', optional(string())], + appliedAmount: ['applied_amount', string()], + transactionTime: ['transaction_time', string()], + paymentMethod: ['payment_method', invoiceEventPaymentSchema], + prepayment: ['prepayment', boolean()], + }) ); diff --git a/src/models/renewalPreview.ts b/src/models/renewalPreview.ts index 32012ec..8437625 100644 --- a/src/models/renewalPreview.ts +++ b/src/models/renewalPreview.ts @@ -41,17 +41,16 @@ export interface RenewalPreview { [key: string]: unknown; } -export const renewalPreviewSchema: Schema = expandoObject({ - nextAssessmentAt: ['next_assessment_at', optional(string())], - subtotalInCents: ['subtotal_in_cents', optional(bigint())], - totalTaxInCents: ['total_tax_in_cents', optional(bigint())], - totalDiscountInCents: ['total_discount_in_cents', optional(bigint())], - totalInCents: ['total_in_cents', optional(bigint())], - existingBalanceInCents: ['existing_balance_in_cents', optional(bigint())], - totalAmountDueInCents: ['total_amount_due_in_cents', optional(bigint())], - uncalculatedTaxes: ['uncalculated_taxes', optional(boolean())], - lineItems: [ - 'line_items', - optional(array(lazy(() => renewalPreviewLineItemSchema))), - ], -}); +export const renewalPreviewSchema: Schema = lazy(() => + expandoObject({ + nextAssessmentAt: ['next_assessment_at', optional(string())], + subtotalInCents: ['subtotal_in_cents', optional(bigint())], + totalTaxInCents: ['total_tax_in_cents', optional(bigint())], + totalDiscountInCents: ['total_discount_in_cents', optional(bigint())], + totalInCents: ['total_in_cents', optional(bigint())], + existingBalanceInCents: ['existing_balance_in_cents', optional(bigint())], + totalAmountDueInCents: ['total_amount_due_in_cents', optional(bigint())], + uncalculatedTaxes: ['uncalculated_taxes', optional(boolean())], + lineItems: ['line_items', optional(array(renewalPreviewLineItemSchema))], + }) +); diff --git a/src/models/renewalPreviewComponent.ts b/src/models/renewalPreviewComponent.ts index 3fd5368..9b878c7 100644 --- a/src/models/renewalPreviewComponent.ts +++ b/src/models/renewalPreviewComponent.ts @@ -4,7 +4,7 @@ * This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ). */ -import { expandoObject, number, optional, Schema } from '../schema.js'; +import { expandoObject, lazy, number, optional, Schema } from '../schema.js'; import { RenewalPreviewComponentComponentId, renewalPreviewComponentComponentIdSchema, @@ -31,16 +31,17 @@ export interface RenewalPreviewComponent { [key: string]: unknown; } -export const renewalPreviewComponentSchema: Schema = expandoObject( - { - componentId: [ - 'component_id', - optional(renewalPreviewComponentComponentIdSchema), - ], - quantity: ['quantity', optional(number())], - pricePointId: [ - 'price_point_id', - optional(renewalPreviewComponentPricePointIdSchema), - ], - } +export const renewalPreviewComponentSchema: Schema = lazy( + () => + expandoObject({ + componentId: [ + 'component_id', + optional(renewalPreviewComponentComponentIdSchema), + ], + quantity: ['quantity', optional(number())], + pricePointId: [ + 'price_point_id', + optional(renewalPreviewComponentPricePointIdSchema), + ], + }) ); diff --git a/src/models/renewalPreviewRequest.ts b/src/models/renewalPreviewRequest.ts index 0cb65ce..fae1c4c 100644 --- a/src/models/renewalPreviewRequest.ts +++ b/src/models/renewalPreviewRequest.ts @@ -16,11 +16,12 @@ export interface RenewalPreviewRequest { [key: string]: unknown; } -export const renewalPreviewRequestSchema: Schema = expandoObject( - { - components: [ - 'components', - optional(array(lazy(() => renewalPreviewComponentSchema))), - ], - } +export const renewalPreviewRequestSchema: Schema = lazy( + () => + expandoObject({ + components: [ + 'components', + optional(array(renewalPreviewComponentSchema)), + ], + }) ); diff --git a/src/models/renewalPreviewResponse.ts b/src/models/renewalPreviewResponse.ts index 510eb35..597fb8e 100644 --- a/src/models/renewalPreviewResponse.ts +++ b/src/models/renewalPreviewResponse.ts @@ -12,6 +12,7 @@ export interface RenewalPreviewResponse { [key: string]: unknown; } -export const renewalPreviewResponseSchema: Schema = expandoObject( - { renewalPreview: ['renewal_preview', lazy(() => renewalPreviewSchema)] } +export const renewalPreviewResponseSchema: Schema = lazy( + () => + expandoObject({ renewalPreview: ['renewal_preview', renewalPreviewSchema] }) ); diff --git a/src/models/resumeOptions.ts b/src/models/resumeOptions.ts index 147bfcb..d88cb76 100644 --- a/src/models/resumeOptions.ts +++ b/src/models/resumeOptions.ts @@ -7,7 +7,7 @@ import { boolean, expandoObject, optional, Schema } from '../schema.js'; export interface ResumeOptions { - /** Chargify will only attempt to resume the subscription's billing period. If not resumable, the subscription will be left in it's current state. */ + /** Chargify will only attempt to resume the subscription's billing period. If not resumable, the subscription will be left in its current state. */ requireResume?: boolean; /** Indicates whether or not Chargify should clear the subscription's existing balance before attempting to resume the subscription. If subscription cannot be resumed, the balance will remain as it was before the attempt to resume was made. */ forgiveBalance?: boolean; diff --git a/src/models/saleRep.ts b/src/models/saleRep.ts index f29b691..dda6b8a 100644 --- a/src/models/saleRep.ts +++ b/src/models/saleRep.ts @@ -28,13 +28,15 @@ export interface SaleRep { [key: string]: unknown; } -export const saleRepSchema: Schema = expandoObject({ - id: ['id', optional(number())], - fullName: ['full_name', optional(string())], - subscriptionsCount: ['subscriptions_count', optional(number())], - testMode: ['test_mode', optional(boolean())], - subscriptions: [ - 'subscriptions', - optional(array(lazy(() => saleRepSubscriptionSchema))), - ], -}); +export const saleRepSchema: Schema = lazy(() => + expandoObject({ + id: ['id', optional(number())], + fullName: ['full_name', optional(string())], + subscriptionsCount: ['subscriptions_count', optional(number())], + testMode: ['test_mode', optional(boolean())], + subscriptions: [ + 'subscriptions', + optional(array(saleRepSubscriptionSchema)), + ], + }) +); diff --git a/src/models/segment.ts b/src/models/segment.ts index ba51504..e5fd848 100644 --- a/src/models/segment.ts +++ b/src/models/segment.ts @@ -49,32 +49,34 @@ export interface Segment { [key: string]: unknown; } -export const segmentSchema: Schema = expandoObject({ - id: ['id', optional(number())], - componentId: ['component_id', optional(number())], - pricePointId: ['price_point_id', optional(number())], - eventBasedBillingMetricId: [ - 'event_based_billing_metric_id', - optional(number()), - ], - pricingScheme: ['pricing_scheme', optional(pricingSchemeSchema)], - segmentProperty1Value: [ - 'segment_property_1_value', - optional(segmentSegmentProperty1ValueSchema), - ], - segmentProperty2Value: [ - 'segment_property_2_value', - optional(segmentSegmentProperty2ValueSchema), - ], - segmentProperty3Value: [ - 'segment_property_3_value', - optional(segmentSegmentProperty3ValueSchema), - ], - segmentProperty4Value: [ - 'segment_property_4_value', - optional(segmentSegmentProperty4ValueSchema), - ], - createdAt: ['created_at', optional(string())], - updatedAt: ['updated_at', optional(string())], - prices: ['prices', optional(array(lazy(() => segmentPriceSchema)))], -}); +export const segmentSchema: Schema = lazy(() => + expandoObject({ + id: ['id', optional(number())], + componentId: ['component_id', optional(number())], + pricePointId: ['price_point_id', optional(number())], + eventBasedBillingMetricId: [ + 'event_based_billing_metric_id', + optional(number()), + ], + pricingScheme: ['pricing_scheme', optional(pricingSchemeSchema)], + segmentProperty1Value: [ + 'segment_property_1_value', + optional(segmentSegmentProperty1ValueSchema), + ], + segmentProperty2Value: [ + 'segment_property_2_value', + optional(segmentSegmentProperty2ValueSchema), + ], + segmentProperty3Value: [ + 'segment_property_3_value', + optional(segmentSegmentProperty3ValueSchema), + ], + segmentProperty4Value: [ + 'segment_property_4_value', + optional(segmentSegmentProperty4ValueSchema), + ], + createdAt: ['created_at', optional(string())], + updatedAt: ['updated_at', optional(string())], + prices: ['prices', optional(array(segmentPriceSchema))], + }) +); diff --git a/src/models/segmentResponse.ts b/src/models/segmentResponse.ts index 3b7587b..ef41560 100644 --- a/src/models/segmentResponse.ts +++ b/src/models/segmentResponse.ts @@ -12,6 +12,6 @@ export interface SegmentResponse { [key: string]: unknown; } -export const segmentResponseSchema: Schema = expandoObject({ - segment: ['segment', optional(lazy(() => segmentSchema))], -}); +export const segmentResponseSchema: Schema = lazy(() => + expandoObject({ segment: ['segment', optional(segmentSchema)] }) +); diff --git a/src/models/serviceCreditResponse.ts b/src/models/serviceCreditResponse.ts index 725d7d7..133e507 100644 --- a/src/models/serviceCreditResponse.ts +++ b/src/models/serviceCreditResponse.ts @@ -12,6 +12,7 @@ export interface ServiceCreditResponse { [key: string]: unknown; } -export const serviceCreditResponseSchema: Schema = expandoObject( - { serviceCredit: ['service_credit', lazy(() => serviceCreditSchema)] } +export const serviceCreditResponseSchema: Schema = lazy( + () => + expandoObject({ serviceCredit: ['service_credit', serviceCreditSchema] }) ); diff --git a/src/models/signupProformaPreview.ts b/src/models/signupProformaPreview.ts index 2df2da5..f4d02e8 100644 --- a/src/models/signupProformaPreview.ts +++ b/src/models/signupProformaPreview.ts @@ -13,15 +13,16 @@ export interface SignupProformaPreview { [key: string]: unknown; } -export const signupProformaPreviewSchema: Schema = expandoObject( - { - currentProformaInvoice: [ - 'current_proforma_invoice', - optional(lazy(() => proformaInvoiceSchema)), - ], - nextProformaInvoice: [ - 'next_proforma_invoice', - optional(lazy(() => proformaInvoiceSchema)), - ], - } +export const signupProformaPreviewSchema: Schema = lazy( + () => + expandoObject({ + currentProformaInvoice: [ + 'current_proforma_invoice', + optional(proformaInvoiceSchema), + ], + nextProformaInvoice: [ + 'next_proforma_invoice', + optional(proformaInvoiceSchema), + ], + }) ); diff --git a/src/models/signupProformaPreviewResponse.ts b/src/models/signupProformaPreviewResponse.ts index b927d2b..39827a5 100644 --- a/src/models/signupProformaPreviewResponse.ts +++ b/src/models/signupProformaPreviewResponse.ts @@ -15,11 +15,12 @@ export interface SignupProformaPreviewResponse { [key: string]: unknown; } -export const signupProformaPreviewResponseSchema: Schema = expandoObject( - { - proformaInvoicePreview: [ - 'proforma_invoice_preview', - lazy(() => signupProformaPreviewSchema), - ], - } +export const signupProformaPreviewResponseSchema: Schema = lazy( + () => + expandoObject({ + proformaInvoicePreview: [ + 'proforma_invoice_preview', + signupProformaPreviewSchema, + ], + }) ); diff --git a/src/models/site.ts b/src/models/site.ts index 75b841c..5fd3cfc 100644 --- a/src/models/site.ts +++ b/src/models/site.ts @@ -49,40 +49,42 @@ export interface Site { [key: string]: unknown; } -export const siteSchema: Schema = expandoObject({ - id: ['id', optional(number())], - name: ['name', optional(string())], - subdomain: ['subdomain', optional(string())], - currency: ['currency', optional(string())], - sellerId: ['seller_id', optional(number())], - nonPrimaryCurrencies: ['non_primary_currencies', optional(array(string()))], - relationshipInvoicingEnabled: [ - 'relationship_invoicing_enabled', - optional(boolean()), - ], - scheduleSubscriptionCancellationEnabled: [ - 'schedule_subscription_cancellation_enabled', - optional(boolean()), - ], - customerHierarchyEnabled: ['customer_hierarchy_enabled', optional(boolean())], - whopaysEnabled: ['whopays_enabled', optional(boolean())], - whopaysDefaultPayer: ['whopays_default_payer', optional(string())], - allocationSettings: [ - 'allocation_settings', - optional(lazy(() => allocationSettingsSchema)), - ], - defaultPaymentCollectionMethod: [ - 'default_payment_collection_method', - optional(string()), - ], - organizationAddress: [ - 'organization_address', - optional(lazy(() => organizationAddressSchema)), - ], - taxConfiguration: [ - 'tax_configuration', - optional(lazy(() => taxConfigurationSchema)), - ], - netTerms: ['net_terms', optional(lazy(() => netTermsSchema))], - test: ['test', optional(boolean())], -}); +export const siteSchema: Schema = lazy(() => + expandoObject({ + id: ['id', optional(number())], + name: ['name', optional(string())], + subdomain: ['subdomain', optional(string())], + currency: ['currency', optional(string())], + sellerId: ['seller_id', optional(number())], + nonPrimaryCurrencies: ['non_primary_currencies', optional(array(string()))], + relationshipInvoicingEnabled: [ + 'relationship_invoicing_enabled', + optional(boolean()), + ], + scheduleSubscriptionCancellationEnabled: [ + 'schedule_subscription_cancellation_enabled', + optional(boolean()), + ], + customerHierarchyEnabled: [ + 'customer_hierarchy_enabled', + optional(boolean()), + ], + whopaysEnabled: ['whopays_enabled', optional(boolean())], + whopaysDefaultPayer: ['whopays_default_payer', optional(string())], + allocationSettings: [ + 'allocation_settings', + optional(allocationSettingsSchema), + ], + defaultPaymentCollectionMethod: [ + 'default_payment_collection_method', + optional(string()), + ], + organizationAddress: [ + 'organization_address', + optional(organizationAddressSchema), + ], + taxConfiguration: ['tax_configuration', optional(taxConfigurationSchema)], + netTerms: ['net_terms', optional(netTermsSchema)], + test: ['test', optional(boolean())], + }) +); diff --git a/src/models/siteResponse.ts b/src/models/siteResponse.ts index f19bc2a..b3fbfea 100644 --- a/src/models/siteResponse.ts +++ b/src/models/siteResponse.ts @@ -12,6 +12,6 @@ export interface SiteResponse { [key: string]: unknown; } -export const siteResponseSchema: Schema = expandoObject({ - site: ['site', lazy(() => siteSchema)], -}); +export const siteResponseSchema: Schema = lazy(() => + expandoObject({ site: ['site', siteSchema] }) +); diff --git a/src/models/siteSummary.ts b/src/models/siteSummary.ts index bd6a3d9..45a9f86 100644 --- a/src/models/siteSummary.ts +++ b/src/models/siteSummary.ts @@ -23,10 +23,12 @@ export interface SiteSummary { [key: string]: unknown; } -export const siteSummarySchema: Schema = expandoObject({ - sellerName: ['seller_name', optional(string())], - siteName: ['site_name', optional(string())], - siteId: ['site_id', optional(number())], - siteCurrency: ['site_currency', optional(string())], - stats: ['stats', optional(lazy(() => siteStatisticsSchema))], -}); +export const siteSummarySchema: Schema = lazy(() => + expandoObject({ + sellerName: ['seller_name', optional(string())], + siteName: ['site_name', optional(string())], + siteId: ['site_id', optional(number())], + siteCurrency: ['site_currency', optional(string())], + stats: ['stats', optional(siteStatisticsSchema)], + }) +); diff --git a/src/models/subscription.ts b/src/models/subscription.ts index c1aaed8..442d86e 100644 --- a/src/models/subscription.ts +++ b/src/models/subscription.ts @@ -28,6 +28,10 @@ import { CollectionMethod, collectionMethodSchema, } from './collectionMethod.js'; +import { + SubscriptionSnapDay, + subscriptionSnapDaySchema, +} from './containers/subscriptionSnapDay.js'; import { CreditCardPaymentProfile, creditCardPaymentProfileSchema, @@ -123,7 +127,7 @@ export interface Subscription { /** (deprecated) The coupon code of the single coupon currently applied to the subscription. See coupon_codes instead as subscriptions can now have more than one coupon. */ couponCode?: string | null; /** The day of the month that the subscription will charge according to calendar billing rules, if used. */ - snapDay?: string | null; + snapDay?: SubscriptionSnapDay | null; /** The type of payment collection to be used in the subscription. For legacy Statements Architecture valid options are - `invoice`, `automatic`. For current Relationship Invoicing Architecture valid options are - `remittance`, `automatic`, `prepaid`. */ paymentCollectionMethod?: CollectionMethod; customer?: Customer; @@ -153,7 +157,7 @@ export interface Subscription { offerId?: number | null; /** On Relationship Invoicing, the ID of the individual paying for the subscription. Defaults to the Customer ID unless the 'Customer Hierarchies & WhoPays' feature is enabled. */ payerId?: number | null; - /** The balance in cents plus the estimated renewal amount in cents. Returned ONLY for readSubscription operation as it's compute intensive operation. */ + /** The balance in cents plus the estimated renewal amount in cents. Returned ONLY for the readSubscription operation as it's a compute intensive operation. */ currentBillingAmountInCents?: bigint; /** The product price point currently subscribed to. */ productPricePointId?: number; @@ -197,121 +201,117 @@ export interface Subscription { [key: string]: unknown; } -export const subscriptionSchema: Schema = expandoObject({ - id: ['id', optional(number())], - state: ['state', optional(subscriptionStateSchema)], - balanceInCents: ['balance_in_cents', optional(bigint())], - totalRevenueInCents: ['total_revenue_in_cents', optional(bigint())], - productPriceInCents: ['product_price_in_cents', optional(bigint())], - productVersionNumber: ['product_version_number', optional(number())], - currentPeriodEndsAt: ['current_period_ends_at', optional(nullable(string()))], - nextAssessmentAt: ['next_assessment_at', optional(nullable(string()))], - trialStartedAt: ['trial_started_at', optional(nullable(string()))], - trialEndedAt: ['trial_ended_at', optional(nullable(string()))], - activatedAt: ['activated_at', optional(nullable(string()))], - expiresAt: ['expires_at', optional(nullable(string()))], - createdAt: ['created_at', optional(string())], - updatedAt: ['updated_at', optional(string())], - cancellationMessage: ['cancellation_message', optional(nullable(string()))], - cancellationMethod: [ - 'cancellation_method', - optional(nullable(cancellationMethodSchema)), - ], - cancelAtEndOfPeriod: [ - 'cancel_at_end_of_period', - optional(nullable(boolean())), - ], - canceledAt: ['canceled_at', optional(nullable(string()))], - currentPeriodStartedAt: [ - 'current_period_started_at', - optional(nullable(string())), - ], - previousState: ['previous_state', optional(subscriptionStateSchema)], - signupPaymentId: ['signup_payment_id', optional(number())], - signupRevenue: ['signup_revenue', optional(string())], - delayedCancelAt: ['delayed_cancel_at', optional(nullable(string()))], - couponCode: ['coupon_code', optional(nullable(string()))], - snapDay: ['snap_day', optional(nullable(string()))], - paymentCollectionMethod: [ - 'payment_collection_method', - optional(collectionMethodSchema), - ], - customer: ['customer', optional(lazy(() => customerSchema))], - product: ['product', optional(lazy(() => productSchema))], - creditCard: [ - 'credit_card', - optional(lazy(() => creditCardPaymentProfileSchema)), - ], - group: [ - 'group', - optional(nullable(lazy(() => nestedSubscriptionGroupSchema))), - ], - bankAccount: [ - 'bank_account', - optional(lazy(() => bankAccountPaymentProfileSchema)), - ], - paymentType: ['payment_type', optional(nullable(string()))], - referralCode: ['referral_code', optional(nullable(string()))], - nextProductId: ['next_product_id', optional(nullable(number()))], - nextProductHandle: ['next_product_handle', optional(nullable(string()))], - couponUseCount: ['coupon_use_count', optional(nullable(number()))], - couponUsesAllowed: ['coupon_uses_allowed', optional(nullable(number()))], - reasonCode: ['reason_code', optional(nullable(string()))], - automaticallyResumeAt: [ - 'automatically_resume_at', - optional(nullable(string())), - ], - couponCodes: ['coupon_codes', optional(array(string()))], - offerId: ['offer_id', optional(nullable(number()))], - payerId: ['payer_id', optional(nullable(number()))], - currentBillingAmountInCents: [ - 'current_billing_amount_in_cents', - optional(bigint()), - ], - productPricePointId: ['product_price_point_id', optional(number())], - productPricePointType: [ - 'product_price_point_type', - optional(pricePointTypeSchema), - ], - nextProductPricePointId: [ - 'next_product_price_point_id', - optional(nullable(number())), - ], - netTerms: ['net_terms', optional(nullable(number()))], - storedCredentialTransactionId: [ - 'stored_credential_transaction_id', - optional(nullable(number())), - ], - reference: ['reference', optional(nullable(string()))], - onHoldAt: ['on_hold_at', optional(nullable(string()))], - prepaidDunning: ['prepaid_dunning', optional(boolean())], - coupons: [ - 'coupons', - optional(array(lazy(() => subscriptionIncludedCouponSchema))), - ], - dunningCommunicationDelayEnabled: [ - 'dunning_communication_delay_enabled', - optional(boolean()), - ], - dunningCommunicationDelayTimeZone: [ - 'dunning_communication_delay_time_zone', - optional(nullable(string())), - ], - receivesInvoiceEmails: [ - 'receives_invoice_emails', - optional(nullable(boolean())), - ], - locale: ['locale', optional(nullable(string()))], - currency: ['currency', optional(string())], - scheduledCancellationAt: [ - 'scheduled_cancellation_at', - optional(nullable(string())), - ], - creditBalanceInCents: ['credit_balance_in_cents', optional(bigint())], - prepaymentBalanceInCents: ['prepayment_balance_in_cents', optional(bigint())], - prepaidConfiguration: [ - 'prepaid_configuration', - optional(nullable(lazy(() => prepaidConfigurationSchema))), - ], - selfServicePageToken: ['self_service_page_token', optional(string())], -}); +export const subscriptionSchema: Schema = lazy(() => + expandoObject({ + id: ['id', optional(number())], + state: ['state', optional(subscriptionStateSchema)], + balanceInCents: ['balance_in_cents', optional(bigint())], + totalRevenueInCents: ['total_revenue_in_cents', optional(bigint())], + productPriceInCents: ['product_price_in_cents', optional(bigint())], + productVersionNumber: ['product_version_number', optional(number())], + currentPeriodEndsAt: [ + 'current_period_ends_at', + optional(nullable(string())), + ], + nextAssessmentAt: ['next_assessment_at', optional(nullable(string()))], + trialStartedAt: ['trial_started_at', optional(nullable(string()))], + trialEndedAt: ['trial_ended_at', optional(nullable(string()))], + activatedAt: ['activated_at', optional(nullable(string()))], + expiresAt: ['expires_at', optional(nullable(string()))], + createdAt: ['created_at', optional(string())], + updatedAt: ['updated_at', optional(string())], + cancellationMessage: ['cancellation_message', optional(nullable(string()))], + cancellationMethod: [ + 'cancellation_method', + optional(nullable(cancellationMethodSchema)), + ], + cancelAtEndOfPeriod: [ + 'cancel_at_end_of_period', + optional(nullable(boolean())), + ], + canceledAt: ['canceled_at', optional(nullable(string()))], + currentPeriodStartedAt: [ + 'current_period_started_at', + optional(nullable(string())), + ], + previousState: ['previous_state', optional(subscriptionStateSchema)], + signupPaymentId: ['signup_payment_id', optional(number())], + signupRevenue: ['signup_revenue', optional(string())], + delayedCancelAt: ['delayed_cancel_at', optional(nullable(string()))], + couponCode: ['coupon_code', optional(nullable(string()))], + snapDay: ['snap_day', optional(nullable(subscriptionSnapDaySchema))], + paymentCollectionMethod: [ + 'payment_collection_method', + optional(collectionMethodSchema), + ], + customer: ['customer', optional(customerSchema)], + product: ['product', optional(productSchema)], + creditCard: ['credit_card', optional(creditCardPaymentProfileSchema)], + group: ['group', optional(nullable(nestedSubscriptionGroupSchema))], + bankAccount: ['bank_account', optional(bankAccountPaymentProfileSchema)], + paymentType: ['payment_type', optional(nullable(string()))], + referralCode: ['referral_code', optional(nullable(string()))], + nextProductId: ['next_product_id', optional(nullable(number()))], + nextProductHandle: ['next_product_handle', optional(nullable(string()))], + couponUseCount: ['coupon_use_count', optional(nullable(number()))], + couponUsesAllowed: ['coupon_uses_allowed', optional(nullable(number()))], + reasonCode: ['reason_code', optional(nullable(string()))], + automaticallyResumeAt: [ + 'automatically_resume_at', + optional(nullable(string())), + ], + couponCodes: ['coupon_codes', optional(array(string()))], + offerId: ['offer_id', optional(nullable(number()))], + payerId: ['payer_id', optional(nullable(number()))], + currentBillingAmountInCents: [ + 'current_billing_amount_in_cents', + optional(bigint()), + ], + productPricePointId: ['product_price_point_id', optional(number())], + productPricePointType: [ + 'product_price_point_type', + optional(pricePointTypeSchema), + ], + nextProductPricePointId: [ + 'next_product_price_point_id', + optional(nullable(number())), + ], + netTerms: ['net_terms', optional(nullable(number()))], + storedCredentialTransactionId: [ + 'stored_credential_transaction_id', + optional(nullable(number())), + ], + reference: ['reference', optional(nullable(string()))], + onHoldAt: ['on_hold_at', optional(nullable(string()))], + prepaidDunning: ['prepaid_dunning', optional(boolean())], + coupons: ['coupons', optional(array(subscriptionIncludedCouponSchema))], + dunningCommunicationDelayEnabled: [ + 'dunning_communication_delay_enabled', + optional(boolean()), + ], + dunningCommunicationDelayTimeZone: [ + 'dunning_communication_delay_time_zone', + optional(nullable(string())), + ], + receivesInvoiceEmails: [ + 'receives_invoice_emails', + optional(nullable(boolean())), + ], + locale: ['locale', optional(nullable(string()))], + currency: ['currency', optional(string())], + scheduledCancellationAt: [ + 'scheduled_cancellation_at', + optional(nullable(string())), + ], + creditBalanceInCents: ['credit_balance_in_cents', optional(bigint())], + prepaymentBalanceInCents: [ + 'prepayment_balance_in_cents', + optional(bigint()), + ], + prepaidConfiguration: [ + 'prepaid_configuration', + optional(nullable(prepaidConfigurationSchema)), + ], + selfServicePageToken: ['self_service_page_token', optional(string())], + }) +); diff --git a/src/models/subscriptionComponent.ts b/src/models/subscriptionComponent.ts index 40ab746..b2a789d 100644 --- a/src/models/subscriptionComponent.ts +++ b/src/models/subscriptionComponent.ts @@ -80,57 +80,61 @@ export interface SubscriptionComponent { [key: string]: unknown; } -export const subscriptionComponentSchema: Schema = expandoObject( - { - id: ['id', optional(number())], - name: ['name', optional(string())], - kind: ['kind', optional(componentKindSchema)], - unitName: ['unit_name', optional(string())], - enabled: ['enabled', optional(boolean())], - unitBalance: ['unit_balance', optional(number())], - currency: ['currency', optional(string())], - allocatedQuantity: [ - 'allocated_quantity', - optional(subscriptionComponentAllocatedQuantitySchema), - ], - pricingScheme: ['pricing_scheme', optional(nullable(pricingSchemeSchema))], - componentId: ['component_id', optional(number())], - componentHandle: ['component_handle', optional(nullable(string()))], - subscriptionId: ['subscription_id', optional(number())], - recurring: ['recurring', optional(boolean())], - upgradeCharge: ['upgrade_charge', optional(nullable(creditTypeSchema))], - downgradeCredit: ['downgrade_credit', optional(nullable(creditTypeSchema))], - archivedAt: ['archived_at', optional(nullable(string()))], - pricePointId: ['price_point_id', optional(nullable(number()))], - pricePointHandle: ['price_point_handle', optional(nullable(string()))], - pricePointType: [ - 'price_point_type', - optional(nullable(pricePointTypeSchema)), - ], - pricePointName: ['price_point_name', optional(nullable(string()))], - productFamilyId: ['product_family_id', optional(number())], - productFamilyHandle: ['product_family_handle', optional(string())], - createdAt: ['created_at', optional(string())], - updatedAt: ['updated_at', optional(string())], - useSiteExchangeRate: [ - 'use_site_exchange_rate', - optional(nullable(boolean())), - ], - description: ['description', optional(nullable(string()))], - allowFractionalQuantities: [ - 'allow_fractional_quantities', - optional(boolean()), - ], - subscription: [ - 'subscription', - optional(lazy(() => subscriptionComponentSubscriptionSchema)), - ], - historicUsages: [ - 'historic_usages', - optional(array(lazy(() => historicUsageSchema))), - ], - displayOnHostedPage: ['display_on_hosted_page', optional(boolean())], - interval: ['interval', optional(number())], - intervalUnit: ['interval_unit', optional(nullable(intervalUnitSchema))], - } +export const subscriptionComponentSchema: Schema = lazy( + () => + expandoObject({ + id: ['id', optional(number())], + name: ['name', optional(string())], + kind: ['kind', optional(componentKindSchema)], + unitName: ['unit_name', optional(string())], + enabled: ['enabled', optional(boolean())], + unitBalance: ['unit_balance', optional(number())], + currency: ['currency', optional(string())], + allocatedQuantity: [ + 'allocated_quantity', + optional(subscriptionComponentAllocatedQuantitySchema), + ], + pricingScheme: [ + 'pricing_scheme', + optional(nullable(pricingSchemeSchema)), + ], + componentId: ['component_id', optional(number())], + componentHandle: ['component_handle', optional(nullable(string()))], + subscriptionId: ['subscription_id', optional(number())], + recurring: ['recurring', optional(boolean())], + upgradeCharge: ['upgrade_charge', optional(nullable(creditTypeSchema))], + downgradeCredit: [ + 'downgrade_credit', + optional(nullable(creditTypeSchema)), + ], + archivedAt: ['archived_at', optional(nullable(string()))], + pricePointId: ['price_point_id', optional(nullable(number()))], + pricePointHandle: ['price_point_handle', optional(nullable(string()))], + pricePointType: [ + 'price_point_type', + optional(nullable(pricePointTypeSchema)), + ], + pricePointName: ['price_point_name', optional(nullable(string()))], + productFamilyId: ['product_family_id', optional(number())], + productFamilyHandle: ['product_family_handle', optional(string())], + createdAt: ['created_at', optional(string())], + updatedAt: ['updated_at', optional(string())], + useSiteExchangeRate: [ + 'use_site_exchange_rate', + optional(nullable(boolean())), + ], + description: ['description', optional(nullable(string()))], + allowFractionalQuantities: [ + 'allow_fractional_quantities', + optional(boolean()), + ], + subscription: [ + 'subscription', + optional(subscriptionComponentSubscriptionSchema), + ], + historicUsages: ['historic_usages', optional(array(historicUsageSchema))], + displayOnHostedPage: ['display_on_hosted_page', optional(boolean())], + interval: ['interval', optional(number())], + intervalUnit: ['interval_unit', optional(nullable(intervalUnitSchema))], + }) ); diff --git a/src/models/subscriptionComponentResponse.ts b/src/models/subscriptionComponentResponse.ts index 4a371c8..18b346f 100644 --- a/src/models/subscriptionComponentResponse.ts +++ b/src/models/subscriptionComponentResponse.ts @@ -15,8 +15,9 @@ export interface SubscriptionComponentResponse { [key: string]: unknown; } -export const subscriptionComponentResponseSchema: Schema = expandoObject( - { - component: ['component', optional(lazy(() => subscriptionComponentSchema))], - } +export const subscriptionComponentResponseSchema: Schema = lazy( + () => + expandoObject({ + component: ['component', optional(subscriptionComponentSchema)], + }) ); diff --git a/src/models/subscriptionCustomPrice.ts b/src/models/subscriptionCustomPrice.ts index 935deb0..8046c1d 100644 --- a/src/models/subscriptionCustomPrice.ts +++ b/src/models/subscriptionCustomPrice.ts @@ -7,6 +7,7 @@ import { boolean, expandoObject, + lazy, nullable, optional, Schema, @@ -41,6 +42,7 @@ import { expirationIntervalUnitSchema, } from './expirationIntervalUnit.js'; import { IntervalUnit, intervalUnitSchema } from './intervalUnit.js'; +import { TrialType, trialTypeSchema } from './trialType.js'; /** (Optional) Used in place of `product_price_point_id` to define a custom price point unique to the subscription */ export interface SubscriptionCustomPrice { @@ -60,6 +62,8 @@ export interface SubscriptionCustomPrice { trialInterval?: SubscriptionCustomPriceTrialInterval; /** (Optional) */ trialIntervalUnit?: IntervalUnit; + /** Indicates how a trial is handled when the trail period ends and there is no credit card on file. For `no_obligation`, the subscription transitions to a Trial Ended state. Maxio will not send any emails or statements. For `payment_expected`, the subscription transitions to a Past Due state. Maxio will send normal dunning emails and statements according to your other settings. */ + trialType?: TrialType | null; /** (Optional) */ initialChargeInCents?: SubscriptionCustomPriceInitialChargeInCents; /** (Optional) */ @@ -73,38 +77,43 @@ export interface SubscriptionCustomPrice { [key: string]: unknown; } -export const subscriptionCustomPriceSchema: Schema = expandoObject( - { - name: ['name', optional(string())], - handle: ['handle', optional(string())], - priceInCents: ['price_in_cents', subscriptionCustomPricePriceInCentsSchema], - interval: ['interval', subscriptionCustomPriceIntervalSchema], - intervalUnit: ['interval_unit', nullable(intervalUnitSchema)], - trialPriceInCents: [ - 'trial_price_in_cents', - optional(subscriptionCustomPriceTrialPriceInCentsSchema), - ], - trialInterval: [ - 'trial_interval', - optional(subscriptionCustomPriceTrialIntervalSchema), - ], - trialIntervalUnit: ['trial_interval_unit', optional(intervalUnitSchema)], - initialChargeInCents: [ - 'initial_charge_in_cents', - optional(subscriptionCustomPriceInitialChargeInCentsSchema), - ], - initialChargeAfterTrial: [ - 'initial_charge_after_trial', - optional(boolean()), - ], - expirationInterval: [ - 'expiration_interval', - optional(subscriptionCustomPriceExpirationIntervalSchema), - ], - expirationIntervalUnit: [ - 'expiration_interval_unit', - optional(nullable(expirationIntervalUnitSchema)), - ], - taxIncluded: ['tax_included', optional(boolean())], - } +export const subscriptionCustomPriceSchema: Schema = lazy( + () => + expandoObject({ + name: ['name', optional(string())], + handle: ['handle', optional(string())], + priceInCents: [ + 'price_in_cents', + subscriptionCustomPricePriceInCentsSchema, + ], + interval: ['interval', subscriptionCustomPriceIntervalSchema], + intervalUnit: ['interval_unit', nullable(intervalUnitSchema)], + trialPriceInCents: [ + 'trial_price_in_cents', + optional(subscriptionCustomPriceTrialPriceInCentsSchema), + ], + trialInterval: [ + 'trial_interval', + optional(subscriptionCustomPriceTrialIntervalSchema), + ], + trialIntervalUnit: ['trial_interval_unit', optional(intervalUnitSchema)], + trialType: ['trial_type', optional(nullable(trialTypeSchema))], + initialChargeInCents: [ + 'initial_charge_in_cents', + optional(subscriptionCustomPriceInitialChargeInCentsSchema), + ], + initialChargeAfterTrial: [ + 'initial_charge_after_trial', + optional(boolean()), + ], + expirationInterval: [ + 'expiration_interval', + optional(subscriptionCustomPriceExpirationIntervalSchema), + ], + expirationIntervalUnit: [ + 'expiration_interval_unit', + optional(nullable(expirationIntervalUnitSchema)), + ], + taxIncluded: ['tax_included', optional(boolean())], + }) ); diff --git a/src/models/subscriptionGroup.ts b/src/models/subscriptionGroup.ts index cde9cc3..759d46e 100644 --- a/src/models/subscriptionGroup.ts +++ b/src/models/subscriptionGroup.ts @@ -32,12 +32,12 @@ export interface SubscriptionGroup { [key: string]: unknown; } -export const subscriptionGroupSchema: Schema = expandoObject( - { +export const subscriptionGroupSchema: Schema = lazy(() => + expandoObject({ customerId: ['customer_id', optional(number())], paymentProfile: [ 'payment_profile', - optional(lazy(() => subscriptionGroupPaymentProfileSchema)), + optional(subscriptionGroupPaymentProfileSchema), ], paymentCollectionMethod: [ 'payment_collection_method', @@ -45,5 +45,5 @@ export const subscriptionGroupSchema: Schema = expandoObject( ], subscriptionIds: ['subscription_ids', optional(array(number()))], createdAt: ['created_at', optional(string())], - } + }) ); diff --git a/src/models/subscriptionGroupBalances.ts b/src/models/subscriptionGroupBalances.ts index bbd30ff..c5345b9 100644 --- a/src/models/subscriptionGroupBalances.ts +++ b/src/models/subscriptionGroupBalances.ts @@ -15,17 +15,12 @@ export interface SubscriptionGroupBalances { [key: string]: unknown; } -export const subscriptionGroupBalancesSchema: Schema = expandoObject( - { - prepayments: ['prepayments', optional(lazy(() => accountBalanceSchema))], - serviceCredits: [ - 'service_credits', - optional(lazy(() => accountBalanceSchema)), - ], - openInvoices: ['open_invoices', optional(lazy(() => accountBalanceSchema))], - pendingDiscounts: [ - 'pending_discounts', - optional(lazy(() => accountBalanceSchema)), - ], - } +export const subscriptionGroupBalancesSchema: Schema = lazy( + () => + expandoObject({ + prepayments: ['prepayments', optional(accountBalanceSchema)], + serviceCredits: ['service_credits', optional(accountBalanceSchema)], + openInvoices: ['open_invoices', optional(accountBalanceSchema)], + pendingDiscounts: ['pending_discounts', optional(accountBalanceSchema)], + }) ); diff --git a/src/models/subscriptionGroupComponentCustomPrice.ts b/src/models/subscriptionGroupComponentCustomPrice.ts index 0107165..30cc008 100644 --- a/src/models/subscriptionGroupComponentCustomPrice.ts +++ b/src/models/subscriptionGroupComponentCustomPrice.ts @@ -21,13 +21,14 @@ export interface SubscriptionGroupComponentCustomPrice { [key: string]: unknown; } -export const subscriptionGroupComponentCustomPriceSchema: Schema = expandoObject( - { - pricingScheme: ['pricing_scheme', optional(pricingSchemeSchema)], - prices: ['prices', optional(array(lazy(() => priceSchema)))], - overagePricing: [ - 'overage_pricing', - optional(array(lazy(() => componentCustomPriceSchema))), - ], - } +export const subscriptionGroupComponentCustomPriceSchema: Schema = lazy( + () => + expandoObject({ + pricingScheme: ['pricing_scheme', optional(pricingSchemeSchema)], + prices: ['prices', optional(array(priceSchema))], + overagePricing: [ + 'overage_pricing', + optional(array(componentCustomPriceSchema)), + ], + }) ); diff --git a/src/models/subscriptionGroupCreditCard.ts b/src/models/subscriptionGroupCreditCard.ts index 6eec36b..5d3fd81 100644 --- a/src/models/subscriptionGroupCreditCard.ts +++ b/src/models/subscriptionGroupCreditCard.ts @@ -4,7 +4,7 @@ * This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ). */ -import { expandoObject, optional, Schema, string } from '../schema.js'; +import { expandoObject, lazy, optional, Schema, string } from '../schema.js'; import { CardType, cardTypeSchema } from './cardType.js'; import { SubscriptionGroupCreditCardExpirationMonth, @@ -46,36 +46,37 @@ export interface SubscriptionGroupCreditCard { [key: string]: unknown; } -export const subscriptionGroupCreditCardSchema: Schema = expandoObject( - { - chargifyToken: ['chargify_token', optional(string())], - vaultToken: ['vault_token', optional(string())], - currentVault: ['current_vault', optional(creditCardVaultSchema)], - gatewayHandle: ['gateway_handle', optional(string())], - firstName: ['first_name', optional(string())], - lastName: ['last_name', optional(string())], - billingAddress: ['billing_address', optional(string())], - billingAddress2: ['billing_address_2', optional(string())], - billingCity: ['billing_city', optional(string())], - billingState: ['billing_state', optional(string())], - billingZip: ['billing_zip', optional(string())], - billingCountry: ['billing_country', optional(string())], - fullNumber: [ - 'full_number', - optional(subscriptionGroupCreditCardFullNumberSchema), - ], - expirationMonth: [ - 'expiration_month', - optional(subscriptionGroupCreditCardExpirationMonthSchema), - ], - expirationYear: [ - 'expiration_year', - optional(subscriptionGroupCreditCardExpirationYearSchema), - ], - lastFour: ['last_four', optional(string())], - cardType: ['card_type', optional(cardTypeSchema)], - customerVaultToken: ['customer_vault_token', optional(string())], - cvv: ['cvv', optional(string())], - paymentType: ['payment_type', optional(string())], - } +export const subscriptionGroupCreditCardSchema: Schema = lazy( + () => + expandoObject({ + chargifyToken: ['chargify_token', optional(string())], + vaultToken: ['vault_token', optional(string())], + currentVault: ['current_vault', optional(creditCardVaultSchema)], + gatewayHandle: ['gateway_handle', optional(string())], + firstName: ['first_name', optional(string())], + lastName: ['last_name', optional(string())], + billingAddress: ['billing_address', optional(string())], + billingAddress2: ['billing_address_2', optional(string())], + billingCity: ['billing_city', optional(string())], + billingState: ['billing_state', optional(string())], + billingZip: ['billing_zip', optional(string())], + billingCountry: ['billing_country', optional(string())], + fullNumber: [ + 'full_number', + optional(subscriptionGroupCreditCardFullNumberSchema), + ], + expirationMonth: [ + 'expiration_month', + optional(subscriptionGroupCreditCardExpirationMonthSchema), + ], + expirationYear: [ + 'expiration_year', + optional(subscriptionGroupCreditCardExpirationYearSchema), + ], + lastFour: ['last_four', optional(string())], + cardType: ['card_type', optional(cardTypeSchema)], + customerVaultToken: ['customer_vault_token', optional(string())], + cvv: ['cvv', optional(string())], + paymentType: ['payment_type', optional(string())], + }) ); diff --git a/src/models/subscriptionGroupPrepaymentRequest.ts b/src/models/subscriptionGroupPrepaymentRequest.ts index 35b6de6..4893ee5 100644 --- a/src/models/subscriptionGroupPrepaymentRequest.ts +++ b/src/models/subscriptionGroupPrepaymentRequest.ts @@ -15,6 +15,9 @@ export interface SubscriptionGroupPrepaymentRequest { [key: string]: unknown; } -export const subscriptionGroupPrepaymentRequestSchema: Schema = expandoObject( - { prepayment: ['prepayment', lazy(() => subscriptionGroupPrepaymentSchema)] } +export const subscriptionGroupPrepaymentRequestSchema: Schema = lazy( + () => + expandoObject({ + prepayment: ['prepayment', subscriptionGroupPrepaymentSchema], + }) ); diff --git a/src/models/subscriptionGroupResponse.ts b/src/models/subscriptionGroupResponse.ts index 8c66df7..a7282f2 100644 --- a/src/models/subscriptionGroupResponse.ts +++ b/src/models/subscriptionGroupResponse.ts @@ -15,11 +15,9 @@ export interface SubscriptionGroupResponse { [key: string]: unknown; } -export const subscriptionGroupResponseSchema: Schema = expandoObject( - { - subscriptionGroup: [ - 'subscription_group', - lazy(() => subscriptionGroupSchema), - ], - } +export const subscriptionGroupResponseSchema: Schema = lazy( + () => + expandoObject({ + subscriptionGroup: ['subscription_group', subscriptionGroupSchema], + }) ); diff --git a/src/models/subscriptionGroupSignup.ts b/src/models/subscriptionGroupSignup.ts index 1d9b51a..2d7c610 100644 --- a/src/models/subscriptionGroupSignup.ts +++ b/src/models/subscriptionGroupSignup.ts @@ -44,30 +44,28 @@ export interface SubscriptionGroupSignup { [key: string]: unknown; } -export const subscriptionGroupSignupSchema: Schema = expandoObject( - { - paymentProfileId: ['payment_profile_id', optional(number())], - payerId: ['payer_id', optional(number())], - payerReference: ['payer_reference', optional(string())], - paymentCollectionMethod: [ - 'payment_collection_method', - optional(collectionMethodSchema), - ], - payerAttributes: [ - 'payer_attributes', - optional(lazy(() => payerAttributesSchema)), - ], - creditCardAttributes: [ - 'credit_card_attributes', - optional(lazy(() => subscriptionGroupCreditCardSchema)), - ], - bankAccountAttributes: [ - 'bank_account_attributes', - optional(lazy(() => subscriptionGroupBankAccountSchema)), - ], - subscriptions: [ - 'subscriptions', - array(lazy(() => subscriptionGroupSignupItemSchema)), - ], - } +export const subscriptionGroupSignupSchema: Schema = lazy( + () => + expandoObject({ + paymentProfileId: ['payment_profile_id', optional(number())], + payerId: ['payer_id', optional(number())], + payerReference: ['payer_reference', optional(string())], + paymentCollectionMethod: [ + 'payment_collection_method', + optional(collectionMethodSchema), + ], + payerAttributes: ['payer_attributes', optional(payerAttributesSchema)], + creditCardAttributes: [ + 'credit_card_attributes', + optional(subscriptionGroupCreditCardSchema), + ], + bankAccountAttributes: [ + 'bank_account_attributes', + optional(subscriptionGroupBankAccountSchema), + ], + subscriptions: [ + 'subscriptions', + array(subscriptionGroupSignupItemSchema), + ], + }) ); diff --git a/src/models/subscriptionGroupSignupComponent.ts b/src/models/subscriptionGroupSignupComponent.ts index 7b897c8..97b6d2f 100644 --- a/src/models/subscriptionGroupSignupComponent.ts +++ b/src/models/subscriptionGroupSignupComponent.ts @@ -37,27 +37,28 @@ export interface SubscriptionGroupSignupComponent { [key: string]: unknown; } -export const subscriptionGroupSignupComponentSchema: Schema = expandoObject( - { - componentId: [ - 'component_id', - optional(subscriptionGroupSignupComponentComponentIdSchema), - ], - allocatedQuantity: [ - 'allocated_quantity', - optional(subscriptionGroupSignupComponentAllocatedQuantitySchema), - ], - unitBalance: [ - 'unit_balance', - optional(subscriptionGroupSignupComponentUnitBalanceSchema), - ], - pricePointId: [ - 'price_point_id', - optional(subscriptionGroupSignupComponentPricePointIdSchema), - ], - customPrice: [ - 'custom_price', - optional(lazy(() => subscriptionGroupComponentCustomPriceSchema)), - ], - } +export const subscriptionGroupSignupComponentSchema: Schema = lazy( + () => + expandoObject({ + componentId: [ + 'component_id', + optional(subscriptionGroupSignupComponentComponentIdSchema), + ], + allocatedQuantity: [ + 'allocated_quantity', + optional(subscriptionGroupSignupComponentAllocatedQuantitySchema), + ], + unitBalance: [ + 'unit_balance', + optional(subscriptionGroupSignupComponentUnitBalanceSchema), + ], + pricePointId: [ + 'price_point_id', + optional(subscriptionGroupSignupComponentPricePointIdSchema), + ], + customPrice: [ + 'custom_price', + optional(subscriptionGroupComponentCustomPriceSchema), + ], + }) ); diff --git a/src/models/subscriptionGroupSignupError.ts b/src/models/subscriptionGroupSignupError.ts index 7819f9f..5dd0dff 100644 --- a/src/models/subscriptionGroupSignupError.ts +++ b/src/models/subscriptionGroupSignupError.ts @@ -30,16 +30,17 @@ export interface SubscriptionGroupSignupError { [key: string]: unknown; } -export const subscriptionGroupSignupErrorSchema: Schema = expandoObject( - { - subscriptions: [ - 'subscriptions', - optional(dict(lazy(() => subscriptionGroupSubscriptionErrorSchema))), - ], - payerReference: ['payer_reference', optional(string())], - payer: ['payer', optional(lazy(() => payerErrorSchema))], - subscriptionGroup: ['subscription_group', optional(array(string()))], - paymentProfileId: ['payment_profile_id', optional(string())], - payerId: ['payer_id', optional(string())], - } +export const subscriptionGroupSignupErrorSchema: Schema = lazy( + () => + expandoObject({ + subscriptions: [ + 'subscriptions', + optional(dict(subscriptionGroupSubscriptionErrorSchema)), + ], + payerReference: ['payer_reference', optional(string())], + payer: ['payer', optional(payerErrorSchema)], + subscriptionGroup: ['subscription_group', optional(array(string()))], + paymentProfileId: ['payment_profile_id', optional(string())], + payerId: ['payer_id', optional(string())], + }) ); diff --git a/src/models/subscriptionGroupSignupEventData.ts b/src/models/subscriptionGroupSignupEventData.ts index 790a957..43ea336 100644 --- a/src/models/subscriptionGroupSignupEventData.ts +++ b/src/models/subscriptionGroupSignupEventData.ts @@ -17,12 +17,13 @@ export interface SubscriptionGroupSignupEventData { [key: string]: unknown; } -export const subscriptionGroupSignupEventDataSchema: Schema = expandoObject( - { - subscriptionGroup: [ - 'subscription_group', - lazy(() => subscriptionGroupSignupFailureDataSchema), - ], - customer: ['customer', nullable(lazy(() => customerSchema))], - } +export const subscriptionGroupSignupEventDataSchema: Schema = lazy( + () => + expandoObject({ + subscriptionGroup: [ + 'subscription_group', + subscriptionGroupSignupFailureDataSchema, + ], + customer: ['customer', nullable(customerSchema)], + }) ); diff --git a/src/models/subscriptionGroupSignupFailureData.ts b/src/models/subscriptionGroupSignupFailureData.ts index f431e5c..1c6d7ff 100644 --- a/src/models/subscriptionGroupSignupFailureData.ts +++ b/src/models/subscriptionGroupSignupFailureData.ts @@ -39,27 +39,28 @@ export interface SubscriptionGroupSignupFailureData { [key: string]: unknown; } -export const subscriptionGroupSignupFailureDataSchema: Schema = expandoObject( - { - payerId: ['payer_id', optional(number())], - payerReference: ['payer_reference', optional(string())], - paymentProfileId: ['payment_profile_id', optional(number())], - paymentCollectionMethod: ['payment_collection_method', optional(string())], - payerAttributes: [ - 'payer_attributes', - optional(lazy(() => payerAttributesSchema)), - ], - creditCardAttributes: [ - 'credit_card_attributes', - optional(lazy(() => subscriptionGroupCreditCardSchema)), - ], - bankAccountAttributes: [ - 'bank_account_attributes', - optional(lazy(() => subscriptionGroupBankAccountSchema)), - ], - subscriptions: [ - 'subscriptions', - optional(array(lazy(() => subscriptionGroupSignupItemSchema))), - ], - } +export const subscriptionGroupSignupFailureDataSchema: Schema = lazy( + () => + expandoObject({ + payerId: ['payer_id', optional(number())], + payerReference: ['payer_reference', optional(string())], + paymentProfileId: ['payment_profile_id', optional(number())], + paymentCollectionMethod: [ + 'payment_collection_method', + optional(string()), + ], + payerAttributes: ['payer_attributes', optional(payerAttributesSchema)], + creditCardAttributes: [ + 'credit_card_attributes', + optional(subscriptionGroupCreditCardSchema), + ], + bankAccountAttributes: [ + 'bank_account_attributes', + optional(subscriptionGroupBankAccountSchema), + ], + subscriptions: [ + 'subscriptions', + optional(array(subscriptionGroupSignupItemSchema)), + ], + }) ); diff --git a/src/models/subscriptionGroupSignupItem.ts b/src/models/subscriptionGroupSignupItem.ts index bd2b701..09dbcb0 100644 --- a/src/models/subscriptionGroupSignupItem.ts +++ b/src/models/subscriptionGroupSignupItem.ts @@ -54,29 +54,27 @@ export interface SubscriptionGroupSignupItem { [key: string]: unknown; } -export const subscriptionGroupSignupItemSchema: Schema = expandoObject( - { - productHandle: ['product_handle', optional(string())], - productId: ['product_id', optional(number())], - productPricePointId: ['product_price_point_id', optional(number())], - productPricePointHandle: ['product_price_point_handle', optional(string())], - offerId: ['offer_id', optional(number())], - reference: ['reference', optional(string())], - primary: ['primary', optional(boolean())], - currency: ['currency', optional(string())], - couponCodes: ['coupon_codes', optional(array(string()))], - components: [ - 'components', - optional(array(lazy(() => subscriptionGroupSignupComponentSchema))), - ], - customPrice: [ - 'custom_price', - optional(lazy(() => subscriptionCustomPriceSchema)), - ], - calendarBilling: [ - 'calendar_billing', - optional(lazy(() => calendarBillingSchema)), - ], - metafields: ['metafields', optional(dict(string()))], - } +export const subscriptionGroupSignupItemSchema: Schema = lazy( + () => + expandoObject({ + productHandle: ['product_handle', optional(string())], + productId: ['product_id', optional(number())], + productPricePointId: ['product_price_point_id', optional(number())], + productPricePointHandle: [ + 'product_price_point_handle', + optional(string()), + ], + offerId: ['offer_id', optional(number())], + reference: ['reference', optional(string())], + primary: ['primary', optional(boolean())], + currency: ['currency', optional(string())], + couponCodes: ['coupon_codes', optional(array(string()))], + components: [ + 'components', + optional(array(subscriptionGroupSignupComponentSchema)), + ], + customPrice: ['custom_price', optional(subscriptionCustomPriceSchema)], + calendarBilling: ['calendar_billing', optional(calendarBillingSchema)], + metafields: ['metafields', optional(dict(string()))], + }) ); diff --git a/src/models/subscriptionGroupSignupRequest.ts b/src/models/subscriptionGroupSignupRequest.ts index f4efefb..74bcdf8 100644 --- a/src/models/subscriptionGroupSignupRequest.ts +++ b/src/models/subscriptionGroupSignupRequest.ts @@ -15,11 +15,9 @@ export interface SubscriptionGroupSignupRequest { [key: string]: unknown; } -export const subscriptionGroupSignupRequestSchema: Schema = expandoObject( - { - subscriptionGroup: [ - 'subscription_group', - lazy(() => subscriptionGroupSignupSchema), - ], - } +export const subscriptionGroupSignupRequestSchema: Schema = lazy( + () => + expandoObject({ + subscriptionGroup: ['subscription_group', subscriptionGroupSignupSchema], + }) ); diff --git a/src/models/subscriptionGroupSignupResponse.ts b/src/models/subscriptionGroupSignupResponse.ts index de0fba1..0787c8e 100644 --- a/src/models/subscriptionGroupSignupResponse.ts +++ b/src/models/subscriptionGroupSignupResponse.ts @@ -65,24 +65,25 @@ export interface SubscriptionGroupSignupResponse { [key: string]: unknown; } -export const subscriptionGroupSignupResponseSchema: Schema = expandoObject( - { - uid: ['uid', optional(string())], - scheme: ['scheme', optional(number())], - customerId: ['customer_id', optional(number())], - paymentProfileId: ['payment_profile_id', optional(number())], - subscriptionIds: ['subscription_ids', optional(array(number()))], - primarySubscriptionId: ['primary_subscription_id', optional(number())], - nextAssessmentAt: ['next_assessment_at', optional(string())], - state: ['state', optional(subscriptionStateSchema)], - cancelAtEndOfPeriod: ['cancel_at_end_of_period', optional(boolean())], - subscriptions: [ - 'subscriptions', - optional(array(lazy(() => subscriptionGroupItemSchema))), - ], - paymentCollectionMethod: [ - 'payment_collection_method', - optional(collectionMethodSchema), - ], - } +export const subscriptionGroupSignupResponseSchema: Schema = lazy( + () => + expandoObject({ + uid: ['uid', optional(string())], + scheme: ['scheme', optional(number())], + customerId: ['customer_id', optional(number())], + paymentProfileId: ['payment_profile_id', optional(number())], + subscriptionIds: ['subscription_ids', optional(array(number()))], + primarySubscriptionId: ['primary_subscription_id', optional(number())], + nextAssessmentAt: ['next_assessment_at', optional(string())], + state: ['state', optional(subscriptionStateSchema)], + cancelAtEndOfPeriod: ['cancel_at_end_of_period', optional(boolean())], + subscriptions: [ + 'subscriptions', + optional(array(subscriptionGroupItemSchema)), + ], + paymentCollectionMethod: [ + 'payment_collection_method', + optional(collectionMethodSchema), + ], + }) ); diff --git a/src/models/subscriptionMRR.ts b/src/models/subscriptionMRR.ts index 46e7b67..fb63e91 100644 --- a/src/models/subscriptionMRR.ts +++ b/src/models/subscriptionMRR.ts @@ -24,8 +24,10 @@ export interface SubscriptionMRR { [key: string]: unknown; } -export const subscriptionMRRSchema: Schema = expandoObject({ - subscriptionId: ['subscription_id', number()], - mrrAmountInCents: ['mrr_amount_in_cents', bigint()], - breakouts: ['breakouts', optional(lazy(() => subscriptionMRRBreakoutSchema))], -}); +export const subscriptionMRRSchema: Schema = lazy(() => + expandoObject({ + subscriptionId: ['subscription_id', number()], + mrrAmountInCents: ['mrr_amount_in_cents', bigint()], + breakouts: ['breakouts', optional(subscriptionMRRBreakoutSchema)], + }) +); diff --git a/src/models/subscriptionMRRResponse.ts b/src/models/subscriptionMRRResponse.ts index 89f238e..52ac141 100644 --- a/src/models/subscriptionMRRResponse.ts +++ b/src/models/subscriptionMRRResponse.ts @@ -12,11 +12,9 @@ export interface SubscriptionMRRResponse { [key: string]: unknown; } -export const subscriptionMRRResponseSchema: Schema = expandoObject( - { - subscriptionsMrr: [ - 'subscriptions_mrr', - array(lazy(() => subscriptionMRRSchema)), - ], - } +export const subscriptionMRRResponseSchema: Schema = lazy( + () => + expandoObject({ + subscriptionsMrr: ['subscriptions_mrr', array(subscriptionMRRSchema)], + }) ); diff --git a/src/models/subscriptionMigrationPreviewOptions.ts b/src/models/subscriptionMigrationPreviewOptions.ts index 8822476..c6d45bd 100644 --- a/src/models/subscriptionMigrationPreviewOptions.ts +++ b/src/models/subscriptionMigrationPreviewOptions.ts @@ -38,17 +38,21 @@ export interface SubscriptionMigrationPreviewOptions { [key: string]: unknown; } -export const subscriptionMigrationPreviewOptionsSchema: Schema = expandoObject( - { - productId: ['product_id', optional(number())], - productPricePointId: ['product_price_point_id', optional(number())], - includeTrial: ['include_trial', optional(boolean())], - includeInitialCharge: ['include_initial_charge', optional(boolean())], - includeCoupons: ['include_coupons', optional(boolean())], - preservePeriod: ['preserve_period', optional(boolean())], - productHandle: ['product_handle', optional(string())], - productPricePointHandle: ['product_price_point_handle', optional(string())], - proration: ['proration', optional(lazy(() => prorationSchema))], - prorationDate: ['proration_date', optional(string())], - } +export const subscriptionMigrationPreviewOptionsSchema: Schema = lazy( + () => + expandoObject({ + productId: ['product_id', optional(number())], + productPricePointId: ['product_price_point_id', optional(number())], + includeTrial: ['include_trial', optional(boolean())], + includeInitialCharge: ['include_initial_charge', optional(boolean())], + includeCoupons: ['include_coupons', optional(boolean())], + preservePeriod: ['preserve_period', optional(boolean())], + productHandle: ['product_handle', optional(string())], + productPricePointHandle: [ + 'product_price_point_handle', + optional(string()), + ], + proration: ['proration', optional(prorationSchema)], + prorationDate: ['proration_date', optional(string())], + }) ); diff --git a/src/models/subscriptionMigrationPreviewRequest.ts b/src/models/subscriptionMigrationPreviewRequest.ts index bc7bf3e..f426e74 100644 --- a/src/models/subscriptionMigrationPreviewRequest.ts +++ b/src/models/subscriptionMigrationPreviewRequest.ts @@ -15,11 +15,9 @@ export interface SubscriptionMigrationPreviewRequest { [key: string]: unknown; } -export const subscriptionMigrationPreviewRequestSchema: Schema = expandoObject( - { - migration: [ - 'migration', - lazy(() => subscriptionMigrationPreviewOptionsSchema), - ], - } +export const subscriptionMigrationPreviewRequestSchema: Schema = lazy( + () => + expandoObject({ + migration: ['migration', subscriptionMigrationPreviewOptionsSchema], + }) ); diff --git a/src/models/subscriptionMigrationPreviewResponse.ts b/src/models/subscriptionMigrationPreviewResponse.ts index 263fc25..b9d57b4 100644 --- a/src/models/subscriptionMigrationPreviewResponse.ts +++ b/src/models/subscriptionMigrationPreviewResponse.ts @@ -15,6 +15,9 @@ export interface SubscriptionMigrationPreviewResponse { [key: string]: unknown; } -export const subscriptionMigrationPreviewResponseSchema: Schema = expandoObject( - { migration: ['migration', lazy(() => subscriptionMigrationPreviewSchema)] } +export const subscriptionMigrationPreviewResponseSchema: Schema = lazy( + () => + expandoObject({ + migration: ['migration', subscriptionMigrationPreviewSchema], + }) ); diff --git a/src/models/subscriptionNoteResponse.ts b/src/models/subscriptionNoteResponse.ts index 0edfe1e..0a14b48 100644 --- a/src/models/subscriptionNoteResponse.ts +++ b/src/models/subscriptionNoteResponse.ts @@ -15,6 +15,6 @@ export interface SubscriptionNoteResponse { [key: string]: unknown; } -export const subscriptionNoteResponseSchema: Schema = expandoObject( - { note: ['note', lazy(() => subscriptionNoteSchema)] } +export const subscriptionNoteResponseSchema: Schema = lazy( + () => expandoObject({ note: ['note', subscriptionNoteSchema] }) ); diff --git a/src/models/subscriptionPreview.ts b/src/models/subscriptionPreview.ts index 5392ddb..fabdcfe 100644 --- a/src/models/subscriptionPreview.ts +++ b/src/models/subscriptionPreview.ts @@ -13,15 +13,15 @@ export interface SubscriptionPreview { [key: string]: unknown; } -export const subscriptionPreviewSchema: Schema = expandoObject( - { +export const subscriptionPreviewSchema: Schema = lazy(() => + expandoObject({ currentBillingManifest: [ 'current_billing_manifest', - optional(lazy(() => billingManifestSchema)), + optional(billingManifestSchema), ], nextBillingManifest: [ 'next_billing_manifest', - optional(lazy(() => billingManifestSchema)), + optional(billingManifestSchema), ], - } + }) ); diff --git a/src/models/subscriptionPreviewResponse.ts b/src/models/subscriptionPreviewResponse.ts index 3491b86..be055ab 100644 --- a/src/models/subscriptionPreviewResponse.ts +++ b/src/models/subscriptionPreviewResponse.ts @@ -15,11 +15,9 @@ export interface SubscriptionPreviewResponse { [key: string]: unknown; } -export const subscriptionPreviewResponseSchema: Schema = expandoObject( - { - subscriptionPreview: [ - 'subscription_preview', - lazy(() => subscriptionPreviewSchema), - ], - } +export const subscriptionPreviewResponseSchema: Schema = lazy( + () => + expandoObject({ + subscriptionPreview: ['subscription_preview', subscriptionPreviewSchema], + }) ); diff --git a/src/models/subscriptionProductMigration.ts b/src/models/subscriptionProductMigration.ts index 8bc7afe..4de9eae 100644 --- a/src/models/subscriptionProductMigration.ts +++ b/src/models/subscriptionProductMigration.ts @@ -36,16 +36,20 @@ export interface SubscriptionProductMigration { [key: string]: unknown; } -export const subscriptionProductMigrationSchema: Schema = expandoObject( - { - productId: ['product_id', optional(number())], - productPricePointId: ['product_price_point_id', optional(number())], - includeTrial: ['include_trial', optional(boolean())], - includeInitialCharge: ['include_initial_charge', optional(boolean())], - includeCoupons: ['include_coupons', optional(boolean())], - preservePeriod: ['preserve_period', optional(boolean())], - productHandle: ['product_handle', optional(string())], - productPricePointHandle: ['product_price_point_handle', optional(string())], - proration: ['proration', optional(lazy(() => prorationSchema))], - } +export const subscriptionProductMigrationSchema: Schema = lazy( + () => + expandoObject({ + productId: ['product_id', optional(number())], + productPricePointId: ['product_price_point_id', optional(number())], + includeTrial: ['include_trial', optional(boolean())], + includeInitialCharge: ['include_initial_charge', optional(boolean())], + includeCoupons: ['include_coupons', optional(boolean())], + preservePeriod: ['preserve_period', optional(boolean())], + productHandle: ['product_handle', optional(string())], + productPricePointHandle: [ + 'product_price_point_handle', + optional(string()), + ], + proration: ['proration', optional(prorationSchema)], + }) ); diff --git a/src/models/subscriptionProductMigrationRequest.ts b/src/models/subscriptionProductMigrationRequest.ts index 14b9dc2..608fc98 100644 --- a/src/models/subscriptionProductMigrationRequest.ts +++ b/src/models/subscriptionProductMigrationRequest.ts @@ -15,6 +15,9 @@ export interface SubscriptionProductMigrationRequest { [key: string]: unknown; } -export const subscriptionProductMigrationRequestSchema: Schema = expandoObject( - { migration: ['migration', lazy(() => subscriptionProductMigrationSchema)] } +export const subscriptionProductMigrationRequestSchema: Schema = lazy( + () => + expandoObject({ + migration: ['migration', subscriptionProductMigrationSchema], + }) ); diff --git a/src/models/subscriptionResponse.ts b/src/models/subscriptionResponse.ts index 7927566..cef8042 100644 --- a/src/models/subscriptionResponse.ts +++ b/src/models/subscriptionResponse.ts @@ -12,6 +12,9 @@ export interface SubscriptionResponse { [key: string]: unknown; } -export const subscriptionResponseSchema: Schema = expandoObject( - { subscription: ['subscription', optional(lazy(() => subscriptionSchema))] } +export const subscriptionResponseSchema: Schema = lazy( + () => + expandoObject({ + subscription: ['subscription', optional(subscriptionSchema)], + }) ); diff --git a/src/models/trialType.ts b/src/models/trialType.ts new file mode 100644 index 0000000..b00308f --- /dev/null +++ b/src/models/trialType.ts @@ -0,0 +1,20 @@ +/** + * AdvancedBilling + * + * This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ). + */ + +import { Schema, stringEnum } from '../schema.js'; + +/** + * Enum for TrialType + */ +export enum TrialType { + NoObligation = 'no_obligation', + PaymentExpected = 'payment_expected', +} + +/** + * Schema for TrialType + */ +export const trialTypeSchema: Schema = stringEnum(TrialType); diff --git a/src/models/updateAllocationExpirationDate.ts b/src/models/updateAllocationExpirationDate.ts index 35b05b6..4dc8dce 100644 --- a/src/models/updateAllocationExpirationDate.ts +++ b/src/models/updateAllocationExpirationDate.ts @@ -15,11 +15,9 @@ export interface UpdateAllocationExpirationDate { [key: string]: unknown; } -export const updateAllocationExpirationDateSchema: Schema = expandoObject( - { - allocation: [ - 'allocation', - optional(lazy(() => allocationExpirationDateSchema)), - ], - } +export const updateAllocationExpirationDateSchema: Schema = lazy( + () => + expandoObject({ + allocation: ['allocation', optional(allocationExpirationDateSchema)], + }) ); diff --git a/src/models/updateComponent.ts b/src/models/updateComponent.ts index 1c8b962..bf8f369 100644 --- a/src/models/updateComponent.ts +++ b/src/models/updateComponent.ts @@ -24,7 +24,7 @@ export interface UpdateComponent { accountingCode?: string | null; /** Boolean flag describing whether a component is taxable or not. */ taxable?: boolean; - /** A string representing the tax code related to the component type. This is especially important when using the Avalara service to tax based on locale. This attribute has a max length of 10 characters. */ + /** A string representing the tax code related to the component type. This is especially important when using AvaTax to tax based on locale. This attribute has a max length of 25 characters. */ taxCode?: string | null; /** One of the following: Business Software, Consumer Software, Digital Services, Physical Goods, Other */ itemCategory?: ItemCategory | null; diff --git a/src/models/updateComponentPricePoint.ts b/src/models/updateComponentPricePoint.ts index a6188ff..2e64fa4 100644 --- a/src/models/updateComponentPricePoint.ts +++ b/src/models/updateComponentPricePoint.ts @@ -36,15 +36,16 @@ export interface UpdateComponentPricePoint { [key: string]: unknown; } -export const updateComponentPricePointSchema: Schema = expandoObject( - { - name: ['name', optional(string())], - handle: ['handle', optional(string())], - pricingScheme: ['pricing_scheme', optional(pricingSchemeSchema)], - useSiteExchangeRate: ['use_site_exchange_rate', optional(boolean())], - taxIncluded: ['tax_included', optional(boolean())], - interval: ['interval', optional(number())], - intervalUnit: ['interval_unit', optional(nullable(intervalUnitSchema))], - prices: ['prices', optional(array(lazy(() => updatePriceSchema)))], - } +export const updateComponentPricePointSchema: Schema = lazy( + () => + expandoObject({ + name: ['name', optional(string())], + handle: ['handle', optional(string())], + pricingScheme: ['pricing_scheme', optional(pricingSchemeSchema)], + useSiteExchangeRate: ['use_site_exchange_rate', optional(boolean())], + taxIncluded: ['tax_included', optional(boolean())], + interval: ['interval', optional(number())], + intervalUnit: ['interval_unit', optional(nullable(intervalUnitSchema))], + prices: ['prices', optional(array(updatePriceSchema))], + }) ); diff --git a/src/models/updateComponentPricePointRequest.ts b/src/models/updateComponentPricePointRequest.ts index 3e99f12..6adc53a 100644 --- a/src/models/updateComponentPricePointRequest.ts +++ b/src/models/updateComponentPricePointRequest.ts @@ -15,11 +15,9 @@ export interface UpdateComponentPricePointRequest { [key: string]: unknown; } -export const updateComponentPricePointRequestSchema: Schema = expandoObject( - { - pricePoint: [ - 'price_point', - optional(lazy(() => updateComponentPricePointSchema)), - ], - } +export const updateComponentPricePointRequestSchema: Schema = lazy( + () => + expandoObject({ + pricePoint: ['price_point', optional(updateComponentPricePointSchema)], + }) ); diff --git a/src/models/updateComponentRequest.ts b/src/models/updateComponentRequest.ts index 3c87ad7..fa96ea4 100644 --- a/src/models/updateComponentRequest.ts +++ b/src/models/updateComponentRequest.ts @@ -12,6 +12,6 @@ export interface UpdateComponentRequest { [key: string]: unknown; } -export const updateComponentRequestSchema: Schema = expandoObject( - { component: ['component', lazy(() => updateComponentSchema)] } +export const updateComponentRequestSchema: Schema = lazy( + () => expandoObject({ component: ['component', updateComponentSchema] }) ); diff --git a/src/models/updateCurrencyPricesRequest.ts b/src/models/updateCurrencyPricesRequest.ts index dc07c16..2307c05 100644 --- a/src/models/updateCurrencyPricesRequest.ts +++ b/src/models/updateCurrencyPricesRequest.ts @@ -15,11 +15,9 @@ export interface UpdateCurrencyPricesRequest { [key: string]: unknown; } -export const updateCurrencyPricesRequestSchema: Schema = expandoObject( - { - currencyPrices: [ - 'currency_prices', - array(lazy(() => updateCurrencyPriceSchema)), - ], - } +export const updateCurrencyPricesRequestSchema: Schema = lazy( + () => + expandoObject({ + currencyPrices: ['currency_prices', array(updateCurrencyPriceSchema)], + }) ); diff --git a/src/models/updateCustomerRequest.ts b/src/models/updateCustomerRequest.ts index 636e6b6..34d10d9 100644 --- a/src/models/updateCustomerRequest.ts +++ b/src/models/updateCustomerRequest.ts @@ -12,6 +12,6 @@ export interface UpdateCustomerRequest { [key: string]: unknown; } -export const updateCustomerRequestSchema: Schema = expandoObject( - { customer: ['customer', lazy(() => updateCustomerSchema)] } +export const updateCustomerRequestSchema: Schema = lazy( + () => expandoObject({ customer: ['customer', updateCustomerSchema] }) ); diff --git a/src/models/updateMetadataRequest.ts b/src/models/updateMetadataRequest.ts index e199b51..187c5d8 100644 --- a/src/models/updateMetadataRequest.ts +++ b/src/models/updateMetadataRequest.ts @@ -12,6 +12,7 @@ export interface UpdateMetadataRequest { [key: string]: unknown; } -export const updateMetadataRequestSchema: Schema = expandoObject( - { metadata: ['metadata', optional(lazy(() => updateMetadataSchema))] } +export const updateMetadataRequestSchema: Schema = lazy( + () => + expandoObject({ metadata: ['metadata', optional(updateMetadataSchema)] }) ); diff --git a/src/models/updateMetafield.ts b/src/models/updateMetafield.ts index 7ee40f5..cdae5f2 100644 --- a/src/models/updateMetafield.ts +++ b/src/models/updateMetafield.ts @@ -20,17 +20,19 @@ export interface UpdateMetafield { name?: string; /** Warning: When updating a metafield's scope attribute, all scope attributes must be passed. Partially complete scope attributes will override the existing settings. */ scope?: MetafieldScope; - /** Indicates how data should be added to the metafield. For example, a text type is just a string, so a given metafield of this type can have any value attached. On the other hand, dropdown and radio have a set of allowed values that can be input, and appear differently on a Public Signup Page. Defaults to 'text' */ + /** Indicates the type of metafield. A text metafield allows any string value. Dropdown and radio metafields have a set of values that can be selected. Defaults to 'text'. */ inputType?: MetafieldInput; - /** Only applicable when input_type is radio or dropdown */ + /** Only applicable when input_type is radio or dropdown. */ mEnum?: string[]; [key: string]: unknown; } -export const updateMetafieldSchema: Schema = expandoObject({ - currentName: ['current_name', optional(string())], - name: ['name', optional(string())], - scope: ['scope', optional(lazy(() => metafieldScopeSchema))], - inputType: ['input_type', optional(metafieldInputSchema)], - mEnum: ['enum', optional(array(string()))], -}); +export const updateMetafieldSchema: Schema = lazy(() => + expandoObject({ + currentName: ['current_name', optional(string())], + name: ['name', optional(string())], + scope: ['scope', optional(metafieldScopeSchema)], + inputType: ['input_type', optional(metafieldInputSchema)], + mEnum: ['enum', optional(array(string()))], + }) +); diff --git a/src/models/updateMetafieldsRequest.ts b/src/models/updateMetafieldsRequest.ts index dd1719a..2fb8de8 100644 --- a/src/models/updateMetafieldsRequest.ts +++ b/src/models/updateMetafieldsRequest.ts @@ -4,7 +4,7 @@ * This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ). */ -import { expandoObject, optional, Schema } from '../schema.js'; +import { expandoObject, lazy, optional, Schema } from '../schema.js'; import { UpdateMetafieldsRequestMetafields, updateMetafieldsRequestMetafieldsSchema, @@ -15,11 +15,12 @@ export interface UpdateMetafieldsRequest { [key: string]: unknown; } -export const updateMetafieldsRequestSchema: Schema = expandoObject( - { - metafields: [ - 'metafields', - optional(updateMetafieldsRequestMetafieldsSchema), - ], - } +export const updateMetafieldsRequestSchema: Schema = lazy( + () => + expandoObject({ + metafields: [ + 'metafields', + optional(updateMetafieldsRequestMetafieldsSchema), + ], + }) ); diff --git a/src/models/updatePaymentProfile.ts b/src/models/updatePaymentProfile.ts index 95ae2dc..aaaa7e6 100644 --- a/src/models/updatePaymentProfile.ts +++ b/src/models/updatePaymentProfile.ts @@ -37,7 +37,7 @@ export interface UpdatePaymentProfile { billingState?: string; /** The credit card or bank account billing address zip code (i.e. 12345). This value is merely passed through to the payment gateway. */ billingZip?: string; - /** The credit card or bank account billing address country, required in [ISO_3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) format (i.e. “US”). This value is merely passed through to the payment gateway. Some gateways require country codes in a specific format. Please check your gateway’s documentation. If creating an ACH subscription, only US is supported at this time. */ + /** The credit card or bank account billing address country, required in [ISO_3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) format (i.e. “US”). This value is merely passed through to the payment gateway. Some gateways require country codes in a specific format. Check your gateway’s documentation. If creating an ACH subscription, only US is supported at this time. */ billingCountry?: string; /** Second line of the customer’s billing address i.e. Apt. 100 */ billingAddress2?: string | null; diff --git a/src/models/updatePaymentProfileRequest.ts b/src/models/updatePaymentProfileRequest.ts index 34778f8..29dba2f 100644 --- a/src/models/updatePaymentProfileRequest.ts +++ b/src/models/updatePaymentProfileRequest.ts @@ -15,8 +15,9 @@ export interface UpdatePaymentProfileRequest { [key: string]: unknown; } -export const updatePaymentProfileRequestSchema: Schema = expandoObject( - { - paymentProfile: ['payment_profile', lazy(() => updatePaymentProfileSchema)], - } +export const updatePaymentProfileRequestSchema: Schema = lazy( + () => + expandoObject({ + paymentProfile: ['payment_profile', updatePaymentProfileSchema], + }) ); diff --git a/src/models/updatePrice.ts b/src/models/updatePrice.ts index 2b3e18b..cec7b4a 100644 --- a/src/models/updatePrice.ts +++ b/src/models/updatePrice.ts @@ -4,7 +4,14 @@ * This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ). */ -import { boolean, expandoObject, number, optional, Schema } from '../schema.js'; +import { + boolean, + expandoObject, + lazy, + number, + optional, + Schema, +} from '../schema.js'; import { UpdatePriceEndingQuantity, updatePriceEndingQuantitySchema, @@ -28,16 +35,18 @@ export interface UpdatePrice { [key: string]: unknown; } -export const updatePriceSchema: Schema = expandoObject({ - id: ['id', optional(number())], - endingQuantity: [ - 'ending_quantity', - optional(updatePriceEndingQuantitySchema), - ], - unitPrice: ['unit_price', optional(updatePriceUnitPriceSchema)], - destroy: ['_destroy', optional(boolean())], - startingQuantity: [ - 'starting_quantity', - optional(updatePriceStartingQuantitySchema), - ], -}); +export const updatePriceSchema: Schema = lazy(() => + expandoObject({ + id: ['id', optional(number())], + endingQuantity: [ + 'ending_quantity', + optional(updatePriceEndingQuantitySchema), + ], + unitPrice: ['unit_price', optional(updatePriceUnitPriceSchema)], + destroy: ['_destroy', optional(boolean())], + startingQuantity: [ + 'starting_quantity', + optional(updatePriceStartingQuantitySchema), + ], + }) +); diff --git a/src/models/updateProductPricePointRequest.ts b/src/models/updateProductPricePointRequest.ts index b15bfcb..45bcc7c 100644 --- a/src/models/updateProductPricePointRequest.ts +++ b/src/models/updateProductPricePointRequest.ts @@ -15,6 +15,9 @@ export interface UpdateProductPricePointRequest { [key: string]: unknown; } -export const updateProductPricePointRequestSchema: Schema = expandoObject( - { pricePoint: ['price_point', lazy(() => updateProductPricePointSchema)] } +export const updateProductPricePointRequestSchema: Schema = lazy( + () => + expandoObject({ + pricePoint: ['price_point', updateProductPricePointSchema], + }) ); diff --git a/src/models/updateReasonCodeRequest.ts b/src/models/updateReasonCodeRequest.ts index ee6b74d..b797d44 100644 --- a/src/models/updateReasonCodeRequest.ts +++ b/src/models/updateReasonCodeRequest.ts @@ -15,6 +15,6 @@ export interface UpdateReasonCodeRequest { [key: string]: unknown; } -export const updateReasonCodeRequestSchema: Schema = expandoObject( - { reasonCode: ['reason_code', lazy(() => updateReasonCodeSchema)] } +export const updateReasonCodeRequestSchema: Schema = lazy( + () => expandoObject({ reasonCode: ['reason_code', updateReasonCodeSchema] }) ); diff --git a/src/models/updateSegment.ts b/src/models/updateSegment.ts index 6e5f710..562225b 100644 --- a/src/models/updateSegment.ts +++ b/src/models/updateSegment.ts @@ -18,10 +18,9 @@ export interface UpdateSegment { [key: string]: unknown; } -export const updateSegmentSchema: Schema = expandoObject({ - pricingScheme: ['pricing_scheme', pricingSchemeSchema], - prices: [ - 'prices', - optional(array(lazy(() => createOrUpdateSegmentPriceSchema))), - ], -}); +export const updateSegmentSchema: Schema = lazy(() => + expandoObject({ + pricingScheme: ['pricing_scheme', pricingSchemeSchema], + prices: ['prices', optional(array(createOrUpdateSegmentPriceSchema))], + }) +); diff --git a/src/models/updateSegmentRequest.ts b/src/models/updateSegmentRequest.ts index fdfe99d..3f49b31 100644 --- a/src/models/updateSegmentRequest.ts +++ b/src/models/updateSegmentRequest.ts @@ -12,6 +12,6 @@ export interface UpdateSegmentRequest { [key: string]: unknown; } -export const updateSegmentRequestSchema: Schema = expandoObject( - { segment: ['segment', lazy(() => updateSegmentSchema)] } +export const updateSegmentRequestSchema: Schema = lazy( + () => expandoObject({ segment: ['segment', updateSegmentSchema] }) ); diff --git a/src/models/updateSubscription.ts b/src/models/updateSubscription.ts index e511091..00aadc3 100644 --- a/src/models/updateSubscription.ts +++ b/src/models/updateSubscription.ts @@ -47,7 +47,7 @@ export interface UpdateSubscription { nextProductId?: string; nextProductPricePointId?: string; /** Use for subscriptions with product eligible for calendar billing only. Value can be 1-28 or 'end'. */ - snapDay?: UpdateSubscriptionSnapDay; + snapDay?: UpdateSubscriptionSnapDay | null; /** (Optional) Set this attribute to a future date/time to update a subscription in the Awaiting Signup Date state, to Awaiting Signup. In the Awaiting Signup state, a subscription behaves like any other. It can be canceled, allocated to, or have its billing date changed. etc. When the `initial_billing_at` date hits, the subscription will transition to the expected state. If the product has a trial, the subscription will enter a trial, otherwise it will go active. Setup fees will be respected either before or after the trial, as configured on the price point. If the payment is due at the initial_billing_at and it fails the subscription will be immediately canceled. You can omit the initial_billing_at date to activate the subscription immediately. See the [subscription import](https://maxio.zendesk.com/hc/en-us/articles/24251489107213-Advanced-Billing-Subscription-Imports#date-format) documentation for more information about Date/Time formats. */ initialBillingAt?: string; /** (Optional) Set this attribute to true to move the subscription from Awaiting Signup, to Awaiting Signup Date. Use this when you want to update a subscription that has an unknown initial billing date. When the first billing date is known, update a subscription to set the `initial_billing_at` date. The subscription moves to the awaiting signup with a scheduled initial billing date. You can omit the initial_billing_at date to activate the subscription immediately. See [Subscription States](https://maxio-chargify.zendesk.com/hc/en-us/articles/5404222005773-Subscription-States) for more information. */ @@ -75,11 +75,11 @@ export interface UpdateSubscription { [key: string]: unknown; } -export const updateSubscriptionSchema: Schema = expandoObject( - { +export const updateSubscriptionSchema: Schema = lazy(() => + expandoObject({ creditCardAttributes: [ 'credit_card_attributes', - optional(lazy(() => creditCardAttributesSchema)), + optional(creditCardAttributesSchema), ], productHandle: ['product_handle', optional(string())], productId: ['product_id', optional(number())], @@ -89,7 +89,7 @@ export const updateSubscriptionSchema: Schema = expandoObjec 'next_product_price_point_id', optional(string()), ], - snapDay: ['snap_day', optional(updateSubscriptionSnapDaySchema)], + snapDay: ['snap_day', optional(nullable(updateSubscriptionSnapDaySchema))], initialBillingAt: ['initial_billing_at', optional(string())], deferSignup: ['defer_signup', optional(boolean())], nextBillingAt: ['next_billing_at', optional(string())], @@ -102,13 +102,10 @@ export const updateSubscriptionSchema: Schema = expandoObjec optional(number()), ], reference: ['reference', optional(string())], - customPrice: [ - 'custom_price', - optional(lazy(() => subscriptionCustomPriceSchema)), - ], + customPrice: ['custom_price', optional(subscriptionCustomPriceSchema)], components: [ 'components', - optional(array(lazy(() => updateSubscriptionComponentSchema))), + optional(array(updateSubscriptionComponentSchema)), ], dunningCommunicationDelayEnabled: [ 'dunning_communication_delay_enabled', @@ -120,5 +117,5 @@ export const updateSubscriptionSchema: Schema = expandoObjec ], productPricePointId: ['product_price_point_id', optional(number())], productPricePointHandle: ['product_price_point_handle', optional(string())], - } + }) ); diff --git a/src/models/updateSubscriptionComponent.ts b/src/models/updateSubscriptionComponent.ts index 7228400..70a1b33 100644 --- a/src/models/updateSubscriptionComponent.ts +++ b/src/models/updateSubscriptionComponent.ts @@ -17,12 +17,10 @@ export interface UpdateSubscriptionComponent { [key: string]: unknown; } -export const updateSubscriptionComponentSchema: Schema = expandoObject( - { - componentId: ['component_id', optional(number())], - customPrice: [ - 'custom_price', - optional(lazy(() => componentCustomPriceSchema)), - ], - } +export const updateSubscriptionComponentSchema: Schema = lazy( + () => + expandoObject({ + componentId: ['component_id', optional(number())], + customPrice: ['custom_price', optional(componentCustomPriceSchema)], + }) ); diff --git a/src/models/updateSubscriptionGroupRequest.ts b/src/models/updateSubscriptionGroupRequest.ts index 75e56ab..1b57bd5 100644 --- a/src/models/updateSubscriptionGroupRequest.ts +++ b/src/models/updateSubscriptionGroupRequest.ts @@ -15,11 +15,9 @@ export interface UpdateSubscriptionGroupRequest { [key: string]: unknown; } -export const updateSubscriptionGroupRequestSchema: Schema = expandoObject( - { - subscriptionGroup: [ - 'subscription_group', - lazy(() => updateSubscriptionGroupSchema), - ], - } +export const updateSubscriptionGroupRequestSchema: Schema = lazy( + () => + expandoObject({ + subscriptionGroup: ['subscription_group', updateSubscriptionGroupSchema], + }) ); diff --git a/src/models/updateSubscriptionNoteRequest.ts b/src/models/updateSubscriptionNoteRequest.ts index 81282f0..f4bb886 100644 --- a/src/models/updateSubscriptionNoteRequest.ts +++ b/src/models/updateSubscriptionNoteRequest.ts @@ -17,6 +17,6 @@ export interface UpdateSubscriptionNoteRequest { [key: string]: unknown; } -export const updateSubscriptionNoteRequestSchema: Schema = expandoObject( - { note: ['note', lazy(() => updateSubscriptionNoteSchema)] } +export const updateSubscriptionNoteRequestSchema: Schema = lazy( + () => expandoObject({ note: ['note', updateSubscriptionNoteSchema] }) ); diff --git a/src/models/updateSubscriptionRequest.ts b/src/models/updateSubscriptionRequest.ts index 6f62c38..66ceb20 100644 --- a/src/models/updateSubscriptionRequest.ts +++ b/src/models/updateSubscriptionRequest.ts @@ -15,6 +15,7 @@ export interface UpdateSubscriptionRequest { [key: string]: unknown; } -export const updateSubscriptionRequestSchema: Schema = expandoObject( - { subscription: ['subscription', lazy(() => updateSubscriptionSchema)] } +export const updateSubscriptionRequestSchema: Schema = lazy( + () => + expandoObject({ subscription: ['subscription', updateSubscriptionSchema] }) ); diff --git a/src/models/upsertPrepaidConfigurationRequest.ts b/src/models/upsertPrepaidConfigurationRequest.ts index 5f770b8..497e6d6 100644 --- a/src/models/upsertPrepaidConfigurationRequest.ts +++ b/src/models/upsertPrepaidConfigurationRequest.ts @@ -15,11 +15,12 @@ export interface UpsertPrepaidConfigurationRequest { [key: string]: unknown; } -export const upsertPrepaidConfigurationRequestSchema: Schema = expandoObject( - { - prepaidConfiguration: [ - 'prepaid_configuration', - lazy(() => upsertPrepaidConfigurationSchema), - ], - } +export const upsertPrepaidConfigurationRequestSchema: Schema = lazy( + () => + expandoObject({ + prepaidConfiguration: [ + 'prepaid_configuration', + upsertPrepaidConfigurationSchema, + ], + }) ); diff --git a/src/models/usage.ts b/src/models/usage.ts index 233ac87..c346e3d 100644 --- a/src/models/usage.ts +++ b/src/models/usage.ts @@ -7,6 +7,7 @@ import { bigint, expandoObject, + lazy, nullable, number, optional, @@ -31,14 +32,16 @@ export interface Usage { [key: string]: unknown; } -export const usageSchema: Schema = expandoObject({ - id: ['id', optional(bigint())], - memo: ['memo', optional(nullable(string()))], - createdAt: ['created_at', optional(string())], - pricePointId: ['price_point_id', optional(number())], - quantity: ['quantity', optional(usageQuantitySchema)], - overageQuantity: ['overage_quantity', optional(number())], - componentId: ['component_id', optional(number())], - componentHandle: ['component_handle', optional(string())], - subscriptionId: ['subscription_id', optional(number())], -}); +export const usageSchema: Schema = lazy(() => + expandoObject({ + id: ['id', optional(bigint())], + memo: ['memo', optional(nullable(string()))], + createdAt: ['created_at', optional(string())], + pricePointId: ['price_point_id', optional(number())], + quantity: ['quantity', optional(usageQuantitySchema)], + overageQuantity: ['overage_quantity', optional(number())], + componentId: ['component_id', optional(number())], + componentHandle: ['component_handle', optional(string())], + subscriptionId: ['subscription_id', optional(number())], + }) +); diff --git a/src/models/usageResponse.ts b/src/models/usageResponse.ts index 731659a..82caa8b 100644 --- a/src/models/usageResponse.ts +++ b/src/models/usageResponse.ts @@ -12,6 +12,6 @@ export interface UsageResponse { [key: string]: unknown; } -export const usageResponseSchema: Schema = expandoObject({ - usage: ['usage', lazy(() => usageSchema)], -}); +export const usageResponseSchema: Schema = lazy(() => + expandoObject({ usage: ['usage', usageSchema] }) +); diff --git a/src/models/voidInvoiceEvent.ts b/src/models/voidInvoiceEvent.ts index 289660e..c36f663 100644 --- a/src/models/voidInvoiceEvent.ts +++ b/src/models/voidInvoiceEvent.ts @@ -25,10 +25,12 @@ export interface VoidInvoiceEvent { [key: string]: unknown; } -export const voidInvoiceEventSchema: Schema = expandoObject({ - id: ['id', bigint()], - timestamp: ['timestamp', string()], - invoice: ['invoice', lazy(() => invoiceSchema)], - eventType: ['event_type', invoiceEventTypeSchema], - eventData: ['event_data', lazy(() => voidInvoiceEventDataSchema)], -}); +export const voidInvoiceEventSchema: Schema = lazy(() => + expandoObject({ + id: ['id', bigint()], + timestamp: ['timestamp', string()], + invoice: ['invoice', invoiceSchema], + eventType: ['event_type', invoiceEventTypeSchema], + eventData: ['event_data', voidInvoiceEventDataSchema], + }) +); diff --git a/src/models/voidInvoiceEventData.ts b/src/models/voidInvoiceEventData.ts index 2ea8038..241af2c 100644 --- a/src/models/voidInvoiceEventData.ts +++ b/src/models/voidInvoiceEventData.ts @@ -30,16 +30,17 @@ export interface VoidInvoiceEventData { [key: string]: unknown; } -export const voidInvoiceEventDataSchema: Schema = expandoObject( - { - creditNoteAttributes: [ - 'credit_note_attributes', - nullable(lazy(() => creditNoteSchema)), - ], - memo: ['memo', nullable(string())], - appliedAmount: ['applied_amount', nullable(string())], - transactionTime: ['transaction_time', nullable(string())], - isAdvanceInvoice: ['is_advance_invoice', boolean()], - reason: ['reason', string()], - } +export const voidInvoiceEventDataSchema: Schema = lazy( + () => + expandoObject({ + creditNoteAttributes: [ + 'credit_note_attributes', + nullable(creditNoteSchema), + ], + memo: ['memo', nullable(string())], + appliedAmount: ['applied_amount', nullable(string())], + transactionTime: ['transaction_time', nullable(string())], + isAdvanceInvoice: ['is_advance_invoice', boolean()], + reason: ['reason', string()], + }) ); diff --git a/src/models/voidInvoiceRequest.ts b/src/models/voidInvoiceRequest.ts index e079291..7780df7 100644 --- a/src/models/voidInvoiceRequest.ts +++ b/src/models/voidInvoiceRequest.ts @@ -12,6 +12,6 @@ export interface VoidInvoiceRequest { [key: string]: unknown; } -export const voidInvoiceRequestSchema: Schema = expandoObject( - { mVoid: ['void', lazy(() => voidInvoiceSchema)] } +export const voidInvoiceRequestSchema: Schema = lazy(() => + expandoObject({ mVoid: ['void', voidInvoiceSchema] }) ); diff --git a/src/models/voidRemainderEvent.ts b/src/models/voidRemainderEvent.ts index 4158261..ca2926b 100644 --- a/src/models/voidRemainderEvent.ts +++ b/src/models/voidRemainderEvent.ts @@ -25,12 +25,12 @@ export interface VoidRemainderEvent { [key: string]: unknown; } -export const voidRemainderEventSchema: Schema = expandoObject( - { +export const voidRemainderEventSchema: Schema = lazy(() => + expandoObject({ id: ['id', bigint()], timestamp: ['timestamp', string()], - invoice: ['invoice', lazy(() => invoiceSchema)], + invoice: ['invoice', invoiceSchema], eventType: ['event_type', invoiceEventTypeSchema], - eventData: ['event_data', lazy(() => voidRemainderEventDataSchema)], - } + eventData: ['event_data', voidRemainderEventDataSchema], + }) ); diff --git a/src/models/voidRemainderEventData.ts b/src/models/voidRemainderEventData.ts index 026b705..a51a941 100644 --- a/src/models/voidRemainderEventData.ts +++ b/src/models/voidRemainderEventData.ts @@ -19,14 +19,12 @@ export interface VoidRemainderEventData { [key: string]: unknown; } -export const voidRemainderEventDataSchema: Schema = expandoObject( - { - creditNoteAttributes: [ - 'credit_note_attributes', - lazy(() => creditNoteSchema), - ], - memo: ['memo', string()], - appliedAmount: ['applied_amount', string()], - transactionTime: ['transaction_time', string()], - } +export const voidRemainderEventDataSchema: Schema = lazy( + () => + expandoObject({ + creditNoteAttributes: ['credit_note_attributes', creditNoteSchema], + memo: ['memo', string()], + appliedAmount: ['applied_amount', string()], + transactionTime: ['transaction_time', string()], + }) ); diff --git a/src/models/webhookResponse.ts b/src/models/webhookResponse.ts index 694ceee..f51ed6a 100644 --- a/src/models/webhookResponse.ts +++ b/src/models/webhookResponse.ts @@ -12,6 +12,6 @@ export interface WebhookResponse { [key: string]: unknown; } -export const webhookResponseSchema: Schema = expandoObject({ - webhook: ['webhook', optional(lazy(() => webhookSchema))], -}); +export const webhookResponseSchema: Schema = lazy(() => + expandoObject({ webhook: ['webhook', optional(webhookSchema)] }) +);