@unboundcx/sdk 2.8.3 → 2.8.5

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/base.js CHANGED
@@ -195,6 +195,7 @@ export class BaseSDK {
195
195
  params.headers = headers;
196
196
 
197
197
  // Try transport plugins first
198
+ console.log(`sdk :: request :: forceFetch:${forceFetch} :: endpoint:${endpoint}`);
198
199
  const transport = await this._getAvailableTransport(forceFetch);
199
200
  let response;
200
201
  if (transport) {
@@ -224,6 +225,9 @@ export class BaseSDK {
224
225
  }
225
226
  } else {
226
227
  // No transport available, fallback to HTTP
228
+ if (forceFetch && process.env.AUTH_V3_TOKEN_TYPE_OVERRIDE) {
229
+ params.headers['x-token-type-override'] = process.env.AUTH_V3_TOKEN_TYPE_OVERRIDE;
230
+ }
227
231
  return this._httpRequest(endpoint, method, params, returnRawResponse);
228
232
  }
229
233
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unboundcx/sdk",
3
- "version": "2.8.3",
3
+ "version": "2.8.5",
4
4
  "description": "Official JavaScript SDK for the Unbound API - A comprehensive toolkit for integrating with Unbound's communication, AI, and data management services",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/services/login.js CHANGED
@@ -51,13 +51,14 @@ export class LoginService {
51
51
  return true;
52
52
  }
53
53
 
54
- async validate() {
54
+ async validate(forceFetch = true) {
55
+ console.log('login :: validate :: forceFetch', forceFetch);
55
56
  const options = {};
56
57
  const validation = await this.sdk._fetch(
57
58
  '/login/validate',
58
59
  'POST',
59
60
  options,
60
- true,
61
+ forceFetch,
61
62
  );
62
63
  return validation;
63
64
  }
@@ -410,7 +410,7 @@ export class StorageService {
410
410
  },
411
411
  );
412
412
 
413
- const params = {};
413
+ const params = { returnRawResponse: true };
414
414
  if (download) {
415
415
  params.query = { download: 'true' };
416
416
  }
@@ -420,7 +420,7 @@ export class StorageService {
420
420
  url += `/storage/${path.startsWith('/') ? path.slice(1) : path}`;
421
421
  }
422
422
 
423
- const result = await this.sdk._fetch(url, 'GET', params);
423
+ const result = await this.sdk._fetch(url, 'GET', params, true);
424
424
  return result;
425
425
  }
426
426
 
package/services/video.js CHANGED
@@ -14,15 +14,27 @@ export class VideoService {
14
14
  return result;
15
15
  }
16
16
 
