@unboundcx/sdk 2.4.2 → 2.5.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.4.2",
3
+ "version": "2.5.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",
@@ -206,21 +206,32 @@ export class PhoneNumbersService {
206
206
  // Porting Methods
207
207
 
208
208
  /**
209
- * Check portability of phone numbers
209
+ * Check portability of phone numbers using two-phase validation
210
+ *
211
+ * Phase 1 (Default): Internal validation using LRN lookup
212
+ * - Validates ownership, duplicates, and carrier compatibility
213
+ * - Sets portabilityStatus to 'pending'
214
+ *
215
+ * Phase 2 (runPortabilityCheck: true): External validation
216
+ * - Runs full portability check with carrier
217
+ * - Updates portabilityStatus to 'portable', 'not-portable', or 'error'
218
+ *
210
219
  * @param {Object} params
211
220
  * @param {string[]} params.phoneNumbers - Array of +E.164 formatted phone numbers
212
221
  * @param {string} [params.portingOrderId] - Optional porting order ID to save results to
222
+ * @param {boolean} [params.runPortabilityCheck=false] - Run external portability validation
213
223
  * @returns {Promise<Object>} Portability check results
214
224
  */
215
- async checkPortability({ phoneNumbers, portingOrderId }) {
225
+ async checkPortability({ phoneNumbers, portingOrderId, runPortabilityCheck = false }) {
216
226
  this.sdk.validateParams(
217
- { phoneNumbers },
227
+ { phoneNumbers, runPortabilityCheck },
218
228
  {
219
229
  phoneNumbers: { type: 'array', required: true },
230
+ runPortabilityCheck: { type: 'boolean', required: false },
220
231
  },
221
232
  );
222
233
 
223
- const body = { phoneNumbers };
234
+ const body = { phoneNumbers, runPortabilityCheck };
224
235
  if (portingOrderId) body.portingOrderId = portingOrderId;
225
236
 
226
237
  const result = await this.sdk._fetch(
@@ -265,11 +276,18 @@ export class PhoneNumbersService {
265
276
  * endUser: { admin: { entityName: "My Company" } }
266
277
  * });
267
278
  *
268
- * // Add phone numbers with validation
279
+ * // Phase 1: Add numbers with internal validation (pending status)
269
280
  * await sdk.phoneNumbers.checkPortability({
270
281
  * phoneNumbers: ["+15551234567"],
271
282
  * portingOrderId: order.id
272
283
  * });
284
+ *
285
+ * // Phase 2: Run external portability check when ready
286
+ * await sdk.phoneNumbers.checkPortability({
287
+ * phoneNumbers: ["+15551234567"],
288
+ * portingOrderId: order.id,
289
+ * runPortabilityCheck: true
290
+ * });
273
291
  */
274
292
  async createPortingOrder({
275
293
  customerReference,
@@ -482,29 +500,40 @@ export class PhoneNumbersService {
482
500
  return result;
483
501
  }
484
502
 
485
- async uploadPortingDocument({
486
- filename,
487
- fileContent,
488
- contentType = 'application/pdf',
489
- documentType = 'loa',
503
+ /**
504
+ * Attach or update a document for a porting order
505
+ *
506
+ * @param {Object} params
507
+ * @param {string} params.portingOrderId - Porting order ID
508
+ * @param {string} [params.storageId] - Storage ID of uploaded file (null to clear)
509
+ * @param {string} [params.documentType='loa'] - Document type (loa, bill, csr, etc.)
510
+ * @param {boolean} [params.isRequired=false] - Whether document is required
511
+ * @param {string} [params.documentId] - Optional: Update existing document by ID
512
+ * @returns {Promise<Object>} Document attachment result with action (created/updated)
513
+ */
514
+ async attachPortingDocument({
490
515
  portingOrderId,
516
+ storageId = null,
517
+ documentType = 'loa',
518
+ isRequired = false,
519
+ documentId = null
491
520
  }) {
492
521
  this.sdk.validateParams(
493
- { filename, fileContent },
522
+ { portingOrderId, documentType },
494
523
  {
495
- filename: { type: 'string', required: true },
496
- fileContent: { type: 'string', required: true },
524
+ portingOrderId: { type: 'string', required: true },
525
+ documentType: { type: 'string', required: true },
497
526
  },
498
527
  );
499
528
 
500
529
  const body = {
501
- filename,
502
- fileContent,
503
- contentType,
530
+ portingOrderId,
531
+ storageId,
504
532
  documentType,
533
+ isRequired
505
534
  };
506
535
 
507
- if (portingOrderId) body.portingOrderId = portingOrderId;
536
+ if (documentId) body.documentId = documentId;
508
537
 
509
538
  const result = await this.sdk._fetch(
510
539
  '/phoneNumbers/porting/documents',