@unboundcx/sdk 4.13.54 → 4.13.56
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unboundcx/sdk",
|
|
3
|
-
"version": "4.13.
|
|
3
|
+
"version": "4.13.56",
|
|
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",
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { internalRequest } from '../../base.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Offer Service - accept/decline a direct offer (transfer/invite/help) routed to a user
|
|
5
|
+
*/
|
|
6
|
+
export class OfferService {
|
|
7
|
+
constructor(sdk) {
|
|
8
|
+
this.sdk = sdk;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Accept a pending direct offer.
|
|
13
|
+
* Creates/reuses the caller's worker session as needed and assigns the task to them.
|
|
14
|
+
*
|
|
15
|
+
* @param {Object} options - Options
|
|
16
|
+
* @param {string} options.offerId - Offer ID
|
|
17
|
+
* @returns {Promise<Object>} { taskId, workerId, isVoice }
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* const result = await sdk.taskRouter.offer.accept({ offerId: 'offer_123' });
|
|
21
|
+
*/
|
|
22
|
+
async accept({ offerId }) {
|
|
23
|
+
this.sdk.validateParams(
|
|
24
|
+
{ offerId },
|
|
25
|
+
{
|
|
26
|
+
offerId: { type: 'string', required: true },
|
|
27
|
+
},
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
const params = {
|
|
31
|
+
body: { offerId },
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const result = await internalRequest(this.sdk,
|
|
35
|
+
'/taskRouter/offers/accept',
|
|
36
|
+
'PUT',
|
|
37
|
+
params,
|
|
38
|
+
);
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Decline a pending direct offer.
|
|
44
|
+
*
|
|
45
|
+
* @param {Object} options - Options
|
|
46
|
+
* @param {string} options.offerId - Offer ID
|
|
47
|
+
* @returns {Promise<Object>} { offerId }
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* const result = await sdk.taskRouter.offer.decline({ offerId: 'offer_123' });
|
|
51
|
+
*/
|
|
52
|
+
async decline({ offerId }) {
|
|
53
|
+
this.sdk.validateParams(
|
|
54
|
+
{ offerId },
|
|
55
|
+
{
|
|
56
|
+
offerId: { type: 'string', required: true },
|
|
57
|
+
},
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
const params = {
|
|
61
|
+
body: { offerId },
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const result = await internalRequest(this.sdk,
|
|
65
|
+
'/taskRouter/offers/decline',
|
|
66
|
+
'PUT',
|
|
67
|
+
params,
|
|
68
|
+
);
|
|
69
|
+
return result;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -2,6 +2,7 @@ import { WorkerService } from './WorkerService.js';
|
|
|
2
2
|
import { TaskService } from './TaskService.js';
|
|
3
3
|
import { MetricsService } from './MetricsService.js';
|
|
4
4
|
import { CCService } from './CCService.js';
|
|
5
|
+
import { OfferService } from './OfferService.js';
|
|
5
6
|
|
|
6
7
|
export class TaskRouterService {
|
|
7
8
|
constructor(sdk) {
|
|
@@ -10,5 +11,6 @@ export class TaskRouterService {
|
|
|
10
11
|
this.task = new TaskService(sdk);
|
|
11
12
|
this.metrics = new MetricsService(sdk);
|
|
12
13
|
this.cc = new CCService(sdk);
|
|
14
|
+
this.offer = new OfferService(sdk);
|
|
13
15
|
}
|
|
14
16
|
}
|
|
@@ -1066,38 +1066,32 @@ export class TaskService {
|
|
|
1066
1066
|
}
|
|
1067
1067
|
|
|
1068
1068
|
/**
|
|
1069
|
-
* Transfer a task to a different queue and/or worker.
|
|
1070
|
-
* in the target queue and re-points live channels to
|
|
1071
|
-
* completed
|
|
1072
|
-
*
|
|
1069
|
+
* Transfer a task to a different queue and/or worker. Every transfer
|
|
1070
|
+
* creates a new task in the target queue and re-points live channels to
|
|
1071
|
+
* it; the old task is completed with the target queue's transfer
|
|
1072
|
+
* disposition.
|
|
1073
1073
|
*
|
|
1074
1074
|
* @param {Object} options - Parameters
|
|
1075
1075
|
* @param {string} options.taskId - The task ID to transfer (required)
|
|
1076
|
-
* @param {
|
|
1077
|
-
* @param {string} [options.
|
|
1078
|
-
* @param {string} [options.
|
|
1079
|
-
* meaningful when a live voice leg exists; otherwise treated as blind.
|
|
1076
|
+
* @param {Object} options.target - Transfer target (required)
|
|
1077
|
+
* @param {string} [options.target.queueId] - Destination queue ID
|
|
1078
|
+
* @param {string} [options.target.workerId] - Destination worker ID
|
|
1080
1079
|
* @param {string} [options.note] - Optional note for the receiving agent
|
|
1081
|
-
* @returns {Promise<Object>} { taskId, newTaskId
|
|
1080
|
+
* @returns {Promise<Object>} { taskId, newTaskId }
|
|
1082
1081
|
*/
|
|
1083
1082
|
async transfer(options = {}) {
|
|
1084
|
-
const { taskId,
|
|
1083
|
+
const { taskId, target, note } = options;
|
|
1085
1084
|
|
|
1086
1085
|
this.sdk.validateParams(
|
|
1087
|
-
{ taskId,
|
|
1086
|
+
{ taskId, target, note },
|
|
1088
1087
|
{
|
|
1089
1088
|
taskId: { type: 'string', required: true },
|
|
1090
|
-
|
|
1091
|
-
workerId: { type: 'string', required: false },
|
|
1092
|
-
mode: { type: 'string', required: false },
|
|
1089
|
+
target: { type: 'object', required: true },
|
|
1093
1090
|
note: { type: 'string', required: false },
|
|
1094
1091
|
},
|
|
1095
1092
|
);
|
|
1096
1093
|
|
|
1097
|
-
const params = { body: { taskId } };
|
|
1098
|
-
if (queueId !== undefined) params.body.queueId = queueId;
|
|
1099
|
-
if (workerId !== undefined) params.body.workerId = workerId;
|
|
1100
|
-
if (mode !== undefined) params.body.mode = mode;
|
|
1094
|
+
const params = { body: { taskId, target } };
|
|
1101
1095
|
if (note !== undefined) params.body.note = note;
|
|
1102
1096
|
|
|
1103
1097
|
return await internalRequest(
|
|
@@ -1108,59 +1102,6 @@ export class TaskService {
|
|
|
1108
1102
|
);
|
|
1109
1103
|
}
|
|
1110
1104
|
|
|
1111
|
-
/**
|
|
1112
|
-
* Complete an attended transfer: unhold the caller, hang up the old
|
|
1113
|
-
* agent's leg, and complete the old task.
|
|
1114
|
-
*
|
|
1115
|
-
* @param {Object} options - Parameters
|
|
1116
|
-
* @param {string} options.taskId - The old task ID (required)
|
|
1117
|
-
* @returns {Promise<Object>} { taskId }
|
|
1118
|
-
*/
|
|
1119
|
-
async transferComplete(options = {}) {
|
|
1120
|
-
const { taskId } = options;
|
|
1121
|
-
|
|
1122
|
-
this.sdk.validateParams(
|
|
1123
|
-
{ taskId },
|
|
1124
|
-
{ taskId: { type: 'string', required: true } },
|
|
1125
|
-
);
|
|
1126
|
-
|
|
1127
|
-
const params = { body: { taskId } };
|
|
1128
|
-
|
|
1129
|
-
return await internalRequest(
|
|
1130
|
-
this.sdk,
|
|
1131
|
-
'/taskRouter/tasks/transfer/complete',
|
|
1132
|
-
'PUT',
|
|
1133
|
-
params,
|
|
1134
|
-
);
|
|
1135
|
-
}
|
|
1136
|
-
|
|
1137
|
-
/**
|
|
1138
|
-
* Cancel an attended transfer: complete/hang up the new task, re-point
|
|
1139
|
-
* channels back to the old task, unhold the caller, and clear the old
|
|
1140
|
-
* task's transfer state.
|
|
1141
|
-
*
|
|
1142
|
-
* @param {Object} options - Parameters
|
|
1143
|
-
* @param {string} options.taskId - The old task ID (required)
|
|
1144
|
-
* @returns {Promise<Object>} { taskId }
|
|
1145
|
-
*/
|
|
1146
|
-
async transferCancel(options = {}) {
|
|
1147
|
-
const { taskId } = options;
|
|
1148
|
-
|
|
1149
|
-
this.sdk.validateParams(
|
|
1150
|
-
{ taskId },
|
|
1151
|
-
{ taskId: { type: 'string', required: true } },
|
|
1152
|
-
);
|
|
1153
|
-
|
|
1154
|
-
const params = { body: { taskId } };
|
|
1155
|
-
|
|
1156
|
-
return await internalRequest(
|
|
1157
|
-
this.sdk,
|
|
1158
|
-
'/taskRouter/tasks/transfer/cancel',
|
|
1159
|
-
'PUT',
|
|
1160
|
-
params,
|
|
1161
|
-
);
|
|
1162
|
-
}
|
|
1163
|
-
|
|
1164
1105
|
/**
|
|
1165
1106
|
* Get the voice transcript for a task, keyed by the media-manager
|
|
1166
1107
|
* bridgeId (not sipCallId) so it works across requeue/transfer.
|