17
- async joinRoom(room, password, email, name, tokenType = 'cookie') {
17
+ async joinRoom(
18
+ room,
19
+ password,
20
+ email,
21
+ name,
22
+ firstName,
23
+ lastName,
24
+ tokenType = 'cookie',
25
+ token,
26
+ ) {
18
27
  this.sdk.validateParams(
19
- { room, password, email, name, tokenType },
28
+ { room, password, email, name, firstName, lastName, tokenType, token },
20
29
  {
21
30
  room: { type: 'string', required: true },
22
31
  password: { type: 'string', required: false },
23
32
  email: { type: 'string', required: false },
24
33
  name: { type: 'string', required: false },
34
+ firstName: { type: 'string', required: false },
35
+ lastName: { type: 'string', required: false },
25
36
  tokenType: { type: 'string', required: true },
37
+ token: { type: 'string', required: false },
26
38
  },
27
39
  );
28
40
 
@@ -32,7 +44,61 @@ export class VideoService {
32
44
  password,
33
45
  email,
34
46
  name,
47
+ firstName,
48
+ lastName,
35
49
  tokenType,
50
+ token,
51
+ },
52
+ };
53
+ const result = await this.sdk._fetch(
54
+ `/video/${room}/join`,
55
+ 'POST',
56
+ params,
57
+ true,
58
+ );
59
+ return result;
60
+ }
61
+
62
+ async joinRoomSip({
63
+ room,
64
+ password,
65
+ phoneNumber,
66
+ engagementSessionId,
67
+ voiceChannelId,
68
+ serverId,
69
+ meetingJoinType = 'outboundApi',
70
+ }) {
71
+ this.sdk.validateParams(
72
+ {
73
+ room,
74
+ password,
75
+ phoneNumber,
76
+ engagementSessionId,
77
+ voiceChannelId,
78
+ serverId,
79
+ meetingJoinType,
80
+ },
81
+ {
82
+ room: { type: 'string', required: true },
83
+ password: { type: 'string', required: false },
84
+ phoneNumber: { type: 'string', required: true },
85
+ engagementSessionId: { type: 'string', required: false },
86
+ voiceChannelId: { type: 'string', required: true },
87
+ serverId: { type: 'string', required: true },
88
+ meetingJoinType: { type: 'string', required: true },
89
+ },
90
+ );
91
+
92
+ const params = {
93
+ body: {
94
+ room,
95
+ password,
96
+ phoneNumber,
97
+ engagementSessionId,
98
+ voiceChannelId,
99
+ serverId,
100
+ meetingJoinType,
101
+ isSip: true,
36
102
  },
37
103
  };
38
104
  const result = await this.sdk._fetch(
@@ -142,6 +208,7 @@ export class VideoService {
142
208
  password,
143
209
  startTime,
144
210
  endTime,
211
+ isAllDay,
145
212
  duration,
146
213
  durationUnit,
147
214
  timezone,
@@ -161,6 +228,7 @@ export class VideoService {
161
228
  password,
162
229
  startTime,
163
230
  endTime,
231
+ isAllDay,
164
232
  duration,
165
233
  durationUnit,
166
234
  timezone,
@@ -179,6 +247,7 @@ export class VideoService {
179
247
  password: { type: 'string', required: false },
180
248
  startTime: { type: 'string', required: false },
181
249
  endTime: { type: 'string', required: false },
250
+ isAllDay: { type: 'boolean', required: false },
182
251
  duration: { type: 'number', required: false },
183
252
  durationUnit: { type: 'string', required: false },
184
253
  timezone: { type: 'string', required: false },
@@ -199,6 +268,7 @@ export class VideoService {
199
268
  password,
200
269
  startTime,
201
270
  endTime,
271
+ isAllDay,
202
272
  duration,
203
273
  durationUnit,
204
274
  timezone,
@@ -308,6 +378,20 @@ export class VideoService {
308
378
  return result;
309
379
  }
310
380
 
381
+ async describe(roomId) {
382
+ this.sdk.validateParams(
383
+ { roomId },
384
+ {
385
+ roomId: { type: 'string', required: true },
386
+ },
387
+ );
388
+
389
+ const params = {};
390
+
391
+ const result = await this.sdk._fetch(`/video/${roomId}`, 'GET', params);
392
+ return result;
393
+ }
394
+
311
395
  async listMeetings(options = {}) {
312
396
  // Validate optional parameters
313
397
  const validationSchema = {};
package/services/voice.js CHANGED
@@ -3,101 +3,48 @@ export class VoiceService {
3
3
  this.sdk = sdk;
4
4
  }
5
5
 
6
- async createCall({
6
+ async call({
7
7
  to,
8
8
  from,
9
- connectionId,
10
- callerId,
9
+ callerIdName,
10
+ callerIdNumber,
11
11
  timeout,
12
- machineDetection,
13
- machineDetectionTimeout,
14
- recordingChannels,
15
- record,
16
- recordingFormat,
17
- recordingTrack,
18
- recordingMaxLength,
19
- transcribe,
20
- transcribeLanguage,
21
- webhookUrl,
22
- commandId,
23
- clientState,
24
- customHeaders,
25
- sipAuthUsername,
26
- sipAuthPassword,
27
- sipTransport,
28
- sipHeaders,
29
- ringTimeout,
30
- answeringMachineDetection,
31
- detectWordOrPhrase,
32
- billingGroupId,
33
- answerUrl,
34
- answerMethod,
12
+ confirmAnswer,
13
+ app,
14
+ variables,
15
+ engagementSessionId,
16
+ voiceChannelId,
17
+ serverId,
35
18
  }) {
36
19
  this.sdk.validateParams(
37
- { to },
20
+ {},
38
21
  {
39
- to: { type: 'string', required: true },
22
+ to: { type: 'string', required: false },
40
23
  from: { type: 'string', required: false },
41
- connectionId: { type: 'string', required: false },
42
- callerId: { type: 'string', required: false },
24
+ callerIdName: { type: 'string', required: false },
25
+ callerIdNumber: { type: 'string', required: false },
43
26
  timeout: { type: 'number', required: false },
44
- machineDetection: { type: 'boolean', required: false },
45
- machineDetectionTimeout: { type: 'number', required: false },
46
- recordingChannels: { type: 'string', required: false },
47
- record: { type: 'boolean', required: false },
48
- recordingFormat: { type: 'string', required: false },
49
- recordingTrack: { type: 'string', required: false },
50
- recordingMaxLength: { type: 'number', required: false },
51
- transcribe: { type: 'boolean', required: false },
52
- transcribeLanguage: { type: 'string', required: false },
53
- webhookUrl: { type: 'string', required: false },
54
- commandId: { type: 'string', required: false },
55
- clientState: { type: 'string', required: false },
56
- customHeaders: { type: 'array', required: false },
57
- sipAuthUsername: { type: 'string', required: false },
58
- sipAuthPassword: { type: 'string', required: false },
59
- sipTransport: { type: 'string', required: false },
60
- sipHeaders: { type: 'array', required: false },
61
- ringTimeout: { type: 'number', required: false },
62
- answeringMachineDetection: { type: 'string', required: false },
63
- detectWordOrPhrase: { type: 'string', required: false },
64
- billingGroupId: { type: 'string', required: false },
65
- answerUrl: { type: 'string', required: false },
66
- answerMethod: { type: 'string', required: false },
27
+ confirmAnswer: { type: 'boolean', required: false },
28
+ app: { type: 'object', required: false },
29
+ variables: { type: 'object', required: false },
30
+ engagementSessionId: { type: 'string', required: false },
31
+ voiceChannelId: { type: 'string', required: false },
32
+ serverId: { type: 'string', required: false },
67
33
  },
68
34
  );
69
35
 
70
- const callData = { to };
36
+ const callData = {};
37
+ if (to) callData.to = to;
71
38
  if (from) callData.from = from;
72
- if (connectionId) callData.connectionId = connectionId;
73
- if (callerId) callData.callerId = callerId;
74
- if (timeout) callData.timeout = timeout;
75
- if (machineDetection !== undefined)
76
- callData.machineDetection = machineDetection;
77
- if (machineDetectionTimeout)
78
- callData.machineDetectionTimeout = machineDetectionTimeout;
79
- if (recordingChannels) callData.recordingChannels = recordingChannels;
80
- if (record !== undefined) callData.record = record;
81
- if (recordingFormat) callData.recordingFormat = recordingFormat;
82
- if (recordingTrack) callData.recordingTrack = recordingTrack;
83
- if (recordingMaxLength) callData.recordingMaxLength = recordingMaxLength;
84
- if (transcribe !== undefined) callData.transcribe = transcribe;
85
- if (transcribeLanguage) callData.transcribeLanguage = transcribeLanguage;
86
- if (webhookUrl) callData.webhookUrl = webhookUrl;
87
- if (commandId) callData.commandId = commandId;
88
- if (clientState) callData.clientState = clientState;
89
- if (customHeaders) callData.customHeaders = customHeaders;
90
- if (sipAuthUsername) callData.sipAuthUsername = sipAuthUsername;
91
- if (sipAuthPassword) callData.sipAuthPassword = sipAuthPassword;
92
- if (sipTransport) callData.sipTransport = sipTransport;
93
- if (sipHeaders) callData.sipHeaders = sipHeaders;
94
- if (ringTimeout) callData.ringTimeout = ringTimeout;
95
- if (answeringMachineDetection)
96
- callData.answeringMachineDetection = answeringMachineDetection;
97
- if (detectWordOrPhrase) callData.detectWordOrPhrase = detectWordOrPhrase;
98
- if (billingGroupId) callData.billingGroupId = billingGroupId;
99
- if (answerUrl) callData.answerUrl = answerUrl;
100
- if (answerMethod) callData.answerMethod = answerMethod;
39
+ if (callerIdName) callData.callerIdName = callerIdName;
40
+ if (callerIdNumber) callData.callerIdNumber = callerIdNumber;
41
+ if (timeout !== undefined) callData.timeout = timeout;
42
+ if (confirmAnswer !== undefined) callData.confirmAnswer = confirmAnswer;
43
+ if (app) callData.app = app;
44
+ if (variables) callData.variables = variables;
45
+ if (engagementSessionId) callData.engagementSessionId = engagementSessionId;
46
+ if (voiceChannelId) callData.voiceChannelId = voiceChannelId;
47
+ if (serverId) callData.serverId = serverId;
101
48
 
102
49
  const params = {
103
50
  body: callData,
@@ -107,462 +54,209 @@ export class VoiceService {
107
54
  return result;
108
55
  }
109
56
 
110
- async hangup(callControlId, clientState, commandId) {
57
+ async hangup(voiceChannelId) {
111
58
  this.sdk.validateParams(
112
- { callControlId },
59
+ { voiceChannelId },
113
60
  {
114
- callControlId: { type: 'string', required: true },
115
- clientState: { type: 'string', required: false },
116
- commandId: { type: 'string', required: false },
61
+ voiceChannelId: { type: 'string', required: true },
117
62
  },
118
63
  );
119
64
 
120
- const hangupData = {};
121
- if (clientState) hangupData.clientState = clientState;
122
- if (commandId) hangupData.commandId = commandId;
123
-
124
- const params = {
125
- body: hangupData,
126
- };
127
-
128
65
  const result = await this.sdk._fetch(
129
- `/voice/calls/${callControlId}/actions/hangup`,
130
- 'POST',
131
- params,
66
+ `/voice/calls/${voiceChannelId}`,
67
+ 'DELETE',
132
68
  );
133
69
  return result;
134
70
  }
135
71
 
136
- async hold(callControlId, audioUrl, clientState, commandId) {
72
+ async hold(channels) {
137
73
  this.sdk.validateParams(
138
- { callControlId },
74
+ { channels },
139
75
  {
140
- callControlId: { type: 'string', required: true },
141
- audioUrl: { type: 'string', required: false },
142
- clientState: { type: 'string', required: false },
143
- commandId: { type: 'string', required: false },
76
+ channels: { type: 'array', required: true },
144
77
  },
145
78
  );
146
79
 
147
- const holdData = {};
148
- if (audioUrl) holdData.audioUrl = audioUrl;
149
- if (clientState) holdData.clientState = clientState;
150
- if (commandId) holdData.commandId = commandId;
151
-
152
80
  const params = {
153
- body: holdData,
81
+ body: { channels },
154
82
  };
155
83
 
156
- const result = await this.sdk._fetch(
157
- `/voice/calls/${callControlId}/actions/hold`,
158
- 'POST',
159
- params,
160
- );
84
+ const result = await this.sdk._fetch('/voice/calls/hold', 'PUT', params);
161
85
  return result;
162
86
  }
163
87
 
164
- async unhold(callControlId, clientState, commandId) {
88
+ async mute(voiceChannelId, action = 'mute', direction = 'in') {
165
89
  this.sdk.validateParams(
166
- { callControlId },
90
+ { voiceChannelId },
167
91
  {
168
- callControlId: { type: 'string', required: true },
169
- clientState: { type: 'string', required: false },
170
- commandId: { type: 'string', required: false },
92
+ voiceChannelId: { type: 'string', required: true },
93
+ action: { type: 'string', required: false },
94
+ direction: { type: 'string', required: false },
171
95
  },
172
96
  );
173
97
 
174
- const unholdData = {};
175
- if (clientState) unholdData.clientState = clientState;
176
- if (commandId) unholdData.commandId = commandId;
177
-
178
98
  const params = {
179
- body: unholdData,
99
+ body: { action, direction },
180
100
  };
181
101
 
182
102
  const result = await this.sdk._fetch(
183
- `/voice/calls/${callControlId}/actions/unhold`,
184
- 'POST',
103
+ `/voice/calls/mute/${voiceChannelId}`,
104
+ 'PUT',
185
105
  params,
186
106
  );
187
107
  return result;
188
108
  }
189
109
 
190
- async mute(callControlId, clientState, commandId) {
191
- this.sdk.validateParams(
192
- { callControlId },
193
- {
194
- callControlId: { type: 'string', required: true },
195
- clientState: { type: 'string', required: false },
196
- commandId: { type: 'string', required: false },
197
- },
198
- );
199
-
200
- const muteData = {};
201
- if (clientState) muteData.clientState = clientState;
202
- if (commandId) muteData.commandId = commandId;
203
-
204
- const params = {
205
- body: muteData,
206
- };
207
-
208
- const result = await this.sdk._fetch(
209
- `/voice/calls/${callControlId}/actions/mute`,
210
- 'POST',
211
- params,
212
- );
213
- return result;
110
+ async unmute(voiceChannelId, direction = 'in') {
111
+ return this.mute(voiceChannelId, 'unmute', direction);
214
112
  }
215
113
 
216
- async unmute(callControlId, clientState, commandId) {
114
+ async sendDtmf(voiceChannelId, dtmf) {
217
115
  this.sdk.validateParams(
218
- { callControlId },
116
+ { voiceChannelId, dtmf },
219
117
  {
220
- callControlId: { type: 'string', required: true },
221
- clientState: { type: 'string', required: false },
222
- commandId: { type: 'string', required: false },
223
- },
224
- );
225
-
226
- const unmuteData = {};
227
- if (clientState) unmuteData.clientState = clientState;
228
- if (commandId) unmuteData.commandId = commandId;
229
-
230
- const params = {
231
- body: unmuteData,
232
- };
233
-
234
- const result = await this.sdk._fetch(
235
- `/voice/calls/${callControlId}/actions/unmute`,
236
- 'POST',
237
- params,
238
- );
239
- return result;
240
- }
241
-
242
- async sendDtmf(callControlId, dtmf, clientState, commandId) {
243
- this.sdk.validateParams(
244
- { callControlId, dtmf },
245
- {
246
- callControlId: { type: 'string', required: true },
118
+ voiceChannelId: { type: 'string', required: true },
247
119
  dtmf: { type: 'string', required: true },
248
- clientState: { type: 'string', required: false },
249
- commandId: { type: 'string', required: false },
250
120
  },
251
121
  );
252
122
 
253
- const dtmfData = { dtmf };
254
- if (clientState) dtmfData.clientState = clientState;
255
- if (commandId) dtmfData.commandId = commandId;
256
-
257
123
  const params = {
258
- body: dtmfData,
124
+ body: { dtmf },
259
125
  };
260
126
 
261
127
  const result = await this.sdk._fetch(
262
- `/voice/calls/${callControlId}/actions/send_dtmf`,
128
+ `/voice/calls/dtmf/${voiceChannelId}`,
263
129
  'POST',
264
130
  params,
265
131
  );
266
132
  return result;
267
133
  }
268
134
 
269
- async record(
270
- callControlId,
271
- recordingChannels,
272
- recordingFormat,
273
- recordingMaxLength,
274
- recordingTerminators,
275
- recordingBeep,
276
- recordingPlayBeep,
277
- clientState,
278
- commandId,
279
- ) {
135
+ async record(voiceChannelId, action = 'start', direction = 'both') {
280
136
  this.sdk.validateParams(
281
- { callControlId },
137
+ { voiceChannelId },
282
138
  {
283
- callControlId: { type: 'string', required: true },
284
- recordingChannels: { type: 'string', required: false },
285
- recordingFormat: { type: 'string', required: false },
286
- recordingMaxLength: { type: 'number', required: false },
287
- recordingTerminators: { type: 'string', required: false },
288
- recordingBeep: { type: 'boolean', required: false },
289
- recordingPlayBeep: { type: 'boolean', required: false },
290
- clientState: { type: 'string', required: false },
291
- commandId: { type: 'string', required: false },
139
+ voiceChannelId: { type: 'string', required: true },
140
+ action: { type: 'string', required: false },
141
+ direction: { type: 'string', required: false },
292
142
  },
293
143
  );
294
144
 
295
- const recordData = {};
296
- if (recordingChannels) recordData.recordingChannels = recordingChannels;
297
- if (recordingFormat) recordData.recordingFormat = recordingFormat;
298
- if (recordingMaxLength) recordData.recordingMaxLength = recordingMaxLength;
299
- if (recordingTerminators)
300
- recordData.recordingTerminators = recordingTerminators;
301
- if (recordingBeep !== undefined) recordData.recordingBeep = recordingBeep;
302
- if (recordingPlayBeep !== undefined)
303
- recordData.recordingPlayBeep = recordingPlayBeep;
304
- if (clientState) recordData.clientState = clientState;
305
- if (commandId) recordData.commandId = commandId;
306
-
307
145
  const params = {
308
- body: recordData,
146
+ body: { action, direction },
309
147
  };
310
148
 
311
149
  const result = await this.sdk._fetch(
312
- `/voice/calls/${callControlId}/actions/record_start`,
150
+ `/voice/calls/record/${voiceChannelId}`,
313
151
  'POST',
314
152
  params,
315
153
  );
316
154
  return result;
317
155
  }
318
156
 
319
- async stopRecording(callControlId, clientState, commandId) {
320
- this.sdk.validateParams(
321
- { callControlId },
322
- {
323
- callControlId: { type: 'string', required: true },
324
- clientState: { type: 'string', required: false },
325
- commandId: { type: 'string', required: false },
326
- },
327
- );
328
-
329
- const stopData = {};
330
- if (clientState) stopData.clientState = clientState;
331
- if (commandId) stopData.commandId = commandId;
157
+ async stopRecording(voiceChannelId, direction = 'both') {
158
+ return this.record(voiceChannelId, 'stop', direction);
159
+ }
332
160
 
333
- const params = {
334
- body: stopData,
335
- };
161
+ async pauseRecording(voiceChannelId, direction = 'both') {
162
+ return this.record(voiceChannelId, 'pause', direction);
163
+ }
336
164
 
337
- const result = await this.sdk._fetch(
338
- `/voice/calls/${callControlId}/actions/record_stop`,
339
- 'POST',
340
- params,
341
- );
342
- return result;
165
+ async resumeRecording(voiceChannelId, direction = 'both') {
166
+ return this.record(voiceChannelId, 'resume', direction);
343
167
  }
344
168
 
345
169
  async transcribe(
346
- callControlId,
347
- transcriptionEngine,
348
- transcriptionLanguage,
349
- transcriptionFormat,
350
- clientState,
351
- commandId,
170
+ voiceChannelId,
171
+ action = 'start',
172
+ direction = 'in',
173
+ forwardText,
174
+ forwardRtp,
352
175
  ) {
353
176
  this.sdk.validateParams(
354
- { callControlId },
177
+ { voiceChannelId },
355
178
  {
356
- callControlId: { type: 'string', required: true },
357
- transcriptionEngine: { type: 'string', required: false },
358
- transcriptionLanguage: { type: 'string', required: false },
359
- transcriptionFormat: { type: 'string', required: false },
360
- clientState: { type: 'string', required: false },
361
- commandId: { type: 'string', required: false },
179
+ voiceChannelId: { type: 'string', required: true },
180
+ action: { type: 'string', required: false },
181
+ direction: { type: 'string', required: false },
182
+ forwardText: { type: 'object', required: false },
183
+ forwardRtp: { type: 'object', required: false },
362
184
  },
363
185
  );
364
186
 
365
- const transcribeData = {};
366
- if (transcriptionEngine)
367
- transcribeData.transcriptionEngine = transcriptionEngine;
368
- if (transcriptionLanguage)
369
- transcribeData.transcriptionLanguage = transcriptionLanguage;
370
- if (transcriptionFormat)
371
- transcribeData.transcriptionFormat = transcriptionFormat;
372
- if (clientState) transcribeData.clientState = clientState;
373
- if (commandId) transcribeData.commandId = commandId;
187
+ const bodyData = { action, direction };
188
+ if (forwardText) bodyData.forwardText = forwardText;
189
+ if (forwardRtp) bodyData.forwardRtp = forwardRtp;
374
190
 
375
191
  const params = {
376
- body: transcribeData,
192
+ body: bodyData,
377
193
  };
378
194
 
379
195
  const result = await this.sdk._fetch(
380
- `/voice/calls/${callControlId}/actions/transcription_start`,
196
+ `/voice/calls/transcribe/${voiceChannelId}`,
381
197
  'POST',
382
198
  params,
383
199
  );
384
200
  return result;
385
201
  }
386
202
 
387
- async stopTranscribing(callControlId, clientState, commandId) {
388
- this.sdk.validateParams(
389
- { callControlId },
390
- {
391
- callControlId: { type: 'string', required: true },
392
- clientState: { type: 'string', required: false },
393
- commandId: { type: 'string', required: false },
394
- },
395
- );
396
-
397
- const stopData = {};
398
- if (clientState) stopData.clientState = clientState;
399
- if (commandId) stopData.commandId = commandId;
400
-
401
- const params = {
402
- body: stopData,
403
- };
404
-
405
- const result = await this.sdk._fetch(
406
- `/voice/calls/${callControlId}/actions/transcription_stop`,
407
- 'POST',
408
- params,
409
- );
410
- return result;
203
+ async stopTranscribing(voiceChannelId, direction = 'in') {
204
+ return this.transcribe(voiceChannelId, 'stop', direction);
411
205
  }
412
206
 
413
- async transfer(
414
- callControlId,
207
+ async transfer({
208
+ channels,
415
209
  to,
416
- from,
417
- answerUrl,
418
- answerMethod,
419
- clientState,
420
- commandId,
421
- ) {
422
- this.sdk.validateParams(
423
- { callControlId, to },
424
- {
425
- callControlId: { type: 'string', required: true },
426
- to: { type: 'string', required: true },
427
- from: { type: 'string', required: false },
428
- answerUrl: { type: 'string', required: false },
429
- answerMethod: { type: 'string', required: false },
430
- clientState: { type: 'string', required: false },
431
- commandId: { type: 'string', required: false },
432
- },
433
- );
434
-
435
- const transferData = { to };
436
- if (from) transferData.from = from;
437
- if (answerUrl) transferData.answerUrl = answerUrl;
438
- if (answerMethod) transferData.answerMethod = answerMethod;
439
- if (clientState) transferData.clientState = clientState;
440
- if (commandId) transferData.commandId = commandId;
441
-
442
- const params = {
443
- body: transferData,
444
- };
445
-
446
- const result = await this.sdk._fetch(
447
- `/voice/calls/${callControlId}/actions/transfer`,
448
- 'POST',
449
- params,
450
- );
451
- return result;
452
- }
453
-
454
- async createConference({
455
- name,
456
- recordingChannels,
457
- recordingFormat,
458
- recordingMaxLength,
459
- recordingTerminators,
460
- webhookUrl,
461
- commandId,
462
- clientState,
210
+ callerIdName,
211
+ callerIdNumber,
212
+ timeout,
213
+ voiceApp,
463
214
  }) {
464
215
  this.sdk.validateParams(
465
- { name },
216
+ { channels },
466
217
  {
467
- name: { type: 'string', required: true },
468
- recordingChannels: { type: 'string', required: false },
469
- recordingFormat: { type: 'string', required: false },
470
- recordingMaxLength: { type: 'number', required: false },
471
- recordingTerminators: { type: 'string', required: false },
472
- webhookUrl: { type: 'string', required: false },
473
- commandId: { type: 'string', required: false },
474
- clientState: { type: 'string', required: false },
475
- },
476
- );
477
-
478
- const conferenceData = { name };
479
- if (recordingChannels) conferenceData.recordingChannels = recordingChannels;
480
- if (recordingFormat) conferenceData.recordingFormat = recordingFormat;
481
- if (recordingMaxLength)
482
- conferenceData.recordingMaxLength = recordingMaxLength;
483
- if (recordingTerminators)
484
- conferenceData.recordingTerminators = recordingTerminators;
485
- if (webhookUrl) conferenceData.webhookUrl = webhookUrl;
486
- if (commandId) conferenceData.commandId = commandId;
487
- if (clientState) conferenceData.clientState = clientState;
488
-
489
- const params = {
490
- body: conferenceData,
491
- };
492
-
493
- const result = await this.sdk._fetch('/voice/conferences', 'POST', params);
494
- return result;
495
- }
496
-
497
- async joinConference(
498
- callControlId,
499
- conferenceId,
500
- startConferenceOnEnter,
501
- endConferenceOnExit,
502
- muted,
503
- hold,
504
- holdAudioUrl,
505
- clientState,
506
- commandId,
507
- ) {
508
- this.sdk.validateParams(
509
- { callControlId, conferenceId },
510
- {
511
- callControlId: { type: 'string', required: true },
512
- conferenceId: { type: 'string', required: true },
513
- startConferenceOnEnter: { type: 'boolean', required: false },
514
- endConferenceOnExit: { type: 'boolean', required: false },
515
- muted: { type: 'boolean', required: false },
516
- hold: { type: 'boolean', required: false },
517
- holdAudioUrl: { type: 'string', required: false },
518
- clientState: { type: 'string', required: false },
519
- commandId: { type: 'string', required: false },
218
+ channels: { type: 'array', required: true },
219
+ to: { type: 'string', required: false },
220
+ callerIdName: { type: 'string', required: false },
221
+ callerIdNumber: { type: 'string', required: false },
222
+ timeout: { type: 'number', required: false },
223
+ voiceApp: { type: 'object', required: false },
520
224
  },
521
225
  );
522
226
 
523
- const joinData = { conferenceId };
524
- if (startConferenceOnEnter !== undefined)
525
- joinData.startConferenceOnEnter = startConferenceOnEnter;
526
- if (endConferenceOnExit !== undefined)
527
- joinData.endConferenceOnExit = endConferenceOnExit;
528
- if (muted !== undefined) joinData.muted = muted;
529
- if (hold !== undefined) joinData.hold = hold;
530
- if (holdAudioUrl) joinData.holdAudioUrl = holdAudioUrl;
531
- if (clientState) joinData.clientState = clientState;
532
- if (commandId) joinData.commandId = commandId;
227
+ const bodyData = { channels };
228
+ if (to) bodyData.to = to;
229
+ if (callerIdName) bodyData.callerIdName = callerIdName;
230
+ if (callerIdNumber) bodyData.callerIdNumber = callerIdNumber;
231
+ if (timeout !== undefined) bodyData.timeout = timeout;
232
+ if (voiceApp) bodyData.voiceApp = voiceApp;
533
233
 
534
234
  const params = {
535
- body: joinData,
235
+ body: bodyData,
536
236
  };
537
237
 
538
238
  const result = await this.sdk._fetch(
539
- `/voice/calls/${callControlId}/actions/conference_join`,
239
+ '/voice/calls/transfer',
540
240
  'POST',
541
241
  params,
542
242
  );
543
243
  return result;
544
244
  }
545
245
 
546
- async leaveConference(callControlId, clientState, commandId) {
246
+ async conference(channels) {
547
247
  this.sdk.validateParams(
548
- { callControlId },
248
+ { channels },
549
249
  {
550
- callControlId: { type: 'string', required: true },
551
- clientState: { type: 'string', required: false },
552
- commandId: { type: 'string', required: false },
250
+ channels: { type: 'array', required: true },
553
251
  },
554
252
  );
555
253
 
556
- const leaveData = {};
557
- if (clientState) leaveData.clientState = clientState;
558
- if (commandId) leaveData.commandId = commandId;
559
-
560
254
  const params = {
561
- body: leaveData,
255
+ body: { channels },
562
256
  };
563
257
 
564
258
  const result = await this.sdk._fetch(
565
- `/voice/calls/${callControlId}/actions/conference_leave`,
259
+ '/voice/calls/conference',
566
260
  'POST',
567
261
  params,
568
262
  );