@unboundcx/sdk 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +456 -0
- package/base.js +263 -0
- package/index.js +181 -0
- package/package.json +88 -0
- package/services/ai.js +151 -0
- package/services/enroll.js +238 -0
- package/services/externalOAuth.js +117 -0
- package/services/generateId.js +39 -0
- package/services/googleCalendar.js +92 -0
- package/services/layouts.js +91 -0
- package/services/login.js +76 -0
- package/services/lookup.js +53 -0
- package/services/messaging.js +687 -0
- package/services/notes.js +137 -0
- package/services/objects.js +163 -0
- package/services/phoneNumbers.js +215 -0
- package/services/portals.js +127 -0
- package/services/recordTypes.js +173 -0
- package/services/sipEndpoints.js +93 -0
- package/services/storage.js +168 -0
- package/services/subscriptions.js +73 -0
- package/services/verification.js +87 -0
- package/services/video.js +380 -0
- package/services/voice.js +434 -0
- package/services/workflows.js +291 -0
- package/test-backwards-compatibility.js +195 -0
- package/test-complete-coverage.js +247 -0
- package/test-constructor-patterns.js +111 -0
|
@@ -0,0 +1,687 @@
|
|
|
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
|
+
async send({
|
|
17
|
+
from,
|
|
18
|
+
to,
|
|
19
|
+
message,
|
|
20
|
+
templateId,
|
|
21
|
+
variables,
|
|
22
|
+
mediaUrls,
|
|
23
|
+
webhookUrl
|
|
24
|
+
}) {
|
|
25
|
+
const messageData = {};
|
|
26
|
+
if (from) messageData.from = from;
|
|
27
|
+
if (message) messageData.message = message;
|
|
28
|
+
if (templateId) messageData.templateId = templateId;
|
|
29
|
+
if (variables) messageData.variables = variables;
|
|
30
|
+
if (mediaUrls) messageData.mediaUrls = mediaUrls;
|
|
31
|
+
if (webhookUrl) messageData.webhookUrl = webhookUrl;
|
|
32
|
+
|
|
33
|
+
this.sdk.validateParams(
|
|
34
|
+
{ to, ...messageData },
|
|
35
|
+
{
|
|
36
|
+
to: { type: 'string', required: true },
|
|
37
|
+
from: { type: 'string', required: false },
|
|
38
|
+
message: { type: 'string', required: false },
|
|
39
|
+
templateId: { type: 'string', required: false },
|
|
40
|
+
variables: { type: 'object', required: false },
|
|
41
|
+
mediaUrls: { type: 'array', required: false },
|
|
42
|
+
webhookUrl: { type: 'string', required: false },
|
|
43
|
+
},
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const options = {
|
|
47
|
+
body: { to, ...messageData },
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const result = await this.sdk._fetch('/messaging/sms', 'POST', options);
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async get(id) {
|
|
55
|
+
this.sdk.validateParams(
|
|
56
|
+
{ id },
|
|
57
|
+
{
|
|
58
|
+
id: { type: 'string', required: true },
|
|
59
|
+
},
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
const result = await this.sdk._fetch(`/messaging/sms/${id}`, 'GET');
|
|
63
|
+
return result;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export class SmsTemplatesService {
|
|
68
|
+
constructor(sdk) {
|
|
69
|
+
this.sdk = sdk;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async create({ name, message, variables }) {
|
|
73
|
+
this.sdk.validateParams(
|
|
74
|
+
{ name, message },
|
|
75
|
+
{
|
|
76
|
+
name: { type: 'string', required: true },
|
|
77
|
+
message: { type: 'string', required: true },
|
|
78
|
+
variables: { type: 'object', required: false },
|
|
79
|
+
},
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
const templateData = { name, message };
|
|
83
|
+
if (variables) templateData.variables = variables;
|
|
84
|
+
|
|
85
|
+
const options = {
|
|
86
|
+
body: templateData,
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const result = await this.sdk._fetch('/messaging/sms/templates', 'POST', options);
|
|
90
|
+
return result;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
async update(id, { name, message, variables }) {
|
|
94
|
+
this.sdk.validateParams(
|
|
95
|
+
{ id },
|
|
96
|
+
{
|
|
97
|
+
id: { type: 'string', required: true },
|
|
98
|
+
name: { type: 'string', required: false },
|
|
99
|
+
message: { type: 'string', required: false },
|
|
100
|
+
variables: { type: 'object', required: false },
|
|
101
|
+
},
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
const updateData = {};
|
|
105
|
+
if (name) updateData.name = name;
|
|
106
|
+
if (message) updateData.message = message;
|
|
107
|
+
if (variables) updateData.variables = variables;
|
|
108
|
+
|
|
109
|
+
const options = {
|
|
110
|
+
body: updateData,
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const result = await this.sdk._fetch(`/messaging/sms/templates/${id}`, 'PUT', options);
|
|
114
|
+
return result;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
async delete(id) {
|
|
118
|
+
this.sdk.validateParams(
|
|
119
|
+
{ id },
|
|
120
|
+
{
|
|
121
|
+
id: { type: 'string', required: true },
|
|
122
|
+
},
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
const result = await this.sdk._fetch(`/messaging/sms/templates/${id}`, 'DELETE');
|
|
126
|
+
return result;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
async get(id) {
|
|
130
|
+
this.sdk.validateParams(
|
|
131
|
+
{ id },
|
|
132
|
+
{
|
|
133
|
+
id: { type: 'string', required: true },
|
|
134
|
+
},
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
const result = await this.sdk._fetch(`/messaging/sms/templates/${id}`, 'GET');
|
|
138
|
+
return result;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
async list() {
|
|
142
|
+
const result = await this.sdk._fetch('/messaging/sms/templates', 'GET');
|
|
143
|
+
return result;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export class EmailService {
|
|
148
|
+
constructor(sdk) {
|
|
149
|
+
this.sdk = sdk;
|
|
150
|
+
this.templates = new EmailTemplatesService(sdk);
|
|
151
|
+
this.domains = new EmailDomainsService(sdk);
|
|
152
|
+
this.addresses = new EmailAddressesService(sdk);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
async send({
|
|
156
|
+
from,
|
|
157
|
+
to,
|
|
158
|
+
cc,
|
|
159
|
+
bcc,
|
|
160
|
+
subject,
|
|
161
|
+
htmlBody,
|
|
162
|
+
textBody,
|
|
163
|
+
templateId,
|
|
164
|
+
variables,
|
|
165
|
+
attachments,
|
|
166
|
+
replyTo,
|
|
167
|
+
priority,
|
|
168
|
+
tags
|
|
169
|
+
}) {
|
|
170
|
+
this.sdk.validateParams(
|
|
171
|
+
{ from, to, subject },
|
|
172
|
+
{
|
|
173
|
+
from: { type: 'string', required: true },
|
|
174
|
+
to: { type: 'string', required: true },
|
|
175
|
+
subject: { type: 'string', required: true },
|
|
176
|
+
cc: { type: 'string', required: false },
|
|
177
|
+
bcc: { type: 'string', required: false },
|
|
178
|
+
htmlBody: { type: 'string', required: false },
|
|
179
|
+
textBody: { type: 'string', required: false },
|
|
180
|
+
templateId: { type: 'string', required: false },
|
|
181
|
+
variables: { type: 'object', required: false },
|
|
182
|
+
attachments: { type: 'array', required: false },
|
|
183
|
+
replyTo: { type: 'string', required: false },
|
|
184
|
+
priority: { type: 'string', required: false },
|
|
185
|
+
tags: { type: 'array', required: false },
|
|
186
|
+
},
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
const emailData = {
|
|
190
|
+
from,
|
|
191
|
+
to,
|
|
192
|
+
subject,
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
if (cc) emailData.cc = cc;
|
|
196
|
+
if (bcc) emailData.bcc = bcc;
|
|
197
|
+
if (htmlBody) emailData.htmlBody = htmlBody;
|
|
198
|
+
if (textBody) emailData.textBody = textBody;
|
|
199
|
+
if (templateId) emailData.templateId = templateId;
|
|
200
|
+
if (variables) emailData.variables = variables;
|
|
201
|
+
if (attachments) emailData.attachments = attachments;
|
|
202
|
+
if (replyTo) emailData.replyTo = replyTo;
|
|
203
|
+
if (priority) emailData.priority = priority;
|
|
204
|
+
if (tags) emailData.tags = tags;
|
|
205
|
+
|
|
206
|
+
const options = {
|
|
207
|
+
body: emailData,
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
const result = await this.sdk._fetch('/messaging/email', 'POST', options);
|
|
211
|
+
return result;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
async get(id) {
|
|
215
|
+
this.sdk.validateParams(
|
|
216
|
+
{ id },
|
|
217
|
+
{
|
|
218
|
+
id: { type: 'string', required: true },
|
|
219
|
+
},
|
|
220
|
+
);
|
|
221
|
+
|
|
222
|
+
const result = await this.sdk._fetch(`/messaging/email/${id}`, 'GET');
|
|
223
|
+
return result;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
async updateDomain(domain, { dkimEnabled, customDkim }) {
|
|
227
|
+
this.sdk.validateParams(
|
|
228
|
+
{ domain },
|
|
229
|
+
{
|
|
230
|
+
domain: { type: 'string', required: true },
|
|
231
|
+
dkimEnabled: { type: 'boolean', required: false },
|
|
232
|
+
customDkim: { type: 'object', required: false },
|
|
233
|
+
},
|
|
234
|
+
);
|
|
235
|
+
|
|
236
|
+
const updateData = {};
|
|
237
|
+
if (dkimEnabled !== undefined) updateData.dkimEnabled = dkimEnabled;
|
|
238
|
+
if (customDkim) updateData.customDkim = customDkim;
|
|
239
|
+
|
|
240
|
+
const options = {
|
|
241
|
+
body: updateData,
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
const result = await this.sdk._fetch(`/messaging/email/domain/${domain}`, 'PUT', options);
|
|
245
|
+
return result;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export class EmailTemplatesService {
|
|
250
|
+
constructor(sdk) {
|
|
251
|
+
this.sdk = sdk;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
async create({ name, subject, htmlBody, textBody, variables }) {
|
|
255
|
+
this.sdk.validateParams(
|
|
256
|
+
{ name, subject },
|
|
257
|
+
{
|
|
258
|
+
name: { type: 'string', required: true },
|
|
259
|
+
subject: { type: 'string', required: true },
|
|
260
|
+
htmlBody: { type: 'string', required: false },
|
|
261
|
+
textBody: { type: 'string', required: false },
|
|
262
|
+
variables: { type: 'object', required: false },
|
|
263
|
+
},
|
|
264
|
+
);
|
|
265
|
+
|
|
266
|
+
const templateData = { name, subject };
|
|
267
|
+
if (htmlBody) templateData.htmlBody = htmlBody;
|
|
268
|
+
if (textBody) templateData.textBody = textBody;
|
|
269
|
+
if (variables) templateData.variables = variables;
|
|
270
|
+
|
|
271
|
+
const options = {
|
|
272
|
+
body: templateData,
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
const result = await this.sdk._fetch('/messaging/email/templates', 'POST', options);
|
|
276
|
+
return result;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
async update(id, { name, subject, htmlBody, textBody, variables }) {
|
|
280
|
+
this.sdk.validateParams(
|
|
281
|
+
{ id },
|
|
282
|
+
{
|
|
283
|
+
id: { type: 'string', required: true },
|
|
284
|
+
name: { type: 'string', required: false },
|
|
285
|
+
subject: { type: 'string', required: false },
|
|
286
|
+
htmlBody: { type: 'string', required: false },
|
|
287
|
+
textBody: { type: 'string', required: false },
|
|
288
|
+
variables: { type: 'object', required: false },
|
|
289
|
+
},
|
|
290
|
+
);
|
|
291
|
+
|
|
292
|
+
const updateData = {};
|
|
293
|
+
if (name) updateData.name = name;
|
|
294
|
+
if (subject) updateData.subject = subject;
|
|
295
|
+
if (htmlBody) updateData.htmlBody = htmlBody;
|
|
296
|
+
if (textBody) updateData.textBody = textBody;
|
|
297
|
+
if (variables) updateData.variables = variables;
|
|
298
|
+
|
|
299
|
+
const options = {
|
|
300
|
+
body: updateData,
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
const result = await this.sdk._fetch(`/messaging/email/templates/${id}`, 'PUT', options);
|
|
304
|
+
return result;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
async delete(id) {
|
|
308
|
+
this.sdk.validateParams(
|
|
309
|
+
{ id },
|
|
310
|
+
{
|
|
311
|
+
id: { type: 'string', required: true },
|
|
312
|
+
},
|
|
313
|
+
);
|
|
314
|
+
|
|
315
|
+
const result = await this.sdk._fetch(`/messaging/email/templates/${id}`, 'DELETE');
|
|
316
|
+
return result;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
async get(id) {
|
|
320
|
+
this.sdk.validateParams(
|
|
321
|
+
{ id },
|
|
322
|
+
{
|
|
323
|
+
id: { type: 'string', required: true },
|
|
324
|
+
},
|
|
325
|
+
);
|
|
326
|
+
|
|
327
|
+
const result = await this.sdk._fetch(`/messaging/email/templates/${id}`, 'GET');
|
|
328
|
+
return result;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
async list() {
|
|
332
|
+
const result = await this.sdk._fetch('/messaging/email/templates', 'GET');
|
|
333
|
+
return result;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
export class EmailDomainsService {
|
|
338
|
+
constructor(sdk) {
|
|
339
|
+
this.sdk = sdk;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
async create(domain) {
|
|
343
|
+
this.sdk.validateParams(
|
|
344
|
+
{ domain },
|
|
345
|
+
{
|
|
346
|
+
domain: { type: 'string', required: true },
|
|
347
|
+
},
|
|
348
|
+
);
|
|
349
|
+
|
|
350
|
+
const options = {
|
|
351
|
+
body: { domain },
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
const result = await this.sdk._fetch('/messaging/email/domains', 'POST', options);
|
|
355
|
+
return result;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
async delete(domain) {
|
|
359
|
+
this.sdk.validateParams(
|
|
360
|
+
{ domain },
|
|
361
|
+
{
|
|
362
|
+
domain: { type: 'string', required: true },
|
|
363
|
+
},
|
|
364
|
+
);
|
|
365
|
+
|
|
366
|
+
const result = await this.sdk._fetch(`/messaging/email/domains/${domain}`, 'DELETE');
|
|
367
|
+
return result;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
async list() {
|
|
371
|
+
const result = await this.sdk._fetch('/messaging/email/domains', 'GET');
|
|
372
|
+
return result;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
async validateDns(domain) {
|
|
376
|
+
this.sdk.validateParams(
|
|
377
|
+
{ domain },
|
|
378
|
+
{
|
|
379
|
+
domain: { type: 'string', required: true },
|
|
380
|
+
},
|
|
381
|
+
);
|
|
382
|
+
|
|
383
|
+
const result = await this.sdk._fetch(`/messaging/email/domains/${domain}/validate`, 'POST');
|
|
384
|
+
return result;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
async checkStatus(domain) {
|
|
388
|
+
this.sdk.validateParams(
|
|
389
|
+
{ domain },
|
|
390
|
+
{
|
|
391
|
+
domain: { type: 'string', required: true },
|
|
392
|
+
},
|
|
393
|
+
);
|
|
394
|
+
|
|
395
|
+
const result = await this.sdk._fetch(`/messaging/email/domains/${domain}/status`, 'GET');
|
|
396
|
+
return result;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
async update(domain, { dkimEnabled, customDkim }) {
|
|
400
|
+
this.sdk.validateParams(
|
|
401
|
+
{ domain },
|
|
402
|
+
{
|
|
403
|
+
domain: { type: 'string', required: true },
|
|
404
|
+
dkimEnabled: { type: 'boolean', required: false },
|
|
405
|
+
customDkim: { type: 'object', required: false },
|
|
406
|
+
},
|
|
407
|
+
);
|
|
408
|
+
|
|
409
|
+
const updateData = {};
|
|
410
|
+
if (dkimEnabled !== undefined) updateData.dkimEnabled = dkimEnabled;
|
|
411
|
+
if (customDkim) updateData.customDkim = customDkim;
|
|
412
|
+
|
|
413
|
+
const options = {
|
|
414
|
+
body: updateData,
|
|
415
|
+
};
|
|
416
|
+
|
|
417
|
+
const result = await this.sdk._fetch(`/messaging/email/domains/${domain}`, 'PUT', options);
|
|
418
|
+
return result;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
export class EmailAddressesService {
|
|
423
|
+
constructor(sdk) {
|
|
424
|
+
this.sdk = sdk;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
async create(email) {
|
|
428
|
+
this.sdk.validateParams(
|
|
429
|
+
{ email },
|
|
430
|
+
{
|
|
431
|
+
email: { type: 'string', required: true },
|
|
432
|
+
},
|
|
433
|
+
);
|
|
434
|
+
|
|
435
|
+
const options = {
|
|
436
|
+
body: { email },
|
|
437
|
+
};
|
|
438
|
+
|
|
439
|
+
const result = await this.sdk._fetch('/messaging/email/addresses', 'POST', options);
|
|
440
|
+
return result;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
async delete(email) {
|
|
444
|
+
this.sdk.validateParams(
|
|
445
|
+
{ email },
|
|
446
|
+
{
|
|
447
|
+
email: { type: 'string', required: true },
|
|
448
|
+
},
|
|
449
|
+
);
|
|
450
|
+
|
|
451
|
+
const result = await this.sdk._fetch(`/messaging/email/addresses/${encodeURIComponent(email)}`, 'DELETE');
|
|
452
|
+
return result;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
async list() {
|
|
456
|
+
const result = await this.sdk._fetch('/messaging/email/addresses', 'GET');
|
|
457
|
+
return result;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
async checkStatus(email) {
|
|
461
|
+
this.sdk.validateParams(
|
|
462
|
+
{ email },
|
|
463
|
+
{
|
|
464
|
+
email: { type: 'string', required: true },
|
|
465
|
+
},
|
|
466
|
+
);
|
|
467
|
+
|
|
468
|
+
const result = await this.sdk._fetch(`/messaging/email/addresses/${encodeURIComponent(email)}/status`, 'GET');
|
|
469
|
+
return result;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
export class CampaignsService {
|
|
474
|
+
constructor(sdk) {
|
|
475
|
+
this.sdk = sdk;
|
|
476
|
+
this.tollFree = new TollFreeCampaignsService(sdk);
|
|
477
|
+
this.tenDlc = new TenDlcCampaignsService(sdk);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
export class TollFreeCampaignsService {
|
|
482
|
+
constructor(sdk) {
|
|
483
|
+
this.sdk = sdk;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
async create({
|
|
487
|
+
companyName,
|
|
488
|
+
phoneNumber,
|
|
489
|
+
description,
|
|
490
|
+
messageFlow,
|
|
491
|
+
helpMessage,
|
|
492
|
+
optInKeywords,
|
|
493
|
+
optOutKeywords,
|
|
494
|
+
website
|
|
495
|
+
}) {
|
|
496
|
+
this.sdk.validateParams(
|
|
497
|
+
{ companyName, phoneNumber, description, messageFlow },
|
|
498
|
+
{
|
|
499
|
+
companyName: { type: 'string', required: true },
|
|
500
|
+
phoneNumber: { type: 'string', required: true },
|
|
501
|
+
description: { type: 'string', required: true },
|
|
502
|
+
messageFlow: { type: 'string', required: true },
|
|
503
|
+
helpMessage: { type: 'string', required: false },
|
|
504
|
+
optInKeywords: { type: 'array', required: false },
|
|
505
|
+
optOutKeywords: { type: 'array', required: false },
|
|
506
|
+
website: { type: 'string', required: false },
|
|
507
|
+
},
|
|
508
|
+
);
|
|
509
|
+
|
|
510
|
+
const campaignData = {
|
|
511
|
+
companyName,
|
|
512
|
+
phoneNumber,
|
|
513
|
+
description,
|
|
514
|
+
messageFlow,
|
|
515
|
+
};
|
|
516
|
+
|
|
517
|
+
if (helpMessage) campaignData.helpMessage = helpMessage;
|
|
518
|
+
if (optInKeywords) campaignData.optInKeywords = optInKeywords;
|
|
519
|
+
if (optOutKeywords) campaignData.optOutKeywords = optOutKeywords;
|
|
520
|
+
if (website) campaignData.website = website;
|
|
521
|
+
|
|
522
|
+
const options = {
|
|
523
|
+
body: campaignData,
|
|
524
|
+
};
|
|
525
|
+
|
|
526
|
+
const result = await this.sdk._fetch('/messaging/campaigns/tollfree', 'POST', options);
|
|
527
|
+
return result;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
async update(campaignId, updateData) {
|
|
531
|
+
this.sdk.validateParams(
|
|
532
|
+
{ campaignId, updateData },
|
|
533
|
+
{
|
|
534
|
+
campaignId: { type: 'string', required: true },
|
|
535
|
+
updateData: { type: 'object', required: true },
|
|
536
|
+
},
|
|
537
|
+
);
|
|
538
|
+
|
|
539
|
+
const options = {
|
|
540
|
+
body: updateData,
|
|
541
|
+
};
|
|
542
|
+
|
|
543
|
+
const result = await this.sdk._fetch(`/messaging/campaigns/tollfree/${campaignId}`, 'PUT', options);
|
|
544
|
+
return result;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
async delete(campaignId) {
|
|
548
|
+
this.sdk.validateParams(
|
|
549
|
+
{ campaignId },
|
|
550
|
+
{
|
|
551
|
+
campaignId: { type: 'string', required: true },
|
|
552
|
+
},
|
|
553
|
+
);
|
|
554
|
+
|
|
555
|
+
const result = await this.sdk._fetch(`/messaging/campaigns/tollfree/${campaignId}`, 'DELETE');
|
|
556
|
+
return result;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
async get(campaignId) {
|
|
560
|
+
this.sdk.validateParams(
|
|
561
|
+
{ campaignId },
|
|
562
|
+
{
|
|
563
|
+
campaignId: { type: 'string', required: true },
|
|
564
|
+
},
|
|
565
|
+
);
|
|
566
|
+
|
|
567
|
+
const result = await this.sdk._fetch(`/messaging/campaigns/tollfree/${campaignId}`, 'GET');
|
|
568
|
+
return result;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
async list() {
|
|
572
|
+
const result = await this.sdk._fetch('/messaging/campaigns/tollfree', 'GET');
|
|
573
|
+
return result;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
async refreshStatus(campaignId) {
|
|
577
|
+
this.sdk.validateParams(
|
|
578
|
+
{ campaignId },
|
|
579
|
+
{
|
|
580
|
+
campaignId: { type: 'string', required: true },
|
|
581
|
+
},
|
|
582
|
+
);
|
|
583
|
+
|
|
584
|
+
const result = await this.sdk._fetch(`/messaging/campaigns/tollfree/${campaignId}/refresh`, 'POST');
|
|
585
|
+
return result;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
async getPhoneNumberStatus(phoneNumber) {
|
|
589
|
+
this.sdk.validateParams(
|
|
590
|
+
{ phoneNumber },
|
|
591
|
+
{
|
|
592
|
+
phoneNumber: { type: 'string', required: true },
|
|
593
|
+
},
|
|
594
|
+
);
|
|
595
|
+
|
|
596
|
+
const options = {
|
|
597
|
+
query: { phoneNumber },
|
|
598
|
+
};
|
|
599
|
+
|
|
600
|
+
const result = await this.sdk._fetch('/messaging/campaigns/tollfree/phone-number-status', 'GET', options);
|
|
601
|
+
return result;
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
export class TenDlcCampaignsService {
|
|
606
|
+
constructor(sdk) {
|
|
607
|
+
this.sdk = sdk;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
async createBrand({
|
|
611
|
+
companyName,
|
|
612
|
+
ein,
|
|
613
|
+
website,
|
|
614
|
+
stockSymbol,
|
|
615
|
+
stockExchange,
|
|
616
|
+
ipPooling,
|
|
617
|
+
optInMessage,
|
|
618
|
+
optInKeywords,
|
|
619
|
+
optOutMessage,
|
|
620
|
+
optOutKeywords,
|
|
621
|
+
helpMessage,
|
|
622
|
+
helpKeywords
|
|
623
|
+
}) {
|
|
624
|
+
this.sdk.validateParams(
|
|
625
|
+
{ companyName },
|
|
626
|
+
{
|
|
627
|
+
companyName: { type: 'string', required: true },
|
|
628
|
+
ein: { type: 'string', required: false },
|
|
629
|
+
website: { type: 'string', required: false },
|
|
630
|
+
stockSymbol: { type: 'string', required: false },
|
|
631
|
+
stockExchange: { type: 'string', required: false },
|
|
632
|
+
ipPooling: { type: 'boolean', required: false },
|
|
633
|
+
optInMessage: { type: 'string', required: false },
|
|
634
|
+
optInKeywords: { type: 'array', required: false },
|
|
635
|
+
optOutMessage: { type: 'string', required: false },
|
|
636
|
+
optOutKeywords: { type: 'array', required: false },
|
|
637
|
+
helpMessage: { type: 'string', required: false },
|
|
638
|
+
helpKeywords: { type: 'array', required: false },
|
|
639
|
+
},
|
|
640
|
+
);
|
|
641
|
+
|
|
642
|
+
const brandData = { companyName };
|
|
643
|
+
if (ein) brandData.ein = ein;
|
|
644
|
+
if (website) brandData.website = website;
|
|
645
|
+
if (stockSymbol) brandData.stockSymbol = stockSymbol;
|
|
646
|
+
if (stockExchange) brandData.stockExchange = stockExchange;
|
|
647
|
+
if (ipPooling !== undefined) brandData.ipPooling = ipPooling;
|
|
648
|
+
if (optInMessage) brandData.optInMessage = optInMessage;
|
|
649
|
+
if (optInKeywords) brandData.optInKeywords = optInKeywords;
|
|
650
|
+
if (optOutMessage) brandData.optOutMessage = optOutMessage;
|
|
651
|
+
if (optOutKeywords) brandData.optOutKeywords = optOutKeywords;
|
|
652
|
+
if (helpMessage) brandData.helpMessage = helpMessage;
|
|
653
|
+
if (helpKeywords) brandData.helpKeywords = helpKeywords;
|
|
654
|
+
|
|
655
|
+
const options = {
|
|
656
|
+
body: brandData,
|
|
657
|
+
};
|
|
658
|
+
|
|
659
|
+
const result = await this.sdk._fetch('/messaging/campaigns/10dlc/brand', 'POST', options);
|
|
660
|
+
return result;
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
async updateBrand(brandId, {
|
|
664
|
+
companyName,
|
|
665
|
+
website
|
|
666
|
+
}) {
|
|
667
|
+
this.sdk.validateParams(
|
|
668
|
+
{ brandId },
|
|
669
|
+
{
|
|
670
|
+
brandId: { type: 'string', required: true },
|
|
671
|
+
companyName: { type: 'string', required: false },
|
|
672
|
+
website: { type: 'string', required: false },
|
|
673
|
+
},
|
|
674
|
+
);
|
|
675
|
+
|
|
676
|
+
const updateData = {};
|
|
677
|
+
if (companyName) updateData.companyName = companyName;
|
|
678
|
+
if (website) updateData.website = website;
|
|
679
|
+
|
|
680
|
+
const options = {
|
|
681
|
+
body: updateData,
|
|
682
|
+
};
|
|
683
|
+
|
|
684
|
+
const result = await this.sdk._fetch(`/messaging/campaigns/10dlc/brand/${brandId}`, 'PUT', options);
|
|
685
|
+
return result;
|
|
686
|
+
}
|
|
687
|
+
}
|