From beb3548144ddd5c3ea79151f2d6a1dab89e09ab9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 17 Feb 2025 19:48:41 +0000 Subject: [PATCH 1/2] feat(api): manual updates (#144) --- .stats.yml | 2 +- README.md | 92 ++++++++--------------------------- src/resources/subscription.ts | 12 ++--- 3 files changed, 27 insertions(+), 79 deletions(-) diff --git a/.stats.yml b/.stats.yml index 8e1aa28..7b6a30c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 30 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/terminal%2Fterminal-d05a14360ad19c97c022f9f0fbc0e129c234aa471d5e4446f38ff07b97cef937.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/terminal%2Fterminal-a43b29f8663937be7722b27c8dd9a7aadfe29c40d575f0f39def413015bc535d.yml diff --git a/README.md b/README.md index b46e309..33f78a2 100644 --- a/README.md +++ b/README.md @@ -28,16 +28,9 @@ const client = new Terminal({ }); async function main() { - const subscription = await client.subscription.create({ - id: 'sub_XXXXXXXXXXXXXXXXXXXXXXXXX', - addressID: 'shp_XXXXXXXXXXXXXXXXXXXXXXXXX', - cardID: 'crd_XXXXXXXXXXXXXXXXXXXXXXXXX', - frequency: 'fixed', - productVariantID: 'var_XXXXXXXXXXXXXXXXXXXXXXXXX', - quantity: 1, - }); + const product = await client.product.list(); - console.log(subscription.data); + console.log(product.data); } main(); @@ -57,15 +50,7 @@ const client = new Terminal({ }); async function main() { - const params: Terminal.SubscriptionCreateParams = { - id: 'sub_XXXXXXXXXXXXXXXXXXXXXXXXX', - addressID: 'shp_XXXXXXXXXXXXXXXXXXXXXXXXX', - cardID: 'crd_XXXXXXXXXXXXXXXXXXXXXXXXX', - frequency: 'fixed', - productVariantID: 'var_XXXXXXXXXXXXXXXXXXXXXXXXX', - quantity: 1, - }; - const subscription: Terminal.SubscriptionCreateResponse = await client.subscription.create(params); + const product: Terminal.ProductListResponse = await client.product.list(); } main(); @@ -82,24 +67,15 @@ a subclass of `APIError` will be thrown: ```ts async function main() { - const subscription = await client.subscription - .create({ - id: 'sub_XXXXXXXXXXXXXXXXXXXXXXXXX', - addressID: 'shp_XXXXXXXXXXXXXXXXXXXXXXXXX', - cardID: 'crd_XXXXXXXXXXXXXXXXXXXXXXXXX', - frequency: 'fixed', - productVariantID: 'var_XXXXXXXXXXXXXXXXXXXXXXXXX', - quantity: 1, - }) - .catch(async (err) => { - if (err instanceof Terminal.APIError) { - console.log(err.status); // 400 - console.log(err.name); // BadRequestError - console.log(err.headers); // {server: 'nginx', ...} - } else { - throw err; - } - }); + const product = await client.product.list().catch(async (err) => { + if (err instanceof Terminal.APIError) { + console.log(err.status); // 400 + console.log(err.name); // BadRequestError + console.log(err.headers); // {server: 'nginx', ...} + } else { + throw err; + } + }); } main(); @@ -134,7 +110,7 @@ const client = new Terminal({ }); // Or, configure per-request: -await client.subscription.create({ id: 'sub_XXXXXXXXXXXXXXXXXXXXXXXXX', addressID: 'shp_XXXXXXXXXXXXXXXXXXXXXXXXX', cardID: 'crd_XXXXXXXXXXXXXXXXXXXXXXXXX', frequency: 'fixed', productVariantID: 'var_XXXXXXXXXXXXXXXXXXXXXXXXX', quantity: 1 }, { +await client.product.list({ maxRetries: 5, }); ``` @@ -151,7 +127,7 @@ const client = new Terminal({ }); // Override per-request: -await client.subscription.create({ id: 'sub_XXXXXXXXXXXXXXXXXXXXXXXXX', addressID: 'shp_XXXXXXXXXXXXXXXXXXXXXXXXX', cardID: 'crd_XXXXXXXXXXXXXXXXXXXXXXXXX', frequency: 'fixed', productVariantID: 'var_XXXXXXXXXXXXXXXXXXXXXXXXX', quantity: 1 }, { +await client.product.list({ timeout: 5 * 1000, }); ``` @@ -172,31 +148,13 @@ You can also use the `.withResponse()` method to get the raw `Response` along wi ```ts const client = new Terminal(); -const response = await client.subscription - .create({ - id: 'sub_XXXXXXXXXXXXXXXXXXXXXXXXX', - addressID: 'shp_XXXXXXXXXXXXXXXXXXXXXXXXX', - cardID: 'crd_XXXXXXXXXXXXXXXXXXXXXXXXX', - frequency: 'fixed', - productVariantID: 'var_XXXXXXXXXXXXXXXXXXXXXXXXX', - quantity: 1, - }) - .asResponse(); +const response = await client.product.list().asResponse(); console.log(response.headers.get('X-My-Header')); console.log(response.statusText); // access the underlying Response object -const { data: subscription, response: raw } = await client.subscription - .create({ - id: 'sub_XXXXXXXXXXXXXXXXXXXXXXXXX', - addressID: 'shp_XXXXXXXXXXXXXXXXXXXXXXXXX', - cardID: 'crd_XXXXXXXXXXXXXXXXXXXXXXXXX', - frequency: 'fixed', - productVariantID: 'var_XXXXXXXXXXXXXXXXXXXXXXXXX', - quantity: 1, - }) - .withResponse(); +const { data: product, response: raw } = await client.product.list().withResponse(); console.log(raw.headers.get('X-My-Header')); -console.log(subscription.data); +console.log(product.data); ``` ### Making custom/undocumented requests @@ -300,19 +258,9 @@ const client = new Terminal({ }); // Override per-request: -await client.subscription.create( - { - id: 'sub_XXXXXXXXXXXXXXXXXXXXXXXXX', - addressID: 'shp_XXXXXXXXXXXXXXXXXXXXXXXXX', - cardID: 'crd_XXXXXXXXXXXXXXXXXXXXXXXXX', - frequency: 'fixed', - productVariantID: 'var_XXXXXXXXXXXXXXXXXXXXXXXXX', - quantity: 1, - }, - { - httpAgent: new http.Agent({ keepAlive: false }), - }, -); +await client.product.list({ + httpAgent: new http.Agent({ keepAlive: false }), +}); ``` ## Semantic versioning diff --git a/src/resources/subscription.ts b/src/resources/subscription.ts index d755fd1..5de4e8f 100644 --- a/src/resources/subscription.ts +++ b/src/resources/subscription.ts @@ -71,15 +71,15 @@ export interface Subscription { /** * Schedule of the subscription. */ - schedule?: Subscription.Type | Subscription.UnionMember1; + schedule?: Subscription.Fixed | Subscription.Weekly; } export namespace Subscription { - export interface Type { + export interface Fixed { type: 'fixed'; } - export interface UnionMember1 { + export interface Weekly { interval: number; type: 'weekly'; @@ -140,15 +140,15 @@ export interface SubscriptionCreateParams { /** * Schedule of the subscription. */ - schedule?: SubscriptionCreateParams.Type | SubscriptionCreateParams.UnionMember1; + schedule?: SubscriptionCreateParams.Fixed | SubscriptionCreateParams.Weekly; } export namespace SubscriptionCreateParams { - export interface Type { + export interface Fixed { type: 'fixed'; } - export interface UnionMember1 { + export interface Weekly { interval: number; type: 'weekly'; From 8dc853924b9728ad2bb7a42bb46af25c05de6295 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 17 Feb 2025 19:48:59 +0000 Subject: [PATCH 2/2] release: 0.10.0-alpha --- .release-please-manifest.json | 2 +- CHANGELOG.md | 8 ++++++++ package.json | 2 +- src/version.ts | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 44b0dc0..cdb81d2 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.9.0-alpha" + ".": "0.10.0-alpha" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 05c414e..77b18ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.10.0-alpha (2025-02-17) + +Full Changelog: [v0.9.0-alpha...v0.10.0-alpha](https://github.com/terminaldotshop/terminal-sdk-js/compare/v0.9.0-alpha...v0.10.0-alpha) + +### Features + +* **api:** manual updates ([#144](https://github.com/terminaldotshop/terminal-sdk-js/issues/144)) ([beb3548](https://github.com/terminaldotshop/terminal-sdk-js/commit/beb3548144ddd5c3ea79151f2d6a1dab89e09ab9)) + ## 0.9.0-alpha (2025-02-16) Full Changelog: [v0.8.0-alpha...v0.9.0-alpha](https://github.com/terminaldotshop/terminal-sdk-js/compare/v0.8.0-alpha...v0.9.0-alpha) diff --git a/package.json b/package.json index 3e6dcec..b4e8e4b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@terminaldotshop/sdk", - "version": "0.9.0-alpha", + "version": "0.10.0-alpha", "description": "The official TypeScript library for the Terminal API", "author": "Terminal ", "types": "dist/index.d.ts", diff --git a/src/version.ts b/src/version.ts index 22ce991..7755791 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '0.9.0-alpha'; // x-release-please-version +export const VERSION = '0.10.0-alpha'; // x-release-please-version