@sentdm/sentdm 0.40.0 → 0.42.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 (139) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/client.d.mts +18 -3
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +18 -3
  5. package/client.d.ts.map +1 -1
  6. package/client.js +13 -0
  7. package/client.js.map +1 -1
  8. package/client.mjs +13 -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 +386 -0
  20. package/resources/calls/calls.d.mts.map +1 -0
  21. package/resources/calls/calls.d.ts +386 -0
  22. package/resources/calls/calls.d.ts.map +1 -0
  23. package/resources/calls/calls.js +158 -0
  24. package/resources/calls/calls.js.map +1 -0
  25. package/resources/calls/calls.mjs +153 -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/conversations.d.mts +63 -8
  84. package/resources/conversations.d.mts.map +1 -1
  85. package/resources/conversations.d.ts +63 -8
  86. package/resources/conversations.d.ts.map +1 -1
  87. package/resources/index.d.mts +3 -1
  88. package/resources/index.d.mts.map +1 -1
  89. package/resources/index.d.ts +3 -1
  90. package/resources/index.d.ts.map +1 -1
  91. package/resources/index.js +5 -1
  92. package/resources/index.js.map +1 -1
  93. package/resources/index.mjs +2 -0
  94. package/resources/index.mjs.map +1 -1
  95. package/resources/me.d.mts +21 -0
  96. package/resources/me.d.mts.map +1 -1
  97. package/resources/me.d.ts +21 -0
  98. package/resources/me.d.ts.map +1 -1
  99. package/resources/me.js +5 -0
  100. package/resources/me.js.map +1 -1
  101. package/resources/me.mjs +5 -0
  102. package/resources/me.mjs.map +1 -1
  103. package/resources/messages.d.mts +76 -8
  104. package/resources/messages.d.mts.map +1 -1
  105. package/resources/messages.d.ts +76 -8
  106. package/resources/messages.d.ts.map +1 -1
  107. package/resources/templates.d.mts +7 -0
  108. package/resources/templates.d.mts.map +1 -1
  109. package/resources/templates.d.ts +7 -0
  110. package/resources/templates.d.ts.map +1 -1
  111. package/resources/webhooks.d.mts +212 -8
  112. package/resources/webhooks.d.mts.map +1 -1
  113. package/resources/webhooks.d.ts +212 -8
  114. package/resources/webhooks.d.ts.map +1 -1
  115. package/resources/webhooks.js +3 -1
  116. package/resources/webhooks.js.map +1 -1
  117. package/resources/webhooks.mjs +3 -1
  118. package/resources/webhooks.mjs.map +1 -1
  119. package/src/client.ts +60 -0
  120. package/src/core/pagination.ts +59 -0
  121. package/src/resources/calls/calls.ts +554 -0
  122. package/src/resources/calls/index.ts +31 -0
  123. package/src/resources/calls/participants.ts +367 -0
  124. package/src/resources/calls.ts +3 -0
  125. package/src/resources/channels/channels.ts +61 -0
  126. package/src/resources/channels/index.ts +27 -0
  127. package/src/resources/channels/voice.ts +864 -0
  128. package/src/resources/channels.ts +3 -0
  129. package/src/resources/conversations.ts +70 -8
  130. package/src/resources/index.ts +21 -0
  131. package/src/resources/me.ts +22 -0
  132. package/src/resources/messages.ts +85 -8
  133. package/src/resources/templates.ts +8 -0
  134. package/src/resources/webhooks.ts +238 -7
  135. package/src/version.ts +1 -1
  136. package/version.d.mts +1 -1
  137. package/version.d.ts +1 -1
  138. package/version.js +1 -1
  139. package/version.mjs +1 -1
