@unboundcx/sdk 2.8.7 → 2.8.8

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.
@@ -31,71 +31,165 @@ export class TenDlcCampaignManagementService {
31
31
  }
32
32
 
33
33
  /**
34
- * Create a new 10DLC campaign
34
+ * Create a new 10DLC campaign draft
35
35
  * @param {Object} params - Campaign parameters
36
+ * @param {string} params.name - Campaign name (required)
36
37
  * @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
38
+ * @param {string} [params.description] - Campaign description
39
+ * @param {string} [params.messageFlow] - How users opt in
42
40
  * @param {string} [params.useCase] - Use case category
41
+ * @param {string[]} [params.samples] - Sample messages (2-5)
42
+ * @param {boolean} [params.autoRenewal] - Auto-renew campaign
43
43
  * @param {string} [params.vertical] - Vertical category
44
+ * @param {string[]} [params.subUseCases] - Sub use cases
45
+ * @param {string} [params.helpMessage] - Response to HELP keyword
46
+ * @param {string[]} [params.helpKeywords] - Help keywords
47
+ * @param {string} [params.optInMessage] - Opt-in message
48
+ * @param {string[]} [params.optInKeywords] - Opt-in keywords
49
+ * @param {string} [params.optOutMessage] - Opt-out message
50
+ * @param {string[]} [params.optOutKeywords] - Opt-out keywords
51
+ * @param {boolean} [params.affiliateMarketing] - Affiliate marketing
52
+ * @param {boolean} [params.ageGated] - Age gated content
53
+ * @param {boolean} [params.directLending] - Direct lending
54
+ * @param {boolean} [params.embeddedLink] - Messages contain URLs
55
+ * @param {boolean} [params.embeddedPhone] - Messages contain phone numbers
56
+ * @param {boolean} [params.numberPool] - Using number pool
57
+ * @param {boolean} [params.subscriberHelp] - HELP keyword supported
58
+ * @param {boolean} [params.subscriberOptin] - Subscribers opted in
59
+ * @param {boolean} [params.subscriberOptout] - Subscribers can opt out
60
+ * @param {boolean} [params.termsAndConditions] - T&C accepted
61
+ * @param {string[]} [params.mnoIds] - MNO IDs
62
+ * @param {string} [params.referenceId] - Custom reference ID
44
63
  * @returns {Promise<Object>} Created campaign details
45
64
  */
46
65
  async create({
66
+ name,
47
67
  brandId,
48
68
  description,
49
69
  messageFlow,
70
+ useCase,
71
+ samples,
72
+ autoRenewal,
73
+ vertical,
74
+ subUseCases,
50
75
  helpMessage,
76
+ helpKeywords,
51
77
  optInMessage,
78
+ optInKeywords,
52
79
  optOutMessage,
53
- useCase,
54
- vertical,
80
+ optOutKeywords,
81
+ affiliateMarketing,
82
+ ageGated,
83
+ directLending,
84
+ embeddedLink,
85
+ embeddedPhone,
86
+ numberPool,
87
+ subscriberHelp,
88
+ subscriberOptin,
89
+ subscriberOptout,
90
+ termsAndConditions,
91
+ mnoIds,
92
+ referenceId,
55
93
  }) {
56
94
  this.sdk.validateParams(
95
+ { name, brandId },
57
96
  {
58
- brandId,
59
- description,
60
- messageFlow,
61
- helpMessage,
62
- optInMessage,
63
- optOutMessage,
64
- useCase,
65
- vertical,
66
- },
67
- {
97
+ name: { type: 'string', required: true },
68
98
  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
99
  },
77
100
  );
78
101
 
79
102
  const campaignData = {
103
+ name,
80
104
  brandId,
81
105
  description,
82
106
  messageFlow,
107
+ useCase,
108
+ samples,
83
109
  };
84
110
 
111
+ if (autoRenewal !== undefined) campaignData.autoRenewal = autoRenewal;
112
+ if (vertical !== undefined) campaignData.vertical = vertical;
113
+ if (subUseCases !== undefined) campaignData.subUseCases = subUseCases;
85
114
  if (helpMessage !== undefined) campaignData.helpMessage = helpMessage;
115
+ if (helpKeywords !== undefined) campaignData.helpKeywords = helpKeywords;
86
116
  if (optInMessage !== undefined) campaignData.optInMessage = optInMessage;
117
+ if (optInKeywords !== undefined) campaignData.optInKeywords = optInKeywords;
87
118
  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
- };
119
+ if (optOutKeywords !== undefined)
120
+ campaignData.optOutKeywords = optOutKeywords;
121
+ if (affiliateMarketing !== undefined)
122
+ campaignData.affiliateMarketing = affiliateMarketing;
123
+ if (ageGated !== undefined) campaignData.ageGated = ageGated;
124
+ if (directLending !== undefined) campaignData.directLending = directLending;
125
+ if (embeddedLink !== undefined) campaignData.embeddedLink = embeddedLink;
126
+ if (embeddedPhone !== undefined) campaignData.embeddedPhone = embeddedPhone;
127
+ if (numberPool !== undefined) campaignData.numberPool = numberPool;
128
+ if (subscriberHelp !== undefined)
129
+ campaignData.subscriberHelp = subscriberHelp;
130
+ if (subscriberOptin !== undefined)
131
+ campaignData.subscriberOptin = subscriberOptin;
132
+ if (subscriberOptout !== undefined)
133
+ campaignData.subscriberOptout = subscriberOptout;
134
+ if (termsAndConditions !== undefined)
135
+ campaignData.termsAndConditions = termsAndConditions;
136
+ if (mnoIds !== undefined) campaignData.mnoIds = mnoIds;
137
+ if (referenceId !== undefined) campaignData.referenceId = referenceId;
94
138
 
