-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from nestrilabs/release-please--branches--main…
…--changes--next--components--sdk release: 0.1.0-alpha.10
- Loading branch information
Showing
10 changed files
with
242 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
".": "0.1.0-alpha.9" | ||
".": "0.1.0-alpha.10" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
configured_endpoints: 22 | ||
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/nestri%2Fnestri-sdk-6d4fd80c0cc52698b7056513b6cfeaa897c4fa638b417dbcddc3c68123f6e3dc.yml | ||
configured_endpoints: 25 | ||
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/nestri%2Fnestri-sdk-b0479074a05fdf83faf7a450fb560e5897d57a919fef69f8ce5a7c289d01db57.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@nestri/sdk", | ||
"version": "0.1.0-alpha.9", | ||
"version": "0.1.0-alpha.10", | ||
"description": "The official TypeScript library for the Nestri API", | ||
"author": "Nestri <[email protected]>", | ||
"types": "dist/index.d.ts", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,123 @@ | ||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. | ||
|
||
import { APIResource } from '../resource'; | ||
import * as Core from '../core'; | ||
|
||
export class Subscriptions extends APIResource {} | ||
export class Subscriptions extends APIResource { | ||
/** | ||
* Create a subscription for the current user. | ||
*/ | ||
create( | ||
body: SubscriptionCreateParams, | ||
options?: Core.RequestOptions, | ||
): Core.APIPromise<SubscriptionCreateResponse> { | ||
return this._client.post('/subscriptions', { body, ...options }); | ||
} | ||
|
||
/** | ||
* List the subscriptions associated with the current user. | ||
*/ | ||
list(options?: Core.RequestOptions): Core.APIPromise<SubscriptionListResponse> { | ||
return this._client.get('/subscriptions', options); | ||
} | ||
|
||
/** | ||
* Cancel a subscription for the current user. | ||
*/ | ||
delete(id: string, options?: Core.RequestOptions): Core.APIPromise<SubscriptionDeleteResponse> { | ||
return this._client.delete(`/subscriptions/${id}`, options); | ||
} | ||
} | ||
|
||
export interface SubscriptionCreateResponse { | ||
data: 'ok'; | ||
} | ||
|
||
export interface SubscriptionListResponse { | ||
/** | ||
* List of subscriptions. | ||
*/ | ||
data: Array<SubscriptionListResponse.Data>; | ||
} | ||
|
||
export namespace SubscriptionListResponse { | ||
/** | ||
* Subscription to a Nestri product. | ||
*/ | ||
export interface Data { | ||
/** | ||
* Unique object identifier. The format and length of IDs may change over time. | ||
*/ | ||
id: string; | ||
|
||
/** | ||
* Frequency of the subscription. | ||
*/ | ||
frequency: 'fixed' | 'daily' | 'weekly' | 'monthly' | 'yearly'; | ||
|
||
/** | ||
* Next billing date for the subscription. | ||
*/ | ||
next: string | number; | ||
|
||
/** | ||
* ID of the product being subscribed to. | ||
*/ | ||
productID: string; | ||
|
||
/** | ||
* Quantity of the subscription. | ||
*/ | ||
quantity: number; | ||
|
||
/** | ||
* Cancelled date for the subscription. | ||
*/ | ||
canceledAt?: string | number; | ||
} | ||
} | ||
|
||
export interface SubscriptionDeleteResponse { | ||
data: 'ok'; | ||
} | ||
|
||
export interface SubscriptionCreateParams { | ||
/** | ||
* Unique object identifier. The format and length of IDs may change over time. | ||
*/ | ||
id: string; | ||
|
||
/** | ||
* Frequency of the subscription. | ||
*/ | ||
frequency: 'fixed' | 'daily' | 'weekly' | 'monthly' | 'yearly'; | ||
|
||
/** | ||
* Next billing date for the subscription. | ||
*/ | ||
next: string | number; | ||
|
||
/** | ||
* ID of the product being subscribed to. | ||
*/ | ||
productID: string; | ||
|
||
/** | ||
* Quantity of the subscription. | ||
*/ | ||
quantity: number; | ||
|
||
/** | ||
* Cancelled date for the subscription. | ||
*/ | ||
canceledAt?: string | number; | ||
} | ||
|
||
export declare namespace Subscriptions { | ||
export { | ||
type SubscriptionCreateResponse as SubscriptionCreateResponse, | ||
type SubscriptionListResponse as SubscriptionListResponse, | ||
type SubscriptionDeleteResponse as SubscriptionDeleteResponse, | ||
type SubscriptionCreateParams as SubscriptionCreateParams, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export const VERSION = '0.1.0-alpha.9'; // x-release-please-version | ||
export const VERSION = '0.1.0-alpha.10'; // x-release-please-version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. | ||
|
||
import Nestri from '@nestri/sdk'; | ||
import { Response } from 'node-fetch'; | ||
|
||
const client = new Nestri({ | ||
bearerToken: 'My Bearer Token', | ||
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', | ||
}); | ||
|
||
describe('resource subscriptions', () => { | ||
test('create: only required params', async () => { | ||
const responsePromise = client.subscriptions.create({ | ||
id: '0bfcb712-df13-4454-81a8-fbee66eddca4', | ||
frequency: 'fixed', | ||
next: '2025-01-09T01:56:23.902Z', | ||
productID: '0bfcb712-df43-4454-81a8-fbee66eddca4', | ||
quantity: 1, | ||
}); | ||
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('create: required and optional params', async () => { | ||
const response = await client.subscriptions.create({ | ||
id: '0bfcb712-df13-4454-81a8-fbee66eddca4', | ||
frequency: 'fixed', | ||
next: '2025-01-09T01:56:23.902Z', | ||
productID: '0bfcb712-df43-4454-81a8-fbee66eddca4', | ||
quantity: 1, | ||
canceledAt: '2025-02-09T01:56:23.902Z', | ||
}); | ||
}); | ||
|
||
test('list', async () => { | ||
const responsePromise = client.subscriptions.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.subscriptions.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( | ||
Nestri.NotFoundError, | ||
); | ||
}); | ||
|
||
test('delete', async () => { | ||
const responsePromise = client.subscriptions.delete('0bfcb712-df13-4454-81a8-fbee66eddca4'); | ||
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.subscriptions.delete('0bfcb712-df13-4454-81a8-fbee66eddca4', { | ||
path: '/_stainless_unknown_path', | ||
}), | ||
).rejects.toThrow(Nestri.NotFoundError); | ||
}); | ||
}); |