@sentdm/sentdm 0.41.0 → 0.43.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.
Files changed (120) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/client.d.mts +20 -3
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +20 -3
  5. package/client.d.ts.map +1 -1
  6. package/client.js +15 -0
  7. package/client.js.map +1 -1
  8. package/client.mjs +15 -0
  9. package/client.mjs.map +1 -1
  10. package/core/pagination.d.mts +25 -0
  11. package/core/pagination.d.mts.map +1 -1
  12. package/core/pagination.d.ts +25 -0
  13. package/core/pagination.d.ts.map +1 -1
  14. package/core/pagination.js +28 -1
  15. package/core/pagination.js.map +1 -1
  16. package/core/pagination.mjs +26 -0
  17. package/core/pagination.mjs.map +1 -1
  18. package/package.json +1 -1
  19. package/resources/calls/calls.d.mts +388 -0
  20. package/resources/calls/calls.d.mts.map +1 -0
  21. package/resources/calls/calls.d.ts +388 -0
  22. package/resources/calls/calls.d.ts.map +1 -0
  23. package/resources/calls/calls.js +159 -0
  24. package/resources/calls/calls.js.map +1 -0
  25. package/resources/calls/calls.mjs +154 -0
  26. package/resources/calls/calls.mjs.map +1 -0
  27. package/resources/calls/index.d.mts +3 -0
  28. package/resources/calls/index.d.mts.map +1 -0
  29. package/resources/calls/index.d.ts +3 -0
  30. package/resources/calls/index.d.ts.map +1 -0
  31. package/resources/calls/index.js +9 -0
  32. package/resources/calls/index.js.map +1 -0
  33. package/resources/calls/index.mjs +4 -0
  34. package/resources/calls/index.mjs.map +1 -0
  35. package/resources/calls/participants.d.mts +258 -0
  36. package/resources/calls/participants.d.mts.map +1 -0
  37. package/resources/calls/participants.d.ts +258 -0
  38. package/resources/calls/participants.d.ts.map +1 -0
  39. package/resources/calls/participants.js +158 -0
  40. package/resources/calls/participants.js.map +1 -0
  41. package/resources/calls/participants.mjs +154 -0
  42. package/resources/calls/participants.mjs.map +1 -0
  43. package/resources/calls.d.mts +2 -0
  44. package/resources/calls.d.mts.map +1 -0
  45. package/resources/calls.d.ts +2 -0
  46. package/resources/calls.d.ts.map +1 -0
  47. package/resources/calls.js +6 -0
  48. package/resources/calls.js.map +1 -0
  49. package/resources/calls.mjs +3 -0
  50. package/resources/calls.mjs.map +1 -0
  51. package/resources/channels/channels.d.mts +10 -0
  52. package/resources/channels/channels.d.mts.map +1 -0
  53. package/resources/channels/channels.d.ts +10 -0
  54. package/resources/channels/channels.d.ts.map +1 -0
  55. package/resources/channels/channels.js +17 -0
  56. package/resources/channels/channels.js.map +1 -0
  57. package/resources/channels/channels.mjs +12 -0
  58. package/resources/channels/channels.mjs.map +1 -0
  59. package/resources/channels/index.d.mts +3 -0
  60. package/resources/channels/index.d.mts.map +1 -0
  61. package/resources/channels/index.d.ts +3 -0
  62. package/resources/channels/index.d.ts.map +1 -0
  63. package/resources/channels/index.js +9 -0
  64. package/resources/channels/index.js.map +1 -0
  65. package/resources/channels/index.mjs +4 -0
  66. package/resources/channels/index.mjs.map +1 -0
  67. package/resources/channels/voice.d.mts +654 -0
  68. package/resources/channels/voice.d.mts.map +1 -0
  69. package/resources/channels/voice.d.ts +654 -0
  70. package/resources/channels/voice.d.ts.map +1 -0
  71. package/resources/channels/voice.js +285 -0
  72. package/resources/channels/voice.js.map +1 -0
  73. package/resources/channels/voice.mjs +281 -0
  74. package/resources/channels/voice.mjs.map +1 -0
  75. package/resources/channels.d.mts +2 -0
  76. package/resources/channels.d.mts.map +1 -0
  77. package/resources/channels.d.ts +2 -0
  78. package/resources/channels.d.ts.map +1 -0
  79. package/resources/channels.js +6 -0
  80. package/resources/channels.js.map +1 -0
  81. package/resources/channels.mjs +3 -0
  82. package/resources/channels.mjs.map +1 -0
  83. package/resources/index.d.mts +3 -1
  84. package/resources/index.d.mts.map +1 -1
  85. package/resources/index.d.ts +3 -1
  86. package/resources/index.d.ts.map +1 -1
  87. package/resources/index.js +5 -1
  88. package/resources/index.js.map +1 -1
  89. package/resources/index.mjs +2 -0
  90. package/resources/index.mjs.map +1 -1
  91. package/resources/messages.d.mts +13 -8
  92. package/resources/messages.d.mts.map +1 -1
  93. package/resources/messages.d.ts +13 -8
  94. package/resources/messages.d.ts.map +1 -1
  95. package/resources/messages.js +7 -4
  96. package/resources/messages.js.map +1 -1
  97. package/resources/messages.mjs +7 -4
  98. package/resources/messages.mjs.map +1 -1
  99. package/resources/webhooks.d.mts +112 -109
  100. package/resources/webhooks.d.mts.map +1 -1
  101. package/resources/webhooks.d.ts +112 -109
  102. package/resources/webhooks.d.ts.map +1 -1
  103. package/src/client.ts +62 -0
  104. package/src/core/pagination.ts +59 -0
  105. package/src/resources/calls/calls.ts +556 -0
  106. package/src/resources/calls/index.ts +31 -0
  107. package/src/resources/calls/participants.ts +367 -0
  108. package/src/resources/calls.ts +3 -0
  109. package/src/resources/channels/channels.ts +61 -0
  110. package/src/resources/channels/index.ts +27 -0
  111. package/src/resources/channels/voice.ts +864 -0
  112. package/src/resources/channels.ts +3 -0
  113. package/src/resources/index.ts +21 -0
  114. package/src/resources/messages.ts +13 -8
  115. package/src/resources/webhooks.ts +127 -122
  116. package/src/version.ts +1 -1
  117. package/version.d.mts +1 -1
  118. package/version.d.ts +1 -1
  119. package/version.js +1 -1
  120. package/version.mjs +1 -1