95
139
  const result = await this.sdk._fetch(
96
140
  '/messaging/campaigns/10dlc/campaign',
97
141
  'POST',
98
- options,
142
+ { body: campaignData },
143
+ );
144
+ return result;
145
+ }
146
+
147
+ /**
148
+ * Submit a draft 10DLC campaign to TCR for registration
149
+ * @param {string} campaignId - Campaign ID to submit
150
+ * @param {Object} params - Submit parameters
151
+ * @param {boolean} params.termsAndConditions - Must be true to accept carrier T&C
152
+ * @returns {Promise<Object>} Submission result with campaign status
153
+ */
154
+ async submit(campaignId, { termsAndConditions } = {}) {
155
+ this.sdk.validateParams(
156
+ { campaignId, termsAndConditions },
157
+ {
158
+ campaignId: { type: 'string', required: true },
159
+ termsAndConditions: { type: 'boolean', required: true },
160
+ },
161
+ );
162
+
163
+ const result = await this.sdk._fetch(
164
+ `/messaging/campaigns/10dlc/campaign/${campaignId}/submit`,
165
+ 'POST',
166
+ { body: { termsAndConditions } },
167
+ );
168
+ return result;
169
+ }
170
+
171
+ /**
172
+ * Duplicate an existing campaign as a new Draft
173
+ * @param {string} campaignId - Source campaign ID to copy from
174
+ * @param {Object} [params] - Optional parameters
175
+ * @param {string} [params.name] - Name for the new campaign (defaults to "Original Name (Copy)")
176
+ * @returns {Promise<Object>} New draft campaign details
177
+ */
178
+ async duplicate(campaignId, { name } = {}) {
179
+ this.sdk.validateParams(
180
+ { campaignId },
181
+ {
182
+ campaignId: { type: 'string', required: true },
183
+ },
184
+ );
185
+
186
+ const body = {};
187
+ if (name !== undefined) body.name = name;
188
+
189
+ const result = await this.sdk._fetch(
190
+ `/messaging/campaigns/10dlc/campaign/${campaignId}/duplicate`,
191
+ 'POST',
192
+ { body },
99
193
  );
100
194
  return result;
101
195
  }
@@ -124,25 +218,30 @@ export class TenDlcCampaignManagementService {
124
218
  * @param {Object} params - Update parameters
125
219
  * @param {string} [params.name] - Campaign name
126
220
  * @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)
221
+ * @param {string} [params.messageFlow] - How users opt in
222
+ * @param {string} [params.useCase] - Use case category
223
+ * @param {string} [params.vertical] - Vertical category
224
+ * @param {string[]} [params.samples] - Sample messages (up to 5)
225
+ * @param {string[]} [params.subUseCases] - Sub use cases
129
226
  * @param {string} [params.webhookUrl] - Webhook URL
130
- * @param {string} [params.helpMessage] - Help message
227
+ * @param {string} [params.helpMessage] - Response to HELP keyword
228
+ * @param {string[]} [params.helpKeywords] - Help keywords
131
229
  * @param {string} [params.optInMessage] - Opt-in message
230
+ * @param {string[]} [params.optInKeywords] - Opt-in keywords
132
231
  * @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
