Skip to content

Commit 6bcd93b

Browse files
feat(api): api update
1 parent 6af5ed0 commit 6bcd93b

16 files changed

Lines changed: 87 additions & 489 deletions

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 19
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/sent%2Fsent-dm-8a7302f9bad8c74c30abe130a90f2a74f5593ef05994a8c45a44cd04774d2cd8.yml
3-
openapi_spec_hash: cf04c958dec8855c924b20966ac83cd5
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/sent%2Fsent-dm-5fcf6a4fbea83adee6ed8ed9288a4b844cdf5df338780c5b9e45329975406779.yml
3+
openapi_spec_hash: dc90dc6f9d435002dbfc529522f4677a
44
config_hash: 78c2ed767ae318d95fa2a87e2eeaa706

README.md

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ const client = new SentDm();
2727
await client.messages.sendToPhone({
2828
phoneNumber: '+1234567890',
2929
templateId: '7ba7b820-9dad-11d1-80b4-00c04fd430c8',
30-
'x-api-key': '',
31-
'x-sender-id': '00000000-0000-0000-0000-000000000000',
3230
});
3331
```
3432

@@ -45,8 +43,6 @@ const client = new SentDm();
4543
const params: SentDm.MessageSendToPhoneParams = {
4644
phoneNumber: '+1234567890',
4745
templateId: '7ba7b820-9dad-11d1-80b4-00c04fd430c8',
48-
'x-api-key': '',
49-
'x-sender-id': '00000000-0000-0000-0000-000000000000',
5046
};
5147
await client.messages.sendToPhone(params);
5248
```
@@ -62,12 +58,7 @@ a subclass of `APIError` will be thrown:
6258
<!-- prettier-ignore -->
6359
```ts
6460
const response = await client.messages
65-
.sendToPhone({
66-
phoneNumber: '+1234567890',
67-
templateId: '7ba7b820-9dad-11d1-80b4-00c04fd430c8',
68-
'x-api-key': '',
69-
'x-sender-id': '00000000-0000-0000-0000-000000000000',
70-
})
61+
.sendToPhone({ phoneNumber: '+1234567890', templateId: '7ba7b820-9dad-11d1-80b4-00c04fd430c8' })
7162
.catch(async (err) => {
7263
if (err instanceof SentDm.APIError) {
7364
console.log(err.status); // 400
@@ -110,12 +101,7 @@ const client = new SentDm({
110101
});
111102

112103
// Or, configure per-request:
113-
await client.messages.sendToPhone({
114-
phoneNumber: '+1234567890',
115-
templateId: '7ba7b820-9dad-11d1-80b4-00c04fd430c8',
116-
'x-api-key': '',
117-
'x-sender-id': '00000000-0000-0000-0000-000000000000',
118-
}, {
104+
await client.messages.sendToPhone({ phoneNumber: '+1234567890', templateId: '7ba7b820-9dad-11d1-80b4-00c04fd430c8' }, {
119105
maxRetries: 5,
120106
});
121107
```
@@ -134,12 +120,7 @@ const client = new SentDm({
134120
});
135121

