@unboundcx/sdk 2.2.6 → 2.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unboundcx/sdk",
3
- "version": "2.2.6",
3
+ "version": "2.3.0",
4
4
  "description": "Official JavaScript SDK for the Unbound API - A comprehensive toolkit for integrating with Unbound's communication, AI, and data management services",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -188,16 +188,29 @@ export class PhoneNumbersService {
188
188
  }
189
189
 
190
190
  async getRoutingOptions() {
191
- const result = await this.sdk._fetch('/phoneNumbers/routing-options', 'GET');
191
+ const result = await this.sdk._fetch(
192
+ '/phoneNumbers/routing-options',
193
+ 'GET',
194
+ );
192
195
  return result;
193
196
  }
194
197
 
195
198
  async getSupportedCountries() {
196
- const result = await this.sdk._fetch('/phoneNumbers/supported-countries', 'GET');
199
+ const result = await this.sdk._fetch(
200
+ '/phoneNumbers/supported-countries',
201
+ 'GET',
202
+ );
197
203
  return result;
198
204
  }
199
205
 
200
206
  // Porting Methods
207
+
208
+ /**
209
+ * Check portability of phone numbers
210
+ * @param {Object} params
211
+ * @param {string[]} params.phoneNumbers - Array of +E.164 formatted phone numbers
212
+ * @returns {Promise<Object>} Portability check results
213
+ */
201
214
  async checkPortability({ phoneNumbers }) {
202
215
  this.sdk.validateParams(
203
216
  { phoneNumbers },
@@ -206,36 +219,80 @@ export class PhoneNumbersService {
206
219
  },
207
220
  );
208
221
 
209
- const result = await this.sdk._fetch('/phoneNumbers/porting/portability-check', 'POST', {
210
- body: { phoneNumbers }
211
- });
222
+ const result = await this.sdk._fetch(
223
+ '/phoneNumbers/porting/portability-check',
224
+ 'POST',
225
+ {
226
+ body: { phoneNumbers },
227
+ },
228
+ );
212
229
  return result;
213
230
  }
214
231
 
232
+ /**
233
+ * Create a draft porting order (no validation - can be built incrementally)
234
+ * @param {Object} params
235
+ * @param {string[]} [params.phoneNumbers] - Array of +E.164 formatted phone numbers
236
+ * @param {Object[]} [params.phoneNumberBlocks] - Array of phone number blocks
237
+ * @param {string} [params.customerReference] - Customer-specified reference number
238
+ * @param {Object} [params.endUser] - End user information
239
+ * @param {Object} [params.endUser.admin] - Admin contact info
240
+ * @param {string} [params.endUser.admin.entityName] - Business/entity name
241
+ * @param {string} [params.endUser.admin.authPersonName] - Authorized person name
242
+ * @param {string} [params.endUser.admin.billingPhoneNumber] - Billing phone number
243
+ * @param {string} [params.endUser.admin.accountNumber] - Account number with current provider
244
+ * @param {string} [params.endUser.admin.taxIdentifier] - Tax identification number (EU)
245
+ * @param {string} [params.endUser.admin.pinPasscode] - PIN/passcode for account access
246
+ * @param {string} [params.endUser.admin.businessIdentifier] - Business identifier (EU)
247
+ * @param {Object} [params.endUser.location] - Location information
248
+ * @param {string} [params.endUser.location.streetAddress] - Street address
249
+ * @param {string} [params.endUser.location.extendedAddress] - Apt/suite/etc
250
+ * @param {string} [params.endUser.location.locality] - City
251
+ * @param {string} [params.endUser.location.administrativeArea] - State/province
252
+ * @param {string} [params.endUser.location.postalCode] - ZIP/postal code
253
+ * @param {string} [params.endUser.location.countryCode] - 2-letter country code
254
+ * @param {Object} [params.activationSettings] - Activation preferences
255
+ * @param {string} [params.activationSettings.focDatetimeRequested] - Requested FOC date/time
256
+ * @param {string} [params.activationSettings.focDatetimeActual] - Actual FOC date/time
257
+ * @param {boolean} [params.activationSettings.fastPortEligible] - Fast port eligibility
258
+ * @param {string} [params.activationSettings.activationStatus] - Activation status
259
+ * @param {Object} [params.phoneNumberConfiguration] - Phone number config
260
+ * @param {string} [params.phoneNumberConfiguration.billingGroupId] - Billing group ID
261
+ * @param {string} [params.phoneNumberConfiguration.connectionId] - Connection ID
262
+ * @param {string} [params.phoneNumberConfiguration.messagingProfileId] - Messaging profile ID
263
+ * @param {string} [params.phoneNumberConfiguration.emergencyAddressId] - Emergency address ID
264
+ * @param {string} [params.phoneNumberConfiguration.phoneNumberType] - Phone number type
265
+ * @param {string} [params.phoneNumberConfiguration.description] - Description
266
+ * @param {string[]} [params.tags] - Array of tags for organization
267
+ * @returns {Promise<Object>} Created draft porting order with ID and status 'draft'
268
+ */
215
269
  async createPortingOrder({
216
270
  phoneNumbers,
217
271
  phoneNumberBlocks,
218
272
  customerReference,
219
273
  endUser,
220
274
  activationSettings,
221
- webhookUrl,
222
- ...additionalData
275
+ phoneNumberConfiguration,
276
+ tags
223
277
  } = {}) {
224
278
  // No validation - creates draft order that can be built incrementally
225
- const body = {
226
- ...additionalData
227
- };
279
+ const body = {};
228
280
 
229
281
  if (phoneNumbers) body.phoneNumbers = phoneNumbers;
230
282
  if (phoneNumberBlocks) body.phoneNumberBlocks = phoneNumberBlocks;
231
283
  if (customerReference) body.customerReference = customerReference;
232
284
  if (endUser) body.endUser = endUser;
233
285
  if (activationSettings) body.activationSettings = activationSettings;
234
- if (webhookUrl) body.webhookUrl = webhookUrl;
286
+ if (phoneNumberConfiguration) body.phoneNumberConfiguration = phoneNumberConfiguration;
287
+ if (tags) body.tags = tags;
235
288
 
236
- const result = await this.sdk._fetch('/phoneNumbers/porting/orders', 'POST', {
237
- body: body
238
- });
289
+ const result = await this.sdk._fetch(
290
+ '/phoneNumbers/porting/orders',
291
+ 'POST',
292
+ {
293
+ body: body,
294
+ },
295
+ );
239
296
  return result;
240
297
  }
