Skip to content

Commit

Permalink
feat(api): update via SDK Studio (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and adamdottv committed Dec 14, 2024
1 parent aaeee44 commit e9c7822
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 79 deletions.
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 20
configured_endpoints: 19
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/terminal%2Fterminal-a63f15bf21a8e3fb542b7d4937d5625f8ef3e699d572d481bc2bdb9df27f27dc.yml
2 changes: 0 additions & 2 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,11 @@ Methods:
Types:

- <code><a href="./src/resources/user.ts">UserUpdateResponse</a></code>
- <code><a href="./src/resources/user.ts">UserInitResponse</a></code>
- <code><a href="./src/resources/user.ts">UserMeResponse</a></code>

Methods:

- <code title="put /user/me">client.user.<a href="./src/resources/user.ts">update</a>({ ...params }) -> UserUpdateResponse</code>
- <code title="get /user/init">client.user.<a href="./src/resources/user.ts">init</a>() -> UserInitResponse</code>
- <code title="get /user/me">client.user.<a href="./src/resources/user.ts">me</a>() -> UserMeResponse</code>

# Address
Expand Down
9 changes: 1 addition & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,7 @@ import {
SubscriptionDeleteResponse,
SubscriptionListResponse,
} from './resources/subscription';
import {
User,
UserInitResponse,
UserMeResponse,
UserUpdateParams,
UserUpdateResponse,
} from './resources/user';
import { User, UserMeResponse, UserUpdateParams, UserUpdateResponse } from './resources/user';

const environments = {
production: 'https://api.terminal.shop/',
Expand Down Expand Up @@ -240,7 +234,6 @@ export declare namespace Terminal {
export {
User as User,
type UserUpdateResponse as UserUpdateResponse,
type UserInitResponse as UserInitResponse,
type UserMeResponse as UserMeResponse,
type UserUpdateParams as UserUpdateParams,
};
Expand Down
8 changes: 1 addition & 7 deletions src/resources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,4 @@ export {
type SubscriptionDeleteResponse,
type SubscriptionCreateParams,
} from './subscription';
export {
User,
type UserUpdateResponse,
type UserInitResponse,
type UserMeResponse,
type UserUpdateParams,
} from './user';
export { User, type UserUpdateResponse, type UserMeResponse, type UserUpdateParams } from './user';
43 changes: 0 additions & 43 deletions src/resources/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,6 @@ export class User extends APIResource {
return this._client.put('/user/me', { body, ...options });
}

/**
* Get initial app data, including user, products, cart, addresses, cards,
* subscriptions, and orders.
*/
init(options?: Core.RequestOptions): Core.APIPromise<UserInitResponse> {
return this._client.get('/user/init', options);
}

/**
* Get the current user.
*/
Expand All @@ -44,40 +36,6 @@ export interface UserUpdateResponse {
data: Shared.User;
}

export interface UserInitResponse {
/**
* Initial app data.
*/
data: UserInitResponse.Data;
}

export namespace UserInitResponse {
/**
* Initial app data.
*/
export interface Data {
addresses: Array<Shared.Address>;

cards: Array<Shared.Card>;

/**
* The current Terminal shop user's cart.
*/
cart: Shared.Cart;

orders: Array<Shared.Order>;

products: Array<Shared.Product>;

subscriptions: Array<Shared.Subscription>;

/**
* A Terminal shop user. (We have users, btw.)
*/
user: Shared.User;
}
}

export interface UserMeResponse {
/**
* A Terminal shop user. (We have users, btw.)
Expand All @@ -100,7 +58,6 @@ export interface UserUpdateParams {
export declare namespace User {
export {
type UserUpdateResponse as UserUpdateResponse,
type UserInitResponse as UserInitResponse,
type UserMeResponse as UserMeResponse,
type UserUpdateParams as UserUpdateParams,
};
Expand Down
18 changes: 0 additions & 18 deletions tests/api-resources/user.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,6 @@ describe('resource user', () => {
).rejects.toThrow(Terminal.NotFoundError);
});

test('init', async () => {
const responsePromise = client.user.init();
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('init: 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.user.init({ path: '/_stainless_unknown_path' })).rejects.toThrow(
Terminal.NotFoundError,
);
});

test('me', async () => {
const responsePromise = client.user.me();
const rawResponse = await responsePromise.asResponse();
Expand Down

0 comments on commit e9c7822

Please sign in to comment.