@@ -0,0 +1,386 @@
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: its
47
+ * status moves to completed and call.completed is sent once the disconnect is
48
+ * reported. A call that has already ended answers 409, and so does a call with no
49
+ * phone leg, such as one between two app users.
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * await client.calls.hangup(
54
+ * 'call_9f2ab000-0000-4000-8000-000000000001',
55
+ * );
56
+ * ```
57
+ */
58
+ hangup(id: string, params: CallHangupParams, options?: RequestOptions): APIPromise<void>;
59
+ /**
60
+ * Returns pre-signed links to the recordings of one of your calls, each valid
61
+ * until its url_expires_at. A recording appears once the call was recorded, by a
62
+ * connect answer with record set, a startRecording instruction or the recordings
63
+ * command, and the call.recording_ready webhook has been sent; until then, and for
64
+ * a call that was never recorded, the list is empty. A call recorded more than
65
+ * once lists every recording, oldest first, each under the recording_id its
66
+ * call.recording_ready webhook carried.
67
+ *
68
+ * @example
69
+ * ```ts
70
+ * const apiResponseOfCallRecordings =
71
+ * await client.calls.listRecordings(
72
+ * 'call_9f2ab000-0000-4000-8000-000000000001',
73
+ * );
74
+ * ```
75
+ */
76
+ listRecordings(id: string, params?: CallListRecordingsParams | null | undefined, options?: RequestOptions): APIPromise<APIResponseOfCallRecordings>;
77
+ /**
78
+ * Starts or stops recording one of your live calls. Use start to begin recording
79
+ * mid-call, or stop to end a recording, whether it was started here or by a
80
+ * connect answer with record set. A call that has already ended answers 409, and
81
+ * so does a call with no phone leg, such as one between two app users, which can't
82
+ * be recorded.
83
+ *
84
+ * @example
85
+ * ```ts
86
+ * await client.calls.record(
87
+ * 'call_9f2ab000-0000-4000-8000-000000000001',
88
+ * );
89
+ * ```
90
+ */
91
+ record(id: string, params: CallRecordParams, options?: RequestOptions): APIPromise<void>;
92
+ }
93
+ export type CallsCallsPage = CallsPage<Call>;
94
+ /**
95
+ * Standard API response envelope for all v3 endpoints
96
+ */
97
+ export interface APIResponseOfCall {
98
+ /**
99
+ * A call record
100
+ */
101
+ data?: Call | null;
102
+ /**
103
+ * Error information
104
+ */
105
+ error?: WebhooksAPI.ErrorDetail | null;
106
+ /**
107
+ * Request and response metadata
108
+ */
109
+ meta?: WebhooksAPI.APIMeta;
110
+ /**
111
+ * Indicates whether the request was successful
112
+ */
113
+ success?: boolean;
114
+ }
115
+ /**
116
+ * Standard API response envelope for all v3 endpoints
117
+ */
118
+ export interface APIResponseOfCallRecordings {
119
+ /**
120
+ * The recordings of a call, each as a short-lived download link
121
+ */
122
+ data?: CallRecordings | null;
123
+ /**
124
+ * Error information
125
+ */
126
+ error?: WebhooksAPI.ErrorDetail | null;
127
+ /**
128
+ * Request and response metadata
129
+ */
130
+ meta?: WebhooksAPI.APIMeta;
131
+ /**
132
+ * Indicates whether the request was successful
133
+ */
134
+ success?: boolean;
135
+ }
136
+ /**
137
+ * Standard API response envelope for all v3 endpoints
138
+ */
139
+ export interface APIResponseOfCallsList {
140
+ /**
141
+ * Paginated list of calls
142
+ */
143
+ data?: CallsList | null;
144
+ /**
145
+ * Error information
146
+ */
147
+ error?: WebhooksAPI.ErrorDetail | null;
148
+ /**
149
+ * Request and response metadata
150
+ */
151
+ meta?: WebhooksAPI.APIMeta;
152
+ /**
153
+ * Indicates whether the request was successful
154
+ */
155
+ success?: boolean;
156
+ }
157
+ /**
158
+ * A call record
159
+ */
160
+ export interface Call {
161
+ /**
162
+ * The call id, the same one carried by the call.request question and every call
163
+ * webhook
164
+ */
165
+ id?: string;
166
+ /**
167
+ * When the call was answered (UTC). Null until then, and always null for a call
168
+ * between two of your app users
169
+ */
170
+ answered_at?: string | null;
171
+ /**
172
+ * outbound for a call placed from your app, inbound for a call to one of your
173
+ * numbers
174
+ */
175
+ direction?: string;
176
+ /**
177
+ * Billable duration in seconds. Null while the call is live
178
+ */
179
+ duration_seconds?: number | null;
180
+ /**
181
+ * When the call ended (UTC). Null while the call is live
182
+ */
183
+ ended_at?: string | null;
184
+ /**
185
+ * Why the call did not complete: callback_timeout, invalid_answer,
186
+ * insufficient_balance, destination_blocked, rejected or no_answer. Null while the
187
+ * call is live, when it completed, and when it failed without a recorded reason
188
+ */
189
+ failure_reason?: string | null;
190
+ /**
191
+ * One end of a call
192
+ */
193
+ from?: CallParty;
194
+ /**
195
+ * Your number that owns the call, in E.164 format: the dialed number for an
196
+ * inbound call, the caller's bound number for a call placed from your app
197
+ */
198
+ number?: string;
199
+ /**
200
+ * What the call cost. Null until it has been priced
201
+ */
202
+ price?: number | null;
203
+ /**
204
+ * True once a recording of the call is available
205
+ */
206
+ recording_available?: boolean;
207
+ /**
208
+ * When the call was placed (UTC)
209
+ */
210
+ started_at?: string;
211
+ /**
212
+ * initiated, ringing, answered, completed, failed, no_answer or rejected
213
+ */
214
+ status?: string;
215
+ /**
216
+ * When the call entered each status, oldest first. Only returned when reading one
217
+ * call
218
+ */
219
+ timeline?: Array<CallTimelineEntry> | null;
220
+ /**
221
+ * One end of a call
222
+ */
223
+ to?: CallParty;
224
+ }
225
+ /**
226
+ * One end of a call
227
+ */
228
+ export interface CallParty {
229
+ /**
230
+ * user for one of your app users, number for a phone number, conference for a
231
+ * room, anonymous for a caller who withheld their number
232
+ */
233
+ kind?: string;
234
+ /**
235
+ * The app user's identity, the phone number in E.164 format, or the room name.
236
+ * Null when the kind is anonymous
237
+ */
238
+ value?: string | null;
239
+ }
240
+ /**
241
+ * A short-lived link to a call recording
242
+ */
243
+ export interface CallRecording {
244
+ /**
245
+ * A pre-signed link that downloads the recording as an MP3 file. Anyone holding it
246
+ * can download the recording until it expires
247
+ */
248
+ download_url?: string;
249
+ /**
250
+ * The recording's id, the one the call.recording_ready webhook announced it under
251
+ */
252
+ recording_id?: string;
253
+ /**
254
+ * When the link stops working (UTC). Request the recordings again for a fresh link
255
+ */
256
+ url_expires_at?: string;
257
+ }
258
+ /**
259
+ * The recordings of a call, each as a short-lived download link
260
+ */
261
+ export interface CallRecordings {
262
+ /**
263
+ * Every recording of the call, oldest first. Empty until the first
264
+ * call.recording_ready webhook has been sent, and for a call that was never
265
+ * recorded
266
+ */
267
+ recordings?: Array<CallRecording>;
268
+ }
269
+ /**
270
+ * When a call entered a status
271
+ */
272
+ export interface CallTimelineEntry {
273
+ /**
274
+ * initiated, ringing, answered, completed, failed, no_answer or rejected
275
+ */
276
+ status?: string;
277
+ /**
278
+ * When the call entered this status (UTC)
279
+ */
280
+ timestamp?: string;
281
+ }
282
+ /**
283
+ * Paginated list of calls
284
+ */
285
+ export interface CallsList {
286
+ /**
287
+ * The calls on this page, most recent first
288
+ */
289
+ calls?: Array<Call>;
290
+ /**
291
+ * Pagination metadata for list responses
292
+ */
293
+ pagination?: WebhooksAPI.PaginationMeta;
294
+ }
295
+ export interface CallRetrieveParams {
296
+ /**
297
+ * Profile UUID to scope the request to a child profile. Only organization API keys
298
+ * can use this header. The profile must belong to the calling organization.
299
+ */
300
+ 'x-profile-id'?: string;
301
+ }
302
+ export interface CallListParams extends CallsPageParams {
303
+ /**
304
+ * Query param: Optional direction filter: outbound for calls placed from your app,
305
+ * inbound for calls to one of your numbers
306
+ */
307
+ direction?: string | null;
308
+ /**
309
+ * Query param: Only calls started at or after this time (ISO 8601)
310
+ */
311
+ from?: string | null;
312
+ /**
313
+ * Query param: Optional filter on the number that owns the call, one of your
314
+ * voice-enabled numbers in E.164 format
315
+ */
316
+ number?: string | null;
317
+ /**
318
+ * Query param: Optional status filter: initiated, ringing, answered, completed,
319
+ * failed, no_answer or rejected
320
+ */
321
+ status?: string | null;
322
+ /**
323
+ * Query param: Only calls started at or before this time (ISO 8601)
324
+ */
325
+ to?: string | null;
326
+ /**
327
+ * Header param: Profile UUID to scope the request to a child profile. Only
328
+ * organization API keys can use this header. The profile must belong to the
329
+ * calling organization.
330
+ */
331
+ 'x-profile-id'?: string;
332
+ }
333
+ export interface CallHangupParams {
334
+ /**
335
+ * Body param: Sandbox flag - when true, the operation is simulated without side
336
+ * effects Useful for testing integrations without actual execution
337
+ */
338
+ sandbox?: boolean;
339
+ /**
340
+ * Header param: Unique key to ensure idempotent request processing. Must be 1-255
341
+ * alphanumeric characters, hyphens, or underscores. Responses are cached for 24
342
+ * hours per key per customer.
343
+ */
344
+ 'Idempotency-Key'?: string;
345
+ /**
346
+ * Header param: Profile UUID to scope the request to a child profile. Only
347
+ * organization API keys can use this header. The profile must belong to the
348
+ * calling organization.
349
+ */
350
+ 'x-profile-id'?: string;
351
+ }
352
+ export interface CallListRecordingsParams {
353
+ /**
354
+ * Profile UUID to scope the request to a child profile. Only organization API keys
355
+ * can use this header. The profile must belong to the calling organization.
356
+ */
357
+ 'x-profile-id'?: string;
358
+ }
359
+ export interface CallRecordParams {
360
+ /**
361
+ * Body param: start to begin recording, stop to end it
362
+ */
363
+ action?: string;
364
+ /**
365
+ * Body param: Sandbox flag - when true, the operation is simulated without side
366
+ * effects Useful for testing integrations without actual execution
367
+ */
368
+ sandbox?: boolean;
369
+ /**
370
+ * Header param: Unique key to ensure idempotent request processing. Must be 1-255
371
+ * alphanumeric characters, hyphens, or underscores. Responses are cached for 24
372
+ * hours per key per customer.
373
+ */
374
+ 'Idempotency-Key'?: string;
375
+ /**
376
+ * Header param: Profile UUID to scope the request to a child profile. Only
377
+ * organization API keys can use this header. The profile must belong to the
378
+ * calling organization.
379
+ */
380
+ 'x-profile-id'?: string;
381
+ }
382
+ export declare namespace Calls {
383
+ 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, };
384
+ 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, };
385
+ }
386
+ //# 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,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AAuB,IAAI,uBAAuB,EACvD,KAAK,0BAA0B,IAAI,0BAA0B,GAC9D,CAAC;CACH"}
@@ -0,0 +1,158 @@
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: its
73
+ * status moves to completed and call.completed is sent once the disconnect is
74
+ * reported. A call that has already ended answers 409, and so does a call with no
75
+ * phone leg, such as one between two app users.
76
+ *
77
+ * @example
78
+ * ```ts
79
+ * await client.calls.hangup(
80
+ * 'call_9f2ab000-0000-4000-8000-000000000001',
81
+ * );
82
+ * ```
83
+ */
84
+ hangup(id, params, options) {
85
+ const { 'Idempotency-Key': idempotencyKey, 'x-profile-id': xProfileID, ...body } = params;
86
+ return this._client.post((0, path_1.path) `/v3/calls/${id}/hangup`, {
87
+ body,
88
+ ...options,
89
+ headers: (0, headers_1.buildHeaders)([
90
+ {
91
+ Accept: '*/*',
92
+ ...(idempotencyKey != null ? { 'Idempotency-Key': idempotencyKey } : undefined),
93
+ ...(xProfileID != null ? { 'x-profile-id': xProfileID } : undefined),
94
+ },
95
+ options?.headers,
96
+ ]),
97
+ });
98
+ }
99
+ /**
100
+ * Returns pre-signed links to the recordings of one of your calls, each valid
101
+ * until its url_expires_at. A recording appears once the call was recorded, by a
102
+ * connect answer with record set, a startRecording instruction or the recordings
103
+ * command, and the call.recording_ready webhook has been sent; until then, and for
104
+ * a call that was never recorded, the list is empty. A call recorded more than
105
+ * once lists every recording, oldest first, each under the recording_id its
106
+ * call.recording_ready webhook carried.
107
+ *
108
+ * @example
109
+ * ```ts
110
+ * const apiResponseOfCallRecordings =
111
+ * await client.calls.listRecordings(
112
+ * 'call_9f2ab000-0000-4000-8000-000000000001',
113
+ * );
114
+ * ```
115
+ */
116
+ listRecordings(id, params = {}, options) {
117
+ const { 'x-profile-id': xProfileID } = params ?? {};
118
+ return this._client.get((0, path_1.path) `/v3/calls/${id}/recordings`, {
119
+ ...options,
120
+ headers: (0, headers_1.buildHeaders)([
121
+ { ...(xProfileID != null ? { 'x-profile-id': xProfileID } : undefined) },
122
+ options?.headers,
123
+ ]),
124
+ });
125
+ }
126
+ /**
127
+ * Starts or stops recording one of your live calls. Use start to begin recording
128
+ * mid-call, or stop to end a recording, whether it was started here or by a
129
+ * connect answer with record set. A call that has already ended answers 409, and
130
+ * so does a call with no phone leg, such as one between two app users, which can't
131
+ * be recorded.
132
+ *
133
+ * @example
134
+ * ```ts
135
+ * await client.calls.record(
136
+ * 'call_9f2ab000-0000-4000-8000-000000000001',
137
+ * );
138
+ * ```
139
+ */
140
+ record(id, params, options) {
141
+ const { 'Idempotency-Key': idempotencyKey, 'x-profile-id': xProfileID, ...body } = params;
142
+ return this._client.post((0, path_1.path) `/v3/calls/${id}/recordings`, {
143
+ body,
144
+ ...options,
145
+ headers: (0, headers_1.buildHeaders)([
146
+ {
147
+ Accept: '*/*',
148
+ ...(idempotencyKey != null ? { 'Idempotency-Key': idempotencyKey } : undefined),
149
+ ...(xProfileID != null ? { 'x-profile-id': xProfileID } : undefined),
150
+ },
151
+ options?.headers,
152
+ ]),
153
+ });
154
+ }
155
+ }
156
+ exports.Calls = Calls;
157
+ Calls.Participants = participants_1.Participants;
158
+ //# 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,iBAAY,GAAiC,IAAI,eAAe,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAoJ9F,CAAC;IAlJC;;;;;;;;;;;OAWG;IACH,QAAQ,CACN,EAAU,EACV,SAAgD,EAAE,EAClD,OAAwB;QAExB,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,GAAG,MAAM,IAAI,EAAE,CAAC;QACpD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAA,WAAI,EAAA,aAAa,EAAE,EAAE,EAAE;YAC7C,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC;gBACpB,EAAE,GAAG,CAAC,UAAU,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE;gBACxE,OAAO,EAAE,OAAO;aACjB,CAAC;SACH,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,IAAI,CACF,SAA4C,EAAE,EAC9C,OAAwB;QAExB,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,GAAG,KAAK,EAAE,GAAG,MAAM,IAAI,EAAE,CAAC;QAC9D,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,WAAW,EAAE,CAAA,sBAAe,CAAA,EAAE;YAC3D,KAAK;YACL,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC;gBACp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