@@ -0,0 +1,388 @@
1
+ import { APIResource } from "../../core/resource.js";
2
+ import * as WebhooksAPI from "../webhooks.js";
3
+ import * as ParticipantsAPI from "./participants.js";
4
+ import { APIResponseOfListOfCallParticipant, CallParticipant, CallParticipantTarget, ParticipantAddParams, ParticipantListParams, ParticipantRemoveAllParams, ParticipantRemoveParams, ParticipantUpdateParams, Participants } from "./participants.js";
5
+ import { APIPromise } from "../../core/api-promise.js";
6
+ import { CallsPage, type CallsPageParams, PagePromise } from "../../core/pagination.js";
7
+ import { RequestOptions } from "../../internal/request-options.js";
8
+ /**
9
+ * Phone calls from the numbers you hold, driven by your own callback URL.
10
+ *
11
+ * `POST /v3/channels/voice` enables a number for calls, with the callback URL Sent asks what to do with each call on it, and `POST /v3/channels/voice/tokens` mints a short-lived token that lets a user of your app place and receive calls as that number. When a call arrives or a caller presses a key, a signed question is POSTed to the callback URL and the answer decides the call; `POST /v3/channels/voice/{number}/test` checks the URL answers the way we need before a real call reaches it, and `POST /v3/channels/voice/{number}/rotate-secret` replaces the signing secret. The call events themselves (`call.completed` and the rest) arrive through your webhooks.
12
+ *
13
+ * Every call is a record under `/v3/calls`: read it, list its recordings once one is ready, hang it up, start or stop recording, and add, mute or remove conference participants while it is live. A leg to a phone number runs for at most what your balance affords at the destination's rate.
14
+ */
15
+ export declare class Calls extends APIResource {
16
+ participants: ParticipantsAPI.Participants;
17
+ /**
18
+ * Retrieves one of your calls by id: the parties, the owning number, the current
19
+ * status with its failure reason, duration, price, recording availability, and a
20
+ * timeline of when the call entered each status.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * const apiResponseOfCall = await client.calls.retrieve(
25
+ * 'call_9f2ab000-0000-4000-8000-000000000001',
26
+ * );
27
+ * ```
28
+ */
29
+ retrieve(id: string, params?: CallRetrieveParams | null | undefined, options?: RequestOptions): APIPromise<APIResponseOfCall>;
30
+ /**
31
+ * Retrieves a paginated list of your calls, most recent first. Filter by
32
+ * direction, status, the owning number, and the time the call started (from and to
33
+ * are inclusive). Use the call webhooks for real-time updates; this list is for
34
+ * looking calls up afterwards.
35
+ *
36
+ * @example
37
+ * ```ts
38
+ * // Automatically fetches more pages as needed.
39
+ * for await (const call of client.calls.list()) {
40
+ * // ...
41
+ * }
42
+ * ```
43
+ */
44
+ list(params?: CallListParams | null | undefined, options?: RequestOptions): PagePromise<CallsCallsPage, Call>;
45
+ /**
46
+ * Ends one of your live calls. The call then ends the way any other call does once
47
+ * the disconnect is reported: an answered call as COMPLETED with call.completed, a
48
+ * call still ringing as NO_ANSWER, REJECTED or FAILED with call.failed. A call
49
+ * that has already ended answers 409, and so does a call with no phone leg, such
50
+ * as one between two app users.
51
+ *
52
+ * @example
53
+ * ```ts
54
+ * await client.calls.hangup(
55
+ * 'call_9f2ab000-0000-4000-8000-000000000001',
56
+ * );
57
+ * ```
58
+ */
59
+ hangup(id: string, params: CallHangupParams, options?: RequestOptions): APIPromise<void>;
60
+ /**
61
+ * Returns pre-signed links to the recordings of one of your calls, each valid
62
+ * until its url_expires_at. A recording appears once the call was recorded, by a
63
+ * connect answer with record set, a startRecording instruction or the recordings
64
+ * command, and the call.recording_ready webhook has been sent; until then, and for
65
+ * a call that was never recorded, the list is empty. A call recorded more than
66
+ * once lists every recording, oldest first, each under the recording_id its
67
+ * call.recording_ready webhook carried.
68
+ *
69
+ * @example
70
+ * ```ts
71
+ * const apiResponseOfCallRecordings =
72
+ * await client.calls.listRecordings(
73
+ * 'call_9f2ab000-0000-4000-8000-000000000001',
74
+ * );
75
+ * ```
76
+ */
77
+ listRecordings(id: string, params?: CallListRecordingsParams | null | undefined, options?: RequestOptions): APIPromise<APIResponseOfCallRecordings>;
78
+ /**
79
+ * Starts or stops recording one of your live calls. Use start to begin recording
80
+ * mid-call, or stop to end a recording, whether it was started here or by a
81
+ * connect answer with record set. A call that has already ended answers 409, and
82
+ * so does a call with no phone leg, such as one between two app users, which can't
83
+ * be recorded.
84
+ *
85
+ * @example
86
+ * ```ts
87
+ * await client.calls.record(
88
+ * 'call_9f2ab000-0000-4000-8000-000000000001',
89
+ * );
90
+ * ```
91
+ */
92
+ record(id: string, params: CallRecordParams, options?: RequestOptions): APIPromise<void>;
93
+ }
94
+ export type CallsCallsPage = CallsPage<Call>;
95
+ /**
96
+ * Standard API response envelope for all v3 endpoints
97
+ */
98
+ export interface APIResponseOfCall {
99
+ /**
100
+ * A call record
101
+ */
102
+ data?: Call | null;
103
+ /**
104
+ * Error information
105
+ */
106
+ error?: WebhooksAPI.ErrorDetail | null;
107
+ /**
108
+ * Request and response metadata
109
+ */
110
+ meta?: WebhooksAPI.APIMeta;
111
+ /**
112
+ * Indicates whether the request was successful
113
+ */
114
+ success?: boolean;
115
+ }
116
+ /**
117
+ * Standard API response envelope for all v3 endpoints
118
+ */
119
+ export interface APIResponseOfCallRecordings {
120
+ /**
121
+ * The recordings of a call, each as a short-lived download link
122
+ */
123
+ data?: CallRecordings | null;
124
+ /**
125
+ * Error information
126
+ */
127
+ error?: WebhooksAPI.ErrorDetail | null;
128
+ /**
129
+ * Request and response metadata
130
+ */
131
+ meta?: WebhooksAPI.APIMeta;
132
+ /**
133
+ * Indicates whether the request was successful
134
+ */
135
+ success?: boolean;
136
+ }
137
+ /**
138
+ * Standard API response envelope for all v3 endpoints
139
+ */
140
+ export interface APIResponseOfCallsList {
141
+ /**
142
+ * Paginated list of calls
143
+ */
144
+ data?: CallsList | null;
145
+ /**
146
+ * Error information
147
+ */
148
+ error?: WebhooksAPI.ErrorDetail | null;
149
+ /**
150
+ * Request and response metadata
151
+ */
152
+ meta?: WebhooksAPI.APIMeta;
153
+ /**
154
+ * Indicates whether the request was successful
155
+ */
156
+ success?: boolean;
157
+ }
158
+ /**
159
+ * A call record
160
+ */
161
+ export interface Call {
162
+ /**
163
+ * The call id, the same one carried by the call.request question and every call
164
+ * webhook
165
+ */
166
+ id?: string;
167
+ /**
168
+ * When the call was answered (UTC). Null until then, and always null for a call
169
+ * between two of your app users
170
+ */
171
+ answered_at?: string | null;
172
+ /**
173
+ * outbound for a call placed from your app, inbound for a call to one of your
174
+ * numbers
175
+ */
176
+ direction?: string;
177
+ /**
178
+ * Billable duration in seconds. Null while the call is live
179
+ */
180
+ duration_seconds?: number | null;
181
+ /**
182
+ * When the call ended (UTC). Null while the call is live
183
+ */
184
+ ended_at?: string | null;
185
+ /**
186
+ * Why the call did not complete: callback_timeout, invalid_answer,
187
+ * insufficient_balance, destination_blocked, callback_not_configured, rejected or
188
+ * no_answer. Null while the call is live, when it completed, and when it failed
189
+ * without a recorded reason
190
+ */
191
+ failure_reason?: string | null;
192
+ /**
193
+ * One end of a call
194
+ */
195
+ from?: CallParty;
196
+ /**
197
+ * Your number that owns the call, in E.164 format: the dialed number for an
198
+ * inbound call, the caller's bound number for a call placed from your app
199
+ */
200
+ number?: string;
201
+ /**
202
+ * What the call cost. Null until it has been priced
203
+ */
204
+ price?: number | null;
205
+ /**
206
+ * True once a recording of the call is available
207
+ */
208
+ recording_available?: boolean;
209
+ /**
210
+ * When the call was placed (UTC)
211
+ */
212
+ started_at?: string;
213
+ /**
214
+ * INITIATED, RINGING, ANSWERED, COMPLETED, FAILED, NO_ANSWER or REJECTED
215
+ */
216
+ status?: string;
217
+ /**
218
+ * When the call entered each status, oldest first. Only returned when reading one
219
+ * call
220
+ */
221
+ timeline?: Array<CallTimelineEntry> | null;
222
+ /**
223
+ * One end of a call
224
+ */
225
+ to?: CallParty;
226
+ }
227
+ /**
228
+ * One end of a call
229
+ */
230
+ export interface CallParty {
231
+ /**
232
+ * user for one of your app users, number for a phone number, conference for a
233
+ * room, anonymous for a caller who withheld their number
234
+ */
235
+ kind?: string;
236
+ /**
237
+ * The app user's identity, the phone number in E.164 format, or the room name.
238
+ * Null when the kind is anonymous
239
+ */
240
+ value?: string | null;
241
+ }
242
+ /**
243
+ * A short-lived link to a call recording
244
+ */
245
+ export interface CallRecording {
246
+ /**
247
+ * A pre-signed link that downloads the recording as an MP3 file. Anyone holding it
248
+ * can download the recording until it expires
249
+ */
250
+ download_url?: string;
251
+ /**
252
+ * The recording's id, the one the call.recording_ready webhook announced it under
253
+ */
254
+ recording_id?: string;
255
+ /**
256
+ * When the link stops working (UTC). Request the recordings again for a fresh link
257
+ */
258
+ url_expires_at?: string;
259
+ }
260
+ /**
261
+ * The recordings of a call, each as a short-lived download link
262
+ */
263
+ export interface CallRecordings {
264
+ /**
265
+ * Every recording of the call, oldest first. Empty until the first
266
+ * call.recording_ready webhook has been sent, and for a call that was never
267
+ * recorded
268
+ */
269
+ recordings?: Array<CallRecording>;
270
+ }
271
+ /**
272
+ * When a call entered a status
273
+ */
274
+ export interface CallTimelineEntry {
275
+ /**
276
+ * INITIATED, RINGING, ANSWERED, COMPLETED, FAILED, NO_ANSWER or REJECTED
277
+ */
278
+ status?: string;
279
+ /**
280
+ * When the call entered this status (UTC)
281
+ */
282
+ timestamp?: string;
283
+ }
284
+ /**
285
+ * Paginated list of calls
286
+ */
287
+ export interface CallsList {
288
+ /**
289
+ * The calls on this page, most recent first
290
+ */
291
+ calls?: Array<Call>;
292
+ /**
293
+ * Pagination metadata for list responses
294
+ */
295
+ pagination?: WebhooksAPI.PaginationMeta;
296
+ }
297
+ export interface CallRetrieveParams {
298
+ /**
299
+ * Profile UUID to scope the request to a child profile. Only organization API keys
300
+ * can use this header. The profile must belong to the calling organization.
301
+ */
302
+ 'x-profile-id'?: string;
303
+ }
304
+ export interface CallListParams extends CallsPageParams {
305
+ /**
306
+ * Query param: Optional direction filter: outbound for calls placed from your app,
307
+ * inbound for calls to one of your numbers
308
+ */
309
+ direction?: string | null;
310
+ /**
311
+ * Query param: Only calls started at or after this time (ISO 8601)
312
+ */
313
+ from?: string | null;
314
+ /**
315
+ * Query param: Optional filter on the number that owns the call, one of your
316
+ * voice-enabled numbers in E.164 format
317
+ */
318
+ number?: string | null;
319
+ /**
320
+ * Query param: Optional status filter: initiated, ringing, answered, completed,
321
+ * failed, no_answer or rejected
322
+ */
323
+ status?: string | null;
324
+ /**
325
+ * Query param: Only calls started at or before this time (ISO 8601)
326
+ */
327
+ to?: string | null;
328
+ /**
329
+ * Header param: Profile UUID to scope the request to a child profile. Only
330
+ * organization API keys can use this header. The profile must belong to the
331
+ * calling organization.
332
+ */
333
+ 'x-profile-id'?: string;
334
+ }
335
+ export interface CallHangupParams {
336
+ /**
337
+ * Body param: Sandbox flag - when true, the operation is simulated without side
338
+ * effects Useful for testing integrations without actual execution
339
+ */
340
+ sandbox?: boolean;
341
+ /**
342
+ * Header param: Unique key to ensure idempotent request processing. Must be 1-255
343
+ * alphanumeric characters, hyphens, or underscores. Responses are cached for 24
344
+ * hours per key per customer.
345
+ */
346
+ 'Idempotency-Key'?: string;
347
+ /**
348
+ * Header param: Profile UUID to scope the request to a child profile. Only
349
+ * organization API keys can use this header. The profile must belong to the
350
+ * calling organization.
351
+ */
352
+ 'x-profile-id'?: string;
353
+ }
354
+ export interface CallListRecordingsParams {
355
+ /**
356
+ * Profile UUID to scope the request to a child profile. Only organization API keys
357
+ * can use this header. The profile must belong to the calling organization.
358
+ */
359
+ 'x-profile-id'?: string;
360
+ }
361
+ export interface CallRecordParams {
362
+ /**
363
+ * Body param: start to begin recording, stop to end it
364
+ */
365
+ action?: string;
366
+ /**
367
+ * Body param: Sandbox flag - when true, the operation is simulated without side
368
+ * effects Useful for testing integrations without actual execution
369
+ */
370
+ sandbox?: boolean;
371
+ /**
372
+ * Header param: Unique key to ensure idempotent request processing. Must be 1-255
373
+ * alphanumeric characters, hyphens, or underscores. Responses are cached for 24
374
+ * hours per key per customer.
375
+ */
376
+ 'Idempotency-Key'?: string;
377
+ /**
378
+ * Header param: Profile UUID to scope the request to a child profile. Only
379
+ * organization API keys can use this header. The profile must belong to the
380
+ * calling organization.
381
+ */
382
+ 'x-profile-id'?: string;
383
+ }
384
+ export declare namespace Calls {
385
+ export { type APIResponseOfCall as APIResponseOfCall, type APIResponseOfCallRecordings as APIResponseOfCallRecordings, type APIResponseOfCallsList as APIResponseOfCallsList, type Call as Call, type CallParty as CallParty, type CallRecording as CallRecording, type CallRecordings as CallRecordings, type CallTimelineEntry as CallTimelineEntry, type CallsList as CallsList, type CallsCallsPage as CallsCallsPage, type CallRetrieveParams as CallRetrieveParams, type CallListParams as CallListParams, type CallHangupParams as CallHangupParams, type CallListRecordingsParams as CallListRecordingsParams, type CallRecordParams as CallRecordParams, };
386
+ export { Participants as Participants, type APIResponseOfListOfCallParticipant as APIResponseOfListOfCallParticipant, type CallParticipant as CallParticipant, type CallParticipantTarget as CallParticipantTarget, type ParticipantUpdateParams as ParticipantUpdateParams, type ParticipantListParams as ParticipantListParams, type ParticipantAddParams as ParticipantAddParams, type ParticipantRemoveParams as ParticipantRemoveParams, type ParticipantRemoveAllParams as ParticipantRemoveAllParams, };
387
+ }
388
+ //# sourceMappingURL=calls.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calls.d.ts","sourceRoot":"","sources":["../../src/resources/calls/calls.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,+BAA4B;AAClD,OAAO,KAAK,WAAW,uBAAoB;AAC3C,OAAO,KAAK,eAAe,0BAAuB;AAClD,OAAO,EACL,kCAAkC,EAClC,eAAe,EACf,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,0BAA0B,EAC1B,uBAAuB,EACvB,uBAAuB,EACvB,YAAY,EACb,0BAAuB;AACxB,OAAO,EAAE,UAAU,EAAE,kCAA+B;AACpD,OAAO,EAAE,SAAS,EAAE,KAAK,eAAe,EAAE,WAAW,EAAE,iCAA8B;AAErF,OAAO,EAAE,cAAc,EAAE,0CAAuC;AAGhE;;;;;;GAMG;AACH,qBAAa,KAAM,SAAQ,WAAW;IACpC,YAAY,EAAE,eAAe,CAAC,YAAY,CAAkD;IAE5F;;;;;;;;;;;OAWG;IACH,QAAQ,CACN,EAAE,EAAE,MAAM,EACV,MAAM,GAAE,kBAAkB,GAAG,IAAI,GAAG,SAAc,EAClD,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CAAC,iBAAiB,CAAC;IAWhC;;;;;;;;;;;;;OAaG;IACH,IAAI,CACF,MAAM,GAAE,cAAc,GAAG,IAAI,GAAG,SAAc,EAC9C,OAAO,CAAC,EAAE,cAAc,GACvB,WAAW,CAAC,cAAc,EAAE,IAAI,CAAC;IAYpC;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,IAAI,CAAC;IAgBxF;;;;;;;;;;;;;;;;OAgBG;IACH,cAAc,CACZ,EAAE,EAAE,MAAM,EACV,MAAM,GAAE,wBAAwB,GAAG,IAAI,GAAG,SAAc,EAC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CAAC,EAAE,MAAM,CAAC;CACzB;AAID,MAAM,CAAC,OAAO,WAAW,KAAK,CAAC;IAC7B,OAAO,EACL,KAAK,iBAAiB,IAAI,iBAAiB,EAC3C,KAAK,2BAA2B,IAAI,2BAA2B,EAC/D,KAAK,sBAAsB,IAAI,sBAAsB,EACrD,KAAK,IAAI,IAAI,IAAI,EACjB,KAAK,SAAS,IAAI,SAAS,EAC3B,KAAK,aAAa,IAAI,aAAa,EACnC,KAAK,cAAc,IAAI,cAAc,EACrC,KAAK,iBAAiB,IAAI,iBAAiB,EAC3C,KAAK,SAAS,IAAI,SAAS,EAC3B,KAAK,cAAc,IAAI,cAAc,EACrC,KAAK,kBAAkB,IAAI,kBAAkB,EAC7C,KAAK,cAAc,IAAI,cAAc,EACrC,KAAK,gBAAgB,IAAI,gBAAgB,EACzC,KAAK,wBAAwB,IAAI,wBAAwB,EACzD,KAAK,gBAAgB,IAAI,gBAAgB,GAC1C,CAAC;IAEF,OAAO,EACL,YAAY,IAAI,YAAY,EAC5B,KAAK,kCAAkC,IAAI,kCAAkC,EAC7E,KAAK,eAAe,IAAI,eAAe,EACvC,KAAK,qBAAqB,IAAI,qBAAqB,EACnD,KAAK,uBAAuB,IAAI,uBAAuB,EACvD,KAAK,qBAAqB,IAAI,qBAAqB,EACnD,KAAK,oBAAoB,IAAI,oBAAoB,EACjD,KAAK,uBAAuB,IAAI,uBAAuB,EACvD,KAAK,0BAA0B,IAAI,0BAA0B,GAC9D,CAAC;CACH"}
@@ -0,0 +1,159 @@
1
+ "use strict";
2
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.Calls = void 0;
5
+ const tslib_1 = require("../../internal/tslib.js");
6
+ const resource_1 = require("../../core/resource.js");
7
+ const ParticipantsAPI = tslib_1.__importStar(require("./participants.js"));
8
+ const participants_1 = require("./participants.js");
9
+ const pagination_1 = require("../../core/pagination.js");
10
+ const headers_1 = require("../../internal/headers.js");
11
+ const path_1 = require("../../internal/utils/path.js");
12
+ /**
13
+ * Phone calls from the numbers you hold, driven by your own callback URL.
14
+ *
15
+ * `POST /v3/channels/voice` enables a number for calls, with the callback URL Sent asks what to do with each call on it, and `POST /v3/channels/voice/tokens` mints a short-lived token that lets a user of your app place and receive calls as that number. When a call arrives or a caller presses a key, a signed question is POSTed to the callback URL and the answer decides the call; `POST /v3/channels/voice/{number}/test` checks the URL answers the way we need before a real call reaches it, and `POST /v3/channels/voice/{number}/rotate-secret` replaces the signing secret. The call events themselves (`call.completed` and the rest) arrive through your webhooks.
16
+ *
17
+ * Every call is a record under `/v3/calls`: read it, list its recordings once one is ready, hang it up, start or stop recording, and add, mute or remove conference participants while it is live. A leg to a phone number runs for at most what your balance affords at the destination's rate.
18
+ */
19
+ class Calls extends resource_1.APIResource {
20
+ constructor() {
21
+ super(...arguments);
22
+ this.participants = new ParticipantsAPI.Participants(this._client);
23
+ }
24
+ /**
25
+ * Retrieves one of your calls by id: the parties, the owning number, the current
26
+ * status with its failure reason, duration, price, recording availability, and a
27
+ * timeline of when the call entered each status.
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * const apiResponseOfCall = await client.calls.retrieve(
32
+ * 'call_9f2ab000-0000-4000-8000-000000000001',
33
+ * );
34
+ * ```
35
+ */
36
+ retrieve(id, params = {}, options) {
37
+ const { 'x-profile-id': xProfileID } = params ?? {};
38
+ return this._client.get((0, path_1.path) `/v3/calls/${id}`, {
39
+ ...options,
40
+ headers: (0, headers_1.buildHeaders)([
41
+ { ...(xProfileID != null ? { 'x-profile-id': xProfileID } : undefined) },
42
+ options?.headers,
43
+ ]),
44
+ });
45
+ }
46
+ /**
47
+ * Retrieves a paginated list of your calls, most recent first. Filter by
48
+ * direction, status, the owning number, and the time the call started (from and to
49
+ * are inclusive). Use the call webhooks for real-time updates; this list is for
50
+ * looking calls up afterwards.
51
+ *
52
+ * @example
53
+ * ```ts
54
+ * // Automatically fetches more pages as needed.
55
+ * for await (const call of client.calls.list()) {
56
+ * // ...
57
+ * }
58
+ * ```
59
+ */
60
+ list(params = {}, options) {
61
+ const { 'x-profile-id': xProfileID, ...query } = params ?? {};
62
+ return this._client.getAPIList('/v3/calls', (pagination_1.CallsPage), {
63
+ query,
64
+ ...options,
65
+ headers: (0, headers_1.buildHeaders)([
66
+ { ...(xProfileID != null ? { 'x-profile-id': xProfileID } : undefined) },
67
+ options?.headers,
68
+ ]),
69
+ });
70
+ }
71
+ /**
72
+ * Ends one of your live calls. The call then ends the way any other call does once
73
+ * the disconnect is reported: an answered call as COMPLETED with call.completed, a
74
+ * call still ringing as NO_ANSWER, REJECTED or FAILED with call.failed. A call
75
+ * that has already ended answers 409, and so does a call with no phone leg, such
76
+ * as one between two app users.
77
+ *
78
+ * @example
79
+ * ```ts
80
+ * await client.calls.hangup(
81
+ * 'call_9f2ab000-0000-4000-8000-000000000001',
82
+ * );
83
+ * ```
84
+ */
85
+ hangup(id, params, options) {
86
+ const { 'Idempotency-Key': idempotencyKey, 'x-profile-id': xProfileID, ...body } = params;
87
+ return this._client.post((0, path_1.path) `/v3/calls/${id}/hangup`, {
88
+ body,
89
+ ...options,
90
+ headers: (0, headers_1.buildHeaders)([
91
+ {
92
+ Accept: '*/*',
93
+ ...(idempotencyKey != null ? { 'Idempotency-Key': idempotencyKey } : undefined),
94
+ ...(xProfileID != null ? { 'x-profile-id': xProfileID } : undefined),
95
+ },
96
+ options?.headers,
97
+ ]),
98
+ });
99
+ }
100
+ /**
101
+ * Returns pre-signed links to the recordings of one of your calls, each valid
102
+ * until its url_expires_at. A recording appears once the call was recorded, by a
103
+ * connect answer with record set, a startRecording instruction or the recordings
104
+ * command, and the call.recording_ready webhook has been sent; until then, and for
105
+ * a call that was never recorded, the list is empty. A call recorded more than
106
+ * once lists every recording, oldest first, each under the recording_id its
107
+ * call.recording_ready webhook carried.
108
+ *
109
+ * @example
110
+ * ```ts
111
+ * const apiResponseOfCallRecordings =
112
+ * await client.calls.listRecordings(
113
+ * 'call_9f2ab000-0000-4000-8000-000000000001',
114
+ * );
115
+ * ```
116
+ */
117
+ listRecordings(id, params = {}, options) {
118
+ const { 'x-profile-id': xProfileID } = params ?? {};
119
+ return this._client.get((0, path_1.path) `/v3/calls/${id}/recordings`, {
120
+ ...options,
121
+ headers: (0, headers_1.buildHeaders)([
122
+ { ...(xProfileID != null ? { 'x-profile-id': xProfileID } : undefined) },
123
+ options?.headers,
124
+ ]),
125
+ });
126
+ }
127
+ /**
128
+ * Starts or stops recording one of your live calls. Use start to begin recording
129
+ * mid-call, or stop to end a recording, whether it was started here or by a
130
+ * connect answer with record set. A call that has already ended answers 409, and
131
+ * so does a call with no phone leg, such as one between two app users, which can't
132
+ * be recorded.
133
+ *
134
+ * @example
135
+ * ```ts
136
+ * await client.calls.record(
137
+ * 'call_9f2ab000-0000-4000-8000-000000000001',
138
+ * );
139
+ * ```
140
+ */
141
+ record(id, params, options) {
142
+ const { 'Idempotency-Key': idempotencyKey, 'x-profile-id': xProfileID, ...body } = params;
143
+ return this._client.post((0, path_1.path) `/v3/calls/${id}/recordings`, {
144
+ body,
145
+ ...options,
146
+ headers: (0, headers_1.buildHeaders)([
147
+ {
148
+ Accept: '*/*',
149
+ ...(idempotencyKey != null ? { 'Idempotency-Key': idempotencyKey } : undefined),
150
+ ...(xProfileID != null ? { 'x-profile-id': xProfileID } : undefined),
151
+ },
152
+ options?.headers,
153
+ ]),
154
+ });
155
+ }
156
+ }
157
+ exports.Calls = Calls;
158
+ Calls.Participants = participants_1.Participants;
159
+ //# sourceMappingURL=calls.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calls.js","sourceRoot":"","sources":["../../src/resources/calls/calls.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;AAEtF,qDAAkD;AAElD,2EAAkD;AAClD,oDAUwB;AAExB,yDAAqF;AACrF,uDAAsD;AAEtD,uDAAiD;AAEjD;;;;;;GAMG;AACH,MAAa,KAAM,SAAQ,sBAAW;IAAtC;;QACE,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