@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.
@@ -0,0 +1,390 @@
1
+ export class TenDlcCampaignManagementService {
2
+ constructor(sdk) {
3
+ this.sdk = sdk;
4
+ }
5
+
6
+ /**
7
+ * List all 10DLC campaigns with optional filtering
8
+ * @param {Object} [params] - Filter parameters
9
+ * @param {number} [params.page=1] - Page number
10
+ * @param {number} [params.limit=50] - Items per page
11
+ * @param {string} [params.name] - Filter by campaign name
12
+ * @param {string} [params.status] - Filter by status
13
+ * @param {string} [params.operatorType='contains'] - Filter operator: contains, equals, startsWith, endsWith
14
+ * @returns {Promise<Array>} List of campaigns
15
+ */
16
+ async list({ page, limit, name, status, operatorType } = {}) {
17
+ const queryParams = new URLSearchParams();
18
+
19
+ if (page !== undefined) queryParams.append('page', page);
20
+ if (limit !== undefined) queryParams.append('limit', limit);
21
+ if (name) queryParams.append('name', name);
22
+ if (status) queryParams.append('status', status);
23
+ if (operatorType) queryParams.append('operatorType', operatorType);
24
+
25
+ const url = queryParams.toString()
26
+ ? `/messaging/campaigns/10dlc/campaign?${queryParams.toString()}`
27
+ : '/messaging/campaigns/10dlc/campaign';
28
+
29
+ const result = await this.sdk._fetch(url, 'GET');
30
+ return result;
31
+ }
32
+
33
+ /**
34
+ * Create a new 10DLC campaign
35
+ * @param {Object} params - Campaign parameters
36
+ * @param {string} params.brandId - Brand ID (required)
37
+ * @param {string} params.description - Campaign description (required)
38
+ * @param {string} params.messageFlow - Message flow description (required)
39
+ * @param {string} [params.helpMessage] - Help message
40
+ * @param {string} [params.optInMessage] - Opt-in message
41
+ * @param {string} [params.optOutMessage] - Opt-out message
42
+ * @param {string} [params.useCase] - Use case category
43
+ * @param {string} [params.vertical] - Vertical category
44
+ * @returns {Promise<Object>} Created campaign details
45
+ */
46
+ async create({
47
+ brandId,
48
+ description,
49
+ messageFlow,
50
+ helpMessage,
51
+ optInMessage,
52
+ optOutMessage,
53
+ useCase,
54
+ vertical,
55
+ }) {
56
+ this.sdk.validateParams(
57
+ {
58
+ brandId,
59
+ description,
60
+ messageFlow,
61
+ helpMessage,
62
+ optInMessage,
63
+ optOutMessage,
64
+ useCase,
65
+ vertical,
66
+ },
67
+ {
68
+ brandId: { type: 'string', required: true },
69
+ description: { type: 'string', required: true },
70
+ messageFlow: { type: 'string', required: true },
71
+ helpMessage: { type: 'string', required: false },
72
+ optInMessage: { type: 'string', required: false },
73
+ optOutMessage: { type: 'string', required: false },
74
+ useCase: { type: 'string', required: false },
75
+ vertical: { type: 'string', required: false },
76
+ },
77
+ );
78
+
79
+ const campaignData = {
80
+ brandId,
81
+ description,
82
+ messageFlow,
83
+ };
84
+
85
+ if (helpMessage !== undefined) campaignData.helpMessage = helpMessage;
86
+ if (optInMessage !== undefined) campaignData.optInMessage = optInMessage;
87
+ if (optOutMessage !== undefined) campaignData.optOutMessage = optOutMessage;
88
+ if (useCase !== undefined) campaignData.useCase = useCase;
89
+ if (vertical !== undefined) campaignData.vertical = vertical;
90
+
91
+ const options = {
92
+ body: campaignData,
93
+ };
94
+
95
+ const result = await this.sdk._fetch(
96
+ '/messaging/campaigns/10dlc/campaign',
97
+ 'POST',
98
+ options,
99
+ );
100
+ return result;
101
+ }
102
+
103
+ /**
104
+ * Get a 10DLC campaign by ID
105
+ */
106
+ async get(campaignId) {
107
+ this.sdk.validateParams(
108
+ { campaignId },
109
+ {
110
+ campaignId: { type: 'string', required: true },
111
+ },
112
+ );
113
+
114
+ const result = await this.sdk._fetch(
115
+ `/messaging/campaigns/10dlc/campaign/${campaignId}`,
116
+ 'GET',
117
+ );
118
+ return result;
119
+ }
120
+
121
+ /**
122
+ * Update a 10DLC campaign
123
+ * @param {string} campaignId - Campaign ID to update
124
+ * @param {Object} params - Update parameters
125
+ * @param {string} [params.name] - Campaign name
126
+ * @param {string} [params.description] - Campaign description
127
+ * @param {string} [params.messageFlow] - Message flow description
128
+ * @param {Array<string>} [params.samples] - Sample messages (up to 4)
129
+ * @param {string} [params.webhookUrl] - Webhook URL
130
+ * @param {string} [params.helpMessage] - Help message
131
+ * @param {string} [params.optInMessage] - Opt-in message
132
+ * @param {string} [params.optOutMessage] - Opt-out message
133
+ * @param {string} [params.helpKeywords] - Help keywords (comma-separated)
134
+ * @param {string} [params.optinKeywords] - Opt-in keywords (comma-separated)
135
+ * @param {string} [params.optoutKeywords] - Opt-out keywords (comma-separated)
136
+ * @param {boolean} [params.affiliateMarketing] - Affiliate marketing flag
137
+ * @param {boolean} [params.ageGated] - Age gated content flag
138
+ * @param {boolean} [params.directLending] - Direct lending flag
139
+ * @param {boolean} [params.embeddedLink] - Embedded links flag
140
+ * @param {boolean} [params.embeddedPhone] - Embedded phone numbers flag
141
+ * @param {boolean} [params.numberPool] - Number pool usage flag
142
+ * @param {boolean} [params.autoRenewal] - Auto-renewal flag
143
+ * @param {boolean} [params.subscriberHelp] - Subscriber help support flag
144
+ * @param {boolean} [params.subscriberOptin] - Subscriber opt-in requirement flag
145
+ * @param {boolean} [params.subscriberOptout] - Subscriber opt-out support flag
146
+ * @returns {Promise<Object>} Updated campaign information
147
+ */
148
+ async update(
149
+ campaignId,
150
+ {
151
+ name,
152
+ description,
153
+ messageFlow,
154
+ samples,
155
+ webhookUrl,
156
+ helpMessage,
157
+ optInMessage,
158
+ optOutMessage,
159
+ helpKeywords,
160
+ optinKeywords,
161
+ optoutKeywords,
162
+ affiliateMarketing,
163
+ ageGated,
164
+ directLending,
165
+ embeddedLink,
166
+ embeddedPhone,
167
+ numberPool,
168
+ autoRenewal,
169
+ subscriberHelp,
170
+ subscriberOptin,
171
+ subscriberOptout,
172
+ } = {},
173
+ ) {
174
+ this.sdk.validateParams(
175
+ {
176
+ campaignId,
177
+ name,
178
+ description,
179
+ messageFlow,
180
+ samples,
181
+ webhookUrl,
182
+ helpMessage,
183
+ optInMessage,
184
+ optOutMessage,
185
+ helpKeywords,
186
+ optinKeywords,
187
+ optoutKeywords,
188
+ affiliateMarketing,
189
+ ageGated,
190
+ directLending,
191
+ embeddedLink,
192
+ embeddedPhone,
193
+ numberPool,
194
+ autoRenewal,
195
+ subscriberHelp,
196
+ subscriberOptin,
197
+ subscriberOptout,
198
+ },
199
+ {
200
+ campaignId: { type: 'string', required: true },
201
+ name: { type: 'string', required: false },
202
+ description: { type: 'string', required: false },
203
+ messageFlow: { type: 'string', required: false },
204
+ samples: { type: 'array', required: false },
205
+ webhookUrl: { type: 'string', required: false },
206
+ helpMessage: { type: 'string', required: false },
207
+ optInMessage: { type: 'string', required: false },
208
+ optOutMessage: { type: 'string', required: false },
209
+ helpKeywords: { type: 'array', required: false },
210
+ optinKeywords: { type: 'array', required: false },
211
+ optoutKeywords: { type: 'array', required: false },
212
+ affiliateMarketing: { type: 'boolean', required: false },
213
+ ageGated: { type: 'boolean', required: false },
214
+ directLending: { type: 'boolean', required: false },
215
+ embeddedLink: { type: 'boolean', required: false },
216
+ embeddedPhone: { type: 'boolean', required: false },
217
+ numberPool: { type: 'boolean', required: false },
218
+ autoRenewal: { type: 'boolean', required: false },
219
+ subscriberHelp: { type: 'boolean', required: false },
220
+ subscriberOptin: { type: 'boolean', required: false },
221
+ subscriberOptout: { type: 'boolean', required: false },
222
+ },
223
+ );
224
+
225
+ const updateData = {};
226
+ if (name !== undefined) updateData.name = name;
227
+ if (description !== undefined) updateData.description = description;
228
+ if (messageFlow !== undefined) updateData.messageFlow = messageFlow;
229
+ if (samples !== undefined) updateData.samples = samples;
230
+ if (webhookUrl !== undefined) updateData.webhookUrl = webhookUrl;
231
+ if (helpMessage !== undefined) updateData.helpMessage = helpMessage;
232
+ if (optInMessage !== undefined) updateData.optInMessage = optInMessage;
233
+ if (optOutMessage !== undefined) updateData.optOutMessage = optOutMessage;
234
+ if (helpKeywords !== undefined) updateData.helpKeywords = helpKeywords;
235
+ if (optinKeywords !== undefined) updateData.optinKeywords = optinKeywords;
236
+ if (optoutKeywords !== undefined)
237
+ updateData.optoutKeywords = optoutKeywords;
238
+ if (affiliateMarketing !== undefined)
239
+ updateData.affiliateMarketing = affiliateMarketing;
240
+ if (ageGated !== undefined) updateData.ageGated = ageGated;
241
+ if (directLending !== undefined) updateData.directLending = directLending;
242
+ if (embeddedLink !== undefined) updateData.embeddedLink = embeddedLink;
243
+ if (embeddedPhone !== undefined) updateData.embeddedPhone = embeddedPhone;
244
+ if (numberPool !== undefined) updateData.numberPool = numberPool;
245
+ if (autoRenewal !== undefined) updateData.autoRenewal = autoRenewal;
246
+ if (subscriberHelp !== undefined)
247
+ updateData.subscriberHelp = subscriberHelp;
248
+ if (subscriberOptin !== undefined)
249
+ updateData.subscriberOptin = subscriberOptin;
250
+ if (subscriberOptout !== undefined)
251
+ updateData.subscriberOptout = subscriberOptout;
252
+
253
+ const options = {
254
+ body: updateData,
255
+ };
256
+
257
+ const result = await this.sdk._fetch(
258
+ `/messaging/campaigns/10dlc/campaign/${campaignId}`,
259
+ 'PUT',
260
+ options,
261
+ );
262
+ return result;
263
+ }
264
+
265
+ /**
266
+ * Delete a 10DLC campaign
267
+ */
268
+ async delete(campaignId) {
269
+ this.sdk.validateParams(
270
+ { campaignId },
271
+ {
272
+ campaignId: { type: 'string', required: true },
273
+ },
274
+ );
275
+
276
+ const result = await this.sdk._fetch(
277
+ `/messaging/campaigns/10dlc/campaign/${campaignId}`,
278
+ 'DELETE',
279
+ );
280
+ return result;
281
+ }
282
+
283
+ /**
284
+ * Get campaign operation status
285
+ */
286
+ async getOperationStatus(campaignId) {
287
+ this.sdk.validateParams(
288
+ { campaignId },
289
+ {
290
+ campaignId: { type: 'string', required: true },
291
+ },
292
+ );
293
+
294
+ const result = await this.sdk._fetch(
295
+ `/messaging/campaigns/10dlc/campaign/${campaignId}/operationStatus`,
296
+ 'GET',
297
+ );
298
+ return result;
299
+ }
300
+
301
+ /**
302
+ * Get MNO campaign metadata
303
+ */
304
+ async getMnoMetaData(campaignId) {
305
+ this.sdk.validateParams(
306
+ { campaignId },
307
+ {
308
+ campaignId: { type: 'string', required: true },
309
+ },
310
+ );
311
+
312
+ const result = await this.sdk._fetch(
313
+ `/messaging/campaigns/10dlc/campaign/${campaignId}/mnoMetaData`,
314
+ 'GET',
315
+ );
316
+ return result;
317
+ }
318
+
319
+ /**
320
+ * Add phone number to campaign
321
+ */
322
+ async addPhoneNumber(campaignId, phoneNumberData) {
323
+ this.sdk.validateParams(
324
+ { campaignId, phoneNumberData },
325
+ {
326
+ campaignId: { type: 'string', required: true },
327
+ phoneNumberData: { type: 'object', required: true },
328
+ },
329
+ );
330
+
331
+ const options = {
332
+ body: phoneNumberData,
333
+ };
334
+
335
+ const result = await this.sdk._fetch(
336
+ `/messaging/campaigns/10dlc/campaign/${campaignId}/phoneNumber`,
337
+ 'POST',
338
+ options,
339
+ );
340
+ return result;
341
+ }
342
+
343
+ /**
344
+ * Update phone number in campaign
345
+ */
346
+ async updatePhoneNumber(campaignId, phoneNumberData) {
347
+ this.sdk.validateParams(
348
+ { campaignId, phoneNumberData },
349
+ {
350
+ campaignId: { type: 'string', required: true },
351
+ phoneNumberData: { type: 'object', required: true },
352
+ },
353
+ );
354
+
355
+ const options = {
356
+ body: phoneNumberData,
357
+ };
358
+
359
+ const result = await this.sdk._fetch(
360
+ `/messaging/campaigns/10dlc/campaign/${campaignId}/phoneNumber`,
361
+ 'PUT',
362
+ options,
363
+ );
364
+ return result;
365
+ }
366
+
367
+ /**
368
+ * Remove phone number from campaign
369
+ */
370
+ async removePhoneNumber(campaignId, phoneNumberData) {
371
+ this.sdk.validateParams(
372
+ { campaignId, phoneNumberData },
373
+ {
374
+ campaignId: { type: 'string', required: true },
375
+ phoneNumberData: { type: 'object', required: true },
376
+ },
377
+ );
378
+
379
+ const options = {
380
+ body: phoneNumberData,
381
+ };
382
+
383
+ const result = await this.sdk._fetch(
384
+ `/messaging/campaigns/10dlc/campaign/${campaignId}/phoneNumber`,
385
+ 'DELETE',
386
+ options,
387
+ );
388
+ return result;
389
+ }
390
+ }
@@ -0,0 +1,32 @@
1
+ import { TenDlcBrandsService } from './TenDlcBrandsService.js';
2
+ import { TenDlcCampaignManagementService } from './TenDlcCampaignManagementService.js';
3
+
4
+ export class TenDlcCampaignsService {
5
+ constructor(sdk) {
6
+ this.sdk = sdk;
7
+ this.brands = new TenDlcBrandsService(sdk);
8
+ this.campaigns = new TenDlcCampaignManagementService(sdk);
9
+ }
10
+
11
+ /**
12
+ * Get phone number campaign status for 10DLC
13
+ * @param {string} phoneNumber - Phone number to check
14
+ * @returns {Promise<Object>} Campaign status information
15
+ */
16
+ async getPhoneNumberCampaignStatus(phoneNumber) {
17
+ this.sdk.validateParams(
18
+ { phoneNumber },
19
+ {
20
+ phoneNumber: { type: 'string', required: true },
21
+ },
22
+ );
23
+
24
+ const result = await this.sdk._fetch(
25
+ `/messaging/campaigns/10dlc/phoneNumber/${encodeURIComponent(
26
+ phoneNumber,
27
+ )}/campaignStatus`,
28
+ 'GET',
29
+ );
30
+ return result;
31
+ }
32
+ }