@unboundcx/sdk 4.8.11 → 4.8.12
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 +3 -3
- package/package.json +1 -1
- package/services/chat.js +143 -4
- package/services/{inbox.js → recents.js} +7 -7
package/index.js
CHANGED
|
@@ -30,7 +30,7 @@ import { FaxService } from './services/fax.js';
|
|
|
30
30
|
import { DocumentsService } from './services/documents.js';
|
|
31
31
|
import { PermissionsService } from './services/permissions.js';
|
|
32
32
|
import { TriggersService } from './services/triggers.js';
|
|
33
|
-
import {
|
|
33
|
+
import { RecentsService } from './services/recents.js';
|
|
34
34
|
import { SearchService } from './services/search.js';
|
|
35
35
|
import { DirectoryService } from './services/directory.js';
|
|
36
36
|
import { ChatService } from './services/chat.js';
|
|
@@ -106,7 +106,7 @@ class UnboundSDK extends BaseSDK {
|
|
|
106
106
|
this.documents = new DocumentsService(this);
|
|
107
107
|
this.permissions = new PermissionsService(this);
|
|
108
108
|
this.triggers = new TriggersService(this);
|
|
109
|
-
this.
|
|
109
|
+
this.recents = new RecentsService(this);
|
|
110
110
|
this.search = new SearchService(this);
|
|
111
111
|
this.directory = new DirectoryService(this);
|
|
112
112
|
this.chat = new ChatService(this);
|
|
@@ -291,7 +291,7 @@ export { WorkerService } from './services/taskRouter/WorkerService.js';
|
|
|
291
291
|
export { KnowledgeBaseService } from './services/knowledgeBase.js';
|
|
292
292
|
export { FaxService } from './services/fax.js';
|
|
293
293
|
export { PermissionsService } from './services/permissions.js';
|
|
294
|
-
export {
|
|
294
|
+
export { RecentsService } from './services/recents.js';
|
|
295
295
|
export { SearchService } from './services/search.js';
|
|
296
296
|
export { DirectoryService } from './services/directory.js';
|
|
297
297
|
export { ChatService } from './services/chat.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unboundcx/sdk",
|
|
3
|
-
"version": "4.8.
|
|
3
|
+
"version": "4.8.12",
|
|
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/chat.js
CHANGED
|
@@ -77,14 +77,15 @@ export class ChatService {
|
|
|
77
77
|
* @param {Object} [params.settings]
|
|
78
78
|
* @returns {Promise<Object>}
|
|
79
79
|
*/
|
|
80
|
-
async updateChannel(id, { name, topic, settings } = {}) {
|
|
80
|
+
async updateChannel(id, { name, topic, settings, kind } = {}) {
|
|
81
81
|
this.sdk.validateParams(
|
|
82
|
-
{ id, name, topic, settings },
|
|
82
|
+
{ id, name, topic, settings, kind },
|
|
83
83
|
{
|
|
84
84
|
id: { type: 'string', required: true },
|
|
85
85
|
name: { type: 'string', required: false },
|
|
86
86
|
topic: { type: 'string', required: false },
|
|
87
87
|
settings: { type: 'object', required: false },
|
|
88
|
+
kind: { type: 'string', required: false },
|
|
88
89
|
},
|
|
89
90
|
);
|
|
90
91
|
|
|
@@ -92,6 +93,7 @@ export class ChatService {
|
|
|
92
93
|
if (name !== undefined) body.name = name;
|
|
93
94
|
if (topic !== undefined) body.topic = topic;
|
|
94
95
|
if (settings !== undefined) body.settings = settings;
|
|
96
|
+
if (kind !== undefined) body.kind = kind;
|
|
95
97
|
|
|
96
98
|
return internalRequest(this.sdk, `/chat/channels/${id}`, 'PATCH', { body });
|
|
97
99
|
}
|
|
@@ -265,6 +267,30 @@ export class ChatService {
|
|
|
265
267
|
return internalRequest(this.sdk, '/chat/dnd', 'PATCH', { body: { enabled } });
|
|
266
268
|
}
|
|
267
269
|
|
|
270
|
+
/**
|
|
271
|
+
* Favorite reaction emojis for the current user.
|
|
272
|
+
* @returns {Promise<Object>}
|
|
273
|
+
*/
|
|
274
|
+
async getEmojiFavorites() {
|
|
275
|
+
return internalRequest(this.sdk, '/chat/emoji-favorites', 'GET');
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Replace the caller's favorite reaction emojis.
|
|
280
|
+
* @param {Object} params
|
|
281
|
+
* @param {string[]} params.emojis
|
|
282
|
+
* @returns {Promise<Object>}
|
|
283
|
+
*/
|
|
284
|
+
async setEmojiFavorites({ emojis } = {}) {
|
|
285
|
+
this.sdk.validateParams(
|
|
286
|
+
{ emojis },
|
|
287
|
+
{ emojis: { type: 'array', required: true } },
|
|
288
|
+
);
|
|
289
|
+
return internalRequest(this.sdk, '/chat/emoji-favorites', 'PATCH', {
|
|
290
|
+
body: { emojis },
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
|
|
268
294
|
/**
|
|
269
295
|
* Advance the read watermark and recompute unread counters.
|
|
270
296
|
* @param {string} channelId
|
|
@@ -365,16 +391,33 @@ export class ChatService {
|
|
|
365
391
|
*/
|
|
366
392
|
async sendMessage(
|
|
367
393
|
channelId,
|
|
368
|
-
{
|
|
394
|
+
{
|
|
395
|
+
message,
|
|
396
|
+
threadRootId,
|
|
397
|
+
alsoSendToChannel,
|
|
398
|
+
storageIds,
|
|
399
|
+
suppressUnfurlUrls,
|
|
400
|
+
unfurls,
|
|
401
|
+
} = {},
|
|
369
402
|
) {
|
|
370
403
|
this.sdk.validateParams(
|
|
371
|
-
{
|
|
404
|
+
{
|
|
405
|
+
channelId,
|
|
406
|
+
message,
|
|
407
|
+
threadRootId,
|
|
408
|
+
alsoSendToChannel,
|
|
409
|
+
storageIds,
|
|
410
|
+
suppressUnfurlUrls,
|
|
411
|
+
unfurls,
|
|
412
|
+
},
|
|
372
413
|
{
|
|
373
414
|
channelId: { type: 'string', required: true },
|
|
374
415
|
message: { type: 'object', required: true },
|
|
375
416
|
threadRootId: { type: 'string', required: false },
|
|
376
417
|
alsoSendToChannel: { type: 'boolean', required: false },
|
|
377
418
|
storageIds: { type: 'array', required: false },
|
|
419
|
+
suppressUnfurlUrls: { type: 'array', required: false },
|
|
420
|
+
unfurls: { type: 'array', required: false },
|
|
378
421
|
},
|
|
379
422
|
);
|
|
380
423
|
|
|
@@ -384,6 +427,10 @@ export class ChatService {
|
|
|
384
427
|
body.alsoSendToChannel = alsoSendToChannel;
|
|
385
428
|
}
|
|
386
429
|
if (storageIds !== undefined) body.storageIds = storageIds;
|
|
430
|
+
if (suppressUnfurlUrls !== undefined) {
|
|
431
|
+
body.suppressUnfurlUrls = suppressUnfurlUrls;
|
|
432
|
+
}
|
|
433
|
+
if (unfurls !== undefined) body.unfurls = unfurls;
|
|
387
434
|
|
|
388
435
|
return internalRequest(this.sdk, `/chat/channels/${channelId}/messages`, 'POST', {
|
|
389
436
|
body,
|
|
@@ -410,6 +457,44 @@ export class ChatService {
|
|
|
410
457
|
});
|
|
411
458
|
}
|
|
412
459
|
|
|
460
|
+
/**
|
|
461
|
+
* Fetch Open Graph data for a URL (composer preview).
|
|
462
|
+
* @param {Object} params
|
|
463
|
+
* @param {string} params.url
|
|
464
|
+
* @returns {Promise<Object>}
|
|
465
|
+
*/
|
|
466
|
+
async previewLink({ url } = {}) {
|
|
467
|
+
this.sdk.validateParams({ url }, { url: { type: 'string', required: true } });
|
|
468
|
+
return internalRequest(
|
|
469
|
+
this.sdk,
|
|
470
|
+
`/chat/link-preview?url=${encodeURIComponent(url)}`,
|
|
471
|
+
'GET',
|
|
472
|
+
);
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* Hide a link preview on a message.
|
|
477
|
+
* @param {string} id
|
|
478
|
+
* @param {Object} params
|
|
479
|
+
* @param {string} params.url
|
|
480
|
+
* @returns {Promise<Object>}
|
|
481
|
+
*/
|
|
482
|
+
async hideUnfurl(id, { url } = {}) {
|
|
483
|
+
this.sdk.validateParams(
|
|
484
|
+
{ id, url },
|
|
485
|
+
{
|
|
486
|
+
id: { type: 'string', required: true },
|
|
487
|
+
url: { type: 'string', required: true },
|
|
488
|
+
},
|
|
489
|
+
);
|
|
490
|
+
return internalRequest(
|
|
491
|
+
this.sdk,
|
|
492
|
+
`/chat/messages/${id}/unfurls/hide`,
|
|
493
|
+
'POST',
|
|
494
|
+
{ body: { url } },
|
|
495
|
+
);
|
|
496
|
+
}
|
|
497
|
+
|
|
413
498
|
/**
|
|
414
499
|
* Delete a message (tombstone).
|
|
415
500
|
* @param {string} id
|
|
@@ -895,6 +980,60 @@ export class ChatService {
|
|
|
895
980
|
return internalRequest(this.sdk, `/chat/pins/${id}`, 'DELETE');
|
|
896
981
|
}
|
|
897
982
|
|
|
983
|
+
/**
|
|
984
|
+
* Pin a message to the top of a channel/feed.
|
|
985
|
+
* @param {string} channelId
|
|
986
|
+
* @param {Object} params
|
|
987
|
+
* @param {string} params.messageId
|
|
988
|
+
* @returns {Promise<Object>}
|
|
989
|
+
*/
|
|
990
|
+
async pinMessage(channelId, { messageId } = {}) {
|
|
991
|
+
this.sdk.validateParams(
|
|
992
|
+
{ channelId, messageId },
|
|
993
|
+
{
|
|
994
|
+
channelId: { type: 'string', required: true },
|
|
995
|
+
messageId: { type: 'string', required: true },
|
|
996
|
+
},
|
|
997
|
+
);
|
|
998
|
+
return internalRequest(
|
|
999
|
+
this.sdk,
|
|
1000
|
+
`/chat/channels/${channelId}/pinned-message`,
|
|
1001
|
+
'PUT',
|
|
1002
|
+
{ body: { messageId } },
|
|
1003
|
+
);
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
/**
|
|
1007
|
+
* Clear the pinned message on a channel/feed.
|
|
1008
|
+
* @param {string} channelId
|
|
1009
|
+
* @returns {Promise<Object>}
|
|
1010
|
+
*/
|
|
1011
|
+
async unpinMessage(channelId) {
|
|
1012
|
+
this.sdk.validateParams(
|
|
1013
|
+
{ channelId },
|
|
1014
|
+
{ channelId: { type: 'string', required: true } },
|
|
1015
|
+
);
|
|
1016
|
+
return internalRequest(
|
|
1017
|
+
this.sdk,
|
|
1018
|
+
`/chat/channels/${channelId}/pinned-message`,
|
|
1019
|
+
'DELETE',
|
|
1020
|
+
);
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
/**
|
|
1024
|
+
* List messages that mention the caller.
|
|
1025
|
+
* @param {Object} [params]
|
|
1026
|
+
* @param {'public'|'private'|'dm'|'group_dm'|'record'} [params.kind]
|
|
1027
|
+
* @param {number} [params.limit]
|
|
1028
|
+
* @returns {Promise<Object>}
|
|
1029
|
+
*/
|
|
1030
|
+
async listMentions({ kind, limit } = {}) {
|
|
1031
|
+
const query = {};
|
|
1032
|
+
if (kind) query.kind = kind;
|
|
1033
|
+
if (limit != null) query.limit = limit;
|
|
1034
|
+
return internalRequest(this.sdk, '/chat/mentions', 'GET', { query });
|
|
1035
|
+
}
|
|
1036
|
+
|
|
898
1037
|
async listAdminChannels(query) {
|
|
899
1038
|
return this.adminListChannels(query);
|
|
900
1039
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { internalRequest } from '../base.js';
|
|
2
|
-
export class
|
|
2
|
+
export class RecentsService {
|
|
3
3
|
constructor(sdk) {
|
|
4
4
|
this.sdk = sdk;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* List unified
|
|
8
|
+
* List unified recents items merged across call/voicemail/fax/sms sources,
|
|
9
9
|
* sorted descending by timestamp.
|
|
10
10
|
*
|
|
11
11
|
* @param {Object} params
|
|
@@ -93,7 +93,7 @@ export class InboxService {
|
|
|
93
93
|
|
|
94
94
|
const params = { query };
|
|
95
95
|
|
|
96
|
-
const result = await internalRequest(this.sdk, '/
|
|
96
|
+
const result = await internalRequest(this.sdk, '/recents', 'GET', params);
|
|
97
97
|
return result;
|
|
98
98
|
}
|
|
99
99
|
|
|
@@ -125,18 +125,18 @@ export class InboxService {
|
|
|
125
125
|
|
|
126
126
|
const params = { query };
|
|
127
127
|
|
|
128
|
-
const result = await internalRequest(this.sdk, '/
|
|
128
|
+
const result = await internalRequest(this.sdk, '/recents/smsThread', 'GET', params);
|
|
129
129
|
return result;
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
/**
|
|
133
|
-
* Fetch
|
|
133
|
+
* Fetch recents stats (calls/talk time/missed/unread voicemail/meetings) for
|
|
134
134
|
* the current user.
|
|
135
135
|
*
|
|
136
136
|
* @returns {Promise<{callsToday: number, talkTimeSeconds: number, missedToday: number, unreadVoicemail: number, oldestUnreadVoicemailAt: string|null, meetingsToday: number, meetingMinutesToday: number}>}
|
|
137
137
|
*/
|
|
138
138
|
async stats() {
|
|
139
|
-
const result = await internalRequest(this.sdk, '/
|
|
139
|
+
const result = await internalRequest(this.sdk, '/recents/stats', 'GET');
|
|
140
140
|
return result;
|
|
141
141
|
}
|
|
142
142
|
|
|
@@ -154,7 +154,7 @@ export class InboxService {
|
|
|
154
154
|
{ voicemailMessageId: { type: 'string', required: true } },
|
|
155
155
|
);
|
|
156
156
|
return await internalRequest(this.sdk,
|
|
157
|
-
`/
|
|
157
|
+
`/recents/voicemail/${voicemailMessageId}/transcribe`,
|
|
158
158
|
'POST',
|
|
159
159
|
{ body: {} },
|
|
160
160
|
);
|