@unboundcx/sdk 2.2.6 → 2.3.1

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.1",
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,25 +302,42 @@ 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
  }
265
326
 
266
- async getPortingOrder(id, { includePhoneNumbers = true } = {}) {
327
+ /**
328
+ * Get a porting order with optional related data
329
+ * @param {string} id - Porting order ID
330
+ * @param {Object} [options]
331
+ * @param {boolean} [options.includePhoneNumbers=true] - Include phone numbers array
332
+ * @param {boolean} [options.includeExceptions=true] - Include exceptions array
333
+ * @param {boolean} [options.includeDocuments=true] - Include documents array with upload status
334
+ * @returns {Promise<Object>} Porting order with requested related data
335
+ */
336
+ async getPortingOrder(id, {
337
+ includePhoneNumbers = true,
338
+ includeExceptions = true,
339
+ includeDocuments = true
340
+ } = {}) {
267
341
  this.sdk.validateParams(
268
342
  { id },
269
343
  {
@@ -272,31 +346,70 @@ export class PhoneNumbersService {
272
346
  );
273
347
 
274
348
  const params = new URLSearchParams();
275
- if (includePhoneNumbers !== undefined) params.append('includePhoneNumbers', includePhoneNumbers);
276
-
349
+ if (includePhoneNumbers !== undefined)
350
+ params.append('includePhoneNumbers', includePhoneNumbers);
351
+ if (includeExceptions !== undefined)
352
+ params.append('includeExceptions', includeExceptions);
353
+ if (includeDocuments !== undefined)
354
+ params.append('includeDocuments', includeDocuments);
355
+
277
356
  const queryString = params.toString();
278
- const url = queryString ? `/phoneNumbers/porting/orders/${id}?${queryString}` : `/phoneNumbers/porting/orders/${id}`;
279
-
357
+ const url = queryString
358
+ ? `/phoneNumbers/porting/orders/${id}?${queryString}`
359
+ : `/phoneNumbers/porting/orders/${id}`;
360
+
280
361
  const result = await this.sdk._fetch(url, 'GET');
281
362
  return result;
282
363
  }
283
364
 
284
- async updatePortingOrder(id, updateData) {
365
+ /**
366
+ * Update a draft porting order (same parameters as createPortingOrder)
367
+ * @param {string} id - Porting order ID
368
+ * @param {Object} params - Same parameters as createPortingOrder
369
+ * @returns {Promise<Object>} Updated porting order
370
+ */
371
+ async updatePortingOrder(id, {
372
+ phoneNumbers,
373
+ phoneNumberBlocks,
374
+ customerReference,
375
+ endUser,
376
+ activationSettings,
377
+ phoneNumberConfiguration,
378
+ tags
379
+ } = {}) {
285
380
  this.sdk.validateParams(
286
- { id, updateData },
381
+ { id },
287
382
  {
288
383
  id: { type: 'string', required: true },
289
- updateData: { type: 'object', required: true },
290
384
  },
291
385
  );
292
386
 
293
- const result = await this.sdk._fetch(`/phoneNumbers/porting/orders/${id}`, 'PUT', {
294
- body: updateData
295
- });
387
+ const body = {};
388
+
389
+ if (phoneNumbers) body.phoneNumbers = phoneNumbers;
390
+ if (phoneNumberBlocks) body.phoneNumberBlocks = phoneNumberBlocks;
391
+ if (customerReference) body.customerReference = customerReference;
392
+ if (endUser) body.endUser = endUser;
393
+ if (activationSettings) body.activationSettings = activationSettings;
394
+ if (phoneNumberConfiguration) body.phoneNumberConfiguration = phoneNumberConfiguration;
395
+ if (tags) body.tags = tags;
396
+
397
+ const result = await this.sdk._fetch(
398
+ `/phoneNumbers/porting/orders/${id}`,
399
+ 'PUT',
400
+ {
401
+ body: body,
402
+ },
403
+ );
296
404
  return result;
297
405
  }
298
406
 
299
- async submitPortingOrder(id, submissionData = {}) {
407
+ /**
408
+ * Submit a draft porting order for processing (validates all required fields)
409
+ * @param {string} id - Porting order ID
410
+ * @returns {Promise<Object>} Submitted porting order with Telnyx status
411
+ */
412
+ async submitPortingOrder(id) {
300
413
  this.sdk.validateParams(
301
414
  { id },
302
415
  {
@@ -304,15 +417,18 @@ export class PhoneNumbersService {
304
417
  },
305
418
  );
306
419
 
307
- // Add the submit status to trigger validation and Telnyx submission
420
+ // Submit the draft order (status is implied)
308
421
  const body = {
309
- ...submissionData,
310
- status: 'submit'
422
+ status: 'submit',
311
423
  };
312
424
 
313
- const result = await this.sdk._fetch(`/phoneNumbers/porting/orders/${id}`, 'PUT', {
314
- body: body
315
- });
425
+ const result = await this.sdk._fetch(
426
+ `/phoneNumbers/porting/orders/${id}`,
427
+ 'PUT',
428
+ {
429
+ body: body,
430
+ },
431
+ );
316
432
  return result;
317
433
  }
318
434
 
@@ -321,7 +437,7 @@ export class PhoneNumbersService {
321
437
  fileContent,
322
438
  contentType = 'application/pdf',
323
439
  documentType = 'loa',
324
- portingOrderId
440
+ portingOrderId,
325
441
  }) {
326
442
  this.sdk.validateParams(
327
443
  { filename, fileContent },
@@ -335,14 +451,18 @@ export class PhoneNumbersService {
335
451
  filename,
336
452
  fileContent,
337
453
  contentType,
338
- documentType
454
+ documentType,
339
455
  };
340
456
 
341
457
  if (portingOrderId) body.portingOrderId = portingOrderId;
342
458
 
343
- const result = await this.sdk._fetch('/phoneNumbers/porting/documents', 'POST', {
344
- body: body
345
- });
459
+ const result = await this.sdk._fetch(
460
+ '/phoneNumbers/porting/documents',
461
+ 'POST',
462
+ {
463
+ body: body,
464
+ },
465
+ );
346
466
  return result;
347
467
  }
348
468
 
@@ -357,10 +477,12 @@ export class PhoneNumbersService {
357
477
  const params = new URLSearchParams();
358
478
  if (page) params.append('page', page);
359
479
  if (limit) params.append('limit', limit);
360
-
480
+
361
481
  const queryString = params.toString();
362
- const url = queryString ? `/phoneNumbers/porting/orders/${id}/events?${queryString}` : `/phoneNumbers/porting/orders/${id}/events`;
363
-
482
+ const url = queryString
483
+ ? `/phoneNumbers/porting/orders/${id}/events?${queryString}`
484
+ : `/phoneNumbers/porting/orders/${id}/events`;
485
+
364
486
  const result = await this.sdk._fetch(url, 'GET');
365
487
  return result;
366
488
  }