@unboundcx/sdk 4.7.0 → 4.8.1

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 CHANGED
@@ -30,6 +30,8 @@ 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 { InboxService } from './services/inbox.js';
34
+ import { DirectoryService } from './services/directory.js';
33
35
 
34
36
  class UnboundSDK extends BaseSDK {
35
37
  constructor(options = {}) {
@@ -101,6 +103,8 @@ class UnboundSDK extends BaseSDK {
101
103
  this.documents = new DocumentsService(this);
102
104
  this.permissions = new PermissionsService(this);
103
105
  this.triggers = new TriggersService(this);
106
+ this.inbox = new InboxService(this);
107
+ this.directory = new DirectoryService(this);
104
108
 
105
109
  // Add additional services that might be missing
106
110
  this._initializeAdditionalServices();
@@ -281,4 +285,6 @@ export { WorkerService } from './services/taskRouter/WorkerService.js';
281
285
  export { KnowledgeBaseService } from './services/knowledgeBase.js';
282
286
  export { FaxService } from './services/fax.js';
283
287
  export { PermissionsService } from './services/permissions.js';
288
+ export { InboxService } from './services/inbox.js';
289
+ export { DirectoryService } from './services/directory.js';
284
290
  export { BaseSDK } from './base.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unboundcx/sdk",
3
- "version": "4.7.0",
3
+ "version": "4.8.1",
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,124 @@
1
+ export class DirectoryService {
2
+ constructor(sdk) {
3
+ this.sdk = sdk;
4
+ }
5
+
6
+ /**
7
+ * List the current user's directory favorites, hydrated with the
8
+ * favorited record and its channels.
9
+ *
10
+ * @returns {Promise<{favorites: Object[]}>}
11
+ */
12
+ async listFavorites() {
13
+ const result = await this.sdk._fetch('/directory/favorites', 'GET');
14
+ return result;
15
+ }
16
+
17
+ /**
18
+ * Add a person or company to directory favorites. Reactivates a
19
+ * soft-deleted favorite on unique conflict.
20
+ *
21
+ * @param {Object} params
22
+ * @param {string} params.objectType - 'person' or 'company' (required).
23
+ * @param {string} params.objectId - Id of the favorited record (required).
24
+ * @param {string[]} [params.channelIds] - Channel ids to pin for this favorite.
25
+ * @returns {Promise<Object>} The created (or reactivated) favorite.
26
+ */
27
+ async addFavorite({ objectType, objectId, channelIds }) {
28
+ this.sdk.validateParams(
29
+ { objectType, objectId, channelIds },
30
+ {
31
+ objectType: { type: 'string', required: true },
32
+ objectId: { type: 'string', required: true },
33
+ channelIds: { type: 'array', required: false },
34
+ },
35
+ );
36
+
37
+ const body = { objectType, objectId };
38
+ if (channelIds !== undefined) body.channelIds = channelIds;
39
+
40
+ const params = { body };
41
+
42
+ const result = await this.sdk._fetch('/directory/favorites', 'POST', params);
43
+ return result;
44
+ }
45
+
46
+ /**
47
+ * Update a directory favorite's pinned channels and/or sort order.
48
+ *
49
+ * @param {string} favoriteId - Id of the favorite to update (required).
50
+ * @param {Object} params
51
+ * @param {string[]} [params.channelIds]
52
+ * @param {number} [params.sortOrder]
53
+ * @returns {Promise<Object>} The updated favorite.
54
+ */
55
+ async updateFavorite(favoriteId, { channelIds, sortOrder } = {}) {
56
+ this.sdk.validateParams(
57
+ { favoriteId, channelIds, sortOrder },
58
+ {
59
+ favoriteId: { type: 'string', required: true },
60
+ channelIds: { type: 'array', required: false },
61
+ sortOrder: { type: 'number', required: false },
62
+ },
63
+ );
64
+
65
+ const body = {};
66
+ if (channelIds !== undefined) body.channelIds = channelIds;
67
+ if (sortOrder !== undefined) body.sortOrder = sortOrder;
68
+
69
+ const params = { body };
70
+
71
+ const result = await this.sdk._fetch(
72
+ `/directory/favorites/${favoriteId}`,
73
+ 'PUT',
74
+ params,
75
+ );
76
+ return result;
77
+ }
78
+
79
+ /**
80
+ * Soft delete a directory favorite.
81
+ *
82
+ * @param {string} favoriteId - Id of the favorite to remove (required).
83
+ * @returns {Promise<Object>}
84
+ */
85
+ async removeFavorite(favoriteId) {
86
+ this.sdk.validateParams(
87
+ { favoriteId },
88
+ {
89
+ favoriteId: { type: 'string', required: true },
90
+ },
91
+ );
92
+
93
+ const result = await this.sdk._fetch(
94
+ `/directory/favorites/${favoriteId}`,
95
+ 'DELETE',
96
+ );
97
+ return result;
98
+ }
99
+
100
+ /**
101
+ * Reorder directory favorites.
102
+ *
103
+ * @param {Object} params
104
+ * @param {string[]} params.order - Favorite ids in the desired order (required).
105
+ * @returns {Promise<{ok: boolean}>}
106
+ */
107
+ async reorderFavorites({ order }) {
108
+ this.sdk.validateParams(
109
+ { order },
110
+ {
111
+ order: { type: 'array', required: true },
112
+ },
113
+ );
114
+
115
+ const params = { body: { order } };
116
+
117
+ const result = await this.sdk._fetch(
118
+ '/directory/favorites/reorder',
119
+ 'PUT',
120
+ params,
121
+ );
122
+ return result;
123
+ }
124
+ }
@@ -0,0 +1,94 @@
1
+ export class InboxService {
2
+ constructor(sdk) {
3
+ this.sdk = sdk;
4
+ }
5
+
6
+ /**
7
+ * List unified inbox items merged across call/voicemail/fax/sms sources,
8
+ * sorted descending by timestamp.
9
+ *
10
+ * @param {Object} params
11
+ * @param {string|string[]} [params.types] - Source kinds to include
12
+ * ('call','voicemail','fax','sms'). Pass an array or a comma-joined
13
+ * string; omit to include all kinds.
14
+ * @param {number} [params.limit] - Max items to return.
15
+ * @param {string} [params.before] - UTC cursor 'YYYY-MM-DD HH:mm:ss';
16
+ * only items strictly older than this are returned.
17
+ * @param {boolean} [params.unreadOnly] - When true, only unread items.
18
+ * @returns {Promise<{items: Object[], nextCursor: string|null}>}
19
+ */
20
+ async list({ types, limit, before, unreadOnly } = {}) {
21
+ this.sdk.validateParams(
22
+ { limit, before, unreadOnly },
23
+ {
24
+ limit: { type: 'number', required: false },
25
+ before: { type: 'string', required: false },
26
+ unreadOnly: { type: 'boolean', required: false },
27
+ },
28
+ );
29
+
30
+ if (
31
+ types !== undefined &&
32
+ typeof types !== 'string' &&
33
+ !Array.isArray(types)
34
+ ) {
35
+ throw new Error('types must be a string or an array of strings');
36
+ }
37
+
38
+ const query = {};
39
+ if (types !== undefined) {
40
+ query.types = Array.isArray(types) ? types.join(',') : types;
41
+ }
42
+ if (limit !== undefined) query.limit = limit;
43
+ if (before !== undefined) query.before = before;
44
+ if (unreadOnly !== undefined) query.unreadOnly = unreadOnly;
45
+
46
+ const params = { query };
47
+
48
+ const result = await this.sdk._fetch('/inbox', 'GET', params);
49
+ return result;
50
+ }
51
+
52
+ /**
53
+ * Fetch a paginated SMS/MMS thread for a phone number + counterparty pair.
54
+ *
55
+ * @param {Object} params
56
+ * @param {string} params.phoneNumberId - Our phone number id (required).
57
+ * @param {string} params.counterparty - Counterparty phone number (required).
58
+ * @param {number} [params.limit] - Max messages to return.
59
+ * @param {string} [params.before] - UTC cursor 'YYYY-MM-DD HH:mm:ss';
60
+ * only messages strictly older than this are returned.
61
+ * @returns {Promise<{messages: Object[], nextCursor: string|null}>}
62
+ */
63
+ async smsThread({ phoneNumberId, counterparty, limit, before }) {
64
+ this.sdk.validateParams(
65
+ { phoneNumberId, counterparty, limit, before },
66
+ {
67
+ phoneNumberId: { type: 'string', required: true },
68
+ counterparty: { type: 'string', required: true },
69
+ limit: { type: 'number', required: false },
70
+ before: { type: 'string', required: false },
71
+ },
72
+ );
73
+
74
+ const query = { phoneNumberId, counterparty };
75
+ if (limit !== undefined) query.limit = limit;
76
+ if (before !== undefined) query.before = before;
77
+
78
+ const params = { query };
79
+
80
+ const result = await this.sdk._fetch('/inbox/smsThread', 'GET', params);
81
+ return result;
82
+ }
83
+
84
+ /**
85
+ * Fetch inbox stats (calls/talk time/missed/unread voicemail) for the
86
+ * current user.
87
+ *
88
+ * @returns {Promise<{callsToday: number, talkTimeSeconds: number, missedToday: number, unreadVoicemail: number, oldestUnreadVoicemailAt: string|null}>}
89
+ */
90
+ async stats() {
91
+ const result = await this.sdk._fetch('/inbox/stats', 'GET');
92
+ return result;
93
+ }
94
+ }