@unboundcx/sdk 4.13.125 → 4.13.127
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/index.js +4 -1
- package/package.json +1 -1
- package/services/messageTemplates.js +109 -2
- package/services/objects.js +4 -0
package/index.js
CHANGED
|
@@ -339,7 +339,10 @@ export { JourneyMembersService } from './services/journeys/JourneyMembersService
|
|
|
339
339
|
export { EmergencyService } from './services/emergency.js';
|
|
340
340
|
export { WebchatService, WebchatWidgetsService } from './services/webchat.js';
|
|
341
341
|
export { CobrowseService, CobrowseVisitorService } from './services/cobrowse.js';
|
|
342
|
-
export {
|
|
342
|
+
export {
|
|
343
|
+
MessageTemplatesService,
|
|
344
|
+
MessageTemplateVersionsService,
|
|
345
|
+
} from './services/messageTemplates.js';
|
|
343
346
|
export { WebchatVisitorService } from './services/webchat/VisitorService.js';
|
|
344
347
|
export { ExternalOAuthService } from './services/externalOAuth.js';
|
|
345
348
|
export { GoogleCalendarService } from './services/googleCalendar.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unboundcx/sdk",
|
|
3
|
-
"version": "4.13.
|
|
3
|
+
"version": "4.13.127",
|
|
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",
|
|
@@ -129,7 +129,8 @@ export class MessageTemplatesCrudService {
|
|
|
129
129
|
* @param {string} options.body
|
|
130
130
|
* @param {'draft'|'active'} [options.status]
|
|
131
131
|
* @param {number} [options.sortOrder]
|
|
132
|
-
* @
|
|
132
|
+
* @param {Array<{url: string, type: 'image'|'video'|'audio'|'document', name?: string}>} [options.media] - MMS attachments, max 10
|
|
133
|
+
* @returns {Promise<Object>} includes `version` (starts at 1; a version row is written on every save)
|
|
133
134
|
*/
|
|
134
135
|
async create(options) {
|
|
135
136
|
this.sdk.validateParams(
|
|
@@ -153,9 +154,12 @@ export class MessageTemplatesCrudService {
|
|
|
153
154
|
}
|
|
154
155
|
|
|
155
156
|
/**
|
|
156
|
-
* Update a stored message template.
|
|
157
|
+
* Update a stored message template. A name/body/media change writes a
|
|
158
|
+
* new row to the version history (a status-only or group-move save does
|
|
159
|
+
* not).
|
|
157
160
|
* @param {string} id
|
|
158
161
|
* @param {Object} options
|
|
162
|
+
* @param {Array<{url: string, type: 'image'|'video'|'audio'|'document', name?: string}>} [options.media]
|
|
159
163
|
* @returns {Promise<Object>}
|
|
160
164
|
*/
|
|
161
165
|
async update(id, options) {
|
|
@@ -182,6 +186,108 @@ export class MessageTemplatesCrudService {
|
|
|
182
186
|
'DELETE',
|
|
183
187
|
);
|
|
184
188
|
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Preview a template interpolated against a record (or a raw body with
|
|
192
|
+
* no saved template), with unresolved-variable highlighting and SMS
|
|
193
|
+
* character/segment count (journeys-plan.md §6.4). Pass either a saved
|
|
194
|
+
* `templateId` or a raw `body`.
|
|
195
|
+
* @param {Object} options
|
|
196
|
+
* @param {string} [options.templateId]
|
|
197
|
+
* @param {string} [options.body] - raw body when there is no saved template
|
|
198
|
+
* @param {string} [options.peopleId] - record to interpolate against
|
|
199
|
+
* @returns {Promise<{text: string, unresolved: string[], fits: boolean, segments: number}>}
|
|
200
|
+
*/
|
|
201
|
+
async preview({ templateId, body, peopleId } = {}) {
|
|
202
|
+
if (!templateId && !body) {
|
|
203
|
+
throw new Error('preview requires templateId or body');
|
|
204
|
+
}
|
|
205
|
+
const endpoint = templateId
|
|
206
|
+
? `/messageTemplates/templates/${templateId}/preview`
|
|
207
|
+
: '/messageTemplates/templates/preview';
|
|
208
|
+
return internalRequest(this.sdk, endpoint, 'POST', {
|
|
209
|
+
body: { templateId, body, peopleId },
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Send a test SMS of the interpolated template to the caller's own
|
|
215
|
+
* on-file number (never an arbitrary address).
|
|
216
|
+
* @param {string} id
|
|
217
|
+
* @returns {Promise<{sent: boolean, to: string}>}
|
|
218
|
+
*/
|
|
219
|
+
async sendTest(id) {
|
|
220
|
+
this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
|
|
221
|
+
return internalRequest(
|
|
222
|
+
this.sdk,
|
|
223
|
+
`/messageTemplates/templates/${id}/sendTest`,
|
|
224
|
+
'POST',
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* "Used by N journeys, M active members" (journeys-plan.md §6.4).
|
|
230
|
+
* @param {string} id
|
|
231
|
+
* @returns {Promise<{journeyCount: number, activeMemberCount: number, journeys: Object[]}>}
|
|
232
|
+
*/
|
|
233
|
+
async usage(id) {
|
|
234
|
+
this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
|
|
235
|
+
return internalRequest(
|
|
236
|
+
this.sdk,
|
|
237
|
+
`/messageTemplates/templates/${id}/usage`,
|
|
238
|
+
'GET',
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Version history for a stored message template (save is live; history +
|
|
245
|
+
* restore). A restore always appends a new version — history is
|
|
246
|
+
* append-only, never a destructive rewrite.
|
|
247
|
+
*/
|
|
248
|
+
export class MessageTemplateVersionsService {
|
|
249
|
+
constructor(sdk) {
|
|
250
|
+
this.sdk = sdk;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* List a template's saved versions, newest first.
|
|
255
|
+
* @param {string} templateId
|
|
256
|
+
* @returns {Promise<Object[]>}
|
|
257
|
+
*/
|
|
258
|
+
async list(templateId) {
|
|
259
|
+
this.sdk.validateParams(
|
|
260
|
+
{ templateId },
|
|
261
|
+
{ templateId: { type: 'string', required: true } },
|
|
262
|
+
);
|
|
263
|
+
return internalRequest(
|
|
264
|
+
this.sdk,
|
|
265
|
+
`/messageTemplates/templates/${templateId}/versions`,
|
|
266
|
+
'GET',
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Restore a prior version — writes a NEW version with that version's
|
|
272
|
+
* content and returns the updated template.
|
|
273
|
+
* @param {string} templateId
|
|
274
|
+
* @param {number} version
|
|
275
|
+
* @returns {Promise<Object>}
|
|
276
|
+
*/
|
|
277
|
+
async restore(templateId, version) {
|
|
278
|
+
this.sdk.validateParams(
|
|
279
|
+
{ templateId, version },
|
|
280
|
+
{
|
|
281
|
+
templateId: { type: 'string', required: true },
|
|
282
|
+
version: { type: 'number', required: true },
|
|
283
|
+
},
|
|
284
|
+
);
|
|
285
|
+
return internalRequest(
|
|
286
|
+
this.sdk,
|
|
287
|
+
`/messageTemplates/templates/${templateId}/versions/${version}/restore`,
|
|
288
|
+
'POST',
|
|
289
|
+
);
|
|
290
|
+
}
|
|
185
291
|
}
|
|
186
292
|
|
|
187
293
|
export class MessageTemplatesService {
|
|
@@ -189,6 +295,7 @@ export class MessageTemplatesService {
|
|
|
189
295
|
this.sdk = sdk;
|
|
190
296
|
this.groups = new MessageTemplateGroupsService(sdk);
|
|
191
297
|
this.templates = new MessageTemplatesCrudService(sdk);
|
|
298
|
+
this.templates.versions = new MessageTemplateVersionsService(sdk);
|
|
192
299
|
}
|
|
193
300
|
|
|
194
301
|
/**
|
package/services/objects.js
CHANGED
|
@@ -1040,6 +1040,7 @@ export class ObjectsService {
|
|
|
1040
1040
|
feedPostWindowSeconds = null,
|
|
1041
1041
|
showInNav = null,
|
|
1042
1042
|
navLabel = null,
|
|
1043
|
+
icon = null,
|
|
1043
1044
|
}) {
|
|
1044
1045
|
this.sdk.validateParams(
|
|
1045
1046
|
{
|
|
@@ -1051,6 +1052,7 @@ export class ObjectsService {
|
|
|
1051
1052
|
feedPostWindowSeconds,
|
|
1052
1053
|
showInNav,
|
|
1053
1054
|
navLabel,
|
|
1055
|
+
icon,
|
|
1054
1056
|
},
|
|
1055
1057
|
{
|
|
1056
1058
|
objectName: { type: 'string', required: true },
|
|
@@ -1061,6 +1063,7 @@ export class ObjectsService {
|
|
|
1061
1063
|
feedPostWindowSeconds: { type: 'number', required: false },
|
|
1062
1064
|
showInNav: { type: 'boolean', required: false },
|
|
1063
1065
|
navLabel: { type: 'string', required: false },
|
|
1066
|
+
icon: { type: 'string', required: false },
|
|
1064
1067
|
},
|
|
1065
1068
|
);
|
|
1066
1069
|
|
|
@@ -1073,6 +1076,7 @@ export class ObjectsService {
|
|
|
1073
1076
|
body.feedPostWindowSeconds = feedPostWindowSeconds;
|
|
1074
1077
|
if (showInNav !== null) body.showInNav = showInNav;
|
|
1075
1078
|
if (navLabel !== null) body.navLabel = navLabel;
|
|
1079
|
+
if (icon !== null) body.icon = icon;
|
|
1076
1080
|
|
|
1077
1081
|
const params = { body };
|
|
1078
1082
|
|