@signalhousellc/sdk 1.0.29 → 1.0.30

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": "@signalhousellc/sdk",
3
- "version": "1.0.29",
3
+ "version": "1.0.30",
4
4
  "description": "Signal House SDK for use with the Signal House platform",
5
5
  "type": "module",
6
6
  "main": "src/SignalHouseSDK.js",
@@ -73,6 +73,54 @@ export class Messages {
73
73
  return this.client(`/message/analytics${queryString}`, { method: "GET", ...options });
74
74
  }
75
75
 
76
+ /**
77
+ * Get aggregated DNC (Do Not Contact) opt-out analytics with optional filters
78
+ * @async
79
+ * @roles api, admin, developer, billing, user
80
+ * @param {Object} params - The parameters for getting DNC analytics
81
+ * @param {string} [params.groupId] - Filter by the ID of the associated group
82
+ * @param {string} [params.subgroupId] - Filter by the ID of the associated subgroup
83
+ * @param {string} [params.brandId] - Filter by the ID of the associated brand
84
+ * @param {string} [params.campaignId] - Filter by the ID of the associated campaign
85
+ * @param {string} [params.phoneNumber] - Filter by the phone number
86
+ * @param {string} [params.carrier] - Filter by the carrier
87
+ * @param {string} [params.startDate] - Filter by start date
88
+ * @param {string} [params.endDate] - Filter by end date
89
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
90
+ * @returns {Promise<Object>} - A promise that resolves to the DNC analytics data (totals, byDate, byPhoneNumber, byCarrier)
91
+ */
92
+ async getDncAnalytics({ groupId, subgroupId, brandId, campaignId, phoneNumber, carrier, startDate, endDate, options = {} }) {
93
+ const filters = { groupId, subgroupId, brandId, campaignId, phoneNumber, carrier, startDate, endDate };
94
+ const queryString = this.client._getQueryString(filters);
95
+ return this.client(`/message/dnc/analytics${queryString}`, { method: "GET", ...options });
96
+ }
97
+
98
+ /**
99
+ * Get paginated Do Not Call records with optional filters
100
+ * @async
101
+ * @roles api, admin, developer, billing, user
102
+ * @param {Object} params - The parameters for getting DNC records
103
+ * @param {string} [params.groupId] - Filter by the ID of the associated group
104
+ * @param {string} [params.subgroupId] - Filter by the ID of the associated subgroup
105
+ * @param {string} [params.brandId] - Filter by the ID of the associated brand
106
+ * @param {string} [params.campaignId] - Filter by the ID of the associated campaign
107
+ * @param {string} [params.phoneNumber] - Filter by the phone number
108
+ * @param {string} [params.carrier] - Filter by the carrier
109
+ * @param {string} [params.startDate] - Filter by start date
110
+ * @param {string} [params.endDate] - Filter by end date
111
+ * @param {number} [params.page] - Page number for pagination
112
+ * @param {number} [params.limit] - Number of records per page
113
+ * @param {string} [params.sortField] - Field to sort by
114
+ * @param {string} [params.sortOrder] - Sort direction (asc, desc)
115
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
116
+ * @returns {Promise<Object>} - A promise that resolves to the paginated DNC records
117
+ */
118
+ async getDncRecords({ groupId, subgroupId, brandId, campaignId, phoneNumber, carrier, startDate, endDate, page, limit, sortField, sortOrder, options = {} }) {
119
+ const filters = { groupId, subgroupId, brandId, campaignId, phoneNumber, carrier, startDate, endDate, page, limit, sortField, sortOrder };
120
+ const queryString = this.client._getQueryString(filters);
121
+ return this.client(`/message/dnc${queryString}`, { method: "GET", ...options });
122
+ }
123
+
76
124
  /**
77
125
  * Send an SMS message to one or more recipient phone numbers
78
126
  * @async
@@ -2,6 +2,49 @@ export class Numbers {
2
2
  constructor(client, enableAdmin) {
3
3
  this.client = client;
4
4
  this.enableAdmin = enableAdmin;
5
+
6
+ if (enableAdmin) {
7
+ this.admin = {
8
+ /**
9
+ * Update a port-in request's status (signalhouse only)
10
+ * @async
11
+ * @roles signalhouse
12
+ * @param {Object} params - The parameters for updating the status
13
+ * @param {string} params.portingId - The _id of the port-in request
14
+ * @param {string} params.status - The new status (PENDING, IN_PROGRESS, REJECTED)
15
+ * @param {string} [params.description] - Optional description for the status change
16
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
17
+ * @returns {Promise<Object>} A promise that resolves to the updated port-in request
18
+ */
19
+ changePortingStatus: async ({ portingId, status, description, options = {} }) => {
20
+ this.client._require({ portingId, status });
21
+ const safeId = encodeURIComponent(portingId);
22
+ return this.client(`/number/portin/${safeId}/status`, {
23
+ method: "PUT",
24
+ body: { status, description },
25
+ ...options,
26
+ });
27
+ },
28
+
29
+ /**
30
+ * Approve a port-in request, setting its status to SUCCESS (signalhouse only)
31
+ * @async
32
+ * @roles signalhouse
33
+ * @param {Object} params - The parameters for approving the request
34
+ * @param {string} params.portingId - The _id of the port-in request
35
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
36
+ * @returns {Promise<Object>} A promise that resolves to the updated port-in request
37
+ */
38
+ approvePortRequest: async ({ portingId, options = {} }) => {
39
+ this.client._require({ portingId });
40
+ const safeId = encodeURIComponent(portingId);
41
+ return this.client(`/number/portin/${safeId}/approve`, {
42
+ method: "POST",
43
+ ...options,
44
+ });
45
+ },
46
+ };
47
+ }
5
48
  }
6
49
 
7
50
  /**
@@ -124,6 +167,39 @@ export class Numbers {
124
167
  return this.client(`/number/portin${queryString}`, { method: "GET", ...options });
125
168
  }
126
169
 
170
+ /**
171
+ * Get a single port-in request by its ID
172
+ * @async
173
+ * @roles api, admin, developer, billing, user
174
+ * @param {Object} params - The parameters for getting the port request
175
+ * @param {string} params.id - The _id of the port-in request
176
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
177
+ * @returns {Promise<Object>} A promise that resolves to the port-in request object
178
+ */
179
+ async getPortRequestById({ id, options = {} }) {
180
+ this.client._require({ id });
181
+ const safeId = encodeURIComponent(id);
182
+ return this.client(`/number/portin/${safeId}`, { method: "GET", ...options });
183
+ }
184
+
185
+ /**
186
+ * Get porting requests - fetches a single request by portingId, or delegates to getPortRequests for listing
187
+ * @async
188
+ * @roles api, admin, developer, billing, user
189
+ * @param {Object} params - The parameters
190
+ * @param {string} [params.portingId] - If provided, fetches a single port request by ID
191
+ * @param {number} [params.page] - Page number for pagination (used when listing)
192
+ * @param {number} [params.limit] - Items per page (used when listing)
193
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
194
+ * @returns {Promise<Object>} A promise that resolves to the port-in request(s)
195
+ */
196
+ async getPortingRequests({ portingId, page, limit, options = {} } = {}) {
197
+ if (portingId) {
198
+ return this.getPortRequestById({ id: portingId, options });
199
+ }
200
+ return this.getPortRequests({ page, limit, options });
201
+ }
202
+
127
203
  /**
128
204
  * Assign phone numbers to a campaign by providing the campaign ID and a list of phone numbers to assign
129
205
  * @async