232
+ * @param {string[]} [params.optOutKeywords] - Opt-out keywords
233
+ * @param {boolean} [params.affiliateMarketing] - Affiliate marketing
234
+ * @param {boolean} [params.ageGated] - Age gated content
235
+ * @param {boolean} [params.directLending] - Direct lending
236
+ * @param {boolean} [params.embeddedLink] - Messages contain URLs
237
+ * @param {boolean} [params.embeddedPhone] - Messages contain phone numbers
238
+ * @param {boolean} [params.numberPool] - Using number pool
239
+ * @param {boolean} [params.autoRenewal] - Auto-renew campaign
240
+ * @param {boolean} [params.subscriberHelp] - HELP keyword supported
241
+ * @param {boolean} [params.subscriberOptin] - Subscribers opted in
242
+ * @param {boolean} [params.subscriberOptout] - Subscribers can opt out
243
+ * @param {boolean} [params.termsAndConditions] - T&C accepted
244
+ * @param {string[]} [params.mnoIds] - MNO IDs
146
245
  * @returns {Promise<Object>} Updated campaign information
147
246
  */
148
247
  async update(
@@ -151,14 +250,17 @@ export class TenDlcCampaignManagementService {
151
250
  name,
152
251
  description,
153
252
  messageFlow,
253
+ useCase,
254
+ vertical,
154
255
  samples,
256
+ subUseCases,
155
257
  webhookUrl,
156
258
  helpMessage,
259
+ helpKeywords,
157
260
  optInMessage,
261
+ optInKeywords,
158
262
  optOutMessage,
159
- helpKeywords,
160
- optinKeywords,
161
- optoutKeywords,
263
+ optOutKeywords,
162
264
  affiliateMarketing,
163
265
  ageGated,
164
266
  directLending,
@@ -169,56 +271,14 @@ export class TenDlcCampaignManagementService {
169
271
  subscriberHelp,
170
272
  subscriberOptin,
171
273
  subscriberOptout,
274
+ termsAndConditions,
275
+ mnoIds,
172
276
  } = {},
173
277
  ) {
174
278
  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
- },
279
+ { campaignId },
199
280
  {
200
281
  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
282
  },
223
283
  );
224
284
 
@@ -226,15 +286,18 @@ export class TenDlcCampaignManagementService {
226
286
  if (name !== undefined) updateData.name = name;
227
287
  if (description !== undefined) updateData.description = description;
228
288
  if (messageFlow !== undefined) updateData.messageFlow = messageFlow;
289
+ if (useCase !== undefined) updateData.useCase = useCase;
290
+ if (vertical !== undefined) updateData.vertical = vertical;
229
291
  if (samples !== undefined) updateData.samples = samples;
292
+ if (subUseCases !== undefined) updateData.subUseCases = subUseCases;
230
293
  if (webhookUrl !== undefined) updateData.webhookUrl = webhookUrl;
231
294
  if (helpMessage !== undefined) updateData.helpMessage = helpMessage;
295
+ if (helpKeywords !== undefined) updateData.helpKeywords = helpKeywords;
232
296
  if (optInMessage !== undefined) updateData.optInMessage = optInMessage;
297
+ if (optInKeywords !== undefined) updateData.optInKeywords = optInKeywords;
233
298
  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;
299
+ if (optOutKeywords !== undefined)
300
+ updateData.optOutKeywords = optOutKeywords;
238
301
  if (affiliateMarketing !== undefined)
239
302
  updateData.affiliateMarketing = affiliateMarketing;
240
303
  if (ageGated !== undefined) updateData.ageGated = ageGated;
@@ -249,15 +312,14 @@ export class TenDlcCampaignManagementService {
249
312
  updateData.subscriberOptin = subscriberOptin;
250
313
  if (subscriberOptout !== undefined)
251
314
  updateData.subscriberOptout = subscriberOptout;
252
-
253
- const options = {
254
- body: updateData,
255
- };
315
+ if (termsAndConditions !== undefined)
316
+ updateData.termsAndConditions = termsAndConditions;
317
+ if (mnoIds !== undefined) updateData.mnoIds = mnoIds;
256
318
 
257
319
  const result = await this.sdk._fetch(
258
320
  `/messaging/campaigns/10dlc/campaign/${campaignId}`,
259
321
  'PUT',
260
- options,
322
+ { body: updateData },
261
323
  );
262
324
  return result;
263
325
  }
@@ -316,6 +378,26 @@ export class TenDlcCampaignManagementService {
316
378
  return result;
317
379
  }
318
380
 
381
+ /**
382
+ * List phone numbers assigned to a campaign
383
+ * @param {string} campaignId - Campaign ID
384
+ * @returns {Promise<Array>} List of phone numbers with linking status
385
+ */
386
+ async listPhoneNumbers(campaignId) {
387
+ this.sdk.validateParams(
388
+ { campaignId },
389
+ {
390
+ campaignId: { type: 'string', required: true },
391
+ },
392
+ );
393
+
394
+ const result = await this.sdk._fetch(
395
+ `/messaging/campaigns/10dlc/campaign/${campaignId}/phoneNumbers`,
396
+ 'GET',
397
+ );
398
+ return result;
399
+ }
400
+
319
401
  /**
320
402
  * Add phone number to campaign
321
403
  */