Skip to content

Commit

Permalink
[DE-746] Update SDK (#64)
Browse files Browse the repository at this point in the history
- Removed deprecated authentication scheme
- Improved error handling, introduced error templates
- Enabled additional model properties
- Renamed `BulkComponentSPricePointAssignment` to `BulkComponentsPricePointAssignment`
- Add query parameters for list subscription group proforma invoices
- Use ProformaInvoiceStatus for list proforma invoices status query parameter
- Added missing fields in the `Allocation` model
- Added missing `404` errors for subscription components endpoints
- Renamed components price points related models to match the proper camelCase style
- Changed `includeNextProformaInvoice` param type from `String` to an enum
- Add enums for proforma invoices and invoices properties:
  - Invoice Discount Source Type
  - Invoice Discount Type
  - Proforma Invoice Discount Source Type
  - Proforma Invoice Role
  - Proforma Invoice Status
  - Tax Source Type
- Remove `ProformaTaxBreakout`, use `InvoiceTaxBreakout` instead
- Make Proforma Invoice reuse `InvoiceConsolidationLevel` and `CollectionMethod` enums instead of strings
- Remove ProformaInvoiceDiscountBreakout - use InvoiceDiscountBreakout instead
- Add missing fields for ProformaInvoiceDiscount
- Add tests for Proforma Invoices
- Merge proforma invoice and preview proforma, add kind for invoice line item
- Add kind to invoice line item
- Add apply_on_subscription_expiration to Coupon models
  • Loading branch information
maciej-nedza authored Mar 5, 2024
1 parent a9e0b42 commit 554c052
Show file tree
Hide file tree
Showing 531 changed files with 3,240 additions and 2,149 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ The following parameters are configurable for the API Client:
| --- | --- | --- |
| `subdomain` | `string` | The subdomain for your Chargify site.<br>*Default*: `'subdomain'` |
| `domain` | `string` | The Chargify server domain.<br>*Default*: `'chargify.com'` |
| `environment` | Environment | The API environment. <br> **Default: `Environment.Production`** |
| `environment` | `Environment` | The API environment. <br> **Default: `Environment.Production`** |
| `timeout` | `number` | Timeout for API calls.<br>*Default*: `30000` |
| `httpClientOptions` | `Partial<HttpClientOptions>` | Stable configurable http client options. |
| `unstableHttpClientOptions` | `any` | Unstable configurable http client options. |
Expand Down
2 changes: 1 addition & 1 deletion doc/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The following parameters are configurable for the API Client:
| --- | --- | --- |
| `subdomain` | `string` | The subdomain for your Chargify site.<br>*Default*: `'subdomain'` |
| `domain` | `string` | The Chargify server domain.<br>*Default*: `'chargify.com'` |
| `environment` | Environment | The API environment. <br> **Default: `Environment.Production`** |
| `environment` | `Environment` | The API environment. <br> **Default: `Environment.Production`** |
| `timeout` | `number` | Timeout for API calls.<br>*Default*: `30000` |
| `httpClientOptions` | `Partial<HttpClientOptions>` | Stable configurable http client options. |
| `unstableHttpClientOptions` | `any` | Unstable configurable http client options. |
Expand Down
2 changes: 1 addition & 1 deletion doc/controllers/invoices.md
Original file line number Diff line number Diff line change
Expand Up @@ -3191,7 +3191,7 @@ try {
],
"taxes": [
{
"source_type": "enim",
"source_type": "Tax",
"line_item_breakouts": [
{
"uid": "in ipsum",
Expand Down
37 changes: 28 additions & 9 deletions doc/controllers/proforma-invoices.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ By default, proforma invoices returned on the index will only include totals, no
```ts
async listSubscriptionGroupProformaInvoices(
uid: string,
lineItems?: boolean,
discounts?: boolean,
taxes?: boolean,
credits?: boolean,
payments?: boolean,
customFields?: boolean,
requestOptions?: RequestOptions
): Promise<ApiResponse<ListProformaInvoicesResponse>>
```
Expand All @@ -95,6 +101,12 @@ async listSubscriptionGroupProformaInvoices(
| Parameter | Type | Tags | Description |
| --- | --- | --- | --- |
| `uid` | `string` | Template, Required | The uid of the subscription group |
| `lineItems` | `boolean \| undefined` | Query, Optional | Include line items data |
| `discounts` | `boolean \| undefined` | Query, Optional | Include discounts data |
| `taxes` | `boolean \| undefined` | Query, Optional | Include taxes data |
| `credits` | `boolean \| undefined` | Query, Optional | Include credits data |
| `payments` | `boolean \| undefined` | Query, Optional | Include payments data |
| `customFields` | `boolean \| undefined` | Query, Optional | Include custom fields data |
| `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. |

## Response Type
Expand All @@ -104,12 +116,19 @@ async listSubscriptionGroupProformaInvoices(
## Example Usage

```ts
const uid = 'uid0';

const collect = {
uid: 'uid0',
lineItems: false,
discounts: false,
taxes: false,
credits: false,
payments: false,
customFields: false
}
try {
// @ts-expect-error: unused variables
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { result, ...httpResponse } = await proformaInvoicesController.listSubscriptionGroupProformaInvoices(uid);
const { result, ...httpResponse } = await proformaInvoicesController.listSubscriptionGroupProformaInvoices(collect);
// Get more response info...
// const { statusCode, headers } = httpResponse;
} catch (error) {
Expand Down Expand Up @@ -248,7 +267,7 @@ async listProformaInvoices(
subscriptionId: number,
startDate?: string,
endDate?: string,
status?: InvoiceStatus,
status?: ProformaInvoiceStatus,
page?: number,
perPage?: number,
direction?: Direction,
Expand All @@ -269,7 +288,7 @@ async listProformaInvoices(
| `subscriptionId` | `number` | Template, Required | The Chargify id of the subscription |
| `startDate` | `string \| undefined` | Query, Optional | The beginning date range for the invoice's Due Date, in the YYYY-MM-DD format. |
| `endDate` | `string \| undefined` | Query, Optional | The ending date range for the invoice's Due Date, in the YYYY-MM-DD format. |
| `status` | [`InvoiceStatus \| undefined`](../../doc/models/invoice-status.md) | Query, Optional | The current status of the invoice. Allowed Values: draft, open, paid, pending, voided |
| `status` | [`ProformaInvoiceStatus \| undefined`](../../doc/models/proforma-invoice-status.md) | Query, Optional | The current status of the invoice. Allowed Values: draft, open, paid, pending, voided |
| `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.<br>Use in query `page=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.<br>Use in query `per_page=200`. |
| `direction` | [`Direction \| undefined`](../../doc/models/direction.md) | Query, Optional | The sort direction of the returned invoices. |
Expand Down Expand Up @@ -392,7 +411,7 @@ Alternatively, if you have some proforma invoices already, you may make a previe
async previewProformaInvoice(
subscriptionId: number,
requestOptions?: RequestOptions
): Promise<ApiResponse<ProformaInvoicePreview>>
): Promise<ApiResponse<ProformaInvoice>>
```

## Parameters
Expand All @@ -404,7 +423,7 @@ async previewProformaInvoice(

## Response Type

[`ProformaInvoicePreview`](../../doc/models/proforma-invoice-preview.md)
[`ProformaInvoice`](../../doc/models/proforma-invoice.md)

## Example Usage

Expand Down Expand Up @@ -513,7 +532,7 @@ A product and customer first name, last name, and email are the minimum requirem

```ts
async previewSignupProformaInvoice(
includeNextProformaInvoice?: string,
include?: CreateSignupProformaPreviewInclude,
body?: CreateSubscriptionRequest,
requestOptions?: RequestOptions
): Promise<ApiResponse<SignupProformaPreviewResponse>>
Expand All @@ -523,7 +542,7 @@ async previewSignupProformaInvoice(

| Parameter | Type | Tags | Description |
| --- | --- | --- | --- |
| `includeNextProformaInvoice` | `string \| undefined` | Query, Optional | Choose to include a proforma invoice preview for the first renewal |
| `include` | [`CreateSignupProformaPreviewInclude \| undefined`](../../doc/models/create-signup-proforma-preview-include.md) | Query, Optional | Choose to include a proforma invoice preview for the first renewal. Use in query `include=next_proforma_invoice`. |
| `body` | [`CreateSubscriptionRequest \| undefined`](../../doc/models/create-subscription-request.md) | Body, Optional | - |
| `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. |

Expand Down
44 changes: 30 additions & 14 deletions doc/controllers/subscription-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,29 +229,29 @@ The `price_point` key can take either a:
```ts
async bulkUpdateSubscriptionComponentsPricePoints(
subscriptionId: number,
body?: BulkComponentSPricePointAssignment,
body?: BulkComponentsPricePointAssignment,
requestOptions?: RequestOptions
): Promise<ApiResponse<BulkComponentSPricePointAssignment>>
): Promise<ApiResponse<BulkComponentsPricePointAssignment>>
```

## Parameters

| Parameter | Type | Tags | Description |
| --- | --- | --- | --- |
| `subscriptionId` | `number` | Template, Required | The Chargify id of the subscription |
| `body` | [`BulkComponentSPricePointAssignment \| undefined`](../../doc/models/bulk-component-s-price-point-assignment.md) | Body, Optional | - |
| `body` | [`BulkComponentsPricePointAssignment \| undefined`](../../doc/models/bulk-components-price-point-assignment.md) | Body, Optional | - |
| `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. |

## Response Type

[`BulkComponentSPricePointAssignment`](../../doc/models/bulk-component-s-price-point-assignment.md)
[`BulkComponentsPricePointAssignment`](../../doc/models/bulk-components-price-point-assignment.md)

## Example Usage

```ts
const subscriptionId = 222;

const body: BulkComponentSPricePointAssignment = {
const body: BulkComponentsPricePointAssignment = {
components: [
{
componentId: 997,
Expand Down Expand Up @@ -361,7 +361,7 @@ try {
```json
{
"subscription": {
"id": -80293620,
"id": 80293620,
"state": "active",
"trial_started_at": null,
"trial_ended_at": null,
Expand Down Expand Up @@ -681,14 +681,28 @@ try {
[
{
"allocation": {
"memo": "moving to 7",
"timestamp": "2012-11-20T22:00:37Z",
"quantity": 7,
"previous_quantity": 3,
"component_id": 11960,
"subscription_id": 2585595,
"proration_upgrade_scheme": "no-prorate",
"proration_downgrade_scheme": "no-prorate"
"allocation_id": 2370199,
"component_id": 41028,
"subscription_id": 352827,
"quantity": 10,
"previous_quantity": 0,
"memo": "Recoding component allocation",
"timestamp": "2024-02-28T09:31:05Z",
"proration_upgrade_scheme": "full-price-attempt-capture",
"proration_downgrade_scheme": "no-prorate",
"price_point_id": 2957424,
"price_point_handle": "uuid:03190e20-b84a-013c-ca77-0286551bb34f",
"price_point_name": "Original",
"previous_price_point_id": 2957424,
"component_handle": "test-prepaid-component-4982065948",
"accrue_charge": false,
"upgrade_charge": "full",
"downgrade_credit": "none",
"created_at": "2024-02-28T04:31:05-05:00",
"initiate_dunning": false,
"expires_at": "2024-08-03T20:00:00-04:00",
"used_quantity": 5,
"charge_id": 11586076
}
},
{
Expand Down Expand Up @@ -1090,6 +1104,7 @@ try {

| HTTP Status Code | Error Description | Exception Class |
| --- | --- | --- |
| 404 | Not Found | `ApiError` |
| 422 | Unprocessable Entity (WebDAV) | [`SubscriptionComponentAllocationError`](../../doc/models/subscription-component-allocation-error.md) |


Expand Down Expand Up @@ -1167,6 +1182,7 @@ try {

| HTTP Status Code | Error Description | Exception Class |
| --- | --- | --- |
| 404 | Not Found | `ApiError` |
| 422 | Unprocessable Entity (WebDAV) | [`SubscriptionComponentAllocationError`](../../doc/models/subscription-component-allocation-error.md) |


Expand Down
3 changes: 3 additions & 0 deletions doc/models/allocation.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
| `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.<br>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.<br>Available values: `full`, `prorated`, `none`. |
| `payment` | [`AllocationPayment \| null \| undefined`](../../doc/models/containers/allocation-payment.md) | Optional | This is a container for one-of cases. |
| `expiresAt` | `string \| undefined` | Optional | - |
| `usedQuantity` | `bigint \| undefined` | Optional | - |
| `chargeId` | `bigint \| undefined` | Optional | - |

## Example (as JSON)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@

# Bulk Component S Price Point Assignment
# Bulk Components Price Point Assignment

## Structure

`BulkComponentSPricePointAssignment`
`BulkComponentsPricePointAssignment`

## Fields

| Name | Type | Tags | Description |
| --- | --- | --- | --- |
| `components` | [`ComponentSPricePointAssignment[] \| undefined`](../../doc/models/component-s-price-point-assignment.md) | Optional | - |
| `components` | [`ComponentPricePointAssignment[] \| undefined`](../../doc/models/component-price-point-assignment.md) | Optional | - |

## Example (as JSON)

Expand Down
23 changes: 23 additions & 0 deletions doc/models/component-price-point-assignment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

# Component Price Point Assignment

## Structure

`ComponentPricePointAssignment`

## Fields

| Name | Type | Tags | Description |
| --- | --- | --- | --- |
| `componentId` | `number \| undefined` | Optional | - |
| `pricePoint` | [`ComponentPricePointAssignmentPricePoint \| undefined`](../../doc/models/containers/component-price-point-assignment-price-point.md) | Optional | This is a container for one-of cases. |

## Example (as JSON)

```json
{
"component_id": 114,
"price_point": "String9"
}
```

23 changes: 0 additions & 23 deletions doc/models/component-s-price-point-assignment.md

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

# Component Price Point Assignment Price Point

## Class Name

`ComponentPricePointAssignmentPricePoint`

## Cases

| Type |
| --- |
| `string` |
| `number` |

This file was deleted.

1 change: 1 addition & 0 deletions doc/models/coupon.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
| `discountType` | [`DiscountType \| undefined`](../../doc/models/discount-type.md) | Optional | - |
| `excludeMidPeriodAllocations` | `boolean \| undefined` | Optional | - |
| `applyOnCancelAtEndOfPeriod` | `boolean \| undefined` | Optional | - |
| `applyOnSubscriptionExpiration` | `boolean \| undefined` | Optional | - |
| `couponRestrictions` | [`CouponRestriction[] \| undefined`](../../doc/models/coupon-restriction.md) | Optional | - |

## Example (as JSON)
Expand Down
1 change: 1 addition & 0 deletions doc/models/create-or-update-flat-amount-coupon.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
| `compoundingStrategy` | [`CompoundingStrategy \| undefined`](../../doc/models/compounding-strategy.md) | Optional | - |
| `excludeMidPeriodAllocations` | `boolean \| undefined` | Optional | - |
| `applyOnCancelAtEndOfPeriod` | `boolean \| undefined` | Optional | - |
| `applyOnSubscriptionExpiration` | `boolean \| undefined` | Optional | - |

## Example (as JSON)

Expand Down
1 change: 1 addition & 0 deletions doc/models/create-or-update-percentage-coupon.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
| `compoundingStrategy` | [`CompoundingStrategy \| undefined`](../../doc/models/compounding-strategy.md) | Optional | - |
| `excludeMidPeriodAllocations` | `boolean \| undefined` | Optional | - |
| `applyOnCancelAtEndOfPeriod` | `boolean \| undefined` | Optional | - |
| `applyOnSubscriptionExpiration` | `boolean \| undefined` | Optional | - |

## Example (as JSON)

Expand Down
19 changes: 19 additions & 0 deletions doc/models/create-signup-proforma-preview-include.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

# Create Signup Proforma Preview Include

## Enumeration

`CreateSignupProformaPreviewInclude`

## Fields

| Name |
| --- |
| `nextProformaInvoice` |

## Example

```
next_proforma_invoice
```

15 changes: 15 additions & 0 deletions doc/models/invoice-discount-source-type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

# Invoice Discount Source Type

## Enumeration

`InvoiceDiscountSourceType`

## Fields

| Name |
| --- |
| `coupon` |
| `referral` |
| `enumAdHocCoupon` |

Loading

0 comments on commit 554c052

Please sign in to comment.