Skip to content

Commit 6afef55

Browse files
feat(api): manual updates
1 parent bb13ec3 commit 6afef55

2 files changed

Lines changed: 28 additions & 6 deletions

File tree

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 19
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/sent%2Fsent-dm-37465954227cd4e96920805a44aa6cf9a51da1f0073be89bbcb69cf32ef6cf22.yml
33
openapi_spec_hash: 145f3fc12cd69c9f6799ded0f10c6ad3
4-
config_hash: 92f10593a2170abafab290d80474cdc7
4+
config_hash: 56966cd0f66591925f8fd02ad6808fb0

README.md

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const client = new SentDm({
3030
await client.messages.sendToPhone({
3131
phoneNumber: '+1234567890',
3232
templateId: '7ba7b820-9dad-11d1-80b4-00c04fd430c8',
33+
templateVariables: { name: 'John Doe', order_id: '12345' },
3334
});
3435
```
3536

@@ -49,6 +50,7 @@ const client = new SentDm({
4950
const params: SentDm.MessageSendToPhoneParams = {
5051
phoneNumber: '+1234567890',
5152
templateId: '7ba7b820-9dad-11d1-80b4-00c04fd430c8',
53+
templateVariables: { name: 'John Doe', order_id: '12345' },
5254
};
5355
await client.messages.sendToPhone(params);
5456
```
@@ -64,7 +66,11 @@ a subclass of `APIError` will be thrown:
6466
<!-- prettier-ignore -->
6567
```ts
6668
const response = await client.messages
67-
.sendToPhone({ phoneNumber: '+1234567890', templateId: '7ba7b820-9dad-11d1-80b4-00c04fd430c8' })
69+
.sendToPhone({
70+
phoneNumber: '+1234567890',
71+
templateId: '7ba7b820-9dad-11d1-80b4-00c04fd430c8',
72+
templateVariables: { name: 'John Doe', order_id: '12345' },
73+
})
6874
.catch(async (err) => {
6975
if (err instanceof SentDm.APIError) {
7076
console.log(err.status); // 400
@@ -105,7 +111,11 @@ const client = new SentDm({
105111
});
106112

107113
// Or, configure per-request:
108-
await client.messages.sendToPhone({ phoneNumber: '+1234567890', templateId: '7ba7b820-9dad-11d1-80b4-00c04fd430c8' }, {
114+
await client.messages.sendToPhone({
115+
phoneNumber: '+1234567890',
116+
templateId: '7ba7b820-9dad-11d1-80b4-00c04fd430c8',
117+
templateVariables: { name: 'John Doe', order_id: '12345' },
118+
}, {
109119
maxRetries: 5,
110120
});
111121
```
@@ -122,7 +132,11 @@ const client = new SentDm({
122132
});
123133

124134
// Override per-request:
125-
await client.messages.sendToPhone({ phoneNumber: '+1234567890', templateId: '7ba7b820-9dad-11d1-80b4-00c04fd430c8' }, {
135+
await client.messages.sendToPhone({
136+
phoneNumber: '+1234567890',
137+
templateId: '7ba7b820-9dad-11d1-80b4-00c04fd430c8',
138+
templateVariables: { name: 'John Doe', order_id: '12345' },
139+
}, {
126140
timeout: 5 * 1000,
127141
});
128142
```
@@ -146,13 +160,21 @@ Unlike `.asResponse()` this method consumes the body, returning once it is parse
146160
const client = new SentDm();
147161

148162
const response = await client.messages
149-
.sendToPhone({ phoneNumber: '+1234567890', templateId: '7ba7b820-9dad-11d1-80b4-00c04fd430c8' })
163+
.sendToPhone({
164+
phoneNumber: '+1234567890',
165+
templateId: '7ba7b820-9dad-11d1-80b4-00c04fd430c8',
166+
templateVariables: { name: 'John Doe', order_id: '12345' },
167+
})
150168
.asResponse();
151169
console.log(response.headers.get('X-My-Header'));
152170
console.log(response.statusText); // access the underlying Response object
153171

154172
const { data: result, response: raw } = await client.messages
155-
.sendToPhone({ phoneNumber: '+1234567890', templateId: '7ba7b820-9dad-11d1-80b4-00c04fd430c8' })
173+
.sendToPhone({
174+
phoneNumber: '+1234567890',
175+
templateId: '7ba7b820-9dad-11d1-80b4-00c04fd430c8',
176+
templateVariables: { name: 'John Doe', order_id: '12345' },
177+
})
156178
.withResponse();
157179
console.log(raw.headers.get('X-My-Header'));
158180
console.log(result);

0 commit comments

Comments
 (0)