diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 58c53eae..5ed75d11 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "4.51.0" + ".": "4.52.0" } diff --git a/.stats.yml b/.stats.yml index efeca04e..ae0299a7 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 101 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-7fca89ba5a0b4997358c25e6cdfb616a1d8b93a6820e25078f3fa5f61110bfe6.yml +configured_endpoints: 103 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-326205df28a52e9ad57c34d7ed1ec85fadd67f9a041df2882ebaa65f6de09930.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index 431892c9..f70f778d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 4.52.0 (2025-01-23) + +Full Changelog: [v4.51.0...v4.52.0](https://github.com/orbcorp/orb-node/compare/v4.51.0...v4.52.0) + +### Features + +* **api:** api update ([#484](https://github.com/orbcorp/orb-node/issues/484)) ([e47c418](https://github.com/orbcorp/orb-node/commit/e47c41801bd4143c786622ce56e15048f9528e13)) + ## 4.51.0 (2025-01-22) Full Changelog: [v4.50.0...v4.51.0](https://github.com/orbcorp/orb-node/compare/v4.50.0...v4.51.0) diff --git a/api.md b/api.md index 6d446d0c..12415ef6 100644 --- a/api.md +++ b/api.md @@ -66,6 +66,8 @@ Methods: - client.customers.delete(customerId) -> void - client.customers.fetch(customerId) -> Customer - client.customers.fetchByExternalId(externalCustomerId) -> Customer +- client.customers.syncPaymentMethodsFromGateway(externalCustomerId) -> void +- client.customers.syncPaymentMethodsFromGatewayByExternalCustomerId(customerId) -> void - client.customers.updateByExternalId(id, { ...params }) -> Customer ## Costs diff --git a/package.json b/package.json index cd6a031d..ca845fb1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "orb-billing", - "version": "4.51.0", + "version": "4.52.0", "description": "The official TypeScript library for the Orb API", "author": "Orb ", "types": "dist/index.d.ts", diff --git a/src/resources/customers/customers.ts b/src/resources/customers/customers.ts index 4e2b2bb2..be9a2489 100644 --- a/src/resources/customers/customers.ts +++ b/src/resources/customers/customers.ts @@ -138,6 +138,42 @@ export class Customers extends APIResource { return this._client.get(`/customers/external_customer_id/${externalCustomerId}`, options); } + /** + * Sync Orb's payment methods for the customer with their gateway. + * + * This method can be called before taking an action that may cause the customer to + * be charged, ensuring that the most up-to-date payment method is charged. + * + * **Note**: This functionality is currently only available for Stripe. + */ + syncPaymentMethodsFromGateway( + externalCustomerId: string, + options?: Core.RequestOptions, + ): Core.APIPromise { + return this._client.post( + `/customers/external_customer_id/${externalCustomerId}/sync_payment_methods_from_gateway`, + { ...options, headers: { Accept: '*/*', ...options?.headers } }, + ); + } + + /** + * Sync Orb's payment methods for the customer with their gateway. + * + * This method can be called before taking an action that may cause the customer to + * be charged, ensuring that the most up-to-date payment method is charged. + * + * **Note**: This functionality is currently only available for Stripe. + */ + syncPaymentMethodsFromGatewayByExternalCustomerId( + customerId: string, + options?: Core.RequestOptions, + ): Core.APIPromise { + return this._client.post(`/customers/${customerId}/sync_payment_methods_from_gateway`, { + ...options, + headers: { Accept: '*/*', ...options?.headers }, + }); + } + /** * This endpoint is used to update customer details given an `external_customer_id` * (see [Customer ID Aliases](/events-and-metrics/customer-aliases)). Note that the diff --git a/src/resources/invoices.ts b/src/resources/invoices.ts index 3f18ac11..b9ea5859 100644 --- a/src/resources/invoices.ts +++ b/src/resources/invoices.ts @@ -296,9 +296,10 @@ export interface Invoice { discounts: Array; /** - * When the invoice payment is due. + * When the invoice payment is due. The due date is null if the invoice is not yet + * finalized. */ - due_date: string; + due_date: string | null; /** * If the invoice has a status of `draft`, this will be the time that the invoice @@ -1286,9 +1287,10 @@ export interface InvoiceFetchUpcomingResponse { discounts: Array; /** - * When the invoice payment is due. + * When the invoice payment is due. The due date is null if the invoice is not yet + * finalized. */ - due_date: string; + due_date: string | null; /** * If the invoice has a status of `draft`, this will be the time that the invoice diff --git a/src/version.ts b/src/version.ts index 9daf60a2..0f31a077 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '4.51.0'; // x-release-please-version +export const VERSION = '4.52.0'; // x-release-please-version diff --git a/tests/api-resources/customers/customers.test.ts b/tests/api-resources/customers/customers.test.ts index abbde7fb..5cf54e85 100644 --- a/tests/api-resources/customers/customers.test.ts +++ b/tests/api-resources/customers/customers.test.ts @@ -165,6 +165,46 @@ describe('resource customers', () => { ).rejects.toThrow(Orb.NotFoundError); }); + test('syncPaymentMethodsFromGateway', async () => { + const responsePromise = client.customers.syncPaymentMethodsFromGateway('external_customer_id'); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('syncPaymentMethodsFromGateway: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.customers.syncPaymentMethodsFromGateway('external_customer_id', { + path: '/_stainless_unknown_path', + }), + ).rejects.toThrow(Orb.NotFoundError); + }); + + test('syncPaymentMethodsFromGatewayByExternalCustomerId', async () => { + const responsePromise = client.customers.syncPaymentMethodsFromGatewayByExternalCustomerId('customer_id'); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('syncPaymentMethodsFromGatewayByExternalCustomerId: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.customers.syncPaymentMethodsFromGatewayByExternalCustomerId('customer_id', { + path: '/_stainless_unknown_path', + }), + ).rejects.toThrow(Orb.NotFoundError); + }); + test('updateByExternalId', async () => { const responsePromise = client.customers.updateByExternalId('external_customer_id', {}); const rawResponse = await responsePromise.asResponse();