@unboundcx/sdk 2.3.1 → 2.4.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.3.1",
3
+ "version": "2.4.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",
@@ -209,9 +209,10 @@ export class PhoneNumbersService {
209
209
  * Check portability of phone numbers
210
210
  * @param {Object} params
211
211
  * @param {string[]} params.phoneNumbers - Array of +E.164 formatted phone numbers
212
+ * @param {string} [params.portingOrderId] - Optional porting order ID to save results to
212
213
  * @returns {Promise<Object>} Portability check results
213
214
  */
214
- async checkPortability({ phoneNumbers }) {
215
+ async checkPortability({ phoneNumbers, portingOrderId }) {
215
216
  this.sdk.validateParams(
216
217
  { phoneNumbers },
217
218
  {
@@ -219,21 +220,22 @@ export class PhoneNumbersService {
219
220
  },
220
221
  );
221
222
 
223
+ const body = { phoneNumbers };
224
+ if (portingOrderId) body.portingOrderId = portingOrderId;
225
+
222
226
  const result = await this.sdk._fetch(
223
227
  '/phoneNumbers/porting/portability-check',
224
228
  'POST',
225
229
  {
226
- body: { phoneNumbers },
230
+ body: body,
227
231
  },
228
232
  );
229
233
  return result;
230
234
  }
231
235
 
232
236
  /**
233
- * Create a draft porting order (no validation - can be built incrementally)
237
+ * Create a draft porting order (no phone numbers - add them via checkPortability)
234
238
  * @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
239
  * @param {string} [params.customerReference] - Customer-specified reference number
238
240
  * @param {Object} [params.endUser] - End user information
239
241
  * @param {Object} [params.endUser.admin] - Admin contact info
@@ -252,38 +254,34 @@ export class PhoneNumbersService {
252
254
  * @param {string} [params.endUser.location.postalCode] - ZIP/postal code
253
255
  * @param {string} [params.endUser.location.countryCode] - 2-letter country code
254
256
  * @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
257
+ * @param {string} [params.activationSettings.focDatetimeRequested] - Requested FOC date/time (ISO 8601 UTC)
258
+ * @param {boolean} [params.activationSettings.fastPortEligible] - Request fast port if available
266
259
  * @param {string[]} [params.tags] - Array of tags for organization
267
260
  * @returns {Promise<Object>} Created draft porting order with ID and status 'draft'
261
+ * @example
262
+ * // Create empty draft order, then add numbers via checkPortability
263
+ * const order = await sdk.phoneNumbers.createPortingOrder({
264
+ * customerReference: "CUST-123",
265
+ * endUser: { admin: { entityName: "My Company" } }
266
+ * });
267
+ *
268
+ * // Add phone numbers with validation
269
+ * await sdk.phoneNumbers.checkPortability({
270
+ * phoneNumbers: ["+15551234567"],
271
+ * portingOrderId: order.id
272
+ * });
268
273
  */
269
274
  async createPortingOrder({
270
- phoneNumbers,
271
- phoneNumberBlocks,
272
275
  customerReference,
273
276
  endUser,
274
277
  activationSettings,
275
- phoneNumberConfiguration,
276
278
  tags
277
279
  } = {}) {
278
- // No validation - creates draft order that can be built incrementally
280
+ // Creates draft order without phone numbers - use checkPortability to add them
279
281
  const body = {};
280
-
281
- if (phoneNumbers) body.phoneNumbers = phoneNumbers;
282
- if (phoneNumberBlocks) body.phoneNumberBlocks = phoneNumberBlocks;
283
282
  if (customerReference) body.customerReference = customerReference;
284
283
  if (endUser) body.endUser = endUser;
285
284
  if (activationSettings) body.activationSettings = activationSettings;
286
- if (phoneNumberConfiguration) body.phoneNumberConfiguration = phoneNumberConfiguration;
287
285
  if (tags) body.tags = tags;
288
286
 
289
287
  const result = await this.sdk._fetch(
@@ -363,18 +361,19 @@ export class PhoneNumbersService {
363
361
  }
364
362
 
365
363
  /**
366
- * Update a draft porting order (same parameters as createPortingOrder)
364
+ * Update a draft porting order (order info only - manage numbers via checkPortability)
367
365
  * @param {string} id - Porting order ID
368
- * @param {Object} params - Same parameters as createPortingOrder
366
+ * @param {Object} params - Order information to update
367
+ * @param {string} [params.customerReference] - Customer-specified reference number
368
+ * @param {Object} [params.endUser] - End user information
369
+ * @param {Object} [params.activationSettings] - Activation preferences
370
+ * @param {string[]} [params.tags] - Array of tags for organization
369
371
  * @returns {Promise<Object>} Updated porting order
370
372
  */
371
373
  async updatePortingOrder(id, {
372
- phoneNumbers,
373
- phoneNumberBlocks,
374
374
  customerReference,
375
375
  endUser,
376
376
  activationSettings,
377
- phoneNumberConfiguration,
378
377
  tags
379
378
  } = {}) {
380
379
  this.sdk.validateParams(
@@ -386,12 +385,9 @@ export class PhoneNumbersService {
386
385
 
387
386
  const body = {};
388
387
 
389
- if (phoneNumbers) body.phoneNumbers = phoneNumbers;
390
- if (phoneNumberBlocks) body.phoneNumberBlocks = phoneNumberBlocks;
391
388
  if (customerReference) body.customerReference = customerReference;
392
389
  if (endUser) body.endUser = endUser;
393
390
  if (activationSettings) body.activationSettings = activationSettings;
394
- if (phoneNumberConfiguration) body.phoneNumberConfiguration = phoneNumberConfiguration;
395
391
  if (tags) body.tags = tags;
396
392
 
397
393
  const result = await this.sdk._fetch(
@@ -432,6 +428,30 @@ export class PhoneNumbersService {
432
428
  return result;
433
429
  }
434
430
 
431
+ /**
432
+ * Delete/cancel a porting order (soft delete)
433
+ * - Draft orders: Immediately cancelled locally
434
+ * - Submitted orders: Cancelled via Telnyx, then status updated to cancel-pending
435
+ * - Cannot delete orders within 48 hours of FOC date
436
+ * - Cannot delete already completed or cancelled orders
437
+ * @param {string} id - Porting order ID
438
+ * @returns {Promise<Object>} Cancellation result with new status
439
+ */
440
+ async deletePortingOrder(id) {
441
+ this.sdk.validateParams(
442
+ { id },
443
+ {
444
+ id: { type: 'string', required: true },
445
+ },
446
+ );
447
+
448
+ const result = await this.sdk._fetch(
449
+ `/phoneNumbers/porting/orders/${id}`,
450
+ 'DELETE'
451
+ );
452
+ return result;
453
+ }
454
+
435
455
  async uploadPortingDocument({
436
456
  filename,
437
457
  fileContent,