@unboundcx/sdk 2.7.7 → 2.8.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.
@@ -1,2100 +1,37 @@
1
- export class MessagingService {
2
- constructor(sdk) {
3
- this.sdk = sdk;
4
- this.sms = new SmsService(sdk);
5
- this.email = new EmailService(sdk);
6
- this.campaigns = new CampaignsService(sdk);
7
- }
8
- }
9
-
10
- export class SmsService {
11
- constructor(sdk) {
12
- this.sdk = sdk;
13
- this.templates = new SmsTemplatesService(sdk);
14
- }
15
-
16
- /**
17
- * Send an SMS/MMS message
18
- * @param {Object} params - Message parameters
19
- * @param {string} params.to - Recipient phone number (required)
20
- * @param {string} [params.from] - Sender phone number
21
- * @param {string} [params.message] - Message text
22
- * @param {string} [params.templateId] - Template ID to use
23
- * @param {Object} [params.variables] - Template variables
24
- * @param {Array<string>} [params.mediaUrls] - Media URLs for MMS
25
- * @param {string} [params.webhookUrl] - Webhook URL for delivery status
26
- * @returns {Promise<Object>} Message details
27
- */
28
- async send({
29
- from,
30
- to,
31
- message,
32
- templateId,
33
- variables,
34
- mediaUrls,
35
- webhookUrl,
36
- }) {
37
- const messageData = {};
38
- if (from) messageData.from = from;
39
- if (message) messageData.message = message;
40
- if (templateId) messageData.templateId = templateId;
41
- if (variables) messageData.variables = variables;
42
- if (mediaUrls) messageData.mediaUrls = mediaUrls;
43
- if (webhookUrl) messageData.webhookUrl = webhookUrl;
44
-
45
- this.sdk.validateParams(
46
- { to, ...messageData },
47
- {
48
- to: { type: 'string', required: true },
49
- from: { type: 'string', required: false },
50
- message: { type: 'string', required: false },
51
- templateId: { type: 'string', required: false },
52
- variables: { type: 'object', required: false },
53
- mediaUrls: { type: 'array', required: false },
54
- webhookUrl: { type: 'string', required: false },
55
- },
56
- );
57
-
58
- const options = {
59
- body: { to, ...messageData },
60
- };
61
-
62
- const result = await this.sdk._fetch('/messaging/sms', 'POST', options);
63
- return result;
64
- }
65
-
66
- /**
67
- * Get SMS/MMS message by ID
68
- * @param {string} id - Message ID
69
- * @returns {Promise<Object>} Message details
70
- */
71
- async get(id) {
72
- this.sdk.validateParams(
73
- { id },
74
- {
75
- id: { type: 'string', required: true },
76
- },
77
- );
78
-
79
- const result = await this.sdk._fetch(`/messaging/sms/${id}`, 'GET');
80
- return result;
81
- }
82
- }
83
-
84
- export class SmsTemplatesService {
85
- constructor(sdk) {
86
- this.sdk = sdk;
87
- }
88
-
89
- /**
90
- * Create SMS template
91
- * @param {Object} params - Template parameters
92
- * @param {string} params.name - Template name (required)
93
- * @param {string} params.message - Template message (required)
94
- * @param {Object} [params.variables] - Template variables
95
- * @returns {Promise<Object>} Created template details
96
- */
97
- async create({ name, message, variables }) {
98
- this.sdk.validateParams(
99
- { name, message },
100
- {
101
- name: { type: 'string', required: true },
102
- message: { type: 'string', required: true },
103
- variables: { type: 'object', required: false },
104
- },
105
- );
106
-
107
- const templateData = { name, message };
108
- if (variables) templateData.variables = variables;
109
-
110
- const options = {
111
- body: templateData,
112
- };
113
-
114
- const result = await this.sdk._fetch(
115
- '/messaging/sms/templates',
116
- 'POST',
117
- options,
118
- );
119
- return result;
120
- }
121
-
122
- /**
123
- * Update SMS template
124
- * @param {string} id - Template ID
125
- * @param {Object} params - Update parameters
126
- * @param {string} [params.name] - Template name
127
- * @param {string} [params.message] - Template message
128
- * @param {Object} [params.variables] - Template variables
129
- * @returns {Promise<Object>} Updated template details
130
- */
131
- async update(id, { name, message, variables }) {
132
- this.sdk.validateParams(
133
- { id },
134
- {
135
- id: { type: 'string', required: true },
136
- name: { type: 'string', required: false },
137
- message: { type: 'string', required: false },
138
- variables: { type: 'object', required: false },
139
- },
140
- );
141
-
142
- const updateData = {};
143
- if (name) updateData.name = name;
144
- if (message) updateData.message = message;
145
- if (variables) updateData.variables = variables;
146
-
147
- const options = {
148
- body: updateData,
149
- };
150
-
151
- const result = await this.sdk._fetch(
152
- `/messaging/sms/templates/${id}`,
153
- 'PUT',
154
- options,
155
- );
156
- return result;
157
- }
158
-
159
- /**
160
- * Delete SMS template
161
- * @param {string} id - Template ID
162
- * @returns {Promise<Object>} Deletion result
163
- */
164
- async delete(id) {
165
- this.sdk.validateParams(
166
- { id },
167
- {
168
- id: { type: 'string', required: true },
169
- },
170
- );
171
-
172
- const result = await this.sdk._fetch(
173
- `/messaging/sms/templates/${id}`,
174
- 'DELETE',
175
- );
176
- return result;
177
- }
178
-
179
- /**
180
- * Get SMS template by ID
181
- * @param {string} id - Template ID
182
- * @returns {Promise<Object>} Template details
183
- */
184
- async get(id) {
185
- this.sdk.validateParams(
186
- { id },
187
- {
188
- id: { type: 'string', required: true },
189
- },
190
- );
191
-
192
- const result = await this.sdk._fetch(
193
- `/messaging/sms/templates/${id}`,
194
- 'GET',
195
- );
196
- return result;
197
- }
198
-
199
- /**
200
- * List all SMS templates
201
- * @returns {Promise<Array>} List of templates
202
- */
203
- async list() {
204
- const result = await this.sdk._fetch('/messaging/sms/templates', 'GET');
205
- return result;
206
- }
207
- }
208
-
209
- export class EmailService {
210
- constructor(sdk) {
211
- this.sdk = sdk;
212
- this.templates = new EmailTemplatesService(sdk);
213
- this.domains = new EmailDomainsService(sdk);
214
- this.addresses = new EmailAddressesService(sdk);
215
- this.analytics = new EmailAnalyticsService(sdk);
216
- this.queue = new EmailQueueService(sdk);
217
- }
218
-
219
- /**
220
- * Send an email message
221
- * @param {Object} params - Email parameters
222
- * @param {string} params.from - Sender email address (required)
223
- * @param {string|Array<string>} params.to - Recipient email address(es) (required)
224
- * @param {string} params.subject - Email subject (required)
225
- * @param {string|Array<string>} [params.cc] - CC recipients
226
- * @param {string|Array<string>} [params.bcc] - BCC recipients
227
- * @param {string} [params.html] - HTML email body
228
- * @param {string} [params.text] - Plain text email body
229
- * @param {string} [params.templateId] - Email template ID to use
230
- * @param {Object} [params.variables] - Template variables for substitution
231
- * @param {Array} [params.storageId] - Array of storage IDs for attachments
232
- * @param {string} [params.replyTo] - Reply-to email address
233
- * @param {string} [params.replyToEmailId] - ID of email this is replying to
234
- * @param {string} [params.relatedId] - Related record ID
235
- * @param {string} [params.emailType='marketing'] - Email type: 'marketing' or 'transactional'
236
- * @param {boolean} [params.tracking=true] - Enable email tracking (opens, clicks)
237
- * @returns {Promise<Object>} Email send result with ID
238
- */
239
- async send({
240
- from,
241
- to,
242
- cc,
243
- bcc,
244
- subject,
245
- html,
246
- text,
247
- templateId,
248
- variables,
249
- storageId,
250
- replyTo,
251
- replyToEmailId,
252
- relatedId,
253
- emailType,
254
- tracking,
255
- }) {
256
- this.sdk.validateParams(
257
- { from, to, subject },
258
- {
259
- from: { type: 'string', required: true },
260
- to: { type: ['string', 'array'], required: true },
261
- subject: { type: 'string', required: true },
262
- cc: { type: ['string', 'array'], required: false },
263
- bcc: { type: ['string', 'array'], required: false },
264
- html: { type: 'string', required: false },
265
- text: { type: 'string', required: false },
266
- templateId: { type: 'string', required: false },
267
- variables: { type: 'object', required: false },
268
- storageId: { type: 'array', required: false },
269
- replyTo: { type: 'string', required: false },
270
- replyToEmailId: { type: 'string', required: false },
271
- relatedId: { type: 'string', required: false },
272
- emailType: { type: 'string', required: false },
273
- tracking: { type: 'boolean', required: false },
274
- },
275
- );
276
-
277
- const emailData = {
278
- from,
279
- to,
280
- subject,
281
- };
282
-
283
- if (cc) emailData.cc = cc;
284
- if (bcc) emailData.bcc = bcc;
285
- if (html) emailData.html = html;
286
- if (text) emailData.text = text;
287
- if (templateId) emailData.templateId = templateId;
288
- if (variables) emailData.variables = variables;
289
- if (storageId) emailData.storageId = storageId;
290
- if (replyTo) emailData.replyTo = replyTo;
291
- if (replyToEmailId) emailData.replyToEmailId = replyToEmailId;
292
- if (relatedId) emailData.relatedId = relatedId;
293
- if (emailType) emailData.emailType = emailType;
294
- if (tracking !== undefined) emailData.tracking = tracking;
295
-
296
- const options = {
297
- body: emailData,
298
- };
299
-
300
- const result = await this.sdk._fetch('/messaging/email', 'POST', options);
301
- return result;
302
- }
303
-
304
- /**
305
- * Get email message by ID
306
- * @param {string} id - Email message ID (required)
307
- * @returns {Promise<Object>} Email message details
308
- */
309
- async get(id) {
310
- this.sdk.validateParams(
311
- { id },
312
- {
313
- id: { type: 'string', required: true },
314
- },
315
- );
316
-
317
- const result = await this.sdk._fetch(`/messaging/email/${id}`, 'GET');
318
- return result;
319
- }
320
-
321
- /**
322
- * Update domain email settings
323
- * @param {string} id - Domain ID (required)
324
- * @param {Object} params - Update parameters
325
- * @param {boolean} [params.dkimEnabled] - Enable DKIM signing
326
- * @param {Object} [params.customDkim] - Custom DKIM configuration
327
- * @returns {Promise<Object>} Updated domain details
328
- */
329
- async updateDomain(id, { dkimEnabled, customDkim }) {
330
- this.sdk.validateParams(
331
- { id },
332
- {
333
- id: { type: 'string', required: true },
334
- dkimEnabled: { type: 'boolean', required: false },
335
- customDkim: { type: 'object', required: false },
336
- },
337
- );
338
-
339
- const updateData = {};
340
- if (dkimEnabled !== undefined) updateData.dkimEnabled = dkimEnabled;
341
- if (customDkim) updateData.customDkim = customDkim;
342
-
343
- const options = {
344
- body: updateData,
345
- };
346
-
347
- const result = await this.sdk._fetch(
348
- `/messaging/email/${id}`,
349
- 'PUT',
350
- options,
351
- );
352
- return result;
353
- }
354
- }
355
-
356
- export class EmailTemplatesService {
357
- constructor(sdk) {
358
- this.sdk = sdk;
359
- }
360
-
361
- /**
362
- * Create email template
363
- * @param {Object} params - Template parameters
364
- * @param {string} params.name - Template name (required)
365
- * @param {string} params.subject - Template subject (required)
366
- * @param {string} [params.html] - HTML template body
367
- * @param {string} [params.text] - Plain text template body
368
- * @param {Object} [params.variables] - Template variable definitions
369
- * @returns {Promise<Object>} Created template details
370
- */
371
- async create({ name, subject, html, text, variables }) {
372
- this.sdk.validateParams(
373
- { name, subject },
374
- {
375
- name: { type: 'string', required: true },
376
- subject: { type: 'string', required: true },
377
- html: { type: 'string', required: false },
378
- text: { type: 'string', required: false },
379
- variables: { type: 'object', required: false },
380
- },
381
- );
382
-
383
- const templateData = { name, subject };
384
- if (html) templateData.html = html;
385
- if (text) templateData.text = text;
386
- if (variables) templateData.variables = variables;
387
-
388
- const options = {
389
- body: templateData,
390
- };
391
-
392
- const result = await this.sdk._fetch(
393
- '/messaging/email/template',
394
- 'POST',
395
- options,
396
- );
397
- return result;
398
- }
399
-
400
- /**
401
- * Update email template
402
- * @param {string} id - Template ID (required)
403
- * @param {Object} params - Update parameters
404
- * @param {string} [params.name] - Template name
405
- * @param {string} [params.subject] - Template subject
406
- * @param {string} [params.html] - HTML template body
407
- * @param {string} [params.text] - Plain text template body
408
- * @param {Object} [params.variables] - Template variable definitions
409
- * @returns {Promise<Object>} Updated template details
410
- */
411
- async update(id, { name, subject, html, text, variables }) {
412
- this.sdk.validateParams(
413
- { id },
414
- {
415
- id: { type: 'string', required: true },
416
- name: { type: 'string', required: false },
417
- subject: { type: 'string', required: false },
418
- html: { type: 'string', required: false },
419
- text: { type: 'string', required: false },
420
- variables: { type: 'object', required: false },
421
- },
422
- );
423
-
424
- const updateData = {};
425
- if (name) updateData.name = name;
426
- if (subject) updateData.subject = subject;
427
- if (html) updateData.html = html;
428
- if (text) updateData.text = text;
429
- if (variables) updateData.variables = variables;
430
-
431
- const options = {
432
- body: updateData,
433
- };
434
-
435
- const result = await this.sdk._fetch(
436
- `/messaging/email/template/${id}`,
437
- 'PUT',
438
- options,
439
- );
440
- return result;
441
- }
442
-
443
- /**
444
- * Delete email template
445
- * @param {string} id - Template ID (required)
446
- * @returns {Promise<Object>} Deletion confirmation
447
- */
448
- async delete(id) {
449
- this.sdk.validateParams(
450
- { id },
451
- {
452
- id: { type: 'string', required: true },
453
- },
454
- );
455
-
456
- const result = await this.sdk._fetch(
457
- `/messaging/email/template/${id}`,
458
- 'DELETE',
459
- );
460
- return result;
461
- }
462
-
463
- /**
464
- * Get email template by ID
465
- * @param {string} id - Template ID (required)
466
- * @returns {Promise<Object>} Template details
467
- */
468
- async get(id) {
469
- this.sdk.validateParams(
470
- { id },
471
- {
472
- id: { type: 'string', required: true },
473
- },
474
- );
475
-
476
- const result = await this.sdk._fetch(
477
- `/messaging/email/template/${id}`,
478
- 'GET',
479
- );
480
- return result;
481
- }
482
-
483
- /**
484
- * List all email templates
485
- * @returns {Promise<Array>} List of email templates
486
- */
487
- async list() {
488
- const result = await this.sdk._fetch('/messaging/email/template', 'GET');
489
- return result;
490
- }
491
- }
492
-
493
- export class EmailDomainsService {
494
- constructor(sdk) {
495
- this.sdk = sdk;
496
- }
497
-
498
- /**
499
- * Create domain verification
500
- * @param {Object} params - Domain parameters
501
- * @param {string} params.domain - Domain name (required)
502
- * @param {string} [params.primaryRegion] - Primary AWS region
503
- * @param {string} [params.secondaryRegion] - Secondary AWS region
504
- * @param {string} [params.mailFromSubdomain='mail'] - Mail-from subdomain
505
- * @returns {Promise<Object>} Created domain with DNS records to configure
506
- */
507
- async create({ domain, primaryRegion, secondaryRegion, mailFromSubdomain }) {
508
- this.sdk.validateParams(
509
- { domain },
510
- {
511
- domain: { type: 'string', required: true },
512
- primaryRegion: { type: 'string', required: false },
513
- secondaryRegion: { type: 'string', required: false },
514
- mailFromSubdomain: { type: 'string', required: false },
515
- },
516
- );
517
-
518
- const domainData = { domain };
519
- if (primaryRegion) domainData.primaryRegion = primaryRegion;
520
- if (secondaryRegion) domainData.secondaryRegion = secondaryRegion;
521
- if (mailFromSubdomain) domainData.mailFromSubdomain = mailFromSubdomain;
522
-
523
- const options = {
524
- body: domainData,
525
- };
526
-
527
- const result = await this.sdk._fetch(
528
- '/messaging/email/validate/domain',
529
- 'POST',
530
- options,
531
- );
532
- return result;
533
- }
534
-
535
- /**
536
- * Delete domain verification
537
- * @param {string} domainId - Domain ID (required)
538
- * @returns {Promise<Object>} Deletion confirmation
539
- */
540
- async delete(domainId) {
541
- this.sdk.validateParams(
542
- { domainId },
543
- {
544
- domainId: { type: 'string', required: true },
545
- },
546
- );
547
-
548
- const options = {
549
- body: { domainId },
550
- };
551
-
552
- const result = await this.sdk._fetch(
553
- '/messaging/email/validate/domain',
554
- 'DELETE',
555
- options,
556
- );
557
- return result;
558
- }
559
-
560
- /**
561
- * List all verified domains
562
- * @returns {Promise<Array>} List of verified domains with status, regions, and portal information
563
- * @example
564
- * // Returns array of domain objects:
565
- * // {
566
- * // id: 'domain-id',
567
- * // domain: 'mydomain.com',
568
- * // primaryRegion: 'us-east-1',
569
- * // secondaryRegion: 'us-west-2',
570
- * // primaryRegionStatus: 'active',
571
- * // secondaryRegionStatus: 'active',
572
- * // portalId: 'portal-id',
573
- * // portalName: 'My Portal',
574
- * // recordTypeId: 'record-type-id',
575
- * // isDeleted: false,
576
- * // createdAt: '2023-...'
577
- * // }
578
- */
579
- async list() {
580
- const result = await this.sdk._fetch('/messaging/email/validate/domain', 'GET');
581
- return result;
582
- }
583
-
584
- /**
585
- * Get domain details by ID including DNS configuration
586
- * @param {string} domainId - Domain ID (required)
587
- * @returns {Promise<Object>} Domain details with DNS records to configure
588
- * @example
589
- * // Returns domain object with DNS records:
590
- * // {
591
- * // id: 'domain-id',
592
- * // domain: 'mydomain.com',
593
- * // primaryRegion: 'us-east-1',
594
- * // secondaryRegion: 'us-west-2',
595
- * // primaryRegionStatus: 'active',
596
- * // secondaryRegionStatus: 'active',
597
- * // mailFrom: 'mail.mydomain.com',
598
- * // portalId: 'portal-id',
599
- * // portalName: 'My Portal',
600
- * // brandId: 'brand-id',
601
- * // recordTypeId: 'record-type-id',
602
- * // createdAt: '2023-...',
603
- * // dns: [
604
- * // {
605
- * // type: 'CNAME',
606
- * // name: 'domainid._domainkey.mydomain.com',
607
- * // value: 'domainid.dkim.example.com',
608
- * // description: 'DKIM signature verification'
609
- * // },
610
- * // {
611
- * // type: 'CNAME',
612
- * // name: 'mail.mydomain.com',
613
- * // value: 'mail.ses.amazonaws.com',
614
- * // description: 'MAIL FROM domain routing'
615
- * // },
616
- * // {
617
- * // type: 'TXT',
618
- * // name: 'mydomain.com',
619
- * // value: '"v=spf1 include:mail.mydomain.com ~all"',
620
- * // description: 'SPF record for email authentication'
621
- * // },
622
- * // {
623
- * // type: 'TXT',
624
- * // name: '_dmarc.mydomain.com',
625
- * // value: '"v=DMARC1; p=quarantine; rua=mailto:dmarc@...',
626
- * // description: 'DMARC policy for email authentication and reporting'
627
- * // }
628
- * // ]
629
- * // }
630
- */
631
- async get(domainId) {
632
- this.sdk.validateParams(
633
- { domainId },
634
- {
635
- domainId: { type: 'string', required: true },
636
- },
637
- );
638
-
639
- const result = await this.sdk._fetch(
640
- `/messaging/email/validate/domain/${domainId}`,
641
- 'GET',
642
- );
643
- return result;
644
- }
645
-
646
- /**
647
- * Validate DNS records for domain
648
- * @param {string} domain - Domain name (required)
649
- * @returns {Promise<Object>} DNS validation results
650
- */
651
- async validateDns(domain) {
652
- this.sdk.validateParams(
653
- { domain },
654
- {
655
- domain: { type: 'string', required: true },
656
- },
657
- );
658
-
659
- const options = {
660
- query: { domain },
661
- };
662
-
663
- const result = await this.sdk._fetch(
664
- '/messaging/email/validate/domain/dns',
665
- 'GET',
666
- options,
667
- );
668
- return result;
669
- }
670
-
671
- /**
672
- * Check domain verification status
673
- * @param {string} domain - Domain name (required)
674
- * @returns {Promise<Object>} Domain verification status
675
- */
676
- async checkStatus(domain) {
677
- this.sdk.validateParams(
678
- { domain },
679
- {
680
- domain: { type: 'string', required: true },
681
- },
682
- );
683
-
684
- const options = {
685
- query: { domain },
686
- };
687
-
688
- const result = await this.sdk._fetch(
689
- '/messaging/email/validate/domain/status',
690
- 'GET',
691
- options,
692
- );
693
- return result;
694
- }
695
-
696
- /**
697
- * Update domain settings
698
- * @param {Object} params - Update parameters
699
- * @param {string} params.domainId - Domain ID (required)
700
- * @param {string} [params.primaryRegion] - Primary AWS region
701
- * @param {string} [params.secondaryRegion] - Secondary AWS region
702
- * @param {boolean} [params.dkimEnabled] - Enable DKIM signing
703
- * @param {Object} [params.customDkim] - Custom DKIM configuration
704
- * @returns {Promise<Object>} Updated domain details
705
- */
706
- async update({ domainId, primaryRegion, secondaryRegion, dkimEnabled, customDkim }) {
707
- this.sdk.validateParams(
708
- { domainId },
709
- {
710
- domainId: { type: 'string', required: true },
711
- primaryRegion: { type: 'string', required: false },
712
- secondaryRegion: { type: 'string', required: false },
713
- dkimEnabled: { type: 'boolean', required: false },
714
- customDkim: { type: 'object', required: false },
715
- },
716
- );
717
-
718
- const updateData = { domainId };
719
- if (primaryRegion) updateData.primaryRegion = primaryRegion;
720
- if (secondaryRegion) updateData.secondaryRegion = secondaryRegion;
721
- if (dkimEnabled !== undefined) updateData.dkimEnabled = dkimEnabled;
722
- if (customDkim) updateData.customDkim = customDkim;
723
-
724
- const options = {
725
- body: updateData,
726
- };
727
-
728
- const result = await this.sdk._fetch(
729
- '/messaging/email/validate/domain',
730
- 'PUT',
731
- options,
732
- );
733
- return result;
734
- }
735
- }
736
-
737
- export class EmailAddressesService {
738
- constructor(sdk) {
739
- this.sdk = sdk;
740
- }
741
-
742
- /**
743
- * Create email address verification
744
- * @param {string} emailAddress - Email address to verify (required)
745
- * @returns {Promise<Object>} Email verification details
746
- */
747
- async create(emailAddress) {
748
- this.sdk.validateParams(
749
- { emailAddress },
750
- {
751
- emailAddress: { type: 'string', required: true },
752
- },
753
- );
754
-
755
- const options = {
756
- body: { emailAddress },
757
- };
758
-
759
- const result = await this.sdk._fetch(
760
- '/messaging/email/validate/emailAddress',
761
- 'POST',
762
- options,
763
- );
764
- return result;
765
- }
766
-
767
- /**
768
- * Delete email address verification
769
- * @param {string} emailAddress - Email address to remove (required)
770
- * @returns {Promise<Object>} Deletion confirmation
771
- */
772
- async delete(emailAddress) {
773
- this.sdk.validateParams(
774
- { emailAddress },
775
- {
776
- emailAddress: { type: 'string', required: true },
777
- },
778
- );
779
-
780
- const result = await this.sdk._fetch(
781
- `/messaging/email/validate/emailAddress/${encodeURIComponent(emailAddress)}`,
782
- 'DELETE',
783
- );
784
- return result;
785
- }
786
-
787
- /**
788
- * List all verified email addresses
789
- * @returns {Promise<Array>} List of verified email addresses
790
- */
791
- async list() {
792
- const result = await this.sdk._fetch('/messaging/email/validate/emailAddress', 'GET');
793
- return result;
794
- }
795
-
796
- /**
797
- * Check email address verification status
798
- * @param {string} emailAddress - Email address to check (required)
799
- * @returns {Promise<Object>} Email verification status
800
- */
801
- async checkStatus(emailAddress) {
802
- this.sdk.validateParams(
803
- { emailAddress },
804
- {
805
- emailAddress: { type: 'string', required: true },
806
- },
807
- );
808
-
809
- const options = {
810
- query: { emailAddress },
811
- };
812
-
813
- const result = await this.sdk._fetch(
814
- '/messaging/email/validate/emailAddress/status',
815
- 'GET',
816
- options,
817
- );
818
- return result;
819
- }
820
- }
821
-
822
- export class CampaignsService {
823
- constructor(sdk) {
824
- this.sdk = sdk;
825
- this.tollFree = new TollFreeCampaignsService(sdk);
826
- this.tenDlc = new TenDlcCampaignsService(sdk);
827
- }
828
- }
829
-
830
- export class TollFreeCampaignsService {
831
- constructor(sdk) {
832
- this.sdk = sdk;
833
- }
834
-
835
- /**
836
- * Create toll-free campaign
837
- * @param {Object} params - Campaign parameters
838
- * @param {string} params.companyName - Company name (required)
839
- * @param {string} params.phoneNumber - Phone number (required)
840
- * @param {string} params.description - Campaign description (required)
841
- * @param {string} params.messageFlow - Message flow description (required)
842
- * @param {string} [params.helpMessage] - Help message
843
- * @param {Array<string>} [params.optInKeywords] - Opt-in keywords
844
- * @param {Array<string>} [params.optOutKeywords] - Opt-out keywords
845
- * @param {string} [params.website] - Business website
846
- * @returns {Promise<Object>} Created campaign details
847
- */
848
- async create({
849
- companyName,
850
- phoneNumber,
851
- description,
852
- messageFlow,
853
- helpMessage,
854
- optInKeywords,
855
- optOutKeywords,
856
- website,
857
- }) {
858
- this.sdk.validateParams(
859
- { companyName, phoneNumber, description, messageFlow },
860
- {
861
- companyName: { type: 'string', required: true },
862
- phoneNumber: { type: 'string', required: true },
863
- description: { type: 'string', required: true },
864
- messageFlow: { type: 'string', required: true },
865
- helpMessage: { type: 'string', required: false },
866
- optInKeywords: { type: 'array', required: false },
867
- optOutKeywords: { type: 'array', required: false },
868
- website: { type: 'string', required: false },
869
- },
870
- );
871
-
872
- const campaignData = {
873
- companyName,
874
- phoneNumber,
875
- description,
876
- messageFlow,
877
- };
878
-
879
- if (helpMessage) campaignData.helpMessage = helpMessage;
880
- if (optInKeywords) campaignData.optInKeywords = optInKeywords;
881
- if (optOutKeywords) campaignData.optOutKeywords = optOutKeywords;
882
- if (website) campaignData.website = website;
883
-
884
- const options = {
885
- body: campaignData,
886
- };
887
-
888
- const result = await this.sdk._fetch(
889
- '/messaging/campaigns/tollfree',
890
- 'POST',
891
- options,
892
- );
893
- return result;
894
- }
895
-
896
- /**
897
- * Get toll-free campaign by ID
898
- * @param {string} campaignId - Campaign ID
899
- * @returns {Promise<Object>} Campaign details
900
- */
901
- async get(campaignId) {
902
- this.sdk.validateParams(
903
- { campaignId },
904
- {
905
- campaignId: { type: 'string', required: true },
906
- },
907
- );
908
-
909
- const result = await this.sdk._fetch(
910
- `/messaging/campaigns/tollfree/${campaignId}`,
911
- 'GET',
912
- );
913
- return result;
914
- }
915
-
916
- /**
917
- * Update toll-free campaign
918
- * @param {string} campaignId - Campaign ID to update
919
- * @param {Object} params - Update parameters
920
- * @param {string} [params.name] - Campaign name
921
- * @param {string} [params.campaignDescription] - Campaign description
922
- * @param {string} [params.address1] - Business address line 1
923
- * @param {string} [params.address2] - Business address line 2
924
- * @param {string} [params.city] - Business city
925
- * @param {string} [params.state] - Business state
926
- * @param {string} [params.zip] - Business zip code
927
- * @param {string} [params.pocFirstName] - Point of contact first name
928
- * @param {string} [params.pocLastName] - Point of contact last name
929
- * @param {string} [params.pocPhoneNumber] - Point of contact phone
930
- * @param {string} [params.pocEmail] - Point of contact email
931
- * @param {string} [params.businessName] - Business name
932
- * @param {string} [params.website] - Business website
933
- * @param {string} [params.messageVolume] - Expected message volume
934
- * @param {string} [params.optInWorkflow] - Opt-in workflow description
935
- * @param {Array<string>} [params.optInWorkflowUrls] - Opt-in workflow image URLs
936
- * @param {Array<string>} [params.phoneNumbers] - Phone numbers for campaign
937
- * @param {string} [params.productionMessageExample] - Production message example
938
- * @param {string} [params.useCase] - Use case category
939
- * @param {string} [params.useCaseDescription] - Use case description
940
- * @param {string} [params.webhookUrl] - Webhook URL
941
- * @returns {Promise<Object>} Updated campaign information
942
- */
943
- async update(campaignId, {
944
- name,
945
- campaignDescription,
946
- address1,
947
- address2,
948
- city,
949
- state,
950
- zip,
951
- pocFirstName,
952
- pocLastName,
953
- pocPhoneNumber,
954
- pocEmail,
955
- businessName,
956
- website,
957
- messageVolume,
958
- optInWorkflow,
959
- optInWorkflowUrls,
960
- phoneNumbers,
961
- productionMessageExample,
962
- useCase,
963
- useCaseDescription,
964
- webhookUrl,
965
- } = {}) {
966
- this.sdk.validateParams(
967
- { campaignId, name, campaignDescription, address1, address2, city, state, zip, pocFirstName, pocLastName, pocPhoneNumber, pocEmail, businessName, website, messageVolume, optInWorkflow, optInWorkflowUrls, phoneNumbers, productionMessageExample, useCase, useCaseDescription, webhookUrl },
968
- {
969
- campaignId: { type: 'string', required: true },
970
- name: { type: 'string', required: false },
971
- campaignDescription: { type: 'string', required: false },
972
- address1: { type: 'string', required: false },
973
- address2: { type: 'string', required: false },
974
- city: { type: 'string', required: false },
975
- state: { type: 'string', required: false },
976
- zip: { type: 'string', required: false },
977
- pocFirstName: { type: 'string', required: false },
978
- pocLastName: { type: 'string', required: false },
979
- pocPhoneNumber: { type: 'string', required: false },
980
- pocEmail: { type: 'string', required: false },
981
- businessName: { type: 'string', required: false },
982
- website: { type: 'string', required: false },
983
- messageVolume: { type: 'string', required: false },
984
- optInWorkflow: { type: 'string', required: false },
985
- optInWorkflowUrls: { type: 'array', required: false },
986
- phoneNumbers: { type: 'array', required: false },
987
- productionMessageExample: { type: 'string', required: false },
988
- useCase: { type: 'string', required: false },
989
- useCaseDescription: { type: 'string', required: false },
990
- webhookUrl: { type: 'string', required: false },
991
- },
992
- );
993
-
994
- const updateData = {};
995
- if (name !== undefined) updateData.name = name;
996
- if (campaignDescription !== undefined) updateData.campaignDescription = campaignDescription;
997
- if (address1 !== undefined) updateData.address1 = address1;
998
- if (address2 !== undefined) updateData.address2 = address2;
999
- if (city !== undefined) updateData.city = city;
1000
- if (state !== undefined) updateData.state = state;
1001
- if (zip !== undefined) updateData.zip = zip;
1002
- if (pocFirstName !== undefined) updateData.pocFirstName = pocFirstName;
1003
- if (pocLastName !== undefined) updateData.pocLastName = pocLastName;
1004
- if (pocPhoneNumber !== undefined) updateData.pocPhoneNumber = pocPhoneNumber;
1005
- if (pocEmail !== undefined) updateData.pocEmail = pocEmail;
1006
- if (businessName !== undefined) updateData.businessName = businessName;
1007
- if (website !== undefined) updateData.website = website;
1008
- if (messageVolume !== undefined) updateData.messageVolume = messageVolume;
1009
- if (optInWorkflow !== undefined) updateData.optInWorkflow = optInWorkflow;
1010
- if (optInWorkflowUrls !== undefined) updateData.optInWorkflowUrls = optInWorkflowUrls;
1011
- if (phoneNumbers !== undefined) updateData.phoneNumbers = phoneNumbers;
1012
- if (productionMessageExample !== undefined) updateData.productionMessageExample = productionMessageExample;
1013
- if (useCase !== undefined) updateData.useCase = useCase;
1014
- if (useCaseDescription !== undefined) updateData.useCaseDescription = useCaseDescription;
1015
- if (webhookUrl !== undefined) updateData.webhookUrl = webhookUrl;
1016
-
1017
- const options = {
1018
- body: updateData,
1019
- };
1020
-
1021
- const result = await this.sdk._fetch(
1022
- `/messaging/campaigns/tollfree/${campaignId}`,
1023
- 'PUT',
1024
- options,
1025
- );
1026
- return result;
1027
- }
1028
-
1029
- async delete(campaignId) {
1030
- this.sdk.validateParams(
1031
- { campaignId },
1032
- {
1033
- campaignId: { type: 'string', required: true },
1034
- },
1035
- );
1036
-
1037
- const result = await this.sdk._fetch(
1038
- `/messaging/campaigns/tollfree/${campaignId}`,
1039
- 'DELETE',
1040
- );
1041
- return result;
1042
- }
1043
-
1044
- /**
1045
- * List all toll-free campaigns with optional filtering
1046
- * @param {Object} [params] - Filter parameters
1047
- * @param {number} [params.page=1] - Page number
1048
- * @param {number} [params.limit=50] - Items per page
1049
- * @param {string} [params.name] - Filter by campaign name
1050
- * @param {string} [params.status] - Filter by status
1051
- * @param {string} [params.operatorType='contains'] - Filter operator: contains, equals, startsWith, endsWith
1052
- * @returns {Promise<Array>} List of campaigns
1053
- */
1054
- async list({ page, limit, name, status, operatorType } = {}) {
1055
- const queryParams = new URLSearchParams();
1056
-
1057
- if (page !== undefined) queryParams.append('page', page);
1058
- if (limit !== undefined) queryParams.append('limit', limit);
1059
- if (name) queryParams.append('name', name);
1060
- if (status) queryParams.append('status', status);
1061
- if (operatorType) queryParams.append('operatorType', operatorType);
1062
-
1063
- const url = queryParams.toString()
1064
- ? `/messaging/campaigns/tollfree?${queryParams.toString()}`
1065
- : '/messaging/campaigns/tollfree';
1066
-
1067
- const result = await this.sdk._fetch(url, 'GET');
1068
- return result;
1069
- }
1070
-
1071
- async refreshStatus(campaignId) {
1072
- this.sdk.validateParams(
1073
- { campaignId },
1074
- {
1075
- campaignId: { type: 'string', required: true },
1076
- },
1077
- );
1078
-
1079
- const result = await this.sdk._fetch(
1080
- `/messaging/campaigns/tollfree/refresh/${campaignId}`,
1081
- 'GET',
1082
- );
1083
- return result;
1084
- }
1085
-
1086
- async getPhoneNumberCampaignStatus(phoneNumber) {
1087
- this.sdk.validateParams(
1088
- { phoneNumber },
1089
- {
1090
- phoneNumber: { type: 'string', required: true },
1091
- },
1092
- );
1093
-
1094
- const result = await this.sdk._fetch(
1095
- `/messaging/campaigns/tollfree/phoneNumber/${encodeURIComponent(
1096
- phoneNumber,
1097
- )}/campaignStatus`,
1098
- 'GET',
1099
- );
1100
- return result;
1101
- }
1102
- }
1103
-
1104
- export class TenDlcCampaignsService {
1105
- constructor(sdk) {
1106
- this.sdk = sdk;
1107
- this.brands = new TenDlcBrandsService(sdk);
1108
- this.campaigns = new TenDlcCampaignManagementService(sdk);
1109
- }
1110
-
1111
- /**
1112
- * Get phone number campaign status for 10DLC
1113
- * @param {string} phoneNumber - Phone number to check
1114
- * @returns {Promise<Object>} Campaign status information
1115
- */
1116
- async getPhoneNumberCampaignStatus(phoneNumber) {
1117
- this.sdk.validateParams(
1118
- { phoneNumber },
1119
- {
1120
- phoneNumber: { type: 'string', required: true },
1121
- },
1122
- );
1123
-
1124
- const result = await this.sdk._fetch(
1125
- `/messaging/campaigns/10dlc/phoneNumber/${encodeURIComponent(
1126
- phoneNumber,
1127
- )}/campaignStatus`,
1128
- 'GET',
1129
- );
1130
- return result;
1131
- }
1132
- }
1133
-
1134
- export class TenDlcBrandsService {
1135
- constructor(sdk) {
1136
- this.sdk = sdk;
1137
- }
1138
-
1139
- /**
1140
- * List all 10DLC brands with optional filtering
1141
- * @param {Object} [params] - Filter parameters
1142
- * @param {number} [params.page=1] - Page number
1143
- * @param {number} [params.limit=50] - Items per page
1144
- * @param {string} [params.name] - Filter by brand name
1145
- * @param {string} [params.status] - Filter by status
1146
- * @param {string} [params.operatorType='contains'] - Filter operator: contains, equals, startsWith, endsWith
1147
- * @returns {Promise<Array>} List of brands
1148
- */
1149
- async list({ page, limit, name, status, operatorType } = {}) {
1150
- const queryParams = new URLSearchParams();
1151
-
1152
- if (page !== undefined) queryParams.append('page', page);
1153
- if (limit !== undefined) queryParams.append('limit', limit);
1154
- if (name) queryParams.append('name', name);
1155
- if (status) queryParams.append('status', status);
1156
- if (operatorType) queryParams.append('operatorType', operatorType);
1157
-
1158
- const url = queryParams.toString()
1159
- ? `/messaging/campaigns/10dlc/brand?${queryParams.toString()}`
1160
- : '/messaging/campaigns/10dlc/brand';
1161
-
1162
- const result = await this.sdk._fetch(url, 'GET');
1163
- return result;
1164
- }
1165
-
1166
- /**
1167
- * Create a new 10DLC brand
1168
- * @param {Object} params - Brand parameters
1169
- * @param {string} params.name - Brand display name (required)
1170
- * @param {string} params.entityType - Entity type: PRIVATE_PROFIT, PUBLIC_PROFIT, NON_PROFIT (required)
1171
- * @param {string} [params.cspId] - CSP ID for resellers
1172
- * @param {string} params.companyName - Company name (required)
1173
- * @param {string} [params.ein] - Employer Identification Number
1174
- * @param {string} params.address1 - Street address (required)
1175
- * @param {string} [params.address2] - Street address line 2
1176
- * @param {string} params.city - City (required)
1177
- * @param {string} params.state - State (required)
1178
- * @param {string} params.postalCode - Postal code (required)
1179
- * @param {string} params.country - Country (required)
1180
- * @param {string} [params.pocFirstName] - Point of contact first name
1181
- * @param {string} [params.pocLastName] - Point of contact last name
1182
- * @param {string} params.pocEmail - Point of contact email (required)
1183
- * @param {string} params.pocPhone - Point of contact phone (required)
1184
- * @param {string} [params.stockSymbol] - Stock symbol for public companies
1185
- * @param {string} [params.stockExchange] - Stock exchange for public companies
1186
- * @param {string} [params.website] - Company website
1187
- * @param {string} params.vertical - Business vertical (required)
1188
- * @param {string} [params.altBusinessId] - Alternative business ID
1189
- * @param {string} [params.altBusinessIdType] - Alternative business ID type
1190
- * @param {string} [params.brandRelationship] - Brand relationship
1191
- * @returns {Promise<Object>} Created brand details
1192
- */
1193
- async create({
1194
- name,
1195
- entityType,
1196
- cspId,
1197
- companyName,
1198
- ein,
1199
- address1,
1200
- address2,
1201
- city,
1202
- state,
1203
- postalCode,
1204
- country,
1205
- pocFirstName,
1206
- pocLastName,
1207
- pocEmail,
1208
- pocPhone,
1209
- stockSymbol,
1210
- stockExchange,
1211
- website,
1212
- vertical,
1213
- altBusinessId,
1214
- altBusinessIdType,
1215
- brandRelationship,
1216
- }) {
1217
- this.sdk.validateParams(
1218
- { name, entityType, companyName, address1, city, state, postalCode, country, pocEmail, pocPhone, vertical },
1219
- {
1220
- name: { type: 'string', required: true },
1221
- entityType: { type: 'string', required: true },
1222
- cspId: { type: 'string', required: false },
1223
- companyName: { type: 'string', required: true },
1224
- ein: { type: 'string', required: false },
1225
- address1: { type: 'string', required: true },
1226
- address2: { type: 'string', required: false },
1227
- city: { type: 'string', required: true },
1228
- state: { type: 'string', required: true },
1229
- postalCode: { type: 'string', required: true },
1230
- country: { type: 'string', required: true },
1231
- pocFirstName: { type: 'string', required: false },
1232
- pocLastName: { type: 'string', required: false },
1233
- pocEmail: { type: 'string', required: true },
1234
- pocPhone: { type: 'string', required: true },
1235
- stockSymbol: { type: 'string', required: false },
1236
- stockExchange: { type: 'string', required: false },
1237
- website: { type: 'string', required: false },
1238
- vertical: { type: 'string', required: true },
1239
- altBusinessId: { type: 'string', required: false },
1240
- altBusinessIdType: { type: 'string', required: false },
1241
- brandRelationship: { type: 'string', required: false },
1242
- },
1243
- );
1244
-
1245
- const brandData = {
1246
- name,
1247
- entityType,
1248
- companyName,
1249
- address1,
1250
- city,
1251
- state,
1252
- postalCode,
1253
- country,
1254
- pocEmail,
1255
- pocPhone,
1256
- vertical,
1257
- };
1258
- if (cspId) brandData.cspId = cspId;
1259
- if (ein) brandData.ein = ein;
1260
- if (address2) brandData.address2 = address2;
1261
- if (pocFirstName) brandData.pocFirstName = pocFirstName;
1262
- if (pocLastName) brandData.pocLastName = pocLastName;
1263
- if (stockSymbol) brandData.stockSymbol = stockSymbol;
1264
- if (stockExchange) brandData.stockExchange = stockExchange;
1265
- if (website) brandData.website = website;
1266
- if (altBusinessId) brandData.altBusinessId = altBusinessId;
1267
- if (altBusinessIdType) brandData.altBusinessIdType = altBusinessIdType;
1268
- if (brandRelationship) brandData.brandRelationship = brandRelationship;
1269
-
1270
- const options = {
1271
- body: brandData,
1272
- };
1273
-
1274
- const result = await this.sdk._fetch(
1275
- '/messaging/campaigns/10dlc/brand',
1276
- 'POST',
1277
- options,
1278
- );
1279
- return result;
1280
- }
1281
-
1282
- /**
1283
- * Get a 10DLC brand by ID
1284
- * @param {string} brandId - Brand ID (required)
1285
- * @returns {Promise<Object>} Brand details
1286
- */
1287
- async get(brandId) {
1288
- this.sdk.validateParams(
1289
- { brandId },
1290
- {
1291
- brandId: { type: 'string', required: true },
1292
- },
1293
- );
1294
-
1295
- const result = await this.sdk._fetch(
1296
- `/messaging/campaigns/10dlc/brand/${brandId}`,
1297
- 'GET',
1298
- );
1299
- return result;
1300
- }
1301
-
1302
- /**
1303
- * Update a 10DLC brand
1304
- * @param {string} brandId - Brand ID to update (required)
1305
- * @param {Object} params - Brand parameters to update
1306
- * @param {string} [params.name] - Brand display name
1307
- * @param {string} [params.entityType] - Entity type: PRIVATE_PROFIT, PUBLIC_PROFIT, NON_PROFIT
1308
- * @param {string} [params.cspId] - CSP ID for resellers
1309
- * @param {string} [params.companyName] - Company name
1310
- * @param {string} [params.ein] - Employer Identification Number
1311
- * @param {string} [params.address1] - Street address
1312
- * @param {string} [params.address2] - Street address line 2
1313
- * @param {string} [params.city] - City
1314
- * @param {string} [params.state] - State
1315
- * @param {string} [params.postalCode] - Postal code
1316
- * @param {string} [params.country] - Country
1317
- * @param {string} [params.pocFirstName] - Point of contact first name
1318
- * @param {string} [params.pocLastName] - Point of contact last name
1319
- * @param {string} [params.pocEmail] - Point of contact email
1320
- * @param {string} [params.pocPhone] - Point of contact phone
1321
- * @param {string} [params.stockSymbol] - Stock symbol for public companies
1322
- * @param {string} [params.stockExchange] - Stock exchange for public companies
1323
- * @param {string} [params.website] - Company website
1324
- * @param {string} [params.vertical] - Business vertical
1325
- * @param {string} [params.altBusinessId] - Alternative business ID
1326
- * @param {string} [params.altBusinessIdType] - Alternative business ID type
1327
- * @param {string} [params.brandRelationship] - Brand relationship
1328
- * @param {string} [params.businessContactEmail] - Business contact email for 2025 compliance
1329
- * @param {string} [params.firstName] - First name for 2025 compliance
1330
- * @param {string} [params.lastName] - Last name for 2025 compliance
1331
- * @param {string} [params.mobilePhone] - Mobile phone for 2025 compliance
1332
- * @returns {Promise<Object>} Updated brand details
1333
- */
1334
- async update(brandId, {
1335
- name,
1336
- entityType,
1337
- cspId,
1338
- companyName,
1339
- ein,
1340
- address1,
1341
- address2,
1342
- city,
1343
- state,
1344
- postalCode,
1345
- country,
1346
- pocFirstName,
1347
- pocLastName,
1348
- pocEmail,
1349
- pocPhone,
1350
- stockSymbol,
1351
- stockExchange,
1352
- website,
1353
- vertical,
1354
- altBusinessId,
1355
- altBusinessIdType,
1356
- brandRelationship,
1357
- businessContactEmail,
1358
- firstName,
1359
- lastName,
1360
- mobilePhone,
1361
- } = {}) {
1362
- this.sdk.validateParams(
1363
- { brandId },
1364
- {
1365
- brandId: { type: 'string', required: true },
1366
- name: { type: 'string', required: false },
1367
- entityType: { type: 'string', required: false },
1368
- cspId: { type: 'string', required: false },
1369
- companyName: { type: 'string', required: false },
1370
- ein: { type: 'string', required: false },
1371
- address1: { type: 'string', required: false },
1372
- address2: { type: 'string', required: false },
1373
- city: { type: 'string', required: false },
1374
- state: { type: 'string', required: false },
1375
- postalCode: { type: 'string', required: false },
1376
- country: { type: 'string', required: false },
1377
- pocFirstName: { type: 'string', required: false },
1378
- pocLastName: { type: 'string', required: false },
1379
- pocEmail: { type: 'string', required: false },
1380
- pocPhone: { type: 'string', required: false },
1381
- stockSymbol: { type: 'string', required: false },
1382
- stockExchange: { type: 'string', required: false },
1383
- website: { type: 'string', required: false },
1384
- vertical: { type: 'string', required: false },
1385
- altBusinessId: { type: 'string', required: false },
1386
- altBusinessIdType: { type: 'string', required: false },
1387
- brandRelationship: { type: 'string', required: false },
1388
- businessContactEmail: { type: 'string', required: false },
1389
- firstName: { type: 'string', required: false },
1390
- lastName: { type: 'string', required: false },
1391
- mobilePhone: { type: 'string', required: false },
1392
- },
1393
- );
1394
-
1395
- const updateData = {};
1396
- if (name !== undefined) updateData.name = name;
1397
- if (entityType !== undefined) updateData.entityType = entityType;
1398
- if (cspId !== undefined) updateData.cspId = cspId;
1399
- if (companyName !== undefined) updateData.companyName = companyName;
1400
- if (ein !== undefined) updateData.ein = ein;
1401
- if (address1 !== undefined) updateData.address1 = address1;
1402
- if (address2 !== undefined) updateData.address2 = address2;
1403
- if (city !== undefined) updateData.city = city;
1404
- if (state !== undefined) updateData.state = state;
1405
- if (postalCode !== undefined) updateData.postalCode = postalCode;
1406
- if (country !== undefined) updateData.country = country;
1407
- if (pocFirstName !== undefined) updateData.pocFirstName = pocFirstName;
1408
- if (pocLastName !== undefined) updateData.pocLastName = pocLastName;
1409
- if (pocEmail !== undefined) updateData.pocEmail = pocEmail;
1410
- if (pocPhone !== undefined) updateData.pocPhone = pocPhone;
1411
- if (stockSymbol !== undefined) updateData.stockSymbol = stockSymbol;
1412
- if (stockExchange !== undefined) updateData.stockExchange = stockExchange;
1413
- if (website !== undefined) updateData.website = website;
1414
- if (vertical !== undefined) updateData.vertical = vertical;
1415
- if (altBusinessId !== undefined) updateData.altBusinessId = altBusinessId;
1416
- if (altBusinessIdType !== undefined) updateData.altBusinessIdType = altBusinessIdType;
1417
- if (brandRelationship !== undefined) updateData.brandRelationship = brandRelationship;
1418
- if (businessContactEmail !== undefined) updateData.businessContactEmail = businessContactEmail;
1419
- if (firstName !== undefined) updateData.firstName = firstName;
1420
- if (lastName !== undefined) updateData.lastName = lastName;
1421
- if (mobilePhone !== undefined) updateData.mobilePhone = mobilePhone;
1422
-
1423
- const options = {
1424
- body: updateData,
1425
- };
1426
-
1427
- const result = await this.sdk._fetch(
1428
- `/messaging/campaigns/10dlc/brand/${brandId}`,
1429
- 'PUT',
1430
- options,
1431
- );
1432
- return result;
1433
- }
1434
-
1435
- /**
1436
- * Delete a 10DLC brand
1437
- * @param {string} brandId - Brand ID to delete (required)
1438
- * @returns {Promise<Object>} Deletion confirmation
1439
- */
1440
- async delete(brandId) {
1441
- this.sdk.validateParams(
1442
- { brandId },
1443
- {
1444
- brandId: { type: 'string', required: true },
1445
- },
1446
- );
1447
-
1448
- const result = await this.sdk._fetch(
1449
- `/messaging/campaigns/10dlc/brand/${brandId}`,
1450
- 'DELETE',
1451
- );
1452
- return result;
1453
- }
1454
-
1455
- /**
1456
- * Revet (re-vet) a 10DLC brand - resubmit brand for carrier approval
1457
- * @param {string} brandId - Brand ID to revet (required)
1458
- * @returns {Promise<Object>} Revet confirmation and updated brand status
1459
- */
1460
- async revet(brandId) {
1461
- this.sdk.validateParams(
1462
- { brandId },
1463
- {
1464
- brandId: { type: 'string', required: true },
1465
- },
1466
- );
1467
-
1468
- const result = await this.sdk._fetch(
1469
- `/messaging/campaigns/10dlc/brand/${brandId}/revet`,
1470
- 'PUT',
1471
- );
1472
- return result;
1473
- }
1474
-
1475
- /**
1476
- * Get brand feedback from carriers
1477
- * @param {string} brandId - Brand ID to get feedback for (required)
1478
- * @returns {Promise<Object>} Brand feedback details from carriers
1479
- */
1480
- async getFeedback(brandId) {
1481
- this.sdk.validateParams(
1482
- { brandId },
1483
- {
1484
- brandId: { type: 'string', required: true },
1485
- },
1486
- );
1487
-
1488
- const result = await this.sdk._fetch(
1489
- `/messaging/campaigns/10dlc/brand/${brandId}/feedback`,
1490
- 'GET',
1491
- );
1492
- return result;
1493
- }
1494
-
1495
- /**
1496
- * Create external brand vetting for higher throughput approval
1497
- * @param {string} brandId - Brand ID to create external vetting for (required)
1498
- * @param {Object} [vettingData] - External vetting data
1499
- * @returns {Promise<Object>} External vetting creation confirmation
1500
- */
1501
- async createExternalVetting(brandId, vettingData) {
1502
- this.sdk.validateParams(
1503
- { brandId },
1504
- {
1505
- brandId: { type: 'string', required: true },
1506
- vettingData: { type: 'object', required: false },
1507
- },
1508
- );
1509
-
1510
- const options = {
1511
- body: vettingData || {},
1512
- };
1513
-
1514
- const result = await this.sdk._fetch(
1515
- `/messaging/campaigns/10dlc/brand/${brandId}/externalVetting`,
1516
- 'POST',
1517
- options,
1518
- );
1519
- return result;
1520
- }
1521
-
1522
- /**
1523
- * Get brand external vetting responses
1524
- * @param {string} brandId - Brand ID to get vetting responses for (required)
1525
- * @returns {Promise<Object>} External vetting responses
1526
- */
1527
- async getExternalVettingResponses(brandId) {
1528
- this.sdk.validateParams(
1529
- { brandId },
1530
- {
1531
- brandId: { type: 'string', required: true },
1532
- },
1533
- );
1534
-
1535
- const result = await this.sdk._fetch(
1536
- `/messaging/campaigns/10dlc/brand/${brandId}/externalvetting/responses`,
1537
- 'GET',
1538
- );
1539
- return result;
1540
- }
1541
-
1542
- /**
1543
- * Resend two-factor authentication email for PUBLIC_PROFIT brands
1544
- * @param {string} brandId - Brand ID to resend 2FA for
1545
- * @returns {Promise<Object>} Success message and details
1546
- */
1547
- async resend2fa(brandId) {
1548
- this.sdk.validateParams(
1549
- { brandId },
1550
- {
1551
- brandId: { type: 'string', required: true },
1552
- },
1553
- );
1554
-
1555
- const result = await this.sdk._fetch(
1556
- `/messaging/campaigns/10dlc/brand/${brandId}/resend-2fa`,
1557
- 'POST',
1558
- );
1559
- return result;
1560
- }
1561
- }
1562
-
1563
- export class TenDlcCampaignManagementService {
1564
- constructor(sdk) {
1565
- this.sdk = sdk;
1566
- }
1567
-
1568
- /**
1569
- * List all 10DLC campaigns with optional filtering
1570
- * @param {Object} [params] - Filter parameters
1571
- * @param {number} [params.page=1] - Page number
1572
- * @param {number} [params.limit=50] - Items per page
1573
- * @param {string} [params.name] - Filter by campaign name
1574
- * @param {string} [params.status] - Filter by status
1575
- * @param {string} [params.operatorType='contains'] - Filter operator: contains, equals, startsWith, endsWith
1576
- * @returns {Promise<Array>} List of campaigns
1577
- */
1578
- async list({ page, limit, name, status, operatorType } = {}) {
1579
- const queryParams = new URLSearchParams();
1580
-
1581
- if (page !== undefined) queryParams.append('page', page);
1582
- if (limit !== undefined) queryParams.append('limit', limit);
1583
- if (name) queryParams.append('name', name);
1584
- if (status) queryParams.append('status', status);
1585
- if (operatorType) queryParams.append('operatorType', operatorType);
1586
-
1587
- const url = queryParams.toString()
1588
- ? `/messaging/campaigns/10dlc/campaign?${queryParams.toString()}`
1589
- : '/messaging/campaigns/10dlc/campaign';
1590
-
1591
- const result = await this.sdk._fetch(url, 'GET');
1592
- return result;
1593
- }
1594
-
1595
- /**
1596
- * Create a new 10DLC campaign
1597
- * @param {Object} params - Campaign parameters
1598
- * @param {string} params.brandId - Brand ID (required)
1599
- * @param {string} params.description - Campaign description (required)
1600
- * @param {string} params.messageFlow - Message flow description (required)
1601
- * @param {string} [params.helpMessage] - Help message
1602
- * @param {string} [params.optInMessage] - Opt-in message
1603
- * @param {string} [params.optOutMessage] - Opt-out message
1604
- * @param {string} [params.useCase] - Use case category
1605
- * @param {string} [params.vertical] - Vertical category
1606
- * @returns {Promise<Object>} Created campaign details
1607
- */
1608
- async create({
1609
- brandId,
1610
- description,
1611
- messageFlow,
1612
- helpMessage,
1613
- optInMessage,
1614
- optOutMessage,
1615
- useCase,
1616
- vertical,
1617
- }) {
1618
- this.sdk.validateParams(
1619
- { brandId, description, messageFlow, helpMessage, optInMessage, optOutMessage, useCase, vertical },
1620
- {
1621
- brandId: { type: 'string', required: true },
1622
- description: { type: 'string', required: true },
1623
- messageFlow: { type: 'string', required: true },
1624
- helpMessage: { type: 'string', required: false },
1625
- optInMessage: { type: 'string', required: false },
1626
- optOutMessage: { type: 'string', required: false },
1627
- useCase: { type: 'string', required: false },
1628
- vertical: { type: 'string', required: false },
1629
- },
1630
- );
1631
-
1632
- const campaignData = {
1633
- brandId,
1634
- description,
1635
- messageFlow,
1636
- };
1637
-
1638
- if (helpMessage !== undefined) campaignData.helpMessage = helpMessage;
1639
- if (optInMessage !== undefined) campaignData.optInMessage = optInMessage;
1640
- if (optOutMessage !== undefined) campaignData.optOutMessage = optOutMessage;
1641
- if (useCase !== undefined) campaignData.useCase = useCase;
1642
- if (vertical !== undefined) campaignData.vertical = vertical;
1643
-
1644
- const options = {
1645
- body: campaignData,
1646
- };
1647
-
1648
- const result = await this.sdk._fetch(
1649
- '/messaging/campaigns/10dlc/campaign',
1650
- 'POST',
1651
- options,
1652
- );
1653
- return result;
1654
- }
1655
-
1656
- /**
1657
- * Get a 10DLC campaign by ID
1658
- */
1659
- async get(campaignId) {
1660
- this.sdk.validateParams(
1661
- { campaignId },
1662
- {
1663
- campaignId: { type: 'string', required: true },
1664
- },
1665
- );
1666
-
1667
- const result = await this.sdk._fetch(
1668
- `/messaging/campaigns/10dlc/campaign/${campaignId}`,
1669
- 'GET',
1670
- );
1671
- return result;
1672
- }
1673
-
1674
- /**
1675
- * Update a 10DLC campaign
1676
- * @param {string} campaignId - Campaign ID to update
1677
- * @param {Object} params - Update parameters
1678
- * @param {string} [params.name] - Campaign name
1679
- * @param {string} [params.description] - Campaign description
1680
- * @param {string} [params.messageFlow] - Message flow description
1681
- * @param {Array<string>} [params.samples] - Sample messages (up to 4)
1682
- * @param {string} [params.webhookUrl] - Webhook URL
1683
- * @param {string} [params.helpMessage] - Help message
1684
- * @param {string} [params.optInMessage] - Opt-in message
1685
- * @param {string} [params.optOutMessage] - Opt-out message
1686
- * @param {string} [params.helpKeywords] - Help keywords (comma-separated)
1687
- * @param {string} [params.optinKeywords] - Opt-in keywords (comma-separated)
1688
- * @param {string} [params.optoutKeywords] - Opt-out keywords (comma-separated)
1689
- * @param {boolean} [params.affiliateMarketing] - Affiliate marketing flag
1690
- * @param {boolean} [params.ageGated] - Age gated content flag
1691
- * @param {boolean} [params.directLending] - Direct lending flag
1692
- * @param {boolean} [params.embeddedLink] - Embedded links flag
1693
- * @param {boolean} [params.embeddedPhone] - Embedded phone numbers flag
1694
- * @param {boolean} [params.numberPool] - Number pool usage flag
1695
- * @param {boolean} [params.autoRenewal] - Auto-renewal flag
1696
- * @param {boolean} [params.subscriberHelp] - Subscriber help support flag
1697
- * @param {boolean} [params.subscriberOptin] - Subscriber opt-in requirement flag
1698
- * @param {boolean} [params.subscriberOptout] - Subscriber opt-out support flag
1699
- * @returns {Promise<Object>} Updated campaign information
1700
- */
1701
- async update(campaignId, {
1702
- name,
1703
- description,
1704
- messageFlow,
1705
- samples,
1706
- webhookUrl,
1707
- helpMessage,
1708
- optInMessage,
1709
- optOutMessage,
1710
- helpKeywords,
1711
- optinKeywords,
1712
- optoutKeywords,
1713
- affiliateMarketing,
1714
- ageGated,
1715
- directLending,
1716
- embeddedLink,
1717
- embeddedPhone,
1718
- numberPool,
1719
- autoRenewal,
1720
- subscriberHelp,
1721
- subscriberOptin,
1722
- subscriberOptout,
1723
- } = {}) {
1724
- this.sdk.validateParams(
1725
- { campaignId, name, description, messageFlow, samples, webhookUrl, helpMessage, optInMessage, optOutMessage, helpKeywords, optinKeywords, optoutKeywords, affiliateMarketing, ageGated, directLending, embeddedLink, embeddedPhone, numberPool, autoRenewal, subscriberHelp, subscriberOptin, subscriberOptout },
1726
- {
1727
- campaignId: { type: 'string', required: true },
1728
- name: { type: 'string', required: false },
1729
- description: { type: 'string', required: false },
1730
- messageFlow: { type: 'string', required: false },
1731
- samples: { type: 'array', required: false },
1732
- webhookUrl: { type: 'string', required: false },
1733
- helpMessage: { type: 'string', required: false },
1734
- optInMessage: { type: 'string', required: false },
1735
- optOutMessage: { type: 'string', required: false },
1736
- helpKeywords: { type: 'array', required: false },
1737
- optinKeywords: { type: 'array', required: false },
1738
- optoutKeywords: { type: 'array', required: false },
1739
- affiliateMarketing: { type: 'boolean', required: false },
1740
- ageGated: { type: 'boolean', required: false },
1741
- directLending: { type: 'boolean', required: false },
1742
- embeddedLink: { type: 'boolean', required: false },
1743
- embeddedPhone: { type: 'boolean', required: false },
1744
- numberPool: { type: 'boolean', required: false },
1745
- autoRenewal: { type: 'boolean', required: false },
1746
- subscriberHelp: { type: 'boolean', required: false },
1747
- subscriberOptin: { type: 'boolean', required: false },
1748
- subscriberOptout: { type: 'boolean', required: false },
1749
- },
1750
- );
1751
-
1752
- const updateData = {};
1753
- if (name !== undefined) updateData.name = name;
1754
- if (description !== undefined) updateData.description = description;
1755
- if (messageFlow !== undefined) updateData.messageFlow = messageFlow;
1756
- if (samples !== undefined) updateData.samples = samples;
1757
- if (webhookUrl !== undefined) updateData.webhookUrl = webhookUrl;
1758
- if (helpMessage !== undefined) updateData.helpMessage = helpMessage;
1759
- if (optInMessage !== undefined) updateData.optInMessage = optInMessage;
1760
- if (optOutMessage !== undefined) updateData.optOutMessage = optOutMessage;
1761
- if (helpKeywords !== undefined) updateData.helpKeywords = helpKeywords;
1762
- if (optinKeywords !== undefined) updateData.optinKeywords = optinKeywords;
1763
- if (optoutKeywords !== undefined) updateData.optoutKeywords = optoutKeywords;
1764
- if (affiliateMarketing !== undefined) updateData.affiliateMarketing = affiliateMarketing;
1765
- if (ageGated !== undefined) updateData.ageGated = ageGated;
1766
- if (directLending !== undefined) updateData.directLending = directLending;
1767
- if (embeddedLink !== undefined) updateData.embeddedLink = embeddedLink;
1768
- if (embeddedPhone !== undefined) updateData.embeddedPhone = embeddedPhone;
1769
- if (numberPool !== undefined) updateData.numberPool = numberPool;
1770
- if (autoRenewal !== undefined) updateData.autoRenewal = autoRenewal;
1771
- if (subscriberHelp !== undefined) updateData.subscriberHelp = subscriberHelp;
1772
- if (subscriberOptin !== undefined) updateData.subscriberOptin = subscriberOptin;
1773
- if (subscriberOptout !== undefined) updateData.subscriberOptout = subscriberOptout;
1774
-
1775
- const options = {
1776
- body: updateData,
1777
- };
1778
-
1779
- const result = await this.sdk._fetch(
1780
- `/messaging/campaigns/10dlc/campaign/${campaignId}`,
1781
- 'PUT',
1782
- options,
1783
- );
1784
- return result;
1785
- }
1786
-
1787
- /**
1788
- * Delete a 10DLC campaign
1789
- */
1790
- async delete(campaignId) {
1791
- this.sdk.validateParams(
1792
- { campaignId },
1793
- {
1794
- campaignId: { type: 'string', required: true },
1795
- },
1796
- );
1797
-
1798
- const result = await this.sdk._fetch(
1799
- `/messaging/campaigns/10dlc/campaign/${campaignId}`,
1800
- 'DELETE',
1801
- );
1802
- return result;
1803
- }
1804
-
1805
- /**
1806
- * Get campaign operation status
1807
- */
1808
- async getOperationStatus(campaignId) {
1809
- this.sdk.validateParams(
1810
- { campaignId },
1811
- {
1812
- campaignId: { type: 'string', required: true },
1813
- },
1814
- );
1815
-
1816
- const result = await this.sdk._fetch(
1817
- `/messaging/campaigns/10dlc/campaign/${campaignId}/operationStatus`,
1818
- 'GET',
1819
- );
1820
- return result;
1821
- }
1822
-
1823
- /**
1824
- * Get MNO campaign metadata
1825
- */
1826
- async getMnoMetaData(campaignId) {
1827
- this.sdk.validateParams(
1828
- { campaignId },
1829
- {
1830
- campaignId: { type: 'string', required: true },
1831
- },
1832
- );
1833
-
1834
- const result = await this.sdk._fetch(
1835
- `/messaging/campaigns/10dlc/campaign/${campaignId}/mnoMetaData`,
1836
- 'GET',
1837
- );
1838
- return result;
1839
- }
1840
-
1841
- /**
1842
- * Add phone number to campaign
1843
- */
1844
- async addPhoneNumber(campaignId, phoneNumberData) {
1845
- this.sdk.validateParams(
1846
- { campaignId, phoneNumberData },
1847
- {
1848
- campaignId: { type: 'string', required: true },
1849
- phoneNumberData: { type: 'object', required: true },
1850
- },
1851
- );
1852
-
1853
- const options = {
1854
- body: phoneNumberData,
1855
- };
1856
-
1857
- const result = await this.sdk._fetch(
1858
- `/messaging/campaigns/10dlc/campaign/${campaignId}/phoneNumber`,
1859
- 'POST',
1860
- options,
1861
- );
1862
- return result;
1863
- }
1864
-
1865
- /**
1866
- * Update phone number in campaign
1867
- */
1868
- async updatePhoneNumber(campaignId, phoneNumberData) {
1869
- this.sdk.validateParams(
1870
- { campaignId, phoneNumberData },
1871
- {
1872
- campaignId: { type: 'string', required: true },
1873
- phoneNumberData: { type: 'object', required: true },
1874
- },
1875
- );
1876
-
1877
- const options = {
1878
- body: phoneNumberData,
1879
- };
1880
-
1881
- const result = await this.sdk._fetch(
1882
- `/messaging/campaigns/10dlc/campaign/${campaignId}/phoneNumber`,
1883
- 'PUT',
1884
- options,
1885
- );
1886
- return result;
1887
- }
1888
-
1889
- /**
1890
- * Remove phone number from campaign
1891
- */
1892
- async removePhoneNumber(campaignId, phoneNumberData) {
1893
- this.sdk.validateParams(
1894
- { campaignId, phoneNumberData },
1895
- {
1896
- campaignId: { type: 'string', required: true },
1897
- phoneNumberData: { type: 'object', required: true },
1898
- },
1899
- );
1900
-
1901
- const options = {
1902
- body: phoneNumberData,
1903
- };
1904
-
1905
- const result = await this.sdk._fetch(
1906
- `/messaging/campaigns/10dlc/campaign/${campaignId}/phoneNumber`,
1907
- 'DELETE',
1908
- options,
1909
- );
1910
- return result;
1911
- }
1912
- }
1913
-
1914
- export class EmailAnalyticsService {
1915
- constructor(sdk) {
1916
- this.sdk = sdk;
1917
- }
1918
-
1919
- /**
1920
- * Get email queue time series analytics
1921
- * @param {Object} [params] - Analytics parameters
1922
- * @param {string} [params.period='24h'] - Time period: '1h', '6h', '24h', '7d', '30d'
1923
- * @param {string} [params.granularity='hour'] - Data granularity: 'minute', 'hour', 'day'
1924
- * @param {string} [params.timezone='UTC'] - Timezone for data grouping (e.g., 'America/New_York', 'UTC')
1925
- * @returns {Promise<Object>} Time series data with summary statistics
1926
- * @example
1927
- * // Get hourly analytics for last 24 hours in EST
1928
- * const analytics = await sdk.messaging.email.analytics.timeSeries({
1929
- * period: '24h',
1930
- * granularity: 'hour',
1931
- * timezone: 'America/New_York'
1932
- * });
1933
- * // Returns: { period, granularity, timezone, data: [{ timestamp, sent, delivered, failed, queued }], summary }
1934
- */
1935
- async timeSeries({ period, granularity, timezone } = {}) {
1936
- const options = { query: {} };
1937
- if (period) options.query.period = period;
1938
- if (granularity) options.query.granularity = granularity;
1939
- if (timezone) options.query.timezone = timezone;
1940
-
1941
- const result = await this.sdk._fetch('/messaging/email/analytics/timeseries', 'GET', options);
1942
- return result;
1943
- }
1944
-
1945
- /**
1946
- * Get email queue summary statistics including engagement metrics
1947
- * @param {Object} [params] - Summary parameters
1948
- * @param {string} [params.period='24h'] - Time period: '1h', '6h', '24h', '7d', '30d'
1949
- * @param {string} [params.timezone='UTC'] - Timezone for data calculation (e.g., 'America/New_York', 'UTC')
1950
- * @returns {Promise<Object>} Summary statistics with engagement metrics
1951
- * @example
1952
- * // Get comprehensive summary stats for last 24 hours in PST
1953
- * const summary = await sdk.messaging.email.analytics.summary({
1954
- * period: '24h',
1955
- * timezone: 'America/Los_Angeles'
1956
- * });
1957
- * // Returns: {
1958
- * // totalSent, totalDelivered, totalFailed, totalQueued,
1959
- * // deliveryRate, errorRate, avgProcessingSeconds, avgEmailsPerHour, avgEmailsPerMinute,
1960
- * // totalReceived, avgReceivedPerHour, avgReceivedPerMinute,
1961
- * // totalOpened, totalOpenEvents, openRate,
1962
- * // totalClicked, totalClickEvents, clickRate,
1963
- * // totalBounced, totalBounceEvents, bounceRate,
1964
- * // totalComplained, totalComplaintEvents, complaintRate,
1965
- * // outboundErrors: [{ id, errorMessage, toEmail, createdAt }]
1966
- * // }
1967
- */
1968
- async summary({ period, timezone } = {}) {
1969
- const options = { query: {} };
1970
- if (period) options.query.period = period;
1971
- if (timezone) options.query.timezone = timezone;
1972
-
1973
- const result = await this.sdk._fetch('/messaging/email/analytics/summary', 'GET', options);
1974
- return result;
1975
- }
1976
-
1977
- /**
1978
- * Get real-time email queue metrics
1979
- * @returns {Promise<Object>} Real-time queue statistics
1980
- * @example
1981
- * // Get current queue status
1982
- * const realtime = await sdk.messaging.email.analytics.realtime();
1983
- * // Returns: { queueDepth, currentSendRatePerMinute, last5Minutes: { sent, delivered, failed } }
1984
- */
1985
- async realtime() {
1986
- const result = await this.sdk._fetch('/messaging/email/analytics/realtime', 'GET');
1987
- return result;
1988
- }
1989
-
1990
- /**
1991
- * Get email error analysis by domain
1992
- * @param {Object} [params] - Error analysis parameters
1993
- * @param {string} [params.period='7d'] - Time period: '24h', '7d', '30d'
1994
- * @returns {Promise<Object>} Error analysis with domain breakdown
1995
- * @example
1996
- * // Get error analysis for last 7 days
1997
- * const errors = await sdk.messaging.email.analytics.errors({ period: '7d' });
1998
- * // Returns: { overallErrorRate, topErrorDomains: [{ domain, errorRate, totalErrors }] }
1999
- */
2000
- async errors({ period } = {}) {
2001
- const options = { query: {} };
2002
- if (period) options.query.period = period;
2003
-
2004
- const result = await this.sdk._fetch('/messaging/email/analytics/errors', 'GET', options);
2005
- return result;
2006
- }
2007
- }
2008
-
2009
- export class EmailQueueService {
2010
- constructor(sdk) {
2011
- this.sdk = sdk;
2012
- }
2013
-
2014
- /**
2015
- * Get email queue items with pagination and status filtering
2016
- * @param {Object} [params] - Queue query parameters
2017
- * @param {number} [params.page=1] - Page number (1-based)
2018
- * @param {number} [params.limit=50] - Number of items per page (max 100)
2019
- * @param {string} [params.status='queued'] - Filter by status: 'queued', 'sent', 'delivered', 'failed'
2020
- * @returns {Promise<Object>} Paginated queue items with metadata
2021
- * @example
2022
- * // Get first page of queued emails
2023
- * const queue = await sdk.messaging.email.queue.list({ page: 1, limit: 25, status: 'queued' });
2024
- * // Returns: {
2025
- * // items: [{
2026
- * // id, status, to, from, subject, carrier, carrierId,
2027
- * // createdAt, lastStatusUpdatedAt, processingTimeSeconds
2028
- * // }],
2029
- * // pagination: {
2030
- * // page, limit, totalItems, totalPages, hasNextPage, hasPreviousPage
2031
- * // },
2032
- * // filter: { status }
2033
- * // }
2034
- */
2035
- async list({ page, limit, status } = {}) {
2036
- const options = { query: {} };
2037
- if (page !== undefined) options.query.page = page;
2038
- if (limit !== undefined) options.query.limit = limit;
2039
- if (status) options.query.status = status;
2040
-
2041
- const result = await this.sdk._fetch('/messaging/email/queue', 'GET', options);
2042
- return result;
2043
- }
2044
-
2045
- /**
2046
- * Get queued emails only (convenience method)
2047
- * @param {Object} [params] - Query parameters
2048
- * @param {number} [params.page=1] - Page number (1-based)
2049
- * @param {number} [params.limit=50] - Number of items per page (max 100)
2050
- * @returns {Promise<Object>} Paginated queued emails
2051
- * @example
2052
- * // Get pending emails waiting to be sent
2053
- * const pending = await sdk.messaging.email.queue.getQueued({ page: 1, limit: 50 });
2054
- */
2055
- async getQueued({ page, limit } = {}) {
2056
- return this.list({ page, limit, status: 'queued' });
2057
- }
2058
-
2059
- /**
2060
- * Get failed emails only (convenience method)
2061
- * @param {Object} [params] - Query parameters
2062
- * @param {number} [params.page=1] - Page number (1-based)
2063
- * @param {number} [params.limit=50] - Number of items per page (max 100)
2064
- * @returns {Promise<Object>} Paginated failed emails
2065
- * @example
2066
- * // Get emails that failed to send
2067
- * const failed = await sdk.messaging.email.queue.getFailed({ page: 1, limit: 50 });
2068
- */
2069
- async getFailed({ page, limit } = {}) {
2070
- return this.list({ page, limit, status: 'failed' });
2071
- }
2072
-
2073
- /**
2074
- * Get sent emails only (convenience method)
2075
- * @param {Object} [params] - Query parameters
2076
- * @param {number} [params.page=1] - Page number (1-based)
2077
- * @param {number} [params.limit=50] - Number of items per page (max 100)
2078
- * @returns {Promise<Object>} Paginated sent emails
2079
- * @example
2080
- * // Get emails that have been sent successfully
2081
- * const sent = await sdk.messaging.email.queue.getSent({ page: 1, limit: 50 });
2082
- */
2083
- async getSent({ page, limit } = {}) {
2084
- return this.list({ page, limit, status: 'sent' });
2085
- }
2086
-
2087
- /**
2088
- * Get delivered emails only (convenience method)
2089
- * @param {Object} [params] - Query parameters
2090
- * @param {number} [params.page=1] - Page number (1-based)
2091
- * @param {number} [params.limit=50] - Number of items per page (max 100)
2092
- * @returns {Promise<Object>} Paginated delivered emails
2093
- * @example
2094
- * // Get emails that have been delivered to recipients
2095
- * const delivered = await sdk.messaging.email.queue.getDelivered({ page: 1, limit: 50 });
2096
- */
2097
- async getDelivered({ page, limit } = {}) {
2098
- return this.list({ page, limit, status: 'delivered' });
2099
- }
2100
- }
1
+ // Import all extracted services
2
+ import { MessagingService } from './messaging/MessagingService.js';
3
+ import { SmsService } from './messaging/SmsService.js';
4
+ import { SmsTemplatesService } from './messaging/SmsTemplatesService.js';
5
+ import { EmailService } from './messaging/EmailService.js';
6
+ import { EmailTemplatesService } from './messaging/EmailTemplatesService.js';
7
+ import { EmailDomainsService } from './messaging/EmailDomainsService.js';
8
+ import { EmailAddressesService } from './messaging/EmailAddressesService.js';
9
+ import { EmailMailboxesService } from './messaging/EmailMailboxesService.js';
10
+ import { CampaignsService } from './messaging/CampaignsService.js';
11
+ import { TollFreeCampaignsService } from './messaging/TollFreeCampaignsService.js';
12
+ import { TenDlcCampaignsService } from './messaging/TenDlcCampaignsService.js';
13
+ import { TenDlcBrandsService } from './messaging/TenDlcBrandsService.js';
14
+ import { TenDlcCampaignManagementService } from './messaging/TenDlcCampaignManagementService.js';
15
+ import { EmailAnalyticsService } from './messaging/EmailAnalyticsService.js';
16
+ import { EmailQueueService } from './messaging/EmailQueueService.js';
17
+ import { EmailSuppressionService } from './messaging/EmailSuppressionService.js';
18
+
19
+ // Re-export all services - maintains exact same API
20
+ export {
21
+ MessagingService,
22
+ SmsService,
23
+ SmsTemplatesService,
24
+ EmailService,
25
+ EmailTemplatesService,
26
+ EmailDomainsService,
27
+ EmailAddressesService,
28
+ EmailMailboxesService,
29
+ CampaignsService,
30
+ TollFreeCampaignsService,
31
+ TenDlcCampaignsService,
32
+ TenDlcBrandsService,
33
+ TenDlcCampaignManagementService,
34
+ EmailAnalyticsService,
35
+ EmailQueueService,
36
+ EmailSuppressionService,
37
+ };