@unboundcx/sdk 4.13.177 → 4.13.179
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
|
@@ -102,9 +102,24 @@ class UnboundSDK extends BaseSDK {
|
|
|
102
102
|
socketStore,
|
|
103
103
|
baseURL,
|
|
104
104
|
tokenDelivery,
|
|
105
|
+
autoRefresh,
|
|
106
|
+
onUnauthorized,
|
|
107
|
+
refreshToken,
|
|
105
108
|
} = options;
|
|
106
109
|
|
|
107
|
-
|
|
110
|
+
// autoRefresh / onUnauthorized / refreshToken must reach BaseSDK or the
|
|
111
|
+
// 401 refresh-and-retry (lib/refreshInterceptor.js) never runs.
|
|
112
|
+
super({
|
|
113
|
+
namespace,
|
|
114
|
+
callId,
|
|
115
|
+
token,
|
|
116
|
+
fwRequestId,
|
|
117
|
+
baseURL,
|
|
118
|
+
tokenDelivery,
|
|
119
|
+
autoRefresh,
|
|
120
|
+
onUnauthorized,
|
|
121
|
+
refreshToken,
|
|
122
|
+
});
|
|
108
123
|
|
|
109
124
|
// Handle client-side specific parameters
|
|
110
125
|
if (url) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unboundcx/sdk",
|
|
3
|
-
"version": "4.13.
|
|
3
|
+
"version": "4.13.179",
|
|
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",
|
|
@@ -6,6 +6,7 @@ import { EmailAnalyticsService } from './EmailAnalyticsService.js';
|
|
|
6
6
|
import { EmailQueueService } from './EmailQueueService.js';
|
|
7
7
|
import { EmailSuppressionService } from './EmailSuppressionService.js';
|
|
8
8
|
import { EmailAccountSettingsService } from './EmailAccountSettingsService.js';
|
|
9
|
+
import { EmailSignaturesService } from './EmailSignaturesService.js';
|
|
9
10
|
|
|
10
11
|
import { internalRequest } from '../../base.js';
|
|
11
12
|
export class EmailService {
|
|
@@ -20,6 +21,7 @@ export class EmailService {
|
|
|
20
21
|
this.suppression = new EmailSuppressionService(sdk);
|
|
21
22
|
// Account-level email settings (plan §3.3).
|
|
22
23
|
this.settings = new EmailAccountSettingsService(sdk);
|
|
24
|
+
this.signatures = new EmailSignaturesService(sdk);
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
/**
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import { internalRequest } from '../../base.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Mail-app email signatures. Exposed as `sdk.messaging.email.signatures`.
|
|
5
|
+
*/
|
|
6
|
+
export class EmailSignaturesService {
|
|
7
|
+
constructor(sdk) {
|
|
8
|
+
this.sdk = sdk;
|
|
9
|
+
this.me = new EmailSignatureMeService(sdk);
|
|
10
|
+
this.templates = new EmailSignatureTemplatesService(sdk);
|
|
11
|
+
this.groups = new EmailSignatureGroupsService(sdk);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Merge fields the signature editor can insert.
|
|
16
|
+
* @returns {Promise<Object>} { fields }
|
|
17
|
+
* @example
|
|
18
|
+
* const { fields } = await sdk.messaging.email.signatures.fields();
|
|
19
|
+
*/
|
|
20
|
+
async fields() {
|
|
21
|
+
return internalRequest(this.sdk, '/messaging/email/signatures/fields', 'GET');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Render a signature for a user.
|
|
26
|
+
* @param {Object} params
|
|
27
|
+
* @param {string} params.html - Signature HTML, including merge tags
|
|
28
|
+
* @param {string} [params.userId] - User to render. Defaults to the caller.
|
|
29
|
+
* @returns {Promise<Object>} { html }
|
|
30
|
+
* @example
|
|
31
|
+
* const { html } = await sdk.messaging.email.signatures.preview({
|
|
32
|
+
* html: 'Hello {{firstName}}',
|
|
33
|
+
* });
|
|
34
|
+
*/
|
|
35
|
+
async preview({ html, userId } = {}) {
|
|
36
|
+
this.sdk.validateParams(
|
|
37
|
+
{ html, userId },
|
|
38
|
+
{
|
|
39
|
+
html: { type: 'string', required: true },
|
|
40
|
+
userId: { type: 'string', required: false },
|
|
41
|
+
},
|
|
42
|
+
);
|
|
43
|
+
const body = { html };
|
|
44
|
+
if (userId !== undefined) body.userId = userId;
|
|
45
|
+
return internalRequest(this.sdk, '/messaging/email/signatures/preview', 'POST', {
|
|
46
|
+
body,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
class EmailSignatureMeService {
|
|
52
|
+
constructor(sdk) {
|
|
53
|
+
this.sdk = sdk;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The caller's effective signature, including shared and forced options.
|
|
58
|
+
* @returns {Promise<Object>}
|
|
59
|
+
* @example
|
|
60
|
+
* const me = await sdk.messaging.email.signatures.me.get();
|
|
61
|
+
*/
|
|
62
|
+
async get() {
|
|
63
|
+
return internalRequest(this.sdk, '/messaging/email/signatures/me', 'GET');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Save the caller's signature choice. Personal html is ignored unless the
|
|
68
|
+
* active option is their own signature.
|
|
69
|
+
* @param {Object} body
|
|
70
|
+
* @param {string} [body.activeId] - `personal` or a shared template id
|
|
71
|
+
* @param {string} [body.html] - Personal signature HTML
|
|
72
|
+
* @param {boolean} [body.addOnNew]
|
|
73
|
+
* @param {boolean} [body.addOnReply]
|
|
74
|
+
* @returns {Promise<Object>}
|
|
75
|
+
* @example
|
|
76
|
+
* await sdk.messaging.email.signatures.me.update({
|
|
77
|
+
* activeId: 'personal',
|
|
78
|
+
* html: '<p>{{fullName__g}}</p>',
|
|
79
|
+
* addOnNew: true,
|
|
80
|
+
* addOnReply: true,
|
|
81
|
+
* });
|
|
82
|
+
*/
|
|
83
|
+
async update(body = {}) {
|
|
84
|
+
return internalRequest(this.sdk, '/messaging/email/signatures/me', 'PUT', {
|
|
85
|
+
body,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Copy a shared signature onto the caller so they can edit it.
|
|
91
|
+
* @param {string} templateId
|
|
92
|
+
* @returns {Promise<Object>}
|
|
93
|
+
* @example
|
|
94
|
+
* await sdk.messaging.email.signatures.me.copy('351...');
|
|
95
|
+
*/
|
|
96
|
+
async copy(templateId) {
|
|
97
|
+
this.sdk.validateParams(
|
|
98
|
+
{ templateId },
|
|
99
|
+
{ templateId: { type: 'string', required: true } },
|
|
100
|
+
);
|
|
101
|
+
return internalRequest(this.sdk, '/messaging/email/signatures/me/copy', 'POST', {
|
|
102
|
+
body: { templateId },
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
class EmailSignatureTemplatesService {
|
|
108
|
+
constructor(sdk) {
|
|
109
|
+
this.sdk = sdk;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* List account signature templates and their assignments.
|
|
114
|
+
* @returns {Promise<Object>} { templates }
|
|
115
|
+
* @example
|
|
116
|
+
* const { templates } = await sdk.messaging.email.signatures.templates.list();
|
|
117
|
+
*/
|
|
118
|
+
async list() {
|
|
119
|
+
return internalRequest(
|
|
120
|
+
this.sdk,
|
|
121
|
+
'/messaging/email/signatures/templates',
|
|
122
|
+
'GET',
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Create an account signature template.
|
|
128
|
+
* @param {Object} body
|
|
129
|
+
* @param {string} body.name
|
|
130
|
+
* @param {string} [body.html]
|
|
131
|
+
* @param {number} [body.priority]
|
|
132
|
+
* @returns {Promise<Object>}
|
|
133
|
+
* @example
|
|
134
|
+
* await sdk.messaging.email.signatures.templates.create({
|
|
135
|
+
* name: 'Standard',
|
|
136
|
+
* html: '<p>{{fullName__g}}</p>',
|
|
137
|
+
* priority: 0,
|
|
138
|
+
* });
|
|
139
|
+
*/
|
|
140
|
+
async create(body = {}) {
|
|
141
|
+
this.sdk.validateParams(
|
|
142
|
+
{ name: body.name },
|
|
143
|
+
{ name: { type: 'string', required: true } },
|
|
144
|
+
);
|
|
145
|
+
return internalRequest(
|
|
146
|
+
this.sdk,
|
|
147
|
+
'/messaging/email/signatures/templates',
|
|
148
|
+
'POST',
|
|
149
|
+
{ body },
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Update an account signature template.
|
|
155
|
+
* @param {string} id
|
|
156
|
+
* @param {Object} body
|
|
157
|
+
* @returns {Promise<Object>}
|
|
158
|
+
* @example
|
|
159
|
+
* await sdk.messaging.email.signatures.templates.update('351...', {
|
|
160
|
+
* name: 'Standard',
|
|
161
|
+
* html: '<p>{{fullName__g}}</p>',
|
|
162
|
+
* });
|
|
163
|
+
*/
|
|
164
|
+
async update(id, body = {}) {
|
|
165
|
+
this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
|
|
166
|
+
return internalRequest(
|
|
167
|
+
this.sdk,
|
|
168
|
+
`/messaging/email/signatures/templates/${id}`,
|
|
169
|
+
'PUT',
|
|
170
|
+
{ body },
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Delete an account signature template.
|
|
176
|
+
* @param {string} id
|
|
177
|
+
* @returns {Promise<Object>}
|
|
178
|
+
* @example
|
|
179
|
+
* await sdk.messaging.email.signatures.templates.delete('351...');
|
|
180
|
+
*/
|
|
181
|
+
async delete(id) {
|
|
182
|
+
this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
|
|
183
|
+
return internalRequest(
|
|
184
|
+
this.sdk,
|
|
185
|
+
`/messaging/email/signatures/templates/${id}`,
|
|
186
|
+
'DELETE',
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Assign a template to a user or group as shared or forced.
|
|
192
|
+
* @param {string} id - Template id
|
|
193
|
+
* @param {Object} body
|
|
194
|
+
* @param {string} body.principalType - `user` or `group`
|
|
195
|
+
* @param {string} body.principalId
|
|
196
|
+
* @param {string} body.mode - `shared` or `forced`
|
|
197
|
+
* @returns {Promise<Object>}
|
|
198
|
+
* @example
|
|
199
|
+
* await sdk.messaging.email.signatures.templates.assign('351...', {
|
|
200
|
+
* principalType: 'user',
|
|
201
|
+
* principalId: '002...',
|
|
202
|
+
* mode: 'shared',
|
|
203
|
+
* });
|
|
204
|
+
*/
|
|
205
|
+
async assign(id, body = {}) {
|
|
206
|
+
this.sdk.validateParams(
|
|
207
|
+
{ id, ...body },
|
|
208
|
+
{
|
|
209
|
+
id: { type: 'string', required: true },
|
|
210
|
+
principalType: { type: 'string', required: true },
|
|
211
|
+
principalId: { type: 'string', required: true },
|
|
212
|
+
mode: { type: 'string', required: true },
|
|
213
|
+
},
|
|
214
|
+
);
|
|
215
|
+
return internalRequest(
|
|
216
|
+
this.sdk,
|
|
217
|
+
`/messaging/email/signatures/templates/${id}/assignments`,
|
|
218
|
+
'POST',
|
|
219
|
+
{ body },
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Remove one assignment from a template.
|
|
225
|
+
* @param {string} templateId
|
|
226
|
+
* @param {string} assignmentId
|
|
227
|
+
* @returns {Promise<Object>}
|
|
228
|
+
* @example
|
|
229
|
+
* await sdk.messaging.email.signatures.templates.unassign('351...', '352...');
|
|
230
|
+
*/
|
|
231
|
+
async unassign(templateId, assignmentId) {
|
|
232
|
+
this.sdk.validateParams(
|
|
233
|
+
{ templateId, assignmentId },
|
|
234
|
+
{
|
|
235
|
+
templateId: { type: 'string', required: true },
|
|
236
|
+
assignmentId: { type: 'string', required: true },
|
|
237
|
+
},
|
|
238
|
+
);
|
|
239
|
+
return internalRequest(
|
|
240
|
+
this.sdk,
|
|
241
|
+
`/messaging/email/signatures/templates/${templateId}/assignments/${assignmentId}`,
|
|
242
|
+
'DELETE',
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
class EmailSignatureGroupsService {
|
|
248
|
+
constructor(sdk) {
|
|
249
|
+
this.sdk = sdk;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Search groups for signature assignment. Returns at most 20 name matches,
|
|
254
|
+
* or the named ids. An empty query returns no rows.
|
|
255
|
+
* @param {Object} [params]
|
|
256
|
+
* @param {string} [params.q]
|
|
257
|
+
* @param {string[]} [params.ids]
|
|
258
|
+
* @returns {Promise<Object>} { results }
|
|
259
|
+
* @example
|
|
260
|
+
* const { results } = await sdk.messaging.email.signatures.groups.search({
|
|
261
|
+
* q: 'support',
|
|
262
|
+
* });
|
|
263
|
+
*/
|
|
264
|
+
async search({ q, ids } = {}) {
|
|
265
|
+
const params = new URLSearchParams();
|
|
266
|
+
if (q) params.set('q', q);
|
|
267
|
+
if (ids?.length) params.set('ids', ids.join(','));
|
|
268
|
+
const query = params.toString();
|
|
269
|
+
return internalRequest(
|
|
270
|
+
this.sdk,
|
|
271
|
+
`/messaging/email/signatures/groups${query ? `?${query}` : ''}`,
|
|
272
|
+
'GET',
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
}
|