@unboundcx/sdk 2.6.7 → 2.6.9

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.6.7",
3
+ "version": "2.6.9",
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",
@@ -321,29 +321,30 @@ export class PhoneNumbersService {
321
321
 
322
322
  async getPortingOrders({
323
323
  page,
324
- includePhoneNumbers = true,
325
324
  status,
326
325
  customerReference,
327
326
  sort,
328
327
  limit,
328
+ id,
329
+ operatorType = 'contains',
329
330
  } = {}) {
330
- const params = new URLSearchParams();
331
+ const query = {
332
+ page,
333
+ status,
334
+ customerReference,
335
+ id,
336
+ operatorType,
337
+ sort,
338
+ limit,
339
+ };
331
340
 
332
- if (page) params.append('page', page);
333
- if (includePhoneNumbers !== undefined)
334
- params.append('includePhoneNumbers', includePhoneNumbers);
335
- if (status) params.append('status', status);
336
- if (customerReference)
337
- params.append('customerReference', customerReference);
338
- if (sort) params.append('sort', sort);
339
- if (limit) params.append('limit', limit);
341
+ const url = '/phoneNumbers/porting/orders';
340
342
 
341
- const queryString = params.toString();
342
- const url = queryString
343
- ? `/phoneNumbers/porting/orders?${queryString}`
344
- : '/phoneNumbers/porting/orders';
343
+ const params = {
344
+ query,
345
+ };
345
346
 
346
- const result = await this.sdk._fetch(url, 'GET');
347
+ const result = await this.sdk._fetch(url, 'GET', params);
347
348
  return result;
348
349
  }
349
350
 
@@ -695,10 +696,10 @@ export class PhoneNumbersService {
695
696
  * @example
696
697
  * // Get all comments
697
698
  * const allComments = await sdk.phoneNumbers.getPortingComments("port_123...");
698
- *
699
+ *
699
700
  * // Get only public comments
700
701
  * const publicComments = await sdk.phoneNumbers.getPortingComments("port_123...", { includeInternal: 'false' });
701
- *
702
+ *
702
703
  * // Get only internal comments
703
704
  * const internalComments = await sdk.phoneNumbers.getPortingComments("port_123...", { includeInternal: 'only' });
704
705
  */
@@ -716,7 +717,9 @@ export class PhoneNumbersService {
716
717
  }
717
718
 
718
719
  const queryString = params.toString();
719
- const url = `/phoneNumbers/porting/orders/${id}/comments${queryString ? '?' + queryString : ''}`;
720
+ const url = `/phoneNumbers/porting/orders/${id}/comments${
721
+ queryString ? '?' + queryString : ''
722
+ }`;
720
723
 
721
724
  const result = await this.sdk._fetch(url, 'GET');
722
725
  return result;
@@ -735,7 +738,7 @@ export class PhoneNumbersService {
735
738
  * comment: "Please expedite this port request",
736
739
  * isInternal: false
737
740
  * });
738
- *
741
+ *
739
742
  * // Post an internal comment (team use only)
740
743
  * const internalComment = await sdk.phoneNumbers.postPortingComment("port_123...", {
741
744
  * comment: "Customer called - they need this ASAP",
@@ -761,6 +764,55 @@ export class PhoneNumbersService {
761
764
  );
762
765
  return result;
763
766
  }
767
+
768
+ /**
769
+ * Auto-create porting orders by grouping phone numbers by carrier
770
+ *
771
+ * Analyzes phone numbers using internal LRN lookup, groups them by carrier,
772
+ * and either previews the groupings (dry run) or creates separate porting
773
+ * orders for each carrier group.
774
+ *
775
+ * @param {Object} params
776
+ * @param {string[]} params.phoneNumbers - Array of +E.164 formatted phone numbers (max 100)
777
+ * @param {string} params.name - Base name for orders (will be appended with carrier names)
778
+ * @param {boolean} [params.dryRun=false] - If true, returns preview without creating orders
779
+ * @returns {Promise<Object>} Carrier groups and creation results
780
+ * @example
781
+ * // Preview carrier groupings
782
+ * const preview = await sdk.phoneNumbers.autoCreateOrders({
783
+ * phoneNumbers: ['+15551234567', '+15551234568', '+15551234569'],
784
+ * name: 'Q1 2025 Port',
785
+ * dryRun: true
786
+ * });
787
+ * // Returns carrier groups with proposed order names
788
+ *
789
+ * // Create orders for each carrier
790
+ * const result = await sdk.phoneNumbers.autoCreateOrders({
791
+ * phoneNumbers: ['+15551234567', '+15551234568', '+15551234569'],
792
+ * name: 'Q1 2025 Port',
793
+ * dryRun: false
794
+ * });
795
+ * // Returns created orders and any errors
796
+ */
797
+ async autoCreateOrders({ phoneNumbers, name, dryRun = false }) {
798
+ this.sdk.validateParams(
799
+ { phoneNumbers, name },
800
+ {
801
+ phoneNumbers: { type: 'array', required: true },
802
+ name: { type: 'string', required: true },
803
+ dryRun: { type: 'boolean', required: false },
804
+ },
805
+ );
806
+
807
+ const result = await this.sdk._fetch(
808
+ '/phoneNumbers/porting/auto-create-orders',
809
+ 'POST',
810
+ {
811
+ body: { phoneNumbers, name, dryRun },
812
+ },
813
+ );
814
+ return result;
815
+ }
764
816
  }
765
817
 
766
818
  export class PhoneNumberCarrierService {