241
298
 
@@ -245,20 +302,24 @@ export class PhoneNumbersService {
245
302
  status,
246
303
  customerReference,
247
304
  sort,
248
- limit
305
+ limit,
249
306
  } = {}) {
250
307
  const params = new URLSearchParams();
251
-
308
+
252
309
  if (page) params.append('page', page);
253
- if (includePhoneNumbers !== undefined) params.append('includePhoneNumbers', includePhoneNumbers);
310
+ if (includePhoneNumbers !== undefined)
311
+ params.append('includePhoneNumbers', includePhoneNumbers);
254
312
  if (status) params.append('status', status);
255
- if (customerReference) params.append('customerReference', customerReference);
313
+ if (customerReference)
314
+ params.append('customerReference', customerReference);
256
315
  if (sort) params.append('sort', sort);
257
316
  if (limit) params.append('limit', limit);
258
317
 
259
318
  const queryString = params.toString();
260
- const url = queryString ? `/phoneNumbers/porting/orders?${queryString}` : '/phoneNumbers/porting/orders';
261
-
319
+ const url = queryString
320
+ ? `/phoneNumbers/porting/orders?${queryString}`
321
+ : '/phoneNumbers/porting/orders';
322
+
262
323
  const result = await this.sdk._fetch(url, 'GET');
263
324
  return result;
264
325
  }
@@ -272,31 +333,66 @@ export class PhoneNumbersService {
272
333
  );
273
334
 
274
335
  const params = new URLSearchParams();
275
- if (includePhoneNumbers !== undefined) params.append('includePhoneNumbers', includePhoneNumbers);
276
-
336
+ if (includePhoneNumbers !== undefined)
337
+ params.append('includePhoneNumbers', includePhoneNumbers);
338
+
277
339
  const queryString = params.toString();
278
- const url = queryString ? `/phoneNumbers/porting/orders/${id}?${queryString}` : `/phoneNumbers/porting/orders/${id}`;
279
-
340
+ const url = queryString
341
+ ? `/phoneNumbers/porting/orders/${id}?${queryString}`
342
+ : `/phoneNumbers/porting/orders/${id}`;
343
+
280
344
  const result = await this.sdk._fetch(url, 'GET');
281
345
  return result;
282
346
  }
283
347
 
