@unboundcx/sdk 4.10.2 → 4.11.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unboundcx/sdk",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.11.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",
|
package/services/drive.js
CHANGED
|
@@ -228,4 +228,25 @@ export class DriveService {
|
|
|
228
228
|
);
|
|
229
229
|
return result;
|
|
230
230
|
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Walk/create a Drive folder path. Path is already interpolated.
|
|
234
|
+
* @param {Object} options
|
|
235
|
+
* @param {string} options.path - e.g. unbound/people/Ada Lovelace
|
|
236
|
+
* @param {string} [options.sharedDriveId]
|
|
237
|
+
* @param {boolean} [options.create]
|
|
238
|
+
*/
|
|
239
|
+
async resolvePath({ path, sharedDriveId, create } = {}) {
|
|
240
|
+
this.sdk.validateParams(
|
|
241
|
+
{ path, sharedDriveId },
|
|
242
|
+
{
|
|
243
|
+
path: { type: 'string', required: true },
|
|
244
|
+
sharedDriveId: { type: 'string', required: false },
|
|
245
|
+
},
|
|
246
|
+
);
|
|
247
|
+
const body = { path };
|
|
248
|
+
if (sharedDriveId !== undefined) body.sharedDriveId = sharedDriveId;
|
|
249
|
+
if (create !== undefined) body.create = create;
|
|
250
|
+
return internalRequest(this.sdk, '/drive/resolvePath', 'POST', { body });
|
|
251
|
+
}
|
|
231
252
|
}
|
|
@@ -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
|
}
|