@unboundcx/sdk 4.10.2 → 4.11.0
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unboundcx/sdk",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.11.0",
|
|
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
|
@@ -825,9 +825,7 @@ export class ChatService {
|
|
|
825
825
|
|
|
826
826
|
/**
|
|
827
827
|
* Admin: get account-level chat settings.
|
|
828
|
-
* @returns {Promise<Object>} `{allowReports, reportReasons
|
|
829
|
-
* `reportNotifications[]` items are `{channelId, channelName, channelKind, reasons}` —
|
|
830
|
-
* `reasons` is `null` when the rule notifies for every reason.
|
|
828
|
+
* @returns {Promise<Object>} `{allowReports, reportReasons}`
|
|
831
829
|
*/
|
|
832
830
|
async adminGetSettings() {
|
|
833
831
|
return internalRequest(this.sdk, "/chat/admin/settings", "GET");
|
|
@@ -838,26 +836,18 @@ export class ChatService {
|
|
|
838
836
|
* @param {Object} params
|
|
839
837
|
* @param {boolean} params.allowReports
|
|
840
838
|
* @param {string[]} [params.reportReasons]
|
|
841
|
-
* @
|
|
842
|
-
* "message reported" card to. Each item: `{channelId: string, reasons:
|
|
843
|
-
* string[]|null}` — `reasons` null/empty means "notify for every
|
|
844
|
-
* reason"; channel must be a non-archived public/private channel.
|
|
845
|
-
* @returns {Promise<Object>} `{allowReports, reportReasons, reportNotifications}`
|
|
839
|
+
* @returns {Promise<Object>} `{allowReports, reportReasons}`
|
|
846
840
|
*/
|
|
847
|
-
async adminPutSettings({ allowReports, reportReasons
|
|
841
|
+
async adminPutSettings({ allowReports, reportReasons } = {}) {
|
|
848
842
|
this.sdk.validateParams(
|
|
849
|
-
{ allowReports, reportReasons
|
|
843
|
+
{ allowReports, reportReasons },
|
|
850
844
|
{
|
|
851
845
|
allowReports: { type: "boolean", required: true },
|
|
852
846
|
reportReasons: { type: "array", required: false },
|
|
853
|
-
reportNotifications: { type: "array", required: false },
|
|
854
847
|
},
|
|
855
848
|
);
|
|
856
849
|
const body = { allowReports };
|
|
857
850
|
if (reportReasons !== undefined) body.reportReasons = reportReasons;
|
|
858
|
-
if (reportNotifications !== undefined) {
|
|
859
|
-
body.reportNotifications = reportNotifications;
|
|
860
|
-
}
|
|
861
851
|
return internalRequest(this.sdk, "/chat/admin/settings", "PUT", {
|
|
862
852
|
body,
|
|
863
853
|
});
|
|
@@ -163,4 +163,81 @@ export class EmailTemplatesService {
|
|
|
163
163
|
const result = await internalRequest(this.sdk, '/messaging/email/template', 'GET');
|
|
164
164
|
return result;
|
|
165
165
|
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Render a template (saved or draft fields) with sample variables for
|
|
169
|
+
* preview, without sending or saving.
|
|
170
|
+
* @param {string} id - Template ID (required)
|
|
171
|
+
* @param {Object} [body] - Draft fields to render
|
|
172
|
+
* @param {string} [body.subject] - Draft subject
|
|
173
|
+
* @param {string} [body.html] - Draft HTML body
|
|
174
|
+
* @param {string} [body.text] - Draft plain-text body
|
|
175
|
+
* @param {Object} [body.variables] - Variable substitution values
|
|
176
|
+
* @returns {Promise<Object>} Rendered preview
|
|
177
|
+
* @example
|
|
178
|
+
* const preview = await sdk.messaging.email.templates.preview('tpl_123', {
|
|
179
|
+
* subject: 'Welcome {{firstName}}',
|
|
180
|
+
* html: '<p>Hello {{firstName}}</p>',
|
|
181
|
+
* variables: { firstName: 'Jane' },
|
|
182
|
+
* });
|
|
183
|
+
*/
|
|
184
|
+
async preview(id, { subject, html, text, variables } = {}) {
|
|
185
|
+
this.sdk.validateParams(
|
|
186
|
+
{ id },
|
|
187
|
+
{
|
|
188
|
+
id: { type: 'string', required: true },
|
|
189
|
+
},
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
const previewData = {};
|
|
193
|
+
if (subject !== undefined) previewData.subject = subject;
|
|
194
|
+
if (html !== undefined) previewData.html = html;
|
|
195
|
+
if (text !== undefined) previewData.text = text;
|
|
196
|
+
if (variables !== undefined) previewData.variables = variables;
|
|
197
|
+
|
|
198
|
+
const options = {
|
|
199
|
+
body: previewData,
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
const result = await internalRequest(this.sdk,
|
|
203
|
+
`/messaging/email/template/${id}/preview`,
|
|
204
|
+
'POST',
|
|
205
|
+
options,
|
|
206
|
+
);
|
|
207
|
+
return result;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Send a test email of a template to an address.
|
|
212
|
+
* @param {string} id - Template ID (required)
|
|
213
|
+
* @param {string} to - Destination email address (required)
|
|
214
|
+
* @param {Object} [body] - Optional overrides (from, subject, html, text, variables)
|
|
215
|
+
* @returns {Promise<Object>} Send confirmation
|
|
216
|
+
* @example
|
|
217
|
+
* await sdk.messaging.email.templates.sendTest('tpl_123', 'a@b.com');
|
|
218
|
+
* await sdk.messaging.email.templates.sendTest('tpl_123', 'a@b.com', {
|
|
219
|
+
* from: 'noreply@example.com',
|
|
220
|
+
* subject: 'Test subject',
|
|
221
|
+
* });
|
|
222
|
+
*/
|
|
223
|
+
async sendTest(id, to, body = {}) {
|
|
224
|
+
this.sdk.validateParams(
|
|
225
|
+
{ id, to },
|
|
226
|
+
{
|
|
227
|
+
id: { type: 'string', required: true },
|
|
228
|
+
to: { type: 'string', required: true },
|
|
229
|
+
},
|
|
230
|
+
);
|
|
231
|
+
|
|
232
|
+
const options = {
|
|
233
|
+
body: { to, ...body },
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
const result = await internalRequest(this.sdk,
|
|
237
|
+
`/messaging/email/template/${id}/test`,
|
|
238
|
+
'POST',
|
|
239
|
+
options,
|
|
240
|
+
);
|
|
241
|
+
return result;
|
|
242
|
+
}
|
|
166
243
|
}
|