284
- async updatePortingOrder(id, updateData) {
348
+ /**
349
+ * Update a draft porting order (same parameters as createPortingOrder)
350
+ * @param {string} id - Porting order ID
351
+ * @param {Object} params - Same parameters as createPortingOrder
352
+ * @returns {Promise<Object>} Updated porting order
353
+ */
354
+ async updatePortingOrder(id, {
355
+ phoneNumbers,
356
+ phoneNumberBlocks,
357
+ customerReference,
358
+ endUser,
359
+ activationSettings,
360
+ phoneNumberConfiguration,
361
+ tags
362
+ } = {}) {
285
363
  this.sdk.validateParams(
286
- { id, updateData },
364
+ { id },
287
365
  {
288
366
  id: { type: 'string', required: true },
289
- updateData: { type: 'object', required: true },
290
367
  },
291
368
  );
292
369
 
293
- const result = await this.sdk._fetch(`/phoneNumbers/porting/orders/${id}`, 'PUT', {
294
- body: updateData
295
- });
370
+ const body = {};
371
+
372
+ if (phoneNumbers) body.phoneNumbers = phoneNumbers;
373
+ if (phoneNumberBlocks) body.phoneNumberBlocks = phoneNumberBlocks;
374
+ if (customerReference) body.customerReference = customerReference;
375
+ if (endUser) body.endUser = endUser;
376
+ if (activationSettings) body.activationSettings = activationSettings;
377
+ if (phoneNumberConfiguration) body.phoneNumberConfiguration = phoneNumberConfiguration;
378
+ if (tags) body.tags = tags;
379
+
380
+ const result = await this.sdk._fetch(
381
+ `/phoneNumbers/porting/orders/${id}`,
382
+ 'PUT',
383
+ {
384
+ body: body,
385
+ },
386
+ );
296
387
  return result;
297
388
  }
298
389
 
299
- async submitPortingOrder(id, submissionData = {}) {
390
+ /**
391
+ * Submit a draft porting order for processing (validates all required fields)
392
+ * @param {string} id - Porting order ID
393
+ * @returns {Promise<Object>} Submitted porting order with Telnyx status
394
+ */
395
+ async submitPortingOrder(id) {
300
396
  this.sdk.validateParams(
301
397
  { id },
302
398
  {
@@ -304,15 +400,18 @@ export class PhoneNumbersService {
304
400
  },
305
401
  );
306
402
 
307
- // Add the submit status to trigger validation and Telnyx submission
403
+ // Submit the draft order (status is implied)
308
404
  const body = {
309
- ...submissionData,
310
- status: 'submit'
405
+ status: 'submit',
311
406
  };
312
407
 
313
- const result = await this.sdk._fetch(`/phoneNumbers/porting/orders/${id}`, 'PUT', {
314
- body: body
315
- });
408
+ const result = await this.sdk._fetch(
409
+ `/phoneNumbers/porting/orders/${id}`,
410
+ 'PUT',
411
+ {
412
+ body: body,
413
+ },
414
+ );
316
415
  return result;
317
416
  }
318
417
 
@@ -321,7 +420,7 @@ export class PhoneNumbersService {
321
420
  fileContent,
322
421
  contentType = 'application/pdf',
323
422
  documentType = 'loa',
324
- portingOrderId
423
+ portingOrderId,
325
424
  }) {
326
425
  this.sdk.validateParams(
327
426
  { filename, fileContent },
@@ -335,14 +434,18 @@ export class PhoneNumbersService {
335
434
  filename,
336
435
  fileContent,
337
436
  contentType,
338
- documentType
437
+ documentType,
339
438
  };
340
439
 
341
440
  if (portingOrderId) body.portingOrderId = portingOrderId;
342
441
 
343
- const result = await this.sdk._fetch('/phoneNumbers/porting/documents', 'POST', {
344
- body: body
345
- });
442
+ const result = await this.sdk._fetch(
443
+ '/phoneNumbers/porting/documents',
444
+ 'POST',
445
+ {
446
+ body: body,
447
+ },
448
+ );
346
449
  return result;
347
450
  }
348
451
 
@@ -357,10 +460,12 @@ export class PhoneNumbersService {
357
460
  const params = new URLSearchParams();
358
461
  if (page) params.append('page', page);
359
462
  if (limit) params.append('limit', limit);
360
-
463
+
361
464
  const queryString = params.toString();
362
- const url = queryString ? `/phoneNumbers/porting/orders/${id}/events?${queryString}` : `/phoneNumbers/porting/orders/${id}/events`;
363
-
465
+ const url = queryString
466
+ ? `/phoneNumbers/porting/orders/${id}/events?${queryString}`
467
+ : `/phoneNumbers/porting/orders/${id}/events`;
468
+
364
469
  const result = await this.sdk._fetch(url, 'GET');
365
470
  return result;
366
471
  }