diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 12ba8adf..c83531e6 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "5.39.0" + ".": "5.40.0" } diff --git a/.stats.yml b/.stats.yml index 8f4293ee..df8db457 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 118 +configured_endpoints: 126 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-a5a28a58483355d3cc3da7ac5c452d548ee17183324318198052968121ca7dba.yml openapi_spec_hash: a317931a99e6d4a122919135a0363e40 -config_hash: 05c94c0e6dbeab2c9b554c2e0d6371a0 +config_hash: bcf82bddb691f6be773ac6cae8c03b9a diff --git a/CHANGELOG.md b/CHANGELOG.md index 3fb9fe1e..34f73810 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 5.40.0 (2026-01-08) + +Full Changelog: [v5.39.0...v5.40.0](https://github.com/orbcorp/orb-node/compare/v5.39.0...v5.40.0) + +### Features + +* **api:** manual updates ([bdaaa9a](https://github.com/orbcorp/orb-node/commit/bdaaa9af5f4d568507a10b4ca0e0e9daaf27937e)) + ## 5.39.0 (2026-01-06) Full Changelog: [v5.38.0...v5.39.0](https://github.com/orbcorp/orb-node/compare/v5.38.0...v5.39.0) diff --git a/api.md b/api.md index e031d974..5925d152 100644 --- a/api.md +++ b/api.md @@ -355,15 +355,18 @@ Methods: Types: - InvoiceFetchUpcomingResponse +- InvoiceListSummaryResponse Methods: - client.invoices.create({ ...params }) -> Invoice - client.invoices.update(invoiceId, { ...params }) -> Invoice - client.invoices.list({ ...params }) -> InvoicesPage +- client.invoices.deleteLineItem(invoiceId, lineItemId) -> void - client.invoices.fetch(invoiceId) -> Invoice - client.invoices.fetchUpcoming({ ...params }) -> InvoiceFetchUpcomingResponse - client.invoices.issue(invoiceId, { ...params }) -> Invoice +- client.invoices.listSummary({ ...params }) -> InvoiceListSummaryResponsesPage - client.invoices.markPaid(invoiceId, { ...params }) -> Invoice - client.invoices.pay(invoiceId) -> Invoice - client.invoices.void(invoiceId) -> Invoice @@ -415,6 +418,20 @@ Methods: - client.plans.externalPlanId.update(otherExternalPlanId, { ...params }) -> Plan - client.plans.externalPlanId.fetch(externalPlanId) -> Plan +## Migrations + +Types: + +- MigrationRetrieveResponse +- MigrationListResponse +- MigrationCancelResponse + +Methods: + +- client.plans.migrations.retrieve(planId, migrationId) -> MigrationRetrieveResponse +- client.plans.migrations.list(planId, { ...params }) -> MigrationListResponsesPage +- client.plans.migrations.cancel(planId, migrationId) -> MigrationCancelResponse + # Prices Types: @@ -542,11 +559,24 @@ Types: - MutatedSubscription - SubscriptionChangeRetrieveResponse +- SubscriptionChangeListResponse - SubscriptionChangeApplyResponse - SubscriptionChangeCancelResponse Methods: - client.subscriptionChanges.retrieve(subscriptionChangeId) -> SubscriptionChangeRetrieveResponse +- client.subscriptionChanges.list({ ...params }) -> SubscriptionChangeListResponsesPage - client.subscriptionChanges.apply(subscriptionChangeId, { ...params }) -> SubscriptionChangeApplyResponse - client.subscriptionChanges.cancel(subscriptionChangeId) -> SubscriptionChangeCancelResponse + +# CreditBlocks + +Types: + +- CreditBlockRetrieveResponse + +Methods: + +- client.creditBlocks.retrieve(blockId) -> CreditBlockRetrieveResponse +- client.creditBlocks.delete(blockId) -> void diff --git a/package.json b/package.json index 3607a1b5..302a2b73 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "orb-billing", - "version": "5.39.0", + "version": "5.40.0", "description": "The official TypeScript library for the Orb API", "author": "Orb ", "types": "dist/index.d.ts", diff --git a/src/index.ts b/src/index.ts index 78309250..1b264f79 100644 --- a/src/index.ts +++ b/src/index.ts @@ -21,6 +21,7 @@ import { AlertsPage, Threshold, } from './resources/alerts'; +import { CreditBlockRetrieveResponse, CreditBlocks } from './resources/credit-blocks'; import { CreditNoteCreateParams, CreditNoteListParams, CreditNotes } from './resources/credit-notes'; import { InvoiceLineItemCreateParams, @@ -33,6 +34,9 @@ import { InvoiceFetchUpcomingResponse, InvoiceIssueParams, InvoiceListParams, + InvoiceListSummaryParams, + InvoiceListSummaryResponse, + InvoiceListSummaryResponsesPage, InvoiceMarkPaidParams, InvoiceUpdateParams, Invoices, @@ -58,6 +62,9 @@ import { SubscriptionChangeApplyParams, SubscriptionChangeApplyResponse, SubscriptionChangeCancelResponse, + SubscriptionChangeListParams, + SubscriptionChangeListResponse, + SubscriptionChangeListResponsesPage, SubscriptionChangeRetrieveResponse, SubscriptionChanges, } from './resources/subscription-changes'; @@ -326,6 +333,7 @@ export class Orb extends Core.APIClient { alerts: API.Alerts = new API.Alerts(this); dimensionalPriceGroups: API.DimensionalPriceGroups = new API.DimensionalPriceGroups(this); subscriptionChanges: API.SubscriptionChanges = new API.SubscriptionChanges(this); + creditBlocks: API.CreditBlocks = new API.CreditBlocks(this); /** * Check whether the base URL is set to its default. @@ -396,6 +404,7 @@ Orb.CustomersPage = CustomersPage; Orb.Events = Events; Orb.InvoiceLineItems = InvoiceLineItems; Orb.Invoices = Invoices; +Orb.InvoiceListSummaryResponsesPage = InvoiceListSummaryResponsesPage; Orb.Items = Items; Orb.ItemsPage = ItemsPage; Orb.Metrics = Metrics; @@ -409,6 +418,8 @@ Orb.Alerts = Alerts; Orb.AlertsPage = AlertsPage; Orb.DimensionalPriceGroupsPage = DimensionalPriceGroupsPage; Orb.SubscriptionChanges = SubscriptionChanges; +Orb.SubscriptionChangeListResponsesPage = SubscriptionChangeListResponsesPage; +Orb.CreditBlocks = CreditBlocks; export declare namespace Orb { export type RequestOptions = Core.RequestOptions; @@ -478,11 +489,14 @@ export declare namespace Orb { export { Invoices as Invoices, type InvoiceFetchUpcomingResponse as InvoiceFetchUpcomingResponse, + type InvoiceListSummaryResponse as InvoiceListSummaryResponse, + InvoiceListSummaryResponsesPage as InvoiceListSummaryResponsesPage, type InvoiceCreateParams as InvoiceCreateParams, type InvoiceUpdateParams as InvoiceUpdateParams, type InvoiceListParams as InvoiceListParams, type InvoiceFetchUpcomingParams as InvoiceFetchUpcomingParams, type InvoiceIssueParams as InvoiceIssueParams, + type InvoiceListSummaryParams as InvoiceListSummaryParams, type InvoiceMarkPaidParams as InvoiceMarkPaidParams, }; @@ -604,11 +618,16 @@ export declare namespace Orb { SubscriptionChanges as SubscriptionChanges, type MutatedSubscription as MutatedSubscription, type SubscriptionChangeRetrieveResponse as SubscriptionChangeRetrieveResponse, + type SubscriptionChangeListResponse as SubscriptionChangeListResponse, type SubscriptionChangeApplyResponse as SubscriptionChangeApplyResponse, type SubscriptionChangeCancelResponse as SubscriptionChangeCancelResponse, + SubscriptionChangeListResponsesPage as SubscriptionChangeListResponsesPage, + type SubscriptionChangeListParams as SubscriptionChangeListParams, type SubscriptionChangeApplyParams as SubscriptionChangeApplyParams, }; + export { CreditBlocks as CreditBlocks, type CreditBlockRetrieveResponse as CreditBlockRetrieveResponse }; + export type Address = API.Address; export type AdjustmentInterval = API.AdjustmentInterval; export type AggregatedCost = API.AggregatedCost; diff --git a/src/resources/credit-blocks.ts b/src/resources/credit-blocks.ts new file mode 100644 index 00000000..ac8a8e9c --- /dev/null +++ b/src/resources/credit-blocks.ts @@ -0,0 +1,81 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../resource'; +import * as Core from '../core'; + +export class CreditBlocks extends APIResource { + /** + * This endpoint returns a credit block identified by its block_id. + */ + retrieve(blockId: string, options?: Core.RequestOptions): Core.APIPromise { + return this._client.get(`/credit_blocks/${blockId}`, options); + } + + /** + * This endpoint deletes a credit block by its ID. + * + * When a credit block is deleted: + * + * - The block is removed from the customer's credit ledger. + * - Any usage of the credit block is reversed, and the ledger is replayed as if + * the block never existed. + * - If invoices were generated from the purchase of the credit block, they will be + * deleted if in draft status, voided if issued, or a credit note will be issued + * if the invoice is paid. + * + * + * Issued invoices that had credits applied from this block will not be regenerated, but the ledger will + * reflect the state as if credits from the deleted block were never applied. + * + */ + delete(blockId: string, options?: Core.RequestOptions): Core.APIPromise { + return this._client.delete(`/credit_blocks/${blockId}`, { + ...options, + headers: { Accept: '*/*', ...options?.headers }, + }); + } +} + +/** + * The Credit Block resource models prepaid credits within Orb. + */ +export interface CreditBlockRetrieveResponse { + id: string; + + balance: number; + + effective_date: string | null; + + expiry_date: string | null; + + filters: Array; + + maximum_initial_balance: number | null; + + per_unit_cost_basis: string | null; + + status: 'active' | 'pending_payment'; +} + +export namespace CreditBlockRetrieveResponse { + export interface Filter { + /** + * The property of the price to filter on. + */ + field: 'price_id' | 'item_id' | 'price_type' | 'currency' | 'pricing_unit_id'; + + /** + * Should prices that match the filter be included or excluded. + */ + operator: 'includes' | 'excludes'; + + /** + * The IDs or values that match this filter. + */ + values: Array; + } +} + +export declare namespace CreditBlocks { + export { type CreditBlockRetrieveResponse as CreditBlockRetrieveResponse }; +} diff --git a/src/resources/index.ts b/src/resources/index.ts index 6f7450dc..ee5da84b 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -36,6 +36,7 @@ export { type CouponCreateParams, type CouponListParams, } from './coupons/coupons'; +export { CreditBlocks, type CreditBlockRetrieveResponse } from './credit-blocks'; export { CreditNotes, type CreditNoteCreateParams, type CreditNoteListParams } from './credit-notes'; export { CustomersPage, @@ -78,13 +79,16 @@ export { type InvoiceLineItemCreateParams, } from './invoice-line-items'; export { + InvoiceListSummaryResponsesPage, Invoices, type InvoiceFetchUpcomingResponse, + type InvoiceListSummaryResponse, type InvoiceCreateParams, type InvoiceUpdateParams, type InvoiceListParams, type InvoiceFetchUpcomingParams, type InvoiceIssueParams, + type InvoiceListSummaryParams, type InvoiceMarkPaidParams, } from './invoices'; export { @@ -117,11 +121,14 @@ export { type PriceEvaluatePreviewEventsParams, } from './prices/prices'; export { + SubscriptionChangeListResponsesPage, SubscriptionChanges, type MutatedSubscription, type SubscriptionChangeRetrieveResponse, + type SubscriptionChangeListResponse, type SubscriptionChangeApplyResponse, type SubscriptionChangeCancelResponse, + type SubscriptionChangeListParams, type SubscriptionChangeApplyParams, } from './subscription-changes'; export { diff --git a/src/resources/invoices.ts b/src/resources/invoices.ts index 58c92578..5713c0e8 100644 --- a/src/resources/invoices.ts +++ b/src/resources/invoices.ts @@ -5,7 +5,7 @@ import { isRequestOptions } from '../core'; import * as Core from '../core'; import * as Shared from './shared'; import { InvoicesPage } from './shared'; -import { type PageParams } from '../pagination'; +import { Page, type PageParams } from '../pagination'; export class Invoices extends APIResource { /** @@ -62,6 +62,24 @@ export class Invoices extends APIResource { return this._client.getAPIList('/invoices', InvoicesPage, { query, ...options }); } + /** + * This endpoint deletes an invoice line item from a draft invoice. + * + * This endpoint only allows deletion of one-off line items (not subscription-based + * line items). The invoice must be in a draft status for this operation to + * succeed. + */ + deleteLineItem( + invoiceId: string, + lineItemId: string, + options?: Core.RequestOptions, + ): Core.APIPromise { + return this._client.delete(`/invoices/${invoiceId}/invoice_line_items/${lineItemId}`, { + ...options, + headers: { Accept: '*/*', ...options?.headers }, + }); + } + /** * This endpoint is used to fetch an [`Invoice`](/core-concepts#invoice) given an * identifier. @@ -107,6 +125,44 @@ export class Invoices extends APIResource { return this._client.post(`/invoices/${invoiceId}/issue`, { body, ...options }); } + /** + * This is a lighter-weight endpoint that returns a list of all + * [`Invoice`](/core-concepts#invoice) summaries for an account in a list format. + * + * These invoice summaries do not include line item details, minimums, maximums, + * and discounts, making this endpoint more efficient. + * + * The list of invoices is ordered starting from the most recently issued invoice + * date. The response also includes + * [`pagination_metadata`](/api-reference/pagination), which lets the caller + * retrieve the next page of results if they exist. + * + * By default, this only returns invoices that are `issued`, `paid`, or `synced`. + * + * When fetching any `draft` invoices, this returns the last-computed invoice + * values for each draft invoice, which may not always be up-to-date since Orb + * regularly refreshes invoices asynchronously. + */ + listSummary( + query?: InvoiceListSummaryParams, + options?: Core.RequestOptions, + ): Core.PagePromise; + listSummary( + options?: Core.RequestOptions, + ): Core.PagePromise; + listSummary( + query: InvoiceListSummaryParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.PagePromise { + if (isRequestOptions(query)) { + return this.listSummary({}, query); + } + return this._client.getAPIList('/invoices/summary', InvoiceListSummaryResponsesPage, { + query, + ...options, + }); + } + /** * This endpoint allows an invoice's status to be set to the `paid` status. This * can only be done to invoices that are in the `issued` or `synced` status. @@ -145,6 +201,8 @@ export class Invoices extends APIResource { } } +export class InvoiceListSummaryResponsesPage extends Page {} + export interface InvoiceFetchUpcomingResponse { id: string; @@ -730,6 +788,457 @@ export namespace InvoiceFetchUpcomingResponse { } } +/** + * #InvoiceApiResourceWithoutLineItems + */ +export interface InvoiceListSummaryResponse { + id: string; + + /** + * This is the final amount required to be charged to the customer and reflects the + * application of the customer balance to the `total` of the invoice. + */ + amount_due: string; + + auto_collection: InvoiceListSummaryResponse.AutoCollection; + + billing_address: Shared.Address | null; + + /** + * The creation time of the resource in Orb. + */ + created_at: string; + + /** + * A list of credit notes associated with the invoice + */ + credit_notes: Array; + + /** + * An ISO 4217 currency string or `credits` + */ + currency: string; + + customer: Shared.CustomerMinified; + + customer_balance_transactions: Array; + + /** + * Tax IDs are commonly required to be displayed on customer invoices, which are + * added to the headers of invoices. + * + * ### Supported Tax ID Countries and Types + * + * | Country | Type | Description | + * | ---------------------- | ------------ | ------------------------------------------------------------------------------------------------------- | + * | Albania | `al_tin` | Albania Tax Identification Number | + * | Andorra | `ad_nrt` | Andorran NRT Number | + * | Angola | `ao_tin` | Angola Tax Identification Number | + * | Argentina | `ar_cuit` | Argentinian Tax ID Number | + * | Armenia | `am_tin` | Armenia Tax Identification Number | + * | Aruba | `aw_tin` | Aruba Tax Identification Number | + * | Australia | `au_abn` | Australian Business Number (AU ABN) | + * | Australia | `au_arn` | Australian Taxation Office Reference Number | + * | Austria | `eu_vat` | European VAT Number | + * | Azerbaijan | `az_tin` | Azerbaijan Tax Identification Number | + * | Bahamas | `bs_tin` | Bahamas Tax Identification Number | + * | Bahrain | `bh_vat` | Bahraini VAT Number | + * | Bangladesh | `bd_bin` | Bangladesh Business Identification Number | + * | Barbados | `bb_tin` | Barbados Tax Identification Number | + * | Belarus | `by_tin` | Belarus TIN Number | + * | Belgium | `eu_vat` | European VAT Number | + * | Benin | `bj_ifu` | Benin Tax Identification Number (Identifiant Fiscal Unique) | + * | Bolivia | `bo_tin` | Bolivian Tax ID | + * | Bosnia and Herzegovina | `ba_tin` | Bosnia and Herzegovina Tax Identification Number | + * | Brazil | `br_cnpj` | Brazilian CNPJ Number | + * | Brazil | `br_cpf` | Brazilian CPF Number | + * | Bulgaria | `bg_uic` | Bulgaria Unified Identification Code | + * | Bulgaria | `eu_vat` | European VAT Number | + * | Burkina Faso | `bf_ifu` | Burkina Faso Tax Identification Number (Numéro d'Identifiant Fiscal Unique) | + * | Cambodia | `kh_tin` | Cambodia Tax Identification Number | + * | Cameroon | `cm_niu` | Cameroon Tax Identification Number (Numéro d'Identifiant fiscal Unique) | + * | Canada | `ca_bn` | Canadian BN | + * | Canada | `ca_gst_hst` | Canadian GST/HST Number | + * | Canada | `ca_pst_bc` | Canadian PST Number (British Columbia) | + * | Canada | `ca_pst_mb` | Canadian PST Number (Manitoba) | + * | Canada | `ca_pst_sk` | Canadian PST Number (Saskatchewan) | + * | Canada | `ca_qst` | Canadian QST Number (Québec) | + * | Cape Verde | `cv_nif` | Cape Verde Tax Identification Number (Número de Identificação Fiscal) | + * | Chile | `cl_tin` | Chilean TIN | + * | China | `cn_tin` | Chinese Tax ID | + * | Colombia | `co_nit` | Colombian NIT Number | + * | Congo-Kinshasa | `cd_nif` | Congo (DR) Tax Identification Number (Número de Identificação Fiscal) | + * | Costa Rica | `cr_tin` | Costa Rican Tax ID | + * | Croatia | `eu_vat` | European VAT Number | + * | Croatia | `hr_oib` | Croatian Personal Identification Number (OIB) | + * | Cyprus | `eu_vat` | European VAT Number | + * | Czech Republic | `eu_vat` | European VAT Number | + * | Denmark | `eu_vat` | European VAT Number | + * | Dominican Republic | `do_rcn` | Dominican RCN Number | + * | Ecuador | `ec_ruc` | Ecuadorian RUC Number | + * | Egypt | `eg_tin` | Egyptian Tax Identification Number | + * | El Salvador | `sv_nit` | El Salvadorian NIT Number | + * | Estonia | `eu_vat` | European VAT Number | + * | Ethiopia | `et_tin` | Ethiopia Tax Identification Number | + * | European Union | `eu_oss_vat` | European One Stop Shop VAT Number for non-Union scheme | + * | Finland | `eu_vat` | European VAT Number | + * | France | `eu_vat` | European VAT Number | + * | Georgia | `ge_vat` | Georgian VAT | + * | Germany | `de_stn` | German Tax Number (Steuernummer) | + * | Germany | `eu_vat` | European VAT Number | + * | Greece | `eu_vat` | European VAT Number | + * | Guinea | `gn_nif` | Guinea Tax Identification Number (Número de Identificação Fiscal) | + * | Hong Kong | `hk_br` | Hong Kong BR Number | + * | Hungary | `eu_vat` | European VAT Number | + * | Hungary | `hu_tin` | Hungary Tax Number (adószám) | + * | Iceland | `is_vat` | Icelandic VAT | + * | India | `in_gst` | Indian GST Number | + * | Indonesia | `id_npwp` | Indonesian NPWP Number | + * | Ireland | `eu_vat` | European VAT Number | + * | Israel | `il_vat` | Israel VAT | + * | Italy | `eu_vat` | European VAT Number | + * | Japan | `jp_cn` | Japanese Corporate Number (_Hōjin Bangō_) | + * | Japan | `jp_rn` | Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_) | + * | Japan | `jp_trn` | Japanese Tax Registration Number (_Tōroku Bangō_) | + * | Kazakhstan | `kz_bin` | Kazakhstani Business Identification Number | + * | Kenya | `ke_pin` | Kenya Revenue Authority Personal Identification Number | + * | Kyrgyzstan | `kg_tin` | Kyrgyzstan Tax Identification Number | + * | Laos | `la_tin` | Laos Tax Identification Number | + * | Latvia | `eu_vat` | European VAT Number | + * | Liechtenstein | `li_uid` | Liechtensteinian UID Number | + * | Liechtenstein | `li_vat` | Liechtenstein VAT Number | + * | Lithuania | `eu_vat` | European VAT Number | + * | Luxembourg | `eu_vat` | European VAT Number | + * | Malaysia | `my_frp` | Malaysian FRP Number | + * | Malaysia | `my_itn` | Malaysian ITN | + * | Malaysia | `my_sst` | Malaysian SST Number | + * | Malta | `eu_vat` | European VAT Number | + * | Mauritania | `mr_nif` | Mauritania Tax Identification Number (Número de Identificação Fiscal) | + * | Mexico | `mx_rfc` | Mexican RFC Number | + * | Moldova | `md_vat` | Moldova VAT Number | + * | Montenegro | `me_pib` | Montenegro PIB Number | + * | Morocco | `ma_vat` | Morocco VAT Number | + * | Nepal | `np_pan` | Nepal PAN Number | + * | Netherlands | `eu_vat` | European VAT Number | + * | New Zealand | `nz_gst` | New Zealand GST Number | + * | Nigeria | `ng_tin` | Nigerian Tax Identification Number | + * | North Macedonia | `mk_vat` | North Macedonia VAT Number | + * | Northern Ireland | `eu_vat` | Northern Ireland VAT Number | + * | Norway | `no_vat` | Norwegian VAT Number | + * | Norway | `no_voec` | Norwegian VAT on e-commerce Number | + * | Oman | `om_vat` | Omani VAT Number | + * | Peru | `pe_ruc` | Peruvian RUC Number | + * | Philippines | `ph_tin` | Philippines Tax Identification Number | + * | Poland | `eu_vat` | European VAT Number | + * | Portugal | `eu_vat` | European VAT Number | + * | Romania | `eu_vat` | European VAT Number | + * | Romania | `ro_tin` | Romanian Tax ID Number | + * | Russia | `ru_inn` | Russian INN | + * | Russia | `ru_kpp` | Russian KPP | + * | Saudi Arabia | `sa_vat` | Saudi Arabia VAT | + * | Senegal | `sn_ninea` | Senegal NINEA Number | + * | Serbia | `rs_pib` | Serbian PIB Number | + * | Singapore | `sg_gst` | Singaporean GST | + * | Singapore | `sg_uen` | Singaporean UEN | + * | Slovakia | `eu_vat` | European VAT Number | + * | Slovenia | `eu_vat` | European VAT Number | + * | Slovenia | `si_tin` | Slovenia Tax Number (davčna številka) | + * | South Africa | `za_vat` | South African VAT Number | + * | South Korea | `kr_brn` | Korean BRN | + * | Spain | `es_cif` | Spanish NIF Number (previously Spanish CIF Number) | + * | Spain | `eu_vat` | European VAT Number | + * | Suriname | `sr_fin` | Suriname FIN Number | + * | Sweden | `eu_vat` | European VAT Number | + * | Switzerland | `ch_uid` | Switzerland UID Number | + * | Switzerland | `ch_vat` | Switzerland VAT Number | + * | Taiwan | `tw_vat` | Taiwanese VAT | + * | Tajikistan | `tj_tin` | Tajikistan Tax Identification Number | + * | Tanzania | `tz_vat` | Tanzania VAT Number | + * | Thailand | `th_vat` | Thai VAT | + * | Turkey | `tr_tin` | Turkish Tax Identification Number | + * | Uganda | `ug_tin` | Uganda Tax Identification Number | + * | Ukraine | `ua_vat` | Ukrainian VAT | + * | United Arab Emirates | `ae_trn` | United Arab Emirates TRN | + * | United Kingdom | `gb_vat` | United Kingdom VAT Number | + * | United States | `us_ein` | United States EIN | + * | Uruguay | `uy_ruc` | Uruguayan RUC Number | + * | Uzbekistan | `uz_tin` | Uzbekistan TIN Number | + * | Uzbekistan | `uz_vat` | Uzbekistan VAT Number | + * | Venezuela | `ve_rif` | Venezuelan RIF Number | + * | Vietnam | `vn_tin` | Vietnamese Tax ID Number | + * | Zambia | `zm_tin` | Zambia Tax Identification Number | + * | Zimbabwe | `zw_tin` | Zimbabwe Tax Identification Number | + */ + customer_tax_id: Shared.CustomerTaxID | null; + + /** + * When the invoice payment is due. The due date is null if the invoice is not yet + * finalized. + */ + due_date: string | null; + + /** + * If the invoice has a status of `draft`, this will be the time that the invoice + * will be eligible to be issued, otherwise it will be `null`. If `auto-issue` is + * true, the invoice will automatically begin issuing at this time. + */ + eligible_to_issue_at: string | null; + + /** + * A URL for the customer-facing invoice portal. This URL expires 30 days after the + * invoice's due date, or 60 days after being re-generated through the UI. + */ + hosted_invoice_url: string | null; + + /** + * The scheduled date of the invoice + */ + invoice_date: string; + + /** + * Automatically generated invoice number to help track and reconcile invoices. + * Invoice numbers have a prefix such as `RFOBWG`. These can be sequential per + * account or customer. + */ + invoice_number: string; + + /** + * The link to download the PDF representation of the `Invoice`. + */ + invoice_pdf: string | null; + + invoice_source: 'subscription' | 'partial' | 'one_off'; + + /** + * If the invoice failed to issue, this will be the last time it failed to issue + * (even if it is now in a different state.) + */ + issue_failed_at: string | null; + + /** + * If the invoice has been issued, this will be the time it transitioned to + * `issued` (even if it is now in a different state.) + */ + issued_at: string | null; + + /** + * Free-form text which is available on the invoice PDF and the Orb invoice portal. + */ + memo: string | null; + + /** + * User specified key-value pairs for the resource. If not present, this defaults + * to an empty dictionary. Individual keys can be removed by setting the value to + * `null`, and the entire metadata mapping can be cleared by setting `metadata` to + * `null`. + */ + metadata: { [key: string]: string }; + + /** + * If the invoice has a status of `paid`, this gives a timestamp when the invoice + * was paid. + */ + paid_at: string | null; + + /** + * A list of payment attempts associated with the invoice + */ + payment_attempts: Array; + + /** + * If payment was attempted on this invoice but failed, this will be the time of + * the most recent attempt. + */ + payment_failed_at: string | null; + + /** + * If payment was attempted on this invoice, this will be the start time of the + * most recent attempt. This field is especially useful for delayed-notification + * payment mechanisms (like bank transfers), where payment can take 3 days or more. + */ + payment_started_at: string | null; + + /** + * If the invoice is in draft, this timestamp will reflect when the invoice is + * scheduled to be issued. + */ + scheduled_issue_at: string | null; + + shipping_address: Shared.Address | null; + + status: 'issued' | 'paid' | 'synced' | 'void' | 'draft'; + + subscription: Shared.SubscriptionMinified | null; + + /** + * If the invoice failed to sync, this will be the last time an external invoicing + * provider sync was attempted. This field will always be `null` for invoices using + * Orb Invoicing. + */ + sync_failed_at: string | null; + + /** + * The total after any minimums and discounts have been applied. + */ + total: string; + + /** + * If the invoice has a status of `void`, this gives a timestamp when the invoice + * was voided. + */ + voided_at: string | null; + + /** + * This is true if the invoice will be automatically issued in the future, and + * false otherwise. + */ + will_auto_issue: boolean; +} + +export namespace InvoiceListSummaryResponse { + export interface AutoCollection { + /** + * True only if auto-collection is enabled for this invoice. + */ + enabled: boolean | null; + + /** + * If the invoice is scheduled for auto-collection, this field will reflect when + * the next attempt will occur. If dunning has been exhausted, or auto-collection + * is not enabled for this invoice, this field will be `null`. + */ + next_attempt_at: string | null; + + /** + * Number of auto-collection payment attempts. + */ + num_attempts: number | null; + + /** + * If Orb has ever attempted payment auto-collection for this invoice, this field + * will reflect when that attempt occurred. In conjunction with `next_attempt_at`, + * this can be used to tell whether the invoice is currently in dunning (that is, + * `previously_attempted_at` is non-null, and `next_attempt_time` is non-null), or + * if dunning has been exhausted (`previously_attempted_at` is non-null, but + * `next_attempt_time` is null). + */ + previously_attempted_at: string | null; + } + + export interface CreditNote { + id: string; + + credit_note_number: string; + + /** + * An optional memo supplied on the credit note. + */ + memo: string | null; + + reason: string; + + total: string; + + type: string; + + /** + * If the credit note has a status of `void`, this gives a timestamp when the + * credit note was voided. + */ + voided_at: string | null; + } + + export interface CustomerBalanceTransaction { + /** + * A unique id for this transaction. + */ + id: string; + + action: + | 'applied_to_invoice' + | 'manual_adjustment' + | 'prorated_refund' + | 'revert_prorated_refund' + | 'return_from_voiding' + | 'credit_note_applied' + | 'credit_note_voided' + | 'overpayment_refund' + | 'external_payment' + | 'small_invoice_carryover'; + + /** + * The value of the amount changed in the transaction. + */ + amount: string; + + /** + * The creation time of this transaction. + */ + created_at: string; + + credit_note: Shared.CreditNoteTiny | null; + + /** + * An optional description provided for manual customer balance adjustments. + */ + description: string | null; + + /** + * The new value of the customer's balance prior to the transaction, in the + * customer's currency. + */ + ending_balance: string; + + invoice: Shared.InvoiceTiny | null; + + /** + * The original value of the customer's balance prior to the transaction, in the + * customer's currency. + */ + starting_balance: string; + + type: 'increment' | 'decrement'; + } + + export interface PaymentAttempt { + /** + * The ID of the payment attempt. + */ + id: string; + + /** + * The amount of the payment attempt. + */ + amount: string; + + /** + * The time at which the payment attempt was created. + */ + created_at: string; + + /** + * The payment provider that attempted to collect the payment. + */ + payment_provider: 'stripe' | null; + + /** + * The ID of the payment attempt in the payment provider. + */ + payment_provider_id: string | null; + + /** + * URL to the downloadable PDF version of the receipt. This field will be `null` + * for payment attempts that did not succeed. + */ + receipt_pdf: string | null; + + /** + * Whether the payment attempt succeeded. + */ + succeeded: boolean; + } +} + export interface InvoiceCreateParams { /** * An ISO 4217 currency string. Must be the same as the customer's currency if it @@ -917,6 +1426,48 @@ export interface InvoiceIssueParams { synchronous?: boolean; } +export interface InvoiceListSummaryParams extends PageParams { + amount?: string | null; + + 'amount[gt]'?: string | null; + + 'amount[lt]'?: string | null; + + customer_id?: string | null; + + date_type?: 'due_date' | 'invoice_date' | null; + + due_date?: string | null; + + /** + * Filters invoices by their due dates within a specific time range in the past. + * Specify the range as a number followed by 'd' (days) or 'm' (months). For + * example, '7d' filters invoices due in the last 7 days, and '2m' filters those + * due in the last 2 months. + */ + due_date_window?: string | null; + + 'due_date[gt]'?: string | null; + + 'due_date[lt]'?: string | null; + + external_customer_id?: string | null; + + 'invoice_date[gt]'?: string | null; + + 'invoice_date[gte]'?: string | null; + + 'invoice_date[lt]'?: string | null; + + 'invoice_date[lte]'?: string | null; + + is_recurring?: boolean | null; + + status?: 'draft' | 'issued' | 'paid' | 'synced' | 'void' | null; + + subscription_id?: string | null; +} + export interface InvoiceMarkPaidParams { /** * A date string to specify the date of the payment. @@ -934,14 +1485,19 @@ export interface InvoiceMarkPaidParams { notes?: string | null; } +Invoices.InvoiceListSummaryResponsesPage = InvoiceListSummaryResponsesPage; + export declare namespace Invoices { export { type InvoiceFetchUpcomingResponse as InvoiceFetchUpcomingResponse, + type InvoiceListSummaryResponse as InvoiceListSummaryResponse, + InvoiceListSummaryResponsesPage as InvoiceListSummaryResponsesPage, type InvoiceCreateParams as InvoiceCreateParams, type InvoiceUpdateParams as InvoiceUpdateParams, type InvoiceListParams as InvoiceListParams, type InvoiceFetchUpcomingParams as InvoiceFetchUpcomingParams, type InvoiceIssueParams as InvoiceIssueParams, + type InvoiceListSummaryParams as InvoiceListSummaryParams, type InvoiceMarkPaidParams as InvoiceMarkPaidParams, }; } diff --git a/src/resources/plans/index.ts b/src/resources/plans/index.ts index b0ef5ba5..d34f7af7 100644 --- a/src/resources/plans/index.ts +++ b/src/resources/plans/index.ts @@ -1,6 +1,14 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. export { ExternalPlanID, type ExternalPlanIDUpdateParams } from './external-plan-id'; +export { + MigrationListResponsesPage, + Migrations, + type MigrationRetrieveResponse, + type MigrationListResponse, + type MigrationCancelResponse, + type MigrationListParams, +} from './migrations'; export { PlansPage, Plans, diff --git a/src/resources/plans/migrations.ts b/src/resources/plans/migrations.ts new file mode 100644 index 00000000..7940ab4c --- /dev/null +++ b/src/resources/plans/migrations.ts @@ -0,0 +1,105 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../resource'; +import { isRequestOptions } from '../../core'; +import * as Core from '../../core'; +import { Page, type PageParams } from '../../pagination'; + +export class Migrations extends APIResource { + /** + * Fetch migration + */ + retrieve( + planId: string, + migrationId: string, + options?: Core.RequestOptions, + ): Core.APIPromise { + return this._client.get(`/plans/${planId}/migrations/${migrationId}`, options); + } + + /** + * This endpoint returns a list of all migrations for a plan. The list of + * migrations is ordered starting from the most recently created migration. The + * response also includes pagination_metadata, which lets the caller retrieve the + * next page of results if they exist. + */ + list( + planId: string, + query?: MigrationListParams, + options?: Core.RequestOptions, + ): Core.PagePromise; + list( + planId: string, + options?: Core.RequestOptions, + ): Core.PagePromise; + list( + planId: string, + query: MigrationListParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.PagePromise { + if (isRequestOptions(query)) { + return this.list(planId, {}, query); + } + return this._client.getAPIList(`/plans/${planId}/migrations`, MigrationListResponsesPage, { + query, + ...options, + }); + } + + /** + * This endpoint cancels a migration. + */ + cancel( + planId: string, + migrationId: string, + options?: Core.RequestOptions, + ): Core.APIPromise { + return this._client.post(`/plans/${planId}/migrations/${migrationId}/cancel`, options); + } +} + +export class MigrationListResponsesPage extends Page {} + +export interface MigrationRetrieveResponse { + id: string; + + effective_time: (string & {}) | (string & {}) | 'end_of_term' | null; + + plan_id: string; + + status: 'not_started' | 'in_progress' | 'completed' | 'action_needed' | 'canceled'; +} + +export interface MigrationListResponse { + id: string; + + effective_time: (string & {}) | (string & {}) | 'end_of_term' | null; + + plan_id: string; + + status: 'not_started' | 'in_progress' | 'completed' | 'action_needed' | 'canceled'; +} + +export interface MigrationCancelResponse { + id: string; + + effective_time: (string & {}) | (string & {}) | 'end_of_term' | null; + + plan_id: string; + + status: 'not_started' | 'in_progress' | 'completed' | 'action_needed' | 'canceled'; +} + +export interface MigrationListParams extends PageParams {} + +Migrations.MigrationListResponsesPage = MigrationListResponsesPage; + +export declare namespace Migrations { + export { + type MigrationRetrieveResponse as MigrationRetrieveResponse, + type MigrationListResponse as MigrationListResponse, + type MigrationCancelResponse as MigrationCancelResponse, + MigrationListResponsesPage as MigrationListResponsesPage, + type MigrationListParams as MigrationListParams, + }; +} diff --git a/src/resources/plans/plans.ts b/src/resources/plans/plans.ts index 4691c45c..b684caa9 100644 --- a/src/resources/plans/plans.ts +++ b/src/resources/plans/plans.ts @@ -6,10 +6,20 @@ import * as Core from '../../core'; import * as Shared from '../shared'; import * as ExternalPlanIDAPI from './external-plan-id'; import { ExternalPlanID, ExternalPlanIDUpdateParams } from './external-plan-id'; +import * as MigrationsAPI from './migrations'; +import { + MigrationCancelResponse, + MigrationListParams, + MigrationListResponse, + MigrationListResponsesPage, + MigrationRetrieveResponse, + Migrations, +} from './migrations'; import { Page, type PageParams } from '../../pagination'; export class Plans extends APIResource { externalPlanId: ExternalPlanIDAPI.ExternalPlanID = new ExternalPlanIDAPI.ExternalPlanID(this._client); + migrations: MigrationsAPI.Migrations = new MigrationsAPI.Migrations(this._client); /** * This endpoint allows creation of plans including their prices. @@ -1214,6 +1224,8 @@ export interface PlanListParams extends PageParams { Plans.PlansPage = PlansPage; Plans.ExternalPlanID = ExternalPlanID; +Plans.Migrations = Migrations; +Plans.MigrationListResponsesPage = MigrationListResponsesPage; export declare namespace Plans { export { @@ -1225,4 +1237,13 @@ export declare namespace Plans { }; export { ExternalPlanID as ExternalPlanID, type ExternalPlanIDUpdateParams as ExternalPlanIDUpdateParams }; + + export { + Migrations as Migrations, + type MigrationRetrieveResponse as MigrationRetrieveResponse, + type MigrationListResponse as MigrationListResponse, + type MigrationCancelResponse as MigrationCancelResponse, + MigrationListResponsesPage as MigrationListResponsesPage, + type MigrationListParams as MigrationListParams, + }; } diff --git a/src/resources/subscription-changes.ts b/src/resources/subscription-changes.ts index 53e425df..d2fb9fb4 100644 --- a/src/resources/subscription-changes.ts +++ b/src/resources/subscription-changes.ts @@ -6,6 +6,7 @@ import * as Core from '../core'; import * as Shared from './shared'; import * as CustomersAPI from './customers/customers'; import * as PlansAPI from './plans/plans'; +import { Page, type PageParams } from '../pagination'; export class SubscriptionChanges extends APIResource { /** @@ -26,6 +27,31 @@ export class SubscriptionChanges extends APIResource { return this._client.get(`/subscription_changes/${subscriptionChangeId}`, options); } + /** + * This endpoint returns a list of pending subscription changes for a customer. Use + * the [Fetch Subscription Change](fetch-subscription-change) endpoint to retrieve + * the expected subscription state after the pending change is applied. + */ + list( + query?: SubscriptionChangeListParams, + options?: Core.RequestOptions, + ): Core.PagePromise; + list( + options?: Core.RequestOptions, + ): Core.PagePromise; + list( + query: SubscriptionChangeListParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.PagePromise { + if (isRequestOptions(query)) { + return this.list({}, query); + } + return this._client.getAPIList('/subscription_changes', SubscriptionChangeListResponsesPage, { + query, + ...options, + }); + } + /** * Apply a subscription change to perform the intended action. If a positive amount * is passed with a request to this endpoint, any eligible invoices that were @@ -64,6 +90,8 @@ export class SubscriptionChanges extends APIResource { } } +export class SubscriptionChangeListResponsesPage extends Page {} + export interface MutatedSubscription { id: string; @@ -282,6 +310,29 @@ export interface SubscriptionChangeRetrieveResponse { plan_id?: string | null; } +export interface SubscriptionChangeListResponse { + id: string; + + /** + * Subscription change will be cancelled at this time and can no longer be applied. + */ + expiration_time: string; + + status: 'pending' | 'applied' | 'cancelled'; + + subscription_id: string | null; + + /** + * When this change was applied. + */ + applied_at?: string | null; + + /** + * When this change was cancelled. + */ + cancelled_at?: string | null; +} + /** * A subscription change represents a desired new subscription / pending change to * an existing subscription. It is a way to first preview the effects on the @@ -392,6 +443,14 @@ export interface SubscriptionChangeCancelResponse { plan_id?: string | null; } +export interface SubscriptionChangeListParams extends PageParams { + customer_id?: string | null; + + external_customer_id?: string | null; + + status?: 'pending' | 'applied' | 'cancelled' | null; +} + export interface SubscriptionChangeApplyParams { /** * Description to apply to the balance transaction representing this credit. @@ -428,12 +487,17 @@ export interface SubscriptionChangeApplyParams { previously_collected_amount?: string | null; } +SubscriptionChanges.SubscriptionChangeListResponsesPage = SubscriptionChangeListResponsesPage; + export declare namespace SubscriptionChanges { export { type MutatedSubscription as MutatedSubscription, type SubscriptionChangeRetrieveResponse as SubscriptionChangeRetrieveResponse, + type SubscriptionChangeListResponse as SubscriptionChangeListResponse, type SubscriptionChangeApplyResponse as SubscriptionChangeApplyResponse, type SubscriptionChangeCancelResponse as SubscriptionChangeCancelResponse, + SubscriptionChangeListResponsesPage as SubscriptionChangeListResponsesPage, + type SubscriptionChangeListParams as SubscriptionChangeListParams, type SubscriptionChangeApplyParams as SubscriptionChangeApplyParams, }; } diff --git a/src/version.ts b/src/version.ts index 5d82ab4e..462c462b 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '5.39.0'; // x-release-please-version +export const VERSION = '5.40.0'; // x-release-please-version diff --git a/tests/api-resources/credit-blocks.test.ts b/tests/api-resources/credit-blocks.test.ts new file mode 100644 index 00000000..383764e7 --- /dev/null +++ b/tests/api-resources/credit-blocks.test.ts @@ -0,0 +1,47 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Orb from 'orb-billing'; +import { Response } from 'node-fetch'; + +const client = new Orb({ + apiKey: 'My API Key', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource creditBlocks', () => { + test('retrieve', async () => { + const responsePromise = client.creditBlocks.retrieve('block_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('retrieve: 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.creditBlocks.retrieve('block_id', { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Orb.NotFoundError); + }); + + test('delete', async () => { + const responsePromise = client.creditBlocks.delete('block_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('delete: 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.creditBlocks.delete('block_id', { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Orb.NotFoundError); + }); +}); diff --git a/tests/api-resources/invoices.test.ts b/tests/api-resources/invoices.test.ts index 16e2b948..1c221ba0 100644 --- a/tests/api-resources/invoices.test.ts +++ b/tests/api-resources/invoices.test.ts @@ -131,6 +131,24 @@ describe('resource invoices', () => { ).rejects.toThrow(Orb.NotFoundError); }); + test('deleteLineItem', async () => { + const responsePromise = client.invoices.deleteLineItem('invoice_id', 'line_item_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('deleteLineItem: 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.invoices.deleteLineItem('invoice_id', 'line_item_id', { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Orb.NotFoundError); + }); + test('fetch', async () => { const responsePromise = client.invoices.fetch('invoice_id'); const rawResponse = await responsePromise.asResponse(); @@ -189,6 +207,54 @@ describe('resource invoices', () => { ).rejects.toThrow(Orb.NotFoundError); }); + test('listSummary', async () => { + const responsePromise = client.invoices.listSummary(); + 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('listSummary: 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.invoices.listSummary({ path: '/_stainless_unknown_path' })).rejects.toThrow( + Orb.NotFoundError, + ); + }); + + test('listSummary: request options and 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.invoices.listSummary( + { + amount: 'amount', + 'amount[gt]': 'amount[gt]', + 'amount[lt]': 'amount[lt]', + cursor: 'cursor', + customer_id: 'customer_id', + date_type: 'due_date', + due_date: '2019-12-27', + due_date_window: 'due_date_window', + 'due_date[gt]': '2019-12-27', + 'due_date[lt]': '2019-12-27', + external_customer_id: 'external_customer_id', + 'invoice_date[gt]': '2019-12-27T18:11:19.117Z', + 'invoice_date[gte]': '2019-12-27T18:11:19.117Z', + 'invoice_date[lt]': '2019-12-27T18:11:19.117Z', + 'invoice_date[lte]': '2019-12-27T18:11:19.117Z', + is_recurring: true, + limit: 1, + status: 'draft', + subscription_id: 'subscription_id', + }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Orb.NotFoundError); + }); + test('markPaid: only required params', async () => { const responsePromise = client.invoices.markPaid('invoice_id', { payment_received_date: '2023-09-22' }); const rawResponse = await responsePromise.asResponse(); diff --git a/tests/api-resources/plans/migrations.test.ts b/tests/api-resources/plans/migrations.test.ts new file mode 100644 index 00000000..f49a828a --- /dev/null +++ b/tests/api-resources/plans/migrations.test.ts @@ -0,0 +1,76 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Orb from 'orb-billing'; +import { Response } from 'node-fetch'; + +const client = new Orb({ + apiKey: 'My API Key', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource migrations', () => { + test('retrieve', async () => { + const responsePromise = client.plans.migrations.retrieve('plan_id', 'migration_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('retrieve: 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.plans.migrations.retrieve('plan_id', 'migration_id', { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Orb.NotFoundError); + }); + + test('list', async () => { + const responsePromise = client.plans.migrations.list('plan_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('list: 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.plans.migrations.list('plan_id', { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Orb.NotFoundError); + }); + + test('list: request options and 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.plans.migrations.list( + 'plan_id', + { cursor: 'cursor', limit: 1 }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Orb.NotFoundError); + }); + + test('cancel', async () => { + const responsePromise = client.plans.migrations.cancel('plan_id', 'migration_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('cancel: 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.plans.migrations.cancel('plan_id', 'migration_id', { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Orb.NotFoundError); + }); +}); diff --git a/tests/api-resources/subscription-changes.test.ts b/tests/api-resources/subscription-changes.test.ts index 1f1e2090..12f0cb4b 100644 --- a/tests/api-resources/subscription-changes.test.ts +++ b/tests/api-resources/subscription-changes.test.ts @@ -27,6 +27,40 @@ describe('resource subscriptionChanges', () => { ).rejects.toThrow(Orb.NotFoundError); }); + test('list', async () => { + const responsePromise = client.subscriptionChanges.list(); + 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('list: 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.subscriptionChanges.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( + Orb.NotFoundError, + ); + }); + + test('list: request options and 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.subscriptionChanges.list( + { + cursor: 'cursor', + customer_id: 'customer_id', + external_customer_id: 'external_customer_id', + limit: 1, + status: 'pending', + }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Orb.NotFoundError); + }); + test('apply', async () => { const responsePromise = client.subscriptionChanges.apply('subscription_change_id'); const rawResponse = await responsePromise.asResponse();