136122
// Override per-request:
137-
await client.messages.sendToPhone({
138-
phoneNumber: '+1234567890',
139-
templateId: '7ba7b820-9dad-11d1-80b4-00c04fd430c8',
140-
'x-api-key': '',
141-
'x-sender-id': '00000000-0000-0000-0000-000000000000',
142-
}, {
123+
await client.messages.sendToPhone({ phoneNumber: '+1234567890', templateId: '7ba7b820-9dad-11d1-80b4-00c04fd430c8' }, {
143124
timeout: 5 * 1000,
144125
});
145126
```
@@ -163,23 +144,13 @@ Unlike `.asResponse()` this method consumes the body, returning once it is parse
163144
const client = new SentDm();
164145

165146
const response = await client.messages
166-
.sendToPhone({
167-
phoneNumber: '+1234567890',
168-
templateId: '7ba7b820-9dad-11d1-80b4-00c04fd430c8',
169-
'x-api-key': '',
170-
'x-sender-id': '00000000-0000-0000-0000-000000000000',
171-
})
147+
.sendToPhone({ phoneNumber: '+1234567890', templateId: '7ba7b820-9dad-11d1-80b4-00c04fd430c8' })
172148
.asResponse();
173149
console.log(response.headers.get('X-My-Header'));
174150
console.log(response.statusText); // access the underlying Response object
175151

176152
const { data: result, response: raw } = await client.messages
177-
.sendToPhone({
178-
phoneNumber: '+1234567890',
179-
templateId: '7ba7b820-9dad-11d1-80b4-00c04fd430c8',
180-
'x-api-key': '',
181-
'x-sender-id': '00000000-0000-0000-0000-000000000000',
182-
})
153+
.sendToPhone({ phoneNumber: '+1234567890', templateId: '7ba7b820-9dad-11d1-80b4-00c04fd430c8' })
183154
.withResponse();
184155
console.log(raw.headers.get('X-My-Header'));
185156
console.log(result);

api.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ Types:
1111
Methods:
1212

1313
- <code title="post /v2/templates">client.templates.<a href="./src/resources/templates.ts">create</a>({ ...params }) -> TemplateResponse</code>
14-
- <code title="get /v2/templates/{id}">client.templates.<a href="./src/resources/templates.ts">retrieve</a>(id, { ...params }) -> TemplateResponse</code>
14+
- <code title="get /v2/templates/{id}">client.templates.<a href="./src/resources/templates.ts">retrieve</a>(id) -> TemplateResponse</code>
1515
- <code title="get /v2/templates">client.templates.<a href="./src/resources/templates.ts">list</a>({ ...params }) -> TemplateListResponse</code>
16-
- <code title="delete /v2/templates/{id}">client.templates.<a href="./src/resources/templates.ts">delete</a>(id, { ...params }) -> void</code>
16+
- <code title="delete /v2/templates/{id}">client.templates.<a href="./src/resources/templates.ts">delete</a>(id) -> void</code>
1717

1818
# Contacts
1919

@@ -36,7 +36,7 @@ Types:
3636

3737
Methods:
3838

39-
- <code title="get /v2/messages/{id}">client.messages.<a href="./src/resources/messages.ts">retrieve</a>(id, { ...params }) -> MessageRetrieveResponse</code>
39+
- <code title="get /v2/messages/{id}">client.messages.<a href="./src/resources/messages.ts">retrieve</a>(id) -> MessageRetrieveResponse</code>
4040
- <code title="post /v2/messages/quick-message">client.messages.<a href="./src/resources/messages.ts">sendQuickMessage</a>({ ...params }) -> void</code>
4141
- <code title="post /v2/messages/contact">client.messages.<a href="./src/resources/messages.ts">sendToContact</a>({ ...params }) -> void</code>
4242
- <code title="post /v2/messages/phone">client.messages.<a href="./src/resources/messages.ts">sendToPhone</a>({ ...params }) -> void</code>
@@ -62,7 +62,7 @@ Types:
6262
Methods:
6363

6464
- <code title="get /v2/organizations">client.organizations.<a href="./src/resources/organizations/organizations.ts">list</a>() -> OrganizationListResponse</code>
65-
- <code title="get /v2/organizations/{orgId}/profiles">client.organizations.<a href="./src/resources/organizations/organizations.ts">retrieveProfiles</a>(orgID, { ...params }) -> OrganizationRetrieveProfilesResponse</code>
65+
- <code title="get /v2/organizations/{orgId}/profiles">client.organizations.<a href="./src/resources/organizations/organizations.ts">retrieveProfiles</a>(orgID) -> OrganizationRetrieveProfilesResponse</code>
6666

6767
## Users
6868

src/client.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import {
2525
Contacts,
2626
} from './resources/contacts';
2727
import {
28-
MessageRetrieveParams,
2928
MessageRetrieveResponse,
3029
MessageSendQuickMessageParams,
3130
MessageSendToContactParams,
@@ -41,17 +40,14 @@ import {
4140
TemplateBodyContent,
4241
TemplateCreateParams,
4342
TemplateDefinition,
44-
TemplateDeleteParams,
4543
TemplateListParams,
4644
TemplateListResponse,
4745
TemplateResponse,
48-
TemplateRetrieveParams,
4946
TemplateVariable,
5047
Templates,
5148
} from './resources/templates';
5249
import {
5350
OrganizationListResponse,
54-
OrganizationRetrieveProfilesParams,
5551
OrganizationRetrieveProfilesResponse,
5652
Organizations,
5753
ProfileSummary,
@@ -788,9 +784,7 @@ export declare namespace SentDm {
788784
type TemplateVariable as TemplateVariable,
789785
type TemplateListResponse as TemplateListResponse,
790786
type TemplateCreateParams as TemplateCreateParams,
791-
type TemplateRetrieveParams as TemplateRetrieveParams,
792787
type TemplateListParams as TemplateListParams,
793-
type TemplateDeleteParams as TemplateDeleteParams,
794788
};
795789

796790
export {
@@ -805,7 +799,6 @@ export declare namespace SentDm {
805799
export {
806800
Messages as Messages,
807801
type MessageRetrieveResponse as MessageRetrieveResponse,
808-
type MessageRetrieveParams as MessageRetrieveParams,
809802
type MessageSendQuickMessageParams as MessageSendQuickMessageParams,
810803
type MessageSendToContactParams as MessageSendToContactParams,
811804
type MessageSendToPhoneParams as MessageSendToPhoneParams,
@@ -822,6 +815,5 @@ export declare namespace SentDm {
822815
type ProfileSummary as ProfileSummary,
823816
type OrganizationListResponse as OrganizationListResponse,
824817
type OrganizationRetrieveProfilesResponse as OrganizationRetrieveProfilesResponse,
825-
type OrganizationRetrieveProfilesParams as OrganizationRetrieveProfilesParams,
826818
};
827819
}

src/resources/contacts.ts

Lines changed: 12 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -2,82 +2,37 @@
22

33
import { APIResource } from '../core/resource';
44
import { APIPromise } from '../core/api-promise';
5-
import { buildHeaders } from '../internal/headers';
65
import { RequestOptions } from '../internal/request-options';
76

87
export class Contacts extends APIResource {
98
/**
109
* Retrieves a paginated list of contacts for the authenticated customer. Supports
1110
* server-side pagination with configurable page size. The customer ID is extracted
1211
* from the authentication token.
13-
*
14-
* @example
15-
* ```ts
16-
* const contacts = await client.contacts.list({
17-
* page: 0,
18-
* pageSize: 0,
19-
* 'x-api-key': '',
20-
* 'x-sender-id': '00000000-0000-0000-0000-000000000000',
21-
* });
22-
* ```
23-
*/
24-
list(params: ContactListParams, options?: RequestOptions): APIPromise<ContactListResponse> {
25-
const { 'x-api-key': xAPIKey, 'x-sender-id': xSenderID, ...query } = params;
26-
return this._client.get('/v2/contacts', {
27-
query,
28-
...options,
29-
headers: buildHeaders([{ 'x-api-key': xAPIKey, 'x-sender-id': xSenderID }, options?.headers]),
30-
});
12+
*/
13+
list(query: ContactListParams, options?: RequestOptions): APIPromise<ContactListResponse> {
14+
return this._client.get('/v2/contacts', { query, ...options });
3115
}
3216

3317
/**
3418
* Retrieves a contact by their phone number for the authenticated customer. Phone
3519
* number should be in international format (e.g., +1234567890). The customer ID is
3620
* extracted from the authentication token.
37-
*
38-
* @example
39-
* ```ts
40-
* const contactListItem =
41-
* await client.contacts.retrieveByPhone({
42-
* phoneNumber: 'phoneNumber',
43-
* 'x-api-key': '',
44-
* 'x-sender-id': '00000000-0000-0000-0000-000000000000',
45-
* });
46-
* ```
4721
*/
4822
retrieveByPhone(
49-
params: ContactRetrieveByPhoneParams,
23+
query: ContactRetrieveByPhoneParams,
5024
options?: RequestOptions,
5125
): APIPromise<ContactListItem> {
52-
const { 'x-api-key': xAPIKey, 'x-sender-id': xSenderID, ...query } = params;
53-
return this._client.get('/v2/contacts/phone', {
54-
query,
55-
...options,
56-
headers: buildHeaders([{ 'x-api-key': xAPIKey, 'x-sender-id': xSenderID }, options?.headers]),
57-
});
26+
return this._client.get('/v2/contacts/phone', { query, ...options });
5827
}
5928

6029
/**
6130
* Retrieves a specific contact by their unique identifier for the authenticated
6231
* customer. The customer ID is extracted from the authentication token. Returns
6332
* detailed contact information including phone number and creation timestamp.
64-
*
65-
* @example
66-
* ```ts
67-
* const contactListItem = await client.contacts.retrieveID({
68-
* id: 'id',
69-
* 'x-api-key': '',
70-
* 'x-sender-id': '00000000-0000-0000-0000-000000000000',
71-
* });
72-
* ```
73-
*/
74-
retrieveID(params: ContactRetrieveIDParams, options?: RequestOptions): APIPromise<ContactListItem> {
75-
const { 'x-api-key': xAPIKey, 'x-sender-id': xSenderID, ...query } = params;
76-
return this._client.get('/v2/contacts/id', {
77-
query,
78-
...options,
79-
headers: buildHeaders([{ 'x-api-key': xAPIKey, 'x-sender-id': xSenderID }, options?.headers]),
80-
});
33+
*/
34+
retrieveID(query: ContactRetrieveIDParams, options?: RequestOptions): APIPromise<ContactListItem> {
35+
return this._client.get('/v2/contacts/id', { query, ...options });
8136
}
8237
}
8338

@@ -152,58 +107,28 @@ export interface ContactListResponse {
152107

153108
export interface ContactListParams {
154109
/**
155-
* Query param: The page number (zero-indexed). Default is 0.
110+
* The page number (zero-indexed). Default is 0.
156111
*/
157112
page: number;
158113

159114
/**
160-
* Query param: The number of items per page. Default is 20.
115+
* The number of items per page. Default is 20.
161116
*/
162117
pageSize: number;
163-
164-
/**
165-
* Header param
166-
*/
167-
'x-api-key': string;
168-
169-
/**
170-
* Header param
171-
*/
172-
'x-sender-id': string;
173118
}
174119

175120
export interface ContactRetrieveByPhoneParams {
176121
/**
177-
* Query param: The phone number in international format (e.g., +1234567890)
122+
* The phone number in international format (e.g., +1234567890)
178123
*/
179124
phoneNumber: string;
180-
181-
/**
182-
* Header param
183-
*/
184-
'x-api-key': string;
185-
186-
/**
187-
* Header param
188-
*/
189-
'x-sender-id': string;
190125
}
191126

192127
export interface ContactRetrieveIDParams {
193128
/**
194-
* Query param: The unique identifier (GUID) of the resource to retrieve
129+
* The unique identifier (GUID) of the resource to retrieve
195130
*/
196131
id: string;
197-
198-
/**
199-
* Header param
200-
*/
201-
'x-api-key': string;
202-
203-
/**
204-
* Header param
205-
*/
206-
'x-sender-id': string;
207132
}
208133

209134
export declare namespace Contacts {

src/resources/index.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export {
1111
export {
1212
Messages,
1313
type MessageRetrieveResponse,
14-
type MessageRetrieveParams,
1514
type MessageSendQuickMessageParams,
1615
type MessageSendToContactParams,
1716
type MessageSendToPhoneParams,
@@ -26,7 +25,6 @@ export {
2625
type ProfileSummary,
2726
type OrganizationListResponse,
2827
type OrganizationRetrieveProfilesResponse,
29-
type OrganizationRetrieveProfilesParams,
3028
} from './organizations/organizations';
3129
export {
3230
Templates,
@@ -36,7 +34,5 @@ export {
3634
type TemplateVariable,
3735
type TemplateListResponse,
3836
type TemplateCreateParams,
39-
type TemplateRetrieveParams,
4037
type TemplateListParams,
41-
type TemplateDeleteParams,
4238
} from './templates';

0 commit comments

Comments
 (0)