@unboundcx/sdk 4.13.40 → 4.13.41
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 +1 -1
- package/services/messaging/SmsService.js +18 -3
- package/services/text.js +50 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unboundcx/sdk",
|
|
3
|
-
"version": "4.13.
|
|
3
|
+
"version": "4.13.41",
|
|
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",
|
|
@@ -10,7 +10,8 @@ export class SmsService {
|
|
|
10
10
|
/**
|
|
11
11
|
* Send an SMS/MMS message
|
|
12
12
|
* @param {Object} params - Message parameters
|
|
13
|
-
* @param {string} params.to - Recipient phone number
|
|
13
|
+
* @param {string|string[]} params.to - Recipient phone number, or an
|
|
14
|
+
* array of up to 8 for a group MMS send (required)
|
|
14
15
|
* @param {string} [params.from] - Sender phone number
|
|
15
16
|
* @param {string} [params.message] - Message text
|
|
16
17
|
* @param {string} [params.templateId] - Template ID to use
|
|
@@ -50,10 +51,24 @@ export class SmsService {
|
|
|
50
51
|
if (taskId) messageData.taskId = taskId;
|
|
51
52
|
if (force !== undefined) messageData.force = force;
|
|
52
53
|
|
|
54
|
+
// `to` is string | string[] (group MMS, up to 8 recipients) --
|
|
55
|
+
// validated by hand since sdk.validateParams has no multi-type support
|
|
56
|
+
// (see TaskService.js's ['string','array'] usage, which hits the same
|
|
57
|
+
// gap) rather than compounding that on a new call site.
|
|
58
|
+
if (to === undefined || to === null) {
|
|
59
|
+
throw new Error('Missing required parameter to');
|
|
60
|
+
}
|
|
61
|
+
if (Array.isArray(to)) {
|
|
62
|
+
if (!to.length || !to.every((n) => typeof n === 'string')) {
|
|
63
|
+
throw new Error('Invalid type for parameter to: expected string or string[]');
|
|
64
|
+
}
|
|
65
|
+
} else if (typeof to !== 'string') {
|
|
66
|
+
throw new Error('Invalid type for parameter to: expected string or string[]');
|
|
67
|
+
}
|
|
68
|
+
|
|
53
69
|
this.sdk.validateParams(
|
|
54
|
-
{
|
|
70
|
+
{ ...messageData },
|
|
55
71
|
{
|
|
56
|
-
to: { type: 'string', required: true },
|
|
57
72
|
from: { type: 'string', required: false },
|
|
58
73
|
message: { type: 'string', required: false },
|
|
59
74
|
templateId: { type: 'string', required: false },
|
package/services/text.js
CHANGED
|
@@ -97,6 +97,56 @@ export class TextConversationsService {
|
|
|
97
97
|
body: { queueId, workflowId, workflowVersionId },
|
|
98
98
|
});
|
|
99
99
|
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Move a TASK-owned conversation to a user (or UC Chat group) or to a
|
|
103
|
+
* workflow (sms-routing-plan.md K4, plan §3.4 "task -> user"/"task ->
|
|
104
|
+
* workflow"). Caller must be the task's current worker or a manager --
|
|
105
|
+
* enforced server-side. Moving to a user creates/reuses the UC Chat
|
|
106
|
+
* channel for that (identity, counterparty) pair starting from now --
|
|
107
|
+
* prior message history is NOT backfilled into the channel.
|
|
108
|
+
* @param {string} id - textConversations id (required)
|
|
109
|
+
* @param {Object} options - Parameters
|
|
110
|
+
* @param {'user'|'workflow'} options.to - Move target (required)
|
|
111
|
+
* @param {string} [options.userId] - Target user (required if to:'user' and no groupId)
|
|
112
|
+
* @param {string} [options.groupId] - Target UC Chat group (required if to:'user' and no userId)
|
|
113
|
+
* @param {'private'|'public'} [options.visibility] - New channel visibility (to:'user' only)
|
|
114
|
+
* @param {string} [options.workflowId] - Move to a workflow's current version
|
|
115
|
+
* @param {string} [options.workflowVersionId] - Move to a pinned workflow version
|
|
116
|
+
* @returns {Promise<Object>} The updated conversation row
|
|
117
|
+
*/
|
|
118
|
+
async move(id, options = {}) {
|
|
119
|
+
const { to, userId, groupId, visibility, workflowId, workflowVersionId } =
|
|
120
|
+
options;
|
|
121
|
+
|
|
122
|
+
this.sdk.validateParams(
|
|
123
|
+
{ id, to, userId, groupId, visibility, workflowId, workflowVersionId },
|
|
124
|
+
{
|
|
125
|
+
id: { type: 'string', required: true },
|
|
126
|
+
to: { type: 'string', required: true },
|
|
127
|
+
userId: { type: 'string', required: false },
|
|
128
|
+
groupId: { type: 'string', required: false },
|
|
129
|
+
visibility: { type: 'string', required: false },
|
|
130
|
+
workflowId: { type: 'string', required: false },
|
|
131
|
+
workflowVersionId: { type: 'string', required: false },
|
|
132
|
+
},
|
|
133
|
+
);
|
|
134
|
+
if (to !== 'user' && to !== 'workflow') {
|
|
135
|
+
throw new Error("move requires to: 'user' or 'workflow'");
|
|
136
|
+
}
|
|
137
|
+
if (to === 'user' && !userId && !groupId) {
|
|
138
|
+
throw new Error("move to:'user' requires userId or groupId");
|
|
139
|
+
}
|
|
140
|
+
if (to === 'workflow' && !workflowId && !workflowVersionId) {
|
|
141
|
+
throw new Error(
|
|
142
|
+
"move to:'workflow' requires workflowId or workflowVersionId",
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return internalRequest(this.sdk, `/text/conversations/${id}/move`, 'POST', {
|
|
147
|
+
body: { to, userId, groupId, visibility, workflowId, workflowVersionId },
|
|
148
|
+
});
|
|
149
|
+
}
|
|
100
150
|
}
|
|
101
151
|
|
|
102
152
|
export class TextService {
|