@unboundcx/sdk 2.6.6 → 2.6.8

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.6",
3
+ "version": "2.6.8",
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",
@@ -654,6 +654,162 @@ export class PhoneNumbersService {
654
654
  );
655
655
  return result;
656
656
  }
657
+
658
+ /**
659
+ * Sync a porting order with the carrier
660
+ * Fetches the latest order details and comments from the carrier and updates the local database
661
+ * @param {string} id - Porting order ID
662
+ * @returns {Promise<Object>} Sync results including updates made and comments added
663
+ * @example
664
+ * const syncResult = await sdk.phoneNumbers.syncPortingOrder("port_123...");
665
+ * // Returns:
666
+ * // {
667
+ * // id: "port_123...",
668
+ * // carrierOrderId: "carrier_abc123",
669
+ * // orderUpdated: true,
670
+ * // commentsAdded: 2,
671
+ * // errors: []
672
+ * // }
673
+ */
674
+ async syncPortingOrder(id) {
675
+ this.sdk.validateParams(
676
+ { id },
677
+ {
678
+ id: { type: 'string', required: true },
679
+ },
680
+ );
681
+
682
+ const result = await this.sdk._fetch(
683
+ `/phoneNumbers/porting/orders/${id}/sync`,
684
+ 'POST',
685
+ );
686
+ return result;
687
+ }
688
+
689
+ /**
690
+ * Get comments for a porting order
691
+ * @param {string} id - Porting order ID
692
+ * @param {Object} [options] - Query options
693
+ * @param {string} [options.includeInternal='true'] - Include internal comments ('true', 'false', 'only')
694
+ * @returns {Promise<Object>} Comments list with metadata
695
+ * @example
696
+ * // Get all comments
697
+ * const allComments = await sdk.phoneNumbers.getPortingComments("port_123...");
698
+ *
699
+ * // Get only public comments
700
+ * const publicComments = await sdk.phoneNumbers.getPortingComments("port_123...", { includeInternal: 'false' });
701
+ *
702
+ * // Get only internal comments
703
+ * const internalComments = await sdk.phoneNumbers.getPortingComments("port_123...", { includeInternal: 'only' });
704
+ */
705
+ async getPortingComments(id, { includeInternal = 'true' } = {}) {
706
+ this.sdk.validateParams(
707
+ { id },
708
+ {
709
+ id: { type: 'string', required: true },
710
+ },
711
+ );
712
+
713
+ const params = new URLSearchParams();
714
+ if (includeInternal !== 'true') {
715
+ params.append('includeInternal', includeInternal);
716
+ }
717
+
718
+ const queryString = params.toString();
719
+ const url = `/phoneNumbers/porting/orders/${id}/comments${queryString ? '?' + queryString : ''}`;
720
+
721
+ const result = await this.sdk._fetch(url, 'GET');
722
+ return result;
723
+ }
724
+
725
+ /**
726
+ * Post a comment on a porting order
727
+ * @param {string} id - Porting order ID
728
+ * @param {Object} params - Comment parameters
729
+ * @param {string} params.comment - Comment body text
730
+ * @param {boolean} [params.isInternal=false] - Whether this is an internal comment (not shared with carrier)
731
+ * @returns {Promise<Object>} Created comment details
732
+ * @example
733
+ * // Post a public comment (shared with carrier)
734
+ * const publicComment = await sdk.phoneNumbers.postPortingComment("port_123...", {
735
+ * comment: "Please expedite this port request",
736
+ * isInternal: false
737
+ * });
738
+ *
739
+ * // Post an internal comment (team use only)
740
+ * const internalComment = await sdk.phoneNumbers.postPortingComment("port_123...", {
741
+ * comment: "Customer called - they need this ASAP",
742
+ * isInternal: true
743
+ * });
744
+ */
745
+ async postPortingComment(id, { comment, isInternal = false }) {
746
+ this.sdk.validateParams(
747
+ { id, comment },
748
+ {
749
+ id: { type: 'string', required: true },
750
+ comment: { type: 'string', required: true },
751
+ isInternal: { type: 'boolean', required: false },
752
+ },
753
+ );
754
+
755
+ const result = await this.sdk._fetch(
756
+ `/phoneNumbers/porting/orders/${id}/comments`,
757
+ 'POST',
758
+ {
759
+ body: { comment, isInternal },
760
+ },
761
+ );
762
+ return result;
763
+ }
764
+
765
+ /**
766
+ * Auto-create porting orders by grouping phone numbers by carrier
767
+ *
768
+ * Analyzes phone numbers using internal LRN lookup, groups them by carrier,
769
+ * and either previews the groupings (dry run) or creates separate porting
770
+ * orders for each carrier group.
771
+ *
772
+ * @param {Object} params
773
+ * @param {string[]} params.phoneNumbers - Array of +E.164 formatted phone numbers (max 100)
774
+ * @param {string} params.name - Base name for orders (will be appended with carrier names)
775
+ * @param {boolean} [params.dryRun=false] - If true, returns preview without creating orders
776
+ * @returns {Promise<Object>} Carrier groups and creation results
777
+ * @example
778
+ * // Preview carrier groupings
779
+ * const preview = await sdk.phoneNumbers.autoCreateOrders({
780
+ * phoneNumbers: ['+15551234567', '+15551234568', '+15551234569'],
781
+ * name: 'Q1 2025 Port',
782
+ * dryRun: true
783
+ * });
784
+ * // Returns carrier groups with proposed order names
785
+ *
786
+ * // Create orders for each carrier
787
+ * const result = await sdk.phoneNumbers.autoCreateOrders({
788
+ * phoneNumbers: ['+15551234567', '+15551234568', '+15551234569'],
789
+ * name: 'Q1 2025 Port',
790
+ * dryRun: false
791
+ * });
792
+ * // Returns created orders and any errors
793
+ */
794
+ async autoCreateOrders({ phoneNumbers, name, dryRun = false }) {
795
+ this.sdk.validateParams(
796
+ { phoneNumbers, name },
797
+ {
798
+ phoneNumbers: { type: 'array', required: true },
799
+ name: { type: 'string', required: true },
800
+ dryRun: { type: 'boolean', required: false },
801
+ },
802
+ );
803
+
804
+ const result = await this.sdk._fetch(
805
+ '/phoneNumbers/porting/auto-create-orders',
806
+ 'POST',
807
+ {
808
+ body: { phoneNumbers, name, dryRun },
809
+ },
810
+ );
811
+ return result;
812
+ }
657
813
  }
658
814
 
659
815
  export class PhoneNumberCarrierService {