@unboundcx/sdk 2.8.2 → 2.8.4

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.2",
3
+ "version": "2.8.4",
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
@@ -28,6 +28,7 @@ export class VideoService {
28
28
 
29
29
  const params = {
30
30
  body: {
31
+ room,
31
32
  password,
32
33
  email,
33
34
  name,
@@ -43,6 +44,56 @@ export class VideoService {
43
44
  return result;
44
45
  }
45
46
 
47
+ async joinRoomSip({
48
+ room,
49
+ password,
50
+ phoneNumber,
51
+ engagementSessionId,
52
+ voiceChannelId,
53
+ serverId,
54
+ meetingJoinType = 'outboundApi',
55
+ }) {
56
+ this.sdk.validateParams(
57
+ {
58
+ room,
59
+ password,
60
+ phoneNumber,
61
+ engagementSessionId,
62
+ voiceChannelId,
63
+ serverId,
64
+ meetingJoinType,
65
+ },
66
+ {
67
+ room: { type: 'string', required: true },
68
+ password: { type: 'string', required: false },
69
+ phoneNumber: { type: 'string', required: true },
70
+ engagementSessionId: { type: 'string', required: false },
71
+ voiceChannelId: { type: 'string', required: true },
72
+ serverId: { type: 'string', required: true },
73
+ meetingJoinType: { type: 'string', required: true },
74
+ },
75
+ );
76
+
77
+ const params = {
78
+ body: {
79
+ room,
80
+ password,
81
+ phoneNumber,
82
+ engagementSessionId,
83
+ voiceChannelId,
84
+ serverId,
85
+ meetingJoinType,
86
+ isSip: true,
87
+ },
88
+ };
89
+ const result = await this.sdk._fetch(
90
+ `/video/${room}/join`,
91
+ 'POST',
92
+ params,
93
+ true,
94
+ );
95
+ return result;
96
+ }
46
97
  async updateParticipant(roomId, participantId, update) {
47
98
  this.sdk.validateParams(
48
99
  { roomId, participantId, update },
@@ -141,6 +192,7 @@ export class VideoService {
141
192
  password,
142
193
  startTime,
143
194
  endTime,
195
+ isAllDay,
144
196
  duration,
145
197
  durationUnit,
146
198
  timezone,
@@ -151,6 +203,7 @@ export class VideoService {
151
203
  startCameraMutedAfter,
152
204
  startMicrophoneMuted,
153
205
  startMicrophoneMutedAfter,
206
+ enableChat,
154
207
  engagementSessionId,
155
208
  }) {
156
209
  this.sdk.validateParams(
@@ -159,6 +212,7 @@ export class VideoService {
159
212
  password,
160
213
  startTime,
161
214
  endTime,
215
+ isAllDay,
162
216
  duration,
163
217
  durationUnit,
164
218
  timezone,
@@ -169,6 +223,7 @@ export class VideoService {
169
223
  startCameraMutedAfter,
170
224
  startMicrophoneMuted,
171
225
  startMicrophoneMutedAfter,
226
+ enableChat,
172
227
  engagementSessionId,
173
228
  },
174
229
  {
@@ -176,6 +231,7 @@ export class VideoService {
176
231
  password: { type: 'string', required: false },
177
232
  startTime: { type: 'string', required: false },
178
233
  endTime: { type: 'string', required: false },
234
+ isAllDay: { type: 'boolean', required: false },
179
235
  duration: { type: 'number', required: false },
180
236
  durationUnit: { type: 'string', required: false },
181
237
  timezone: { type: 'string', required: false },
@@ -186,6 +242,7 @@ export class VideoService {
186
242
  startCameraMutedAfter: { type: 'number', required: false },
187
243
  startMicrophoneMuted: { type: 'boolean', required: false },
188
244
  startMicrophoneMutedAfter: { type: 'number', required: false },
245
+ enableChat: { type: 'boolean', required: false },
189
246
  engagementSessionId: { type: 'string', required: false },
190
247
  },
191
248
  );
@@ -195,6 +252,7 @@ export class VideoService {
195
252
  password,
196
253
  startTime,
197
254
  endTime,
255
+ isAllDay,
198
256
  duration,
199
257
  durationUnit,
200
258
  timezone,
@@ -205,6 +263,7 @@ export class VideoService {
205
263
  startCameraMutedAfter,
206
264
  startMicrophoneMuted,
207
265
  startMicrophoneMutedAfter,
266
+ enableChat,
208
267
  engagementSessionId,
209
268
  },
210
269
  };
@@ -241,6 +300,8 @@ export class VideoService {
241
300
  validationSchema.startMicrophoneMuted = { type: 'boolean' };
242
301
  if ('startMicrophoneMutedAfter' in update)
243
302
  validationSchema.startMicrophoneMutedAfter = { type: 'number' };
303
+ if ('enableChat' in update)
304
+ validationSchema.enableChat = { type: 'boolean' };
244
305
 
245
306
  if (Object.keys(validationSchema).length > 0) {
246
307
  this.sdk.validateParams(update, validationSchema);
@@ -255,6 +316,28 @@ export class VideoService {
255
316
  return result;
256
317
  }
257
318
 
319
+ async updateRoomBot(roomId, { isRecording, isTranscribing }) {
320
+ this.sdk.validateParams(
321
+ { roomId, isRecording, isTranscribing },
322
+ {
323
+ roomId: { type: 'string', required: true },
324
+ isRecording: { type: 'boolean', required: false },
325
+ isTranscribing: { type: 'boolean', required: false },
326
+ },
327
+ );
328
+ const update = {
329
+ isRecording,
330
+ isTranscribing,
331
+ };
332
+ const params = {
333
+ body: {
334
+ ...update,
335
+ },
336
+ };
337
+ const result = await this.sdk._fetch(`/video/${roomId}/bot`, 'PUT', params);
338
+ return result;
339
+ }
340
+
258
341
  async placeCall(roomId, phoneNumber, callerIdNumber) {
259
342
  this.sdk.validateParams(
260
343
  { roomId, phoneNumber, callerIdNumber },
@@ -472,4 +555,149 @@ export class VideoService {
472
555
  const result = await this.sdk._fetch('/video/survey', 'POST', params);
473
556
  return result;
474
557
  }
558
+
559
+ /**
560
+ * Post a chat message to a video room
561
+ * @param {string} roomId - The video room ID
562
+ * @param {Array} content - Message content as JSON array (TipTap format)
563
+ * @param {string} [storageId] - Optional storage ID for attachments
564
+ * @returns {Promise} Created feed message
565
+ */
566
+ async postChatMessage(roomId, content, storageId = null) {
567
+ this.sdk.validateParams(
568
+ { roomId, content },
569
+ {
570
+ roomId: { type: 'string', required: true },
571
+ content: { type: 'array', required: true },
572
+ },
573
+ );
574
+
575
+ const body = {
576
+ content,
577
+ };
578
+
579
+ if (storageId) {
580
+ body.storageId = storageId;
581
+ }
582
+
583
+ const params = { body };
584
+
585
+ const result = await this.sdk._fetch(
586
+ `/video/${roomId}/chat`,
587
+ 'POST',
588
+ params,
589
+ );
590
+ return result;
591
+ }
592
+
593
+ /**
594
+ * Get chat messages from a video room
595
+ * @param {string} roomId - The video room ID
596
+ * @param {Object} [options={}] - Query options
597
+ * @param {string} [options.select] - Fields to select
598
+ * @param {number} [options.limit] - Limit number of results
599
+ * @param {string} [options.nextId] - Cursor for next page
600
+ * @param {string} [options.previousId] - Cursor for previous page
601
+ * @param {string} [options.orderByDirection] - 'ASC' or 'DESC'
602
+ * @param {boolean} [options.expandDetails] - Whether to expand details
603
+ * @returns {Promise} Chat messages with participant info
604
+ */
605
+ async getChatMessages(roomId, options = {}) {
606
+ this.sdk.validateParams(
607
+ { roomId },
608
+ {
609
+ roomId: { type: 'string', required: true },
610
+ },
611
+ );
612
+
613
+ // Validate optional parameters
614
+ const validationSchema = {};
615
+ if ('select' in options) validationSchema.select = { type: 'string' };
616
+ if ('limit' in options) validationSchema.limit = { type: 'number' };
617
+ if ('nextId' in options) validationSchema.nextId = { type: 'string' };
618
+ if ('previousId' in options)
619
+ validationSchema.previousId = { type: 'string' };
620
+ if ('orderByDirection' in options)
621
+ validationSchema.orderByDirection = { type: 'string' };
622
+ if ('expandDetails' in options)
623
+ validationSchema.expandDetails = { type: 'boolean' };
624
+
625
+ if (Object.keys(validationSchema).length > 0) {
626
+ this.sdk.validateParams(options, validationSchema);
627
+ }
628
+
629
+ const params = {
630
+ query: options,
631
+ };
632
+
633
+ const result = await this.sdk._fetch(
634
+ `/video/${roomId}/chat`,
635
+ 'GET',
636
+ params,
637
+ );
638
+ return result;
639
+ }
640
+
641
+ /**
642
+ * Edit a chat message in a video room
643
+ * Only the participant who created the message can edit it
644
+ * @param {string} roomId - The video room ID
645
+ * @param {string} messageId - The message ID to edit
646
+ * @param {Array} content - Updated message content as JSON array (TipTap format)
647
+ * @param {string} [storageId] - Optional storage ID for attachments
648
+ * @returns {Promise} Updated feed message
649
+ */
650
+ async editChatMessage(roomId, messageId, content, storageId = null) {
651
+ this.sdk.validateParams(
652
+ { roomId, messageId, content },
653
+ {
654
+ roomId: { type: 'string', required: true },
655
+ messageId: { type: 'string', required: true },
656
+ content: { type: 'array', required: true },
657
+ },
658
+ );
659
+
660
+ const body = {
661
+ content,
662
+ };
663
+
664
+ if (storageId) {
665
+ body.storageId = storageId;
666
+ }
667
+
668
+ const params = { body };
669
+
670
+ const result = await this.sdk._fetch(
671
+ `/video/${roomId}/chat/${messageId}`,
672
+ 'PUT',
673
+ params,
674
+ );
675
+ return result;
676
+ }
677
+
678
+ /**
679
+ * Delete a chat message from a video room
680
+ * Hosts can delete any message, participants can only delete their own
681
+ * @param {string} roomId - The video room ID
682
+ * @param {string} messageId - The message ID to delete
683
+ * @returns {Promise} Deletion result
684
+ */
685
+ async deleteChatMessage(roomId, messageId) {
686
+ this.sdk.validateParams(
687
+ { roomId, messageId },
688
+ {
689
+ roomId: { type: 'string', required: true },
690
+ messageId: { type: 'string', required: true },
691
+ },
692
+ );
693
+
694
+ const params = {};
695
+
696
+ const result = await this.sdk._fetch(
697
+ `/video/${roomId}/chat/${messageId}`,
698
+ 'DELETE',
699
+ params,
700
+ );
701
+ return result;
702
+ }
475
703
  }
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
  );