@unboundcx/sdk 2.6.5 → 2.6.6

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/base.js CHANGED
@@ -306,7 +306,34 @@ export class BaseSDK {
306
306
 
307
307
  const response = await fetch(url, options);
308
308
 
309
- // Check content type to determine how to parse the response
309
+ // Check if the response indicates an HTTP error
310
+ // These are API/configuration errors, not transport failures
311
+ if (!response.ok) {
312
+ let errorBody;
313
+ const contentType = response.headers.get('content-type') || '';
314
+
315
+ try {
316
+ if (contentType.includes('application/json')) {
317
+ errorBody = await response.json();
318
+ } else {
319
+ errorBody = await response.text();
320
+ }
321
+ } catch (parseError) {
322
+ errorBody = `HTTP ${response.status} ${response.statusText}`;
323
+ }
324
+
325
+ // Create a structured error for API/HTTP failures
326
+ const httpError = new Error(`API :: Error :: https :: ${options.method} :: ${endpoint} :: ${response.status} :: ${response.statusText}`);
327
+ httpError.status = response.status;
328
+ httpError.statusText = response.statusText;
329
+ httpError.method = options.method;
330
+ httpError.endpoint = endpoint;
331
+ httpError.body = errorBody;
332
+
333
+ throw httpError;
334
+ }
335
+
336
+ // Check content type to determine how to parse successful response
310
337
  const contentType = response.headers.get('content-type') || '';
311
338
  let bodyResponse;
312
339
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unboundcx/sdk",
3
- "version": "2.6.5",
3
+ "version": "2.6.6",
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",
@@ -204,25 +204,29 @@ export class PhoneNumbersService {
204
204
  }
205
205
 
206
206
  // Porting Methods
207
-
207
+
208
208
  /**
209
209
  * Check portability of phone numbers using two-phase validation
210
- *
210
+ *
211
211
  * Phase 1 (Default): Internal validation using LRN lookup
212
212
  * - Validates ownership, duplicates, and carrier compatibility
213
213
  * - Sets portabilityStatus to 'pending'
214
- *
215
- * Phase 2 (runPortabilityCheck: true): External validation
214
+ *
215
+ * Phase 2 (runPortabilityCheck: true): External validation
216
216
  * - Runs full portability check with carrier
217
217
  * - Updates portabilityStatus to 'portable', 'not-portable', or 'error'
218
- *
218
+ *
219
219
  * @param {Object} params
220
220
  * @param {string[]} params.phoneNumbers - Array of +E.164 formatted phone numbers
221
221
  * @param {string} [params.portingOrderId] - Optional porting order ID to save results to
222
222
  * @param {boolean} [params.runPortabilityCheck=false] - Run external portability validation
223
223
  * @returns {Promise<Object>} Portability check results
224
224
  */
225
- async checkPortability({ phoneNumbers, portingOrderId, runPortabilityCheck = false }) {
225
+ async checkPortability({
226
+ phoneNumbers,
227
+ portingOrderId,
228
+ runPortabilityCheck = false,
229
+ }) {
226
230
  this.sdk.validateParams(
227
231
  { phoneNumbers, runPortabilityCheck },
228
232
  {
@@ -267,6 +271,7 @@ export class PhoneNumbersService {
267
271
  * @param {Object} [params.activationSettings] - Activation preferences
268
272
  * @param {string} [params.activationSettings.focDatetimeRequested] - Requested FOC date/time (ISO 8601 UTC)
269
273
  * @param {boolean} [params.activationSettings.fastPortEligible] - Request fast port if available
274
+ * @param {string} [params.portOrderType] - Port type: 'full' or 'partial' (defaults to 'full')
270
275
  * @param {string[]} [params.tags] - Array of tags for organization
271
276
  * @returns {Promise<Object>} Created draft porting order with ID and status 'draft'
272
277
  * @example
@@ -275,13 +280,13 @@ export class PhoneNumbersService {
275
280
  * customerReference: "CUST-123",
276
281
  * endUser: { admin: { entityName: "My Company" } }
277
282
  * });
278
- *
283
+ *
279
284
  * // Phase 1: Add numbers with internal validation (pending status)
280
285
  * await sdk.phoneNumbers.checkPortability({
281
286
  * phoneNumbers: ["+15551234567"],
282
287
  * portingOrderId: order.id
283
288
  * });
284
- *
289
+ *
285
290
  * // Phase 2: Run external portability check when ready
286
291
  * await sdk.phoneNumbers.checkPortability({
287
292
  * phoneNumbers: ["+15551234567"],
@@ -293,13 +298,15 @@ export class PhoneNumbersService {
293
298
  customerReference,
294
299
  endUser,
295
300
  activationSettings,
296
- tags
301
+ portOrderType,
302
+ tags,
297
303
  } = {}) {
298
304
  // Creates draft order without phone numbers - use checkPortability to add them
299
305
  const body = {};
300
306
  if (customerReference) body.customerReference = customerReference;
301
307
  if (endUser) body.endUser = endUser;
302
308
  if (activationSettings) body.activationSettings = activationSettings;
309
+ if (portOrderType) body.portOrderType = portOrderType;
303
310
  if (tags) body.tags = tags;
304
311
 
305
312
  const result = await this.sdk._fetch(
@@ -349,11 +356,14 @@ export class PhoneNumbersService {
349
356
  * @param {boolean} [options.includeDocuments=true] - Include documents array with upload status
350
357
  * @returns {Promise<Object>} Porting order with requested related data
351
358
  */
352
- async getPortingOrder(id, {
353
- includePhoneNumbers = true,
354
- includeExceptions = true,
355
- includeDocuments = true
356
- } = {}) {
359
+ async getPortingOrder(
360
+ id,
361
+ {
362
+ includePhoneNumbers = true,
363
+ includeExceptions = true,
364
+ includeDocuments = true,
365
+ } = {},
366
+ ) {
357
367
  this.sdk.validateParams(
358
368
  { id },
359
369
  {
@@ -385,15 +395,20 @@ export class PhoneNumbersService {
385
395
  * @param {string} [params.customerReference] - Customer-specified reference number
386
396
  * @param {Object} [params.endUser] - End user information
387
397
  * @param {Object} [params.activationSettings] - Activation preferences
398
+ * @param {string} [params.portOrderType] - Port type: 'full' or 'partial'
388
399
  * @param {string[]} [params.tags] - Array of tags for organization
389
400
  * @returns {Promise<Object>} Updated porting order
390
401
  */
391
- async updatePortingOrder(id, {
392
- customerReference,
393
- endUser,
394
- activationSettings,
395
- tags
396
- } = {}) {
402
+ async updatePortingOrder(
403
+ id,
404
+ {
405
+ customerReference,
406
+ endUser,
407
+ activationSettings,
408
+ portOrderType,
409
+ tags,
410
+ } = {},
411
+ ) {
397
412
  this.sdk.validateParams(
398
413
  { id },
399
414
  {
@@ -406,6 +421,7 @@ export class PhoneNumbersService {
406
421
  if (customerReference) body.customerReference = customerReference;
407
422
  if (endUser) body.endUser = endUser;
408
423
  if (activationSettings) body.activationSettings = activationSettings;
424
+ if (portOrderType) body.portOrderType = portOrderType;
409
425
  if (tags) body.tags = tags;
410
426
 
411
427
  const result = await this.sdk._fetch(
@@ -465,7 +481,7 @@ export class PhoneNumbersService {
465
481
 
466
482
  const result = await this.sdk._fetch(
467
483
  `/phoneNumbers/porting/orders/${id}`,
468
- 'DELETE'
484
+ 'DELETE',
469
485
  );
470
486
  return result;
471
487
  }
@@ -480,7 +496,7 @@ export class PhoneNumbersService {
480
496
  * @returns {Promise<Object>} Removal confirmation with updated counts
481
497
  * @example
482
498
  * await sdk.phoneNumbers.removePhoneNumberFromOrder(
483
- * "port_123...",
499
+ * "port_123...",
484
500
  * "+15551234567"
485
501
  * );
486
502
  */
@@ -494,15 +510,17 @@ export class PhoneNumbersService {
494
510
  );
495
511
 
496
512
  const result = await this.sdk._fetch(
497
- `/phoneNumbers/porting/orders/${encodeURIComponent(portingOrderId)}/numbers/${encodeURIComponent(phoneNumber)}`,
498
- 'DELETE'
513
+ `/phoneNumbers/porting/orders/${encodeURIComponent(
514
+ portingOrderId,
515
+ )}/numbers/${encodeURIComponent(phoneNumber)}`,
516
+ 'DELETE',
499
517
  );
500
518
  return result;
501
519
  }
502
520
 
503
521
  /**
504
522
  * Attach or update a document for a porting order
505
- *
523
+ *
506
524
  * @param {Object} params
507
525
  * @param {string} params.portingOrderId - Porting order ID
508
526
  * @param {string} [params.storageId] - Storage ID of uploaded file (null to clear)
@@ -516,7 +534,7 @@ export class PhoneNumbersService {
516
534
  storageId = null,
517
535
  documentType = 'loa',
518
536
  isRequired = false,
519
- documentId = null
537
+ documentId = null,
520
538
  }) {
521
539
  this.sdk.validateParams(
522
540
  { portingOrderId, documentType },
@@ -530,7 +548,7 @@ export class PhoneNumbersService {
530
548
  portingOrderId,
531
549
  storageId,
532
550
  documentType,
533
- isRequired
551
+ isRequired,
534
552
  };
535
553
 
536
554
  if (documentId) body.documentId = documentId;
@@ -547,10 +565,10 @@ export class PhoneNumbersService {
547
565
 
548
566
  /**
549
567
  * Generate Letter of Authorization (LOA) for a porting order
550
- *
568
+ *
551
569
  * Automatically generates a PDF LOA document using template data from the porting order,
552
570
  * uploads it to storage, and attaches it to the order as an LOA document.
553
- *
571
+ *
554
572
  * @param {Object} params
555
573
  * @param {string} params.portingOrderId - Porting order ID to generate LOA for
556
574
  * @param {string} params.signerName - Full name of person signing the LOA
@@ -568,7 +586,9 @@ export class PhoneNumbersService {
568
586
  );
569
587
 
570
588
  const result = await this.sdk._fetch(
571
- `/phoneNumbers/porting/orders/${encodeURIComponent(portingOrderId)}/generate-loa`,
589
+ `/phoneNumbers/porting/orders/${encodeURIComponent(
590
+ portingOrderId,
591
+ )}/generate-loa`,
572
592
  'POST',
573
593
  {
574
594
  body: { signerName, signerTitle },
@@ -611,7 +631,7 @@ export class PhoneNumbersService {
611
631
  * // Returns:
612
632
  * // {
613
633
  * // id: "port_123...",
614
- * // status: "draft",
634
+ * // status: "draft",
615
635
  * // availableDates: [
616
636
  * // { date: "2025-08-30T00:00:00.000Z", type: "Standard", available: true },
617
637
  * // { date: "2025-09-02T00:00:00.000Z", type: "Express", available: true }
@@ -630,7 +650,7 @@ export class PhoneNumbersService {
630
650
 
631
651
  const result = await this.sdk._fetch(
632
652
  `/phoneNumbers/porting/orders/${id}/foc-windows`,
633
- 'GET'
653
+ 'GET',
634
654
  );
635
655
  return result;
636
656
  }