@zavudev/sdk 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/client.d.mts +3 -0
- package/client.d.mts.map +1 -1
- package/client.d.ts +3 -0
- package/client.d.ts.map +1 -1
- package/client.js +3 -0
- package/client.js.map +1 -1
- package/client.mjs +3 -0
- package/client.mjs.map +1 -1
- package/package.json +1 -1
- package/resources/broadcasts/broadcasts.d.mts +361 -0
- package/resources/broadcasts/broadcasts.d.mts.map +1 -0
- package/resources/broadcasts/broadcasts.d.ts +361 -0
- package/resources/broadcasts/broadcasts.d.ts.map +1 -0
- package/resources/broadcasts/broadcasts.js +131 -0
- package/resources/broadcasts/broadcasts.js.map +1 -0
- package/resources/broadcasts/broadcasts.mjs +126 -0
- package/resources/broadcasts/broadcasts.mjs.map +1 -0
- package/resources/broadcasts/contacts.d.mts +120 -0
- package/resources/broadcasts/contacts.d.mts.map +1 -0
- package/resources/broadcasts/contacts.d.ts +120 -0
- package/resources/broadcasts/contacts.d.ts.map +1 -0
- package/resources/broadcasts/contacts.js +76 -0
- package/resources/broadcasts/contacts.js.map +1 -0
- package/resources/broadcasts/contacts.mjs +72 -0
- package/resources/broadcasts/contacts.mjs.map +1 -0
- package/resources/broadcasts/index.d.mts +3 -0
- package/resources/broadcasts/index.d.mts.map +1 -0
- package/resources/broadcasts/index.d.ts +3 -0
- package/resources/broadcasts/index.d.ts.map +1 -0
- package/resources/broadcasts/index.js +9 -0
- package/resources/broadcasts/index.js.map +1 -0
- package/resources/broadcasts/index.mjs +4 -0
- package/resources/broadcasts/index.mjs.map +1 -0
- package/resources/broadcasts.d.mts +2 -0
- package/resources/broadcasts.d.mts.map +1 -0
- package/resources/broadcasts.d.ts +2 -0
- package/resources/broadcasts.d.ts.map +1 -0
- package/resources/broadcasts.js +6 -0
- package/resources/broadcasts.js.map +1 -0
- package/resources/broadcasts.mjs +3 -0
- package/resources/broadcasts.mjs.map +1 -0
- package/resources/index.d.mts +1 -0
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +1 -0
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +3 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +1 -0
- package/resources/index.mjs.map +1 -1
- package/src/client.ts +45 -0
- package/src/resources/broadcasts/broadcasts.ts +519 -0
- package/src/resources/broadcasts/contacts.ts +160 -0
- package/src/resources/broadcasts/index.ts +31 -0
- package/src/resources/broadcasts.ts +3 -0
- package/src/resources/index.ts +22 -0
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
|
@@ -0,0 +1,519 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { APIResource } from '../../core/resource';
|
|
4
|
+
import * as ContactsAPI from './contacts';
|
|
5
|
+
import {
|
|
6
|
+
ContactAddParams,
|
|
7
|
+
ContactAddResponse,
|
|
8
|
+
ContactListParams,
|
|
9
|
+
ContactRemoveParams,
|
|
10
|
+
Contacts,
|
|
11
|
+
} from './contacts';
|
|
12
|
+
import { APIPromise } from '../../core/api-promise';
|
|
13
|
+
import { Cursor, type CursorParams, PagePromise } from '../../core/pagination';
|
|
14
|
+
import { buildHeaders } from '../../internal/headers';
|
|
15
|
+
import { RequestOptions } from '../../internal/request-options';
|
|
16
|
+
import { path } from '../../internal/utils/path';
|
|
17
|
+
|
|
18
|
+
export class Broadcasts extends APIResource {
|
|
19
|
+
contacts: ContactsAPI.Contacts = new ContactsAPI.Contacts(this._client);
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Create a new broadcast campaign. Add contacts after creation, then send.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* const broadcast = await client.broadcasts.create({
|
|
27
|
+
* channel: 'sms',
|
|
28
|
+
* name: 'Black Friday Sale',
|
|
29
|
+
* text: 'Hi {{name}}, check out our Black Friday deals! Use code FRIDAY20 for 20% off.',
|
|
30
|
+
* });
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
create(body: BroadcastCreateParams, options?: RequestOptions): APIPromise<BroadcastCreateResponse> {
|
|
34
|
+
return this._client.post('/v1/broadcasts', { body, ...options });
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Get broadcast
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* const broadcast = await client.broadcasts.retrieve(
|
|
43
|
+
* 'broadcastId',
|
|
44
|
+
* );
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
retrieve(broadcastID: string, options?: RequestOptions): APIPromise<BroadcastRetrieveResponse> {
|
|
48
|
+
return this._client.get(path`/v1/broadcasts/${broadcastID}`, options);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Update a broadcast in draft status.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts
|
|
56
|
+
* const broadcast = await client.broadcasts.update(
|
|
57
|
+
* 'broadcastId',
|
|
58
|
+
* );
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
update(
|
|
62
|
+
broadcastID: string,
|
|
63
|
+
body: BroadcastUpdateParams,
|
|
64
|
+
options?: RequestOptions,
|
|
65
|
+
): APIPromise<BroadcastUpdateResponse> {
|
|
66
|
+
return this._client.patch(path`/v1/broadcasts/${broadcastID}`, { body, ...options });
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* List broadcasts for this project.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```ts
|
|
74
|
+
* // Automatically fetches more pages as needed.
|
|
75
|
+
* for await (const broadcast of client.broadcasts.list()) {
|
|
76
|
+
* // ...
|
|
77
|
+
* }
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
list(
|
|
81
|
+
query: BroadcastListParams | null | undefined = {},
|
|
82
|
+
options?: RequestOptions,
|
|
83
|
+
): PagePromise<BroadcastsCursor, Broadcast> {
|
|
84
|
+
return this._client.getAPIList('/v1/broadcasts', Cursor<Broadcast>, { query, ...options });
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Delete a broadcast in draft status.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```ts
|
|
92
|
+
* await client.broadcasts.delete('broadcastId');
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
delete(broadcastID: string, options?: RequestOptions): APIPromise<void> {
|
|
96
|
+
return this._client.delete(path`/v1/broadcasts/${broadcastID}`, {
|
|
97
|
+
...options,
|
|
98
|
+
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Cancel a broadcast. Pending contacts will be skipped, but already queued
|
|
104
|
+
* messages may still be delivered.
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```ts
|
|
108
|
+
* const response = await client.broadcasts.cancel(
|
|
109
|
+
* 'broadcastId',
|
|
110
|
+
* );
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
cancel(broadcastID: string, options?: RequestOptions): APIPromise<BroadcastCancelResponse> {
|
|
114
|
+
return this._client.post(path`/v1/broadcasts/${broadcastID}/cancel`, options);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Get real-time progress of a broadcast including delivery counts and estimated
|
|
119
|
+
* completion time.
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```ts
|
|
123
|
+
* const broadcastProgress = await client.broadcasts.progress(
|
|
124
|
+
* 'broadcastId',
|
|
125
|
+
* );
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
progress(broadcastID: string, options?: RequestOptions): APIPromise<BroadcastProgress> {
|
|
129
|
+
return this._client.get(path`/v1/broadcasts/${broadcastID}/progress`, options);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Start sending the broadcast immediately or schedule for later. Reserves the
|
|
134
|
+
* estimated cost from your balance.
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```ts
|
|
138
|
+
* const response = await client.broadcasts.send(
|
|
139
|
+
* 'broadcastId',
|
|
140
|
+
* );
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
send(
|
|
144
|
+
broadcastID: string,
|
|
145
|
+
body: BroadcastSendParams | null | undefined = {},
|
|
146
|
+
options?: RequestOptions,
|
|
147
|
+
): APIPromise<BroadcastSendResponse> {
|
|
148
|
+
return this._client.post(path`/v1/broadcasts/${broadcastID}/send`, { body, ...options });
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export type BroadcastsCursor = Cursor<Broadcast>;
|
|
153
|
+
|
|
154
|
+
export type BroadcastContactsCursor = Cursor<BroadcastContact>;
|
|
155
|
+
|
|
156
|
+
export interface Broadcast {
|
|
157
|
+
id: string;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Broadcast delivery channel.
|
|
161
|
+
*/
|
|
162
|
+
channel: BroadcastChannel;
|
|
163
|
+
|
|
164
|
+
createdAt: string;
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Type of message for broadcast.
|
|
168
|
+
*/
|
|
169
|
+
messageType: BroadcastMessageType;
|
|
170
|
+
|
|
171
|
+
name: string;
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Current status of the broadcast.
|
|
175
|
+
*/
|
|
176
|
+
status: BroadcastStatus;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Total number of contacts in the broadcast.
|
|
180
|
+
*/
|
|
181
|
+
totalContacts: number;
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Actual cost so far in USD.
|
|
185
|
+
*/
|
|
186
|
+
actualCost?: number | null;
|
|
187
|
+
|
|
188
|
+
completedAt?: string;
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Content for non-text broadcast message types.
|
|
192
|
+
*/
|
|
193
|
+
content?: BroadcastContent;
|
|
194
|
+
|
|
195
|
+
deliveredCount?: number;
|
|
196
|
+
|
|
197
|
+
emailSubject?: string;
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Estimated total cost in USD.
|
|
201
|
+
*/
|
|
202
|
+
estimatedCost?: number | null;
|
|
203
|
+
|
|
204
|
+
failedCount?: number;
|
|
205
|
+
|
|
206
|
+
metadata?: { [key: string]: string };
|
|
207
|
+
|
|
208
|
+
pendingCount?: number;
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Amount reserved from balance in USD.
|
|
212
|
+
*/
|
|
213
|
+
reservedAmount?: number | null;
|
|
214
|
+
|
|
215
|
+
scheduledAt?: string;
|
|
216
|
+
|
|
217
|
+
senderId?: string;
|
|
218
|
+
|
|
219
|
+
sendingCount?: number;
|
|
220
|
+
|
|
221
|
+
startedAt?: string;
|
|
222
|
+
|
|
223
|
+
text?: string;
|
|
224
|
+
|
|
225
|
+
updatedAt?: string;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Broadcast delivery channel.
|
|
230
|
+
*/
|
|
231
|
+
export type BroadcastChannel = 'sms' | 'whatsapp' | 'email';
|
|
232
|
+
|
|
233
|
+
export interface BroadcastContact {
|
|
234
|
+
id: string;
|
|
235
|
+
|
|
236
|
+
createdAt: string;
|
|
237
|
+
|
|
238
|
+
recipient: string;
|
|
239
|
+
|
|
240
|
+
recipientType: 'phone' | 'email';
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Status of a contact within a broadcast.
|
|
244
|
+
*/
|
|
245
|
+
status: BroadcastContactStatus;
|
|
246
|
+
|
|
247
|
+
cost?: number | null;
|
|
248
|
+
|
|
249
|
+
errorCode?: string;
|
|
250
|
+
|
|
251
|
+
errorMessage?: string;
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Associated message ID after processing.
|
|
255
|
+
*/
|
|
256
|
+
messageId?: string;
|
|
257
|
+
|
|
258
|
+
processedAt?: string;
|
|
259
|
+
|
|
260
|
+
templateVariables?: { [key: string]: string };
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Status of a contact within a broadcast.
|
|
265
|
+
*/
|
|
266
|
+
export type BroadcastContactStatus = 'pending' | 'queued' | 'sending' | 'delivered' | 'failed' | 'skipped';
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Content for non-text broadcast message types.
|
|
270
|
+
*/
|
|
271
|
+
export interface BroadcastContent {
|
|
272
|
+
/**
|
|
273
|
+
* Filename for documents.
|
|
274
|
+
*/
|
|
275
|
+
filename?: string;
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Media ID if already uploaded.
|
|
279
|
+
*/
|
|
280
|
+
mediaId?: string;
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* URL of the media file.
|
|
284
|
+
*/
|
|
285
|
+
mediaUrl?: string;
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* MIME type of the media.
|
|
289
|
+
*/
|
|
290
|
+
mimeType?: string;
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Template ID for template messages.
|
|
294
|
+
*/
|
|
295
|
+
templateId?: string;
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Default template variables (can be overridden per contact).
|
|
299
|
+
*/
|
|
300
|
+
templateVariables?: { [key: string]: string };
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Type of message for broadcast.
|
|
305
|
+
*/
|
|
306
|
+
export type BroadcastMessageType = 'text' | 'image' | 'video' | 'audio' | 'document' | 'template';
|
|
307
|
+
|
|
308
|
+
export interface BroadcastProgress {
|
|
309
|
+
broadcastId: string;
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Successfully delivered.
|
|
313
|
+
*/
|
|
314
|
+
delivered: number;
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Failed to deliver.
|
|
318
|
+
*/
|
|
319
|
+
failed: number;
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Not yet queued for sending.
|
|
323
|
+
*/
|
|
324
|
+
pending: number;
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Percentage complete (0-100).
|
|
328
|
+
*/
|
|
329
|
+
percentComplete: number;
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Currently being sent.
|
|
333
|
+
*/
|
|
334
|
+
sending: number;
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Skipped (broadcast cancelled).
|
|
338
|
+
*/
|
|
339
|
+
skipped: number;
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Current status of the broadcast.
|
|
343
|
+
*/
|
|
344
|
+
status: BroadcastStatus;
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Total contacts in broadcast.
|
|
348
|
+
*/
|
|
349
|
+
total: number;
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Actual cost so far in USD.
|
|
353
|
+
*/
|
|
354
|
+
actualCost?: number | null;
|
|
355
|
+
|
|
356
|
+
estimatedCompletionAt?: string;
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Estimated total cost in USD.
|
|
360
|
+
*/
|
|
361
|
+
estimatedCost?: number | null;
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Amount reserved from balance in USD.
|
|
365
|
+
*/
|
|
366
|
+
reservedAmount?: number | null;
|
|
367
|
+
|
|
368
|
+
startedAt?: string;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Current status of the broadcast.
|
|
373
|
+
*/
|
|
374
|
+
export type BroadcastStatus =
|
|
375
|
+
| 'draft'
|
|
376
|
+
| 'scheduled'
|
|
377
|
+
| 'sending'
|
|
378
|
+
| 'paused'
|
|
379
|
+
| 'completed'
|
|
380
|
+
| 'cancelled'
|
|
381
|
+
| 'failed';
|
|
382
|
+
|
|
383
|
+
export interface BroadcastCreateResponse {
|
|
384
|
+
broadcast: Broadcast;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
export interface BroadcastRetrieveResponse {
|
|
388
|
+
broadcast: Broadcast;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
export interface BroadcastUpdateResponse {
|
|
392
|
+
broadcast: Broadcast;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
export interface BroadcastCancelResponse {
|
|
396
|
+
broadcast: Broadcast;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
export interface BroadcastSendResponse {
|
|
400
|
+
broadcast: Broadcast;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
export interface BroadcastCreateParams {
|
|
404
|
+
/**
|
|
405
|
+
* Broadcast delivery channel.
|
|
406
|
+
*/
|
|
407
|
+
channel: BroadcastChannel;
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* Name of the broadcast campaign.
|
|
411
|
+
*/
|
|
412
|
+
name: string;
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Content for non-text broadcast message types.
|
|
416
|
+
*/
|
|
417
|
+
content?: BroadcastContent;
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* HTML body for email broadcasts.
|
|
421
|
+
*/
|
|
422
|
+
emailHtmlBody?: string;
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* Email subject line. Required for email broadcasts.
|
|
426
|
+
*/
|
|
427
|
+
emailSubject?: string;
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* Idempotency key to prevent duplicate broadcasts.
|
|
431
|
+
*/
|
|
432
|
+
idempotencyKey?: string;
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* Type of message for broadcast.
|
|
436
|
+
*/
|
|
437
|
+
messageType?: BroadcastMessageType;
|
|
438
|
+
|
|
439
|
+
metadata?: { [key: string]: string };
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Schedule the broadcast for future delivery.
|
|
443
|
+
*/
|
|
444
|
+
scheduledAt?: string;
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* Sender profile ID. Uses default sender if omitted.
|
|
448
|
+
*/
|
|
449
|
+
senderId?: string;
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* Text content or caption. Supports template variables: {{name}}, {{1}}, etc.
|
|
453
|
+
*/
|
|
454
|
+
text?: string;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
export interface BroadcastUpdateParams {
|
|
458
|
+
/**
|
|
459
|
+
* Content for non-text broadcast message types.
|
|
460
|
+
*/
|
|
461
|
+
content?: BroadcastContent;
|
|
462
|
+
|
|
463
|
+
emailHtmlBody?: string;
|
|
464
|
+
|
|
465
|
+
emailSubject?: string;
|
|
466
|
+
|
|
467
|
+
metadata?: { [key: string]: string };
|
|
468
|
+
|
|
469
|
+
name?: string;
|
|
470
|
+
|
|
471
|
+
text?: string;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
export interface BroadcastListParams extends CursorParams {
|
|
475
|
+
/**
|
|
476
|
+
* Current status of the broadcast.
|
|
477
|
+
*/
|
|
478
|
+
status?: BroadcastStatus;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
export interface BroadcastSendParams {
|
|
482
|
+
/**
|
|
483
|
+
* Schedule for future delivery. Omit to send immediately.
|
|
484
|
+
*/
|
|
485
|
+
scheduledAt?: string;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
Broadcasts.Contacts = Contacts;
|
|
489
|
+
|
|
490
|
+
export declare namespace Broadcasts {
|
|
491
|
+
export {
|
|
492
|
+
type Broadcast as Broadcast,
|
|
493
|
+
type BroadcastChannel as BroadcastChannel,
|
|
494
|
+
type BroadcastContact as BroadcastContact,
|
|
495
|
+
type BroadcastContactStatus as BroadcastContactStatus,
|
|
496
|
+
type BroadcastContent as BroadcastContent,
|
|
497
|
+
type BroadcastMessageType as BroadcastMessageType,
|
|
498
|
+
type BroadcastProgress as BroadcastProgress,
|
|
499
|
+
type BroadcastStatus as BroadcastStatus,
|
|
500
|
+
type BroadcastCreateResponse as BroadcastCreateResponse,
|
|
501
|
+
type BroadcastRetrieveResponse as BroadcastRetrieveResponse,
|
|
502
|
+
type BroadcastUpdateResponse as BroadcastUpdateResponse,
|
|
503
|
+
type BroadcastCancelResponse as BroadcastCancelResponse,
|
|
504
|
+
type BroadcastSendResponse as BroadcastSendResponse,
|
|
505
|
+
type BroadcastsCursor as BroadcastsCursor,
|
|
506
|
+
type BroadcastCreateParams as BroadcastCreateParams,
|
|
507
|
+
type BroadcastUpdateParams as BroadcastUpdateParams,
|
|
508
|
+
type BroadcastListParams as BroadcastListParams,
|
|
509
|
+
type BroadcastSendParams as BroadcastSendParams,
|
|
510
|
+
};
|
|
511
|
+
|
|
512
|
+
export {
|
|
513
|
+
Contacts as Contacts,
|
|
514
|
+
type ContactAddResponse as ContactAddResponse,
|
|
515
|
+
type ContactListParams as ContactListParams,
|
|
516
|
+
type ContactAddParams as ContactAddParams,
|
|
517
|
+
type ContactRemoveParams as ContactRemoveParams,
|
|
518
|
+
};
|
|
519
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { APIResource } from '../../core/resource';
|
|
4
|
+
import * as BroadcastsAPI from './broadcasts';
|
|
5
|
+
import { BroadcastContactsCursor } from './broadcasts';
|
|
6
|
+
import { APIPromise } from '../../core/api-promise';
|
|
7
|
+
import { Cursor, type CursorParams, PagePromise } from '../../core/pagination';
|
|
8
|
+
import { buildHeaders } from '../../internal/headers';
|
|
9
|
+
import { RequestOptions } from '../../internal/request-options';
|
|
10
|
+
import { path } from '../../internal/utils/path';
|
|
11
|
+
|
|
12
|
+
export class Contacts extends APIResource {
|
|
13
|
+
/**
|
|
14
|
+
* List contacts in a broadcast with optional status filter.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* // Automatically fetches more pages as needed.
|
|
19
|
+
* for await (const broadcastContact of client.broadcasts.contacts.list(
|
|
20
|
+
* 'broadcastId',
|
|
21
|
+
* )) {
|
|
22
|
+
* // ...
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
list(
|
|
27
|
+
broadcastID: string,
|
|
28
|
+
query: ContactListParams | null | undefined = {},
|
|
29
|
+
options?: RequestOptions,
|
|
30
|
+
): PagePromise<BroadcastContactsCursor, BroadcastsAPI.BroadcastContact> {
|
|
31
|
+
return this._client.getAPIList(
|
|
32
|
+
path`/v1/broadcasts/${broadcastID}/contacts`,
|
|
33
|
+
Cursor<BroadcastsAPI.BroadcastContact>,
|
|
34
|
+
{ query, ...options },
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Add contacts to a broadcast in batch. Maximum 1000 contacts per request.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* const response = await client.broadcasts.contacts.add(
|
|
44
|
+
* 'broadcastId',
|
|
45
|
+
* {
|
|
46
|
+
* contacts: [
|
|
47
|
+
* {
|
|
48
|
+
* recipient: '+14155551234',
|
|
49
|
+
* templateVariables: {
|
|
50
|
+
* name: 'John',
|
|
51
|
+
* order_id: 'ORD-001',
|
|
52
|
+
* },
|
|
53
|
+
* },
|
|
54
|
+
* {
|
|
55
|
+
* recipient: '+14155555678',
|
|
56
|
+
* templateVariables: {
|
|
57
|
+
* name: 'Jane',
|
|
58
|
+
* order_id: 'ORD-002',
|
|
59
|
+
* },
|
|
60
|
+
* },
|
|
61
|
+
* ],
|
|
62
|
+
* },
|
|
63
|
+
* );
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
add(broadcastID: string, body: ContactAddParams, options?: RequestOptions): APIPromise<ContactAddResponse> {
|
|
67
|
+
return this._client.post(path`/v1/broadcasts/${broadcastID}/contacts`, { body, ...options });
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Remove a contact from a broadcast in draft status.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```ts
|
|
75
|
+
* await client.broadcasts.contacts.remove('contactId', {
|
|
76
|
+
* broadcastId: 'broadcastId',
|
|
77
|
+
* });
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
remove(contactID: string, params: ContactRemoveParams, options?: RequestOptions): APIPromise<void> {
|
|
81
|
+
const { broadcastId } = params;
|
|
82
|
+
return this._client.delete(path`/v1/broadcasts/${broadcastId}/contacts/${contactID}`, {
|
|
83
|
+
...options,
|
|
84
|
+
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface ContactAddResponse {
|
|
90
|
+
/**
|
|
91
|
+
* Number of contacts successfully added.
|
|
92
|
+
*/
|
|
93
|
+
added: number;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Number of duplicate contacts skipped.
|
|
97
|
+
*/
|
|
98
|
+
duplicates: number;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Number of invalid contacts rejected.
|
|
102
|
+
*/
|
|
103
|
+
invalid: number;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Details about invalid contacts.
|
|
107
|
+
*/
|
|
108
|
+
errors?: Array<ContactAddResponse.Error>;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export namespace ContactAddResponse {
|
|
112
|
+
export interface Error {
|
|
113
|
+
reason?: string;
|
|
114
|
+
|
|
115
|
+
recipient?: string;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export interface ContactListParams extends CursorParams {
|
|
120
|
+
/**
|
|
121
|
+
* Status of a contact within a broadcast.
|
|
122
|
+
*/
|
|
123
|
+
status?: BroadcastsAPI.BroadcastContactStatus;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export interface ContactAddParams {
|
|
127
|
+
/**
|
|
128
|
+
* List of contacts to add (max 1000 per request).
|
|
129
|
+
*/
|
|
130
|
+
contacts: Array<ContactAddParams.Contact>;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export namespace ContactAddParams {
|
|
134
|
+
export interface Contact {
|
|
135
|
+
/**
|
|
136
|
+
* Phone number (E.164) or email address.
|
|
137
|
+
*/
|
|
138
|
+
recipient: string;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Per-contact template variables to personalize the message.
|
|
142
|
+
*/
|
|
143
|
+
templateVariables?: { [key: string]: string };
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export interface ContactRemoveParams {
|
|
148
|
+
broadcastId: string;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export declare namespace Contacts {
|
|
152
|
+
export {
|
|
153
|
+
type ContactAddResponse as ContactAddResponse,
|
|
154
|
+
type ContactListParams as ContactListParams,
|
|
155
|
+
type ContactAddParams as ContactAddParams,
|
|
156
|
+
type ContactRemoveParams as ContactRemoveParams,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export { type BroadcastContactsCursor };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
export {
|
|
4
|
+
Broadcasts,
|
|
5
|
+
type Broadcast,
|
|
6
|
+
type BroadcastChannel,
|
|
7
|
+
type BroadcastContact,
|
|
8
|
+
type BroadcastContactStatus,
|
|
9
|
+
type BroadcastContent,
|
|
10
|
+
type BroadcastMessageType,
|
|
11
|
+
type BroadcastProgress,
|
|
12
|
+
type BroadcastStatus,
|
|
13
|
+
type BroadcastCreateResponse,
|
|
14
|
+
type BroadcastRetrieveResponse,
|
|
15
|
+
type BroadcastUpdateResponse,
|
|
16
|
+
type BroadcastCancelResponse,
|
|
17
|
+
type BroadcastSendResponse,
|
|
18
|
+
type BroadcastCreateParams,
|
|
19
|
+
type BroadcastUpdateParams,
|
|
20
|
+
type BroadcastListParams,
|
|
21
|
+
type BroadcastSendParams,
|
|
22
|
+
type BroadcastContactsCursor,
|
|
23
|
+
type BroadcastsCursor,
|
|
24
|
+
} from './broadcasts';
|
|
25
|
+
export {
|
|
26
|
+
Contacts,
|
|
27
|
+
type ContactAddResponse,
|
|
28
|
+
type ContactListParams,
|
|
29
|
+
type ContactAddParams,
|
|
30
|
+
type ContactRemoveParams,
|
|
31
|
+
} from './contacts';
|