@unboundcx/sdk 2.7.3 → 2.7.5
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 +1 -1
- package/services/messaging.js +383 -67
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unboundcx/sdk",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.5",
|
|
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/messaging.js
CHANGED
|
@@ -212,39 +212,64 @@ export class EmailService {
|
|
|
212
212
|
this.templates = new EmailTemplatesService(sdk);
|
|
213
213
|
this.domains = new EmailDomainsService(sdk);
|
|
214
214
|
this.addresses = new EmailAddressesService(sdk);
|
|
215
|
+
this.analytics = new EmailAnalyticsService(sdk);
|
|
215
216
|
}
|
|
216
217
|
|
|
218
|
+
/**
|
|
219
|
+
* Send an email message
|
|
220
|
+
* @param {Object} params - Email parameters
|
|
221
|
+
* @param {string} params.from - Sender email address (required)
|
|
222
|
+
* @param {string|Array<string>} params.to - Recipient email address(es) (required)
|
|
223
|
+
* @param {string} params.subject - Email subject (required)
|
|
224
|
+
* @param {string|Array<string>} [params.cc] - CC recipients
|
|
225
|
+
* @param {string|Array<string>} [params.bcc] - BCC recipients
|
|
226
|
+
* @param {string} [params.html] - HTML email body
|
|
227
|
+
* @param {string} [params.text] - Plain text email body
|
|
228
|
+
* @param {string} [params.templateId] - Email template ID to use
|
|
229
|
+
* @param {Object} [params.variables] - Template variables for substitution
|
|
230
|
+
* @param {Array} [params.storageId] - Array of storage IDs for attachments
|
|
231
|
+
* @param {string} [params.replyTo] - Reply-to email address
|
|
232
|
+
* @param {string} [params.replyToEmailId] - ID of email this is replying to
|
|
233
|
+
* @param {string} [params.relatedId] - Related record ID
|
|
234
|
+
* @param {string} [params.emailType='marketing'] - Email type: 'marketing' or 'transactional'
|
|
235
|
+
* @param {boolean} [params.tracking=true] - Enable email tracking (opens, clicks)
|
|
236
|
+
* @returns {Promise<Object>} Email send result with ID
|
|
237
|
+
*/
|
|
217
238
|
async send({
|
|
218
239
|
from,
|
|
219
240
|
to,
|
|
220
241
|
cc,
|
|
221
242
|
bcc,
|
|
222
243
|
subject,
|
|
223
|
-
|
|
224
|
-
|
|
244
|
+
html,
|
|
245
|
+
text,
|
|
225
246
|
templateId,
|
|
226
247
|
variables,
|
|
227
|
-
|
|
248
|
+
storageId,
|
|
228
249
|
replyTo,
|
|
229
|
-
|
|
230
|
-
|
|
250
|
+
replyToEmailId,
|
|
251
|
+
relatedId,
|
|
252
|
+
emailType,
|
|
253
|
+
tracking,
|
|
231
254
|
}) {
|
|
232
255
|
this.sdk.validateParams(
|
|
233
256
|
{ from, to, subject },
|
|
234
257
|
{
|
|
235
258
|
from: { type: 'string', required: true },
|
|
236
|
-
to: { type: 'string', required: true },
|
|
259
|
+
to: { type: ['string', 'array'], required: true },
|
|
237
260
|
subject: { type: 'string', required: true },
|
|
238
|
-
cc: { type: 'string', required: false },
|
|
239
|
-
bcc: { type: 'string', required: false },
|
|
240
|
-
|
|
241
|
-
|
|
261
|
+
cc: { type: ['string', 'array'], required: false },
|
|
262
|
+
bcc: { type: ['string', 'array'], required: false },
|
|
263
|
+
html: { type: 'string', required: false },
|
|
264
|
+
text: { type: 'string', required: false },
|
|
242
265
|
templateId: { type: 'string', required: false },
|
|
243
266
|
variables: { type: 'object', required: false },
|
|
244
|
-
|
|
267
|
+
storageId: { type: 'array', required: false },
|
|
245
268
|
replyTo: { type: 'string', required: false },
|
|
246
|
-
|
|
247
|
-
|
|
269
|
+
replyToEmailId: { type: 'string', required: false },
|
|
270
|
+
relatedId: { type: 'string', required: false },
|
|
271
|
+
emailType: { type: 'string', required: false },
|
|
272
|
+
tracking: { type: 'boolean', required: false },
|
|
248
273
|
},
|
|
249
274
|
);
|
|
250
275
|
|
|
@@ -256,14 +281,16 @@ export class EmailService {
|
|
|
256
281
|
|
|
257
282
|
if (cc) emailData.cc = cc;
|
|
258
283
|
if (bcc) emailData.bcc = bcc;
|
|
259
|
-
if (
|
|
260
|
-
if (
|
|
284
|
+
if (html) emailData.html = html;
|
|
285
|
+
if (text) emailData.text = text;
|
|
261
286
|
if (templateId) emailData.templateId = templateId;
|
|
262
287
|
if (variables) emailData.variables = variables;
|
|
263
|
-
if (
|
|
288
|
+
if (storageId) emailData.storageId = storageId;
|
|
264
289
|
if (replyTo) emailData.replyTo = replyTo;
|
|
265
|
-
if (
|
|
266
|
-
if (
|
|
290
|
+
if (replyToEmailId) emailData.replyToEmailId = replyToEmailId;
|
|
291
|
+
if (relatedId) emailData.relatedId = relatedId;
|
|
292
|
+
if (emailType) emailData.emailType = emailType;
|
|
293
|
+
if (tracking !== undefined) emailData.tracking = tracking;
|
|
267
294
|
|
|
268
295
|
const options = {
|
|
269
296
|
body: emailData,
|
|
@@ -273,6 +300,11 @@ export class EmailService {
|
|
|
273
300
|
return result;
|
|
274
301
|
}
|
|
275
302
|
|
|
303
|
+
/**
|
|
304
|
+
* Get email message by ID
|
|
305
|
+
* @param {string} id - Email message ID (required)
|
|
306
|
+
* @returns {Promise<Object>} Email message details
|
|
307
|
+
*/
|
|
276
308
|
async get(id) {
|
|
277
309
|
this.sdk.validateParams(
|
|
278
310
|
{ id },
|
|
@@ -285,11 +317,19 @@ export class EmailService {
|
|
|
285
317
|
return result;
|
|
286
318
|
}
|
|
287
319
|
|
|
288
|
-
|
|
320
|
+
/**
|
|
321
|
+
* Update domain email settings
|
|
322
|
+
* @param {string} id - Domain ID (required)
|
|
323
|
+
* @param {Object} params - Update parameters
|
|
324
|
+
* @param {boolean} [params.dkimEnabled] - Enable DKIM signing
|
|
325
|
+
* @param {Object} [params.customDkim] - Custom DKIM configuration
|
|
326
|
+
* @returns {Promise<Object>} Updated domain details
|
|
327
|
+
*/
|
|
328
|
+
async updateDomain(id, { dkimEnabled, customDkim }) {
|
|
289
329
|
this.sdk.validateParams(
|
|
290
|
-
{
|
|
330
|
+
{ id },
|
|
291
331
|
{
|
|
292
|
-
|
|
332
|
+
id: { type: 'string', required: true },
|
|
293
333
|
dkimEnabled: { type: 'boolean', required: false },
|
|
294
334
|
customDkim: { type: 'object', required: false },
|
|
295
335
|
},
|
|
@@ -304,7 +344,7 @@ export class EmailService {
|
|
|
304
344
|
};
|
|
305
345
|
|
|
306
346
|
const result = await this.sdk._fetch(
|
|
307
|
-
`/messaging/email
|
|
347
|
+
`/messaging/email/${id}`,
|
|
308
348
|
'PUT',
|
|
309
349
|
options,
|
|
310
350
|
);
|
|
@@ -317,21 +357,31 @@ export class EmailTemplatesService {
|
|
|
317
357
|
this.sdk = sdk;
|
|
318
358
|
}
|
|
319
359
|
|
|
320
|
-
|
|
360
|
+
/**
|
|
361
|
+
* Create email template
|
|
362
|
+
* @param {Object} params - Template parameters
|
|
363
|
+
* @param {string} params.name - Template name (required)
|
|
364
|
+
* @param {string} params.subject - Template subject (required)
|
|
365
|
+
* @param {string} [params.html] - HTML template body
|
|
366
|
+
* @param {string} [params.text] - Plain text template body
|
|
367
|
+
* @param {Object} [params.variables] - Template variable definitions
|
|
368
|
+
* @returns {Promise<Object>} Created template details
|
|
369
|
+
*/
|
|
370
|
+
async create({ name, subject, html, text, variables }) {
|
|
321
371
|
this.sdk.validateParams(
|
|
322
372
|
{ name, subject },
|
|
323
373
|
{
|
|
324
374
|
name: { type: 'string', required: true },
|
|
325
375
|
subject: { type: 'string', required: true },
|
|
326
|
-
|
|
327
|
-
|
|
376
|
+
html: { type: 'string', required: false },
|
|
377
|
+
text: { type: 'string', required: false },
|
|
328
378
|
variables: { type: 'object', required: false },
|
|
329
379
|
},
|
|
330
380
|
);
|
|
331
381
|
|
|
332
382
|
const templateData = { name, subject };
|
|
333
|
-
if (
|
|
334
|
-
if (
|
|
383
|
+
if (html) templateData.html = html;
|
|
384
|
+
if (text) templateData.text = text;
|
|
335
385
|
if (variables) templateData.variables = variables;
|
|
336
386
|
|
|
337
387
|
const options = {
|
|
@@ -339,22 +389,33 @@ export class EmailTemplatesService {
|
|
|
339
389
|
};
|
|
340
390
|
|
|
341
391
|
const result = await this.sdk._fetch(
|
|
342
|
-
'/messaging/email/
|
|
392
|
+
'/messaging/email/template',
|
|
343
393
|
'POST',
|
|
344
394
|
options,
|
|
345
395
|
);
|
|
346
396
|
return result;
|
|
347
397
|
}
|
|
348
398
|
|
|
349
|
-
|
|
399
|
+
/**
|
|
400
|
+
* Update email template
|
|
401
|
+
* @param {string} id - Template ID (required)
|
|
402
|
+
* @param {Object} params - Update parameters
|
|
403
|
+
* @param {string} [params.name] - Template name
|
|
404
|
+
* @param {string} [params.subject] - Template subject
|
|
405
|
+
* @param {string} [params.html] - HTML template body
|
|
406
|
+
* @param {string} [params.text] - Plain text template body
|
|
407
|
+
* @param {Object} [params.variables] - Template variable definitions
|
|
408
|
+
* @returns {Promise<Object>} Updated template details
|
|
409
|
+
*/
|
|
410
|
+
async update(id, { name, subject, html, text, variables }) {
|
|
350
411
|
this.sdk.validateParams(
|
|
351
412
|
{ id },
|
|
352
413
|
{
|
|
353
414
|
id: { type: 'string', required: true },
|
|
354
415
|
name: { type: 'string', required: false },
|
|
355
416
|
subject: { type: 'string', required: false },
|
|
356
|
-
|
|
357
|
-
|
|
417
|
+
html: { type: 'string', required: false },
|
|
418
|
+
text: { type: 'string', required: false },
|
|
358
419
|
variables: { type: 'object', required: false },
|
|
359
420
|
},
|
|
360
421
|
);
|
|
@@ -362,8 +423,8 @@ export class EmailTemplatesService {
|
|
|
362
423
|
const updateData = {};
|
|
363
424
|
if (name) updateData.name = name;
|
|
364
425
|
if (subject) updateData.subject = subject;
|
|
365
|
-
if (
|
|
366
|
-
if (
|
|
426
|
+
if (html) updateData.html = html;
|
|
427
|
+
if (text) updateData.text = text;
|
|
367
428
|
if (variables) updateData.variables = variables;
|
|
368
429
|
|
|
369
430
|
const options = {
|
|
@@ -371,13 +432,18 @@ export class EmailTemplatesService {
|
|
|
371
432
|
};
|
|
372
433
|
|
|
373
434
|
const result = await this.sdk._fetch(
|
|
374
|
-
`/messaging/email/
|
|
435
|
+
`/messaging/email/template/${id}`,
|
|
375
436
|
'PUT',
|
|
376
437
|
options,
|
|
377
438
|
);
|
|
378
439
|
return result;
|
|
379
440
|
}
|
|
380
441
|
|
|
442
|
+
/**
|
|
443
|
+
* Delete email template
|
|
444
|
+
* @param {string} id - Template ID (required)
|
|
445
|
+
* @returns {Promise<Object>} Deletion confirmation
|
|
446
|
+
*/
|
|
381
447
|
async delete(id) {
|
|
382
448
|
this.sdk.validateParams(
|
|
383
449
|
{ id },
|
|
@@ -387,12 +453,17 @@ export class EmailTemplatesService {
|
|
|
387
453
|
);
|
|
388
454
|
|
|
389
455
|
const result = await this.sdk._fetch(
|
|
390
|
-
`/messaging/email/
|
|
456
|
+
`/messaging/email/template/${id}`,
|
|
391
457
|
'DELETE',
|
|
392
458
|
);
|
|
393
459
|
return result;
|
|
394
460
|
}
|
|
395
461
|
|
|
462
|
+
/**
|
|
463
|
+
* Get email template by ID
|
|
464
|
+
* @param {string} id - Template ID (required)
|
|
465
|
+
* @returns {Promise<Object>} Template details
|
|
466
|
+
*/
|
|
396
467
|
async get(id) {
|
|
397
468
|
this.sdk.validateParams(
|
|
398
469
|
{ id },
|
|
@@ -402,14 +473,18 @@ export class EmailTemplatesService {
|
|
|
402
473
|
);
|
|
403
474
|
|
|
404
475
|
const result = await this.sdk._fetch(
|
|
405
|
-
`/messaging/email/
|
|
476
|
+
`/messaging/email/template/${id}`,
|
|
406
477
|
'GET',
|
|
407
478
|
);
|
|
408
479
|
return result;
|
|
409
480
|
}
|
|
410
481
|
|
|
482
|
+
/**
|
|
483
|
+
* List all email templates
|
|
484
|
+
* @returns {Promise<Array>} List of email templates
|
|
485
|
+
*/
|
|
411
486
|
async list() {
|
|
412
|
-
const result = await this.sdk._fetch('/messaging/email/
|
|
487
|
+
const result = await this.sdk._fetch('/messaging/email/template', 'GET');
|
|
413
488
|
return result;
|
|
414
489
|
}
|
|
415
490
|
}
|
|
@@ -419,46 +494,159 @@ export class EmailDomainsService {
|
|
|
419
494
|
this.sdk = sdk;
|
|
420
495
|
}
|
|
421
496
|
|
|
422
|
-
|
|
497
|
+
/**
|
|
498
|
+
* Create domain verification
|
|
499
|
+
* @param {Object} params - Domain parameters
|
|
500
|
+
* @param {string} params.domain - Domain name (required)
|
|
501
|
+
* @param {string} [params.primaryRegion] - Primary AWS region
|
|
502
|
+
* @param {string} [params.secondaryRegion] - Secondary AWS region
|
|
503
|
+
* @param {string} [params.mailFromSubdomain='mail'] - Mail-from subdomain
|
|
504
|
+
* @returns {Promise<Object>} Created domain with DNS records to configure
|
|
505
|
+
*/
|
|
506
|
+
async create({ domain, primaryRegion, secondaryRegion, mailFromSubdomain }) {
|
|
423
507
|
this.sdk.validateParams(
|
|
424
508
|
{ domain },
|
|
425
509
|
{
|
|
426
510
|
domain: { type: 'string', required: true },
|
|
511
|
+
primaryRegion: { type: 'string', required: false },
|
|
512
|
+
secondaryRegion: { type: 'string', required: false },
|
|
513
|
+
mailFromSubdomain: { type: 'string', required: false },
|
|
427
514
|
},
|
|
428
515
|
);
|
|
429
516
|
|
|
517
|
+
const domainData = { domain };
|
|
518
|
+
if (primaryRegion) domainData.primaryRegion = primaryRegion;
|
|
519
|
+
if (secondaryRegion) domainData.secondaryRegion = secondaryRegion;
|
|
520
|
+
if (mailFromSubdomain) domainData.mailFromSubdomain = mailFromSubdomain;
|
|
521
|
+
|
|
430
522
|
const options = {
|
|
431
|
-
body:
|
|
523
|
+
body: domainData,
|
|
432
524
|
};
|
|
433
525
|
|
|
434
526
|
const result = await this.sdk._fetch(
|
|
435
|
-
'/messaging/email/
|
|
527
|
+
'/messaging/email/validate/domain',
|
|
436
528
|
'POST',
|
|
437
529
|
options,
|
|
438
530
|
);
|
|
439
531
|
return result;
|
|
440
532
|
}
|
|
441
533
|
|
|
442
|
-
|
|
534
|
+
/**
|
|
535
|
+
* Delete domain verification
|
|
536
|
+
* @param {string} domainId - Domain ID (required)
|
|
537
|
+
* @returns {Promise<Object>} Deletion confirmation
|
|
538
|
+
*/
|
|
539
|
+
async delete(domainId) {
|
|
443
540
|
this.sdk.validateParams(
|
|
444
|
-
{
|
|
541
|
+
{ domainId },
|
|
445
542
|
{
|
|
446
|
-
|
|
543
|
+
domainId: { type: 'string', required: true },
|
|
447
544
|
},
|
|
448
545
|
);
|
|
449
546
|
|
|
547
|
+
const options = {
|
|
548
|
+
body: { domainId },
|
|
549
|
+
};
|
|
550
|
+
|
|
450
551
|
const result = await this.sdk._fetch(
|
|
451
|
-
|
|
552
|
+
'/messaging/email/validate/domain',
|
|
452
553
|
'DELETE',
|
|
554
|
+
options,
|
|
453
555
|
);
|
|
454
556
|
return result;
|
|
455
557
|
}
|
|
456
558
|
|
|
559
|
+
/**
|
|
560
|
+
* List all verified domains
|
|
561
|
+
* @returns {Promise<Array>} List of verified domains with status, regions, and portal information
|
|
562
|
+
* @example
|
|
563
|
+
* // Returns array of domain objects:
|
|
564
|
+
* // {
|
|
565
|
+
* // id: 'domain-id',
|
|
566
|
+
* // domain: 'mydomain.com',
|
|
567
|
+
* // primaryRegion: 'us-east-1',
|
|
568
|
+
* // secondaryRegion: 'us-west-2',
|
|
569
|
+
* // primaryRegionStatus: 'active',
|
|
570
|
+
* // secondaryRegionStatus: 'active',
|
|
571
|
+
* // portalId: 'portal-id',
|
|
572
|
+
* // portalName: 'My Portal',
|
|
573
|
+
* // recordTypeId: 'record-type-id',
|
|
574
|
+
* // isDeleted: false,
|
|
575
|
+
* // createdAt: '2023-...'
|
|
576
|
+
* // }
|
|
577
|
+
*/
|
|
457
578
|
async list() {
|
|
458
|
-
const result = await this.sdk._fetch('/messaging/email/
|
|
579
|
+
const result = await this.sdk._fetch('/messaging/email/validate/domain', 'GET');
|
|
459
580
|
return result;
|
|
460
581
|
}
|
|
461
582
|
|
|
583
|
+
/**
|
|
584
|
+
* Get domain details by ID including DNS configuration
|
|
585
|
+
* @param {string} domainId - Domain ID (required)
|
|
586
|
+
* @returns {Promise<Object>} Domain details with DNS records to configure
|
|
587
|
+
* @example
|
|
588
|
+
* // Returns domain object with DNS records:
|
|
589
|
+
* // {
|
|
590
|
+
* // id: 'domain-id',
|
|
591
|
+
* // domain: 'mydomain.com',
|
|
592
|
+
* // primaryRegion: 'us-east-1',
|
|
593
|
+
* // secondaryRegion: 'us-west-2',
|
|
594
|
+
* // primaryRegionStatus: 'active',
|
|
595
|
+
* // secondaryRegionStatus: 'active',
|
|
596
|
+
* // mailFrom: 'mail.mydomain.com',
|
|
597
|
+
* // portalId: 'portal-id',
|
|
598
|
+
* // portalName: 'My Portal',
|
|
599
|
+
* // brandId: 'brand-id',
|
|
600
|
+
* // recordTypeId: 'record-type-id',
|
|
601
|
+
* // createdAt: '2023-...',
|
|
602
|
+
* // dns: [
|
|
603
|
+
* // {
|
|
604
|
+
* // type: 'CNAME',
|
|
605
|
+
* // name: 'domainid._domainkey.mydomain.com',
|
|
606
|
+
* // value: 'domainid.dkim.example.com',
|
|
607
|
+
* // description: 'DKIM signature verification'
|
|
608
|
+
* // },
|
|
609
|
+
* // {
|
|
610
|
+
* // type: 'CNAME',
|
|
611
|
+
* // name: 'mail.mydomain.com',
|
|
612
|
+
* // value: 'mail.ses.amazonaws.com',
|
|
613
|
+
* // description: 'MAIL FROM domain routing'
|
|
614
|
+
* // },
|
|
615
|
+
* // {
|
|
616
|
+
* // type: 'TXT',
|
|
617
|
+
* // name: 'mydomain.com',
|
|
618
|
+
* // value: '"v=spf1 include:mail.mydomain.com ~all"',
|
|
619
|
+
* // description: 'SPF record for email authentication'
|
|
620
|
+
* // },
|
|
621
|
+
* // {
|
|
622
|
+
* // type: 'TXT',
|
|
623
|
+
* // name: '_dmarc.mydomain.com',
|
|
624
|
+
* // value: '"v=DMARC1; p=quarantine; rua=mailto:dmarc@...',
|
|
625
|
+
* // description: 'DMARC policy for email authentication and reporting'
|
|
626
|
+
* // }
|
|
627
|
+
* // ]
|
|
628
|
+
* // }
|
|
629
|
+
*/
|
|
630
|
+
async get(domainId) {
|
|
631
|
+
this.sdk.validateParams(
|
|
632
|
+
{ domainId },
|
|
633
|
+
{
|
|
634
|
+
domainId: { type: 'string', required: true },
|
|
635
|
+
},
|
|
636
|
+
);
|
|
637
|
+
|
|
638
|
+
const result = await this.sdk._fetch(
|
|
639
|
+
`/messaging/email/validate/domain/${domainId}`,
|
|
640
|
+
'GET',
|
|
641
|
+
);
|
|
642
|
+
return result;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
/**
|
|
646
|
+
* Validate DNS records for domain
|
|
647
|
+
* @param {string} domain - Domain name (required)
|
|
648
|
+
* @returns {Promise<Object>} DNS validation results
|
|
649
|
+
*/
|
|
462
650
|
async validateDns(domain) {
|
|
463
651
|
this.sdk.validateParams(
|
|
464
652
|
{ domain },
|
|
@@ -467,13 +655,23 @@ export class EmailDomainsService {
|
|
|
467
655
|
},
|
|
468
656
|
);
|
|
469
657
|
|
|
658
|
+
const options = {
|
|
659
|
+
query: { domain },
|
|
660
|
+
};
|
|
661
|
+
|
|
470
662
|
const result = await this.sdk._fetch(
|
|
471
|
-
|
|
472
|
-
'
|
|
663
|
+
'/messaging/email/validate/domain/dns',
|
|
664
|
+
'GET',
|
|
665
|
+
options,
|
|
473
666
|
);
|
|
474
667
|
return result;
|
|
475
668
|
}
|
|
476
669
|
|
|
670
|
+
/**
|
|
671
|
+
* Check domain verification status
|
|
672
|
+
* @param {string} domain - Domain name (required)
|
|
673
|
+
* @returns {Promise<Object>} Domain verification status
|
|
674
|
+
*/
|
|
477
675
|
async checkStatus(domain) {
|
|
478
676
|
this.sdk.validateParams(
|
|
479
677
|
{ domain },
|
|
@@ -482,24 +680,43 @@ export class EmailDomainsService {
|
|
|
482
680
|
},
|
|
483
681
|
);
|
|
484
682
|
|
|
683
|
+
const options = {
|
|
684
|
+
query: { domain },
|
|
685
|
+
};
|
|
686
|
+
|
|
485
687
|
const result = await this.sdk._fetch(
|
|
486
|
-
|
|
688
|
+
'/messaging/email/validate/domain/status',
|
|
487
689
|
'GET',
|
|
690
|
+
options,
|
|
488
691
|
);
|
|
489
692
|
return result;
|
|
490
693
|
}
|
|
491
694
|
|
|
492
|
-
|
|
695
|
+
/**
|
|
696
|
+
* Update domain settings
|
|
697
|
+
* @param {Object} params - Update parameters
|
|
698
|
+
* @param {string} params.domainId - Domain ID (required)
|
|
699
|
+
* @param {string} [params.primaryRegion] - Primary AWS region
|
|
700
|
+
* @param {string} [params.secondaryRegion] - Secondary AWS region
|
|
701
|
+
* @param {boolean} [params.dkimEnabled] - Enable DKIM signing
|
|
702
|
+
* @param {Object} [params.customDkim] - Custom DKIM configuration
|
|
703
|
+
* @returns {Promise<Object>} Updated domain details
|
|
704
|
+
*/
|
|
705
|
+
async update({ domainId, primaryRegion, secondaryRegion, dkimEnabled, customDkim }) {
|
|
493
706
|
this.sdk.validateParams(
|
|
494
|
-
{
|
|
707
|
+
{ domainId },
|
|
495
708
|
{
|
|
496
|
-
|
|
709
|
+
domainId: { type: 'string', required: true },
|
|
710
|
+
primaryRegion: { type: 'string', required: false },
|
|
711
|
+
secondaryRegion: { type: 'string', required: false },
|
|
497
712
|
dkimEnabled: { type: 'boolean', required: false },
|
|
498
713
|
customDkim: { type: 'object', required: false },
|
|
499
714
|
},
|
|
500
715
|
);
|
|
501
716
|
|
|
502
|
-
const updateData = {};
|
|
717
|
+
const updateData = { domainId };
|
|
718
|
+
if (primaryRegion) updateData.primaryRegion = primaryRegion;
|
|
719
|
+
if (secondaryRegion) updateData.secondaryRegion = secondaryRegion;
|
|
503
720
|
if (dkimEnabled !== undefined) updateData.dkimEnabled = dkimEnabled;
|
|
504
721
|
if (customDkim) updateData.customDkim = customDkim;
|
|
505
722
|
|
|
@@ -508,7 +725,7 @@ export class EmailDomainsService {
|
|
|
508
725
|
};
|
|
509
726
|
|
|
510
727
|
const result = await this.sdk._fetch(
|
|
511
|
-
|
|
728
|
+
'/messaging/email/validate/domain',
|
|
512
729
|
'PUT',
|
|
513
730
|
options,
|
|
514
731
|
);
|
|
@@ -521,57 +738,81 @@ export class EmailAddressesService {
|
|
|
521
738
|
this.sdk = sdk;
|
|
522
739
|
}
|
|
523
740
|
|
|
524
|
-
|
|
741
|
+
/**
|
|
742
|
+
* Create email address verification
|
|
743
|
+
* @param {string} emailAddress - Email address to verify (required)
|
|
744
|
+
* @returns {Promise<Object>} Email verification details
|
|
745
|
+
*/
|
|
746
|
+
async create(emailAddress) {
|
|
525
747
|
this.sdk.validateParams(
|
|
526
|
-
{
|
|
748
|
+
{ emailAddress },
|
|
527
749
|
{
|
|
528
|
-
|
|
750
|
+
emailAddress: { type: 'string', required: true },
|
|
529
751
|
},
|
|
530
752
|
);
|
|
531
753
|
|
|
532
754
|
const options = {
|
|
533
|
-
body: {
|
|
755
|
+
body: { emailAddress },
|
|
534
756
|
};
|
|
535
757
|
|
|
536
758
|
const result = await this.sdk._fetch(
|
|
537
|
-
'/messaging/email/
|
|
759
|
+
'/messaging/email/validate/emailAddress',
|
|
538
760
|
'POST',
|
|
539
761
|
options,
|
|
540
762
|
);
|
|
541
763
|
return result;
|
|
542
764
|
}
|
|
543
765
|
|
|
544
|
-
|
|
766
|
+
/**
|
|
767
|
+
* Delete email address verification
|
|
768
|
+
* @param {string} emailAddress - Email address to remove (required)
|
|
769
|
+
* @returns {Promise<Object>} Deletion confirmation
|
|
770
|
+
*/
|
|
771
|
+
async delete(emailAddress) {
|
|
545
772
|
this.sdk.validateParams(
|
|
546
|
-
{
|
|
773
|
+
{ emailAddress },
|
|
547
774
|
{
|
|
548
|
-
|
|
775
|
+
emailAddress: { type: 'string', required: true },
|
|
549
776
|
},
|
|
550
777
|
);
|
|
551
778
|
|
|
552
779
|
const result = await this.sdk._fetch(
|
|
553
|
-
`/messaging/email/
|
|
780
|
+
`/messaging/email/validate/emailAddress/${encodeURIComponent(emailAddress)}`,
|
|
554
781
|
'DELETE',
|
|
555
782
|
);
|
|
556
783
|
return result;
|
|
557
784
|
}
|
|
558
785
|
|
|
786
|
+
/**
|
|
787
|
+
* List all verified email addresses
|
|
788
|
+
* @returns {Promise<Array>} List of verified email addresses
|
|
789
|
+
*/
|
|
559
790
|
async list() {
|
|
560
|
-
const result = await this.sdk._fetch('/messaging/email/
|
|
791
|
+
const result = await this.sdk._fetch('/messaging/email/validate/emailAddress', 'GET');
|
|
561
792
|
return result;
|
|
562
793
|
}
|
|
563
794
|
|
|
564
|
-
|
|
795
|
+
/**
|
|
796
|
+
* Check email address verification status
|
|
797
|
+
* @param {string} emailAddress - Email address to check (required)
|
|
798
|
+
* @returns {Promise<Object>} Email verification status
|
|
799
|
+
*/
|
|
800
|
+
async checkStatus(emailAddress) {
|
|
565
801
|
this.sdk.validateParams(
|
|
566
|
-
{
|
|
802
|
+
{ emailAddress },
|
|
567
803
|
{
|
|
568
|
-
|
|
804
|
+
emailAddress: { type: 'string', required: true },
|
|
569
805
|
},
|
|
570
806
|
);
|
|
571
807
|
|
|
808
|
+
const options = {
|
|
809
|
+
query: { emailAddress },
|
|
810
|
+
};
|
|
811
|
+
|
|
572
812
|
const result = await this.sdk._fetch(
|
|
573
|
-
|
|
813
|
+
'/messaging/email/validate/emailAddress/status',
|
|
574
814
|
'GET',
|
|
815
|
+
options,
|
|
575
816
|
);
|
|
576
817
|
return result;
|
|
577
818
|
}
|
|
@@ -1668,3 +1909,78 @@ export class TenDlcCampaignManagementService {
|
|
|
1668
1909
|
return result;
|
|
1669
1910
|
}
|
|
1670
1911
|
}
|
|
1912
|
+
|
|
1913
|
+
export class EmailAnalyticsService {
|
|
1914
|
+
constructor(sdk) {
|
|
1915
|
+
this.sdk = sdk;
|
|
1916
|
+
}
|
|
1917
|
+
|
|
1918
|
+
/**
|
|
1919
|
+
* Get email queue time series analytics
|
|
1920
|
+
* @param {Object} [params] - Analytics parameters
|
|
1921
|
+
* @param {string} [params.period='24h'] - Time period: '1h', '6h', '24h', '7d', '30d'
|
|
1922
|
+
* @param {string} [params.granularity='hour'] - Data granularity: 'minute', 'hour', 'day'
|
|
1923
|
+
* @returns {Promise<Object>} Time series data with summary statistics
|
|
1924
|
+
* @example
|
|
1925
|
+
* // Get hourly analytics for last 24 hours
|
|
1926
|
+
* const analytics = await sdk.messaging.email.analytics.timeSeries({ period: '24h', granularity: 'hour' });
|
|
1927
|
+
* // Returns: { period, granularity, data: [{ timestamp, sent, delivered, failed, queued }], summary }
|
|
1928
|
+
*/
|
|
1929
|
+
async timeSeries({ period, granularity } = {}) {
|
|
1930
|
+
const options = { query: {} };
|
|
1931
|
+
if (period) options.query.period = period;
|
|
1932
|
+
if (granularity) options.query.granularity = granularity;
|
|
1933
|
+
|
|
1934
|
+
const result = await this.sdk._fetch('/messaging/email/analytics/timeseries', 'GET', options);
|
|
1935
|
+
return result;
|
|
1936
|
+
}
|
|
1937
|
+
|
|
1938
|
+
/**
|
|
1939
|
+
* Get email queue summary statistics
|
|
1940
|
+
* @param {Object} [params] - Summary parameters
|
|
1941
|
+
* @param {string} [params.period='24h'] - Time period: '1h', '6h', '24h', '7d', '30d'
|
|
1942
|
+
* @returns {Promise<Object>} Summary statistics
|
|
1943
|
+
* @example
|
|
1944
|
+
* // Get summary stats for last 24 hours
|
|
1945
|
+
* const summary = await sdk.messaging.email.analytics.summary({ period: '24h' });
|
|
1946
|
+
* // Returns: { totalSent, deliveryRate, errorRate, avgEmailsPerMinute, avgProcessingSeconds }
|
|
1947
|
+
*/
|
|
1948
|
+
async summary({ period } = {}) {
|
|
1949
|
+
const options = { query: {} };
|
|
1950
|
+
if (period) options.query.period = period;
|
|
1951
|
+
|
|
1952
|
+
const result = await this.sdk._fetch('/messaging/email/analytics/summary', 'GET', options);
|
|
1953
|
+
return result;
|
|
1954
|
+
}
|
|
1955
|
+
|
|
1956
|
+
/**
|
|
1957
|
+
* Get real-time email queue metrics
|
|
1958
|
+
* @returns {Promise<Object>} Real-time queue statistics
|
|
1959
|
+
* @example
|
|
1960
|
+
* // Get current queue status
|
|
1961
|
+
* const realtime = await sdk.messaging.email.analytics.realtime();
|
|
1962
|
+
* // Returns: { queueDepth, currentSendRatePerMinute, last5Minutes: { sent, delivered, failed } }
|
|
1963
|
+
*/
|
|
1964
|
+
async realtime() {
|
|
1965
|
+
const result = await this.sdk._fetch('/messaging/email/analytics/realtime', 'GET');
|
|
1966
|
+
return result;
|
|
1967
|
+
}
|
|
1968
|
+
|
|
1969
|
+
/**
|
|
1970
|
+
* Get email error analysis by domain
|
|
1971
|
+
* @param {Object} [params] - Error analysis parameters
|
|
1972
|
+
* @param {string} [params.period='7d'] - Time period: '24h', '7d', '30d'
|
|
1973
|
+
* @returns {Promise<Object>} Error analysis with domain breakdown
|
|
1974
|
+
* @example
|
|
1975
|
+
* // Get error analysis for last 7 days
|
|
1976
|
+
* const errors = await sdk.messaging.email.analytics.errors({ period: '7d' });
|
|
1977
|
+
* // Returns: { overallErrorRate, topErrorDomains: [{ domain, errorRate, totalErrors }] }
|
|
1978
|
+
*/
|
|
1979
|
+
async errors({ period } = {}) {
|
|
1980
|
+
const options = { query: {} };
|
|
1981
|
+
if (period) options.query.period = period;
|
|
1982
|
+
|
|
1983
|
+
const result = await this.sdk._fetch('/messaging/email/analytics/errors', 'GET', options);
|
|
1984
|
+
return result;
|
|
1985
|
+
}
|
|
1986
|
+
}
|