@signalhousellc/sdk 1.0.56 → 1.0.62
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 +1 -1
- package/src/SignalHouseSDK.js +1 -1
- package/src/domains/Auth.js +4 -2
- package/src/domains/Brands.js +275 -206
- package/src/domains/Campaigns.js +417 -226
- package/src/domains/Messages.js +37 -1
- package/src/domains/Numbers.js +457 -378
- package/src/domains/Voice.js +13 -4
- package/src/domains/voice/CallLogs.js +105 -0
- package/src/domains/voice/GlobalVoiceSettings.js +48 -0
- package/src/domains/voice/ProgrammableVoiceProfiles.js +181 -0
- package/src/domains/voice/SipTrunks.js +37 -0
package/src/domains/Numbers.js
CHANGED
|
@@ -1,400 +1,479 @@
|
|
|
1
1
|
export class Numbers {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
constructor(client, multipartClient, enableAdmin) {
|
|
3
|
+
this.client = client;
|
|
4
|
+
this.multipartClient = multipartClient;
|
|
5
|
+
this.enableAdmin = enableAdmin;
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
7
|
+
if (enableAdmin) {
|
|
8
|
+
this.admin = {
|
|
9
|
+
/**
|
|
10
|
+
* Update a port-in request's status (signalhouse only)
|
|
11
|
+
* @async
|
|
12
|
+
* @roles signalhouse
|
|
13
|
+
* @param {Object} params - The parameters for updating the status
|
|
14
|
+
* @param {string} params.portingId - The _id of the port-in request
|
|
15
|
+
* @param {string} params.status - The new status (PENDING, IN_PROGRESS, REJECTED)
|
|
16
|
+
* @param {string} [params.description] - Optional description for the status change
|
|
17
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
18
|
+
* @returns {Promise<Object>} A promise that resolves to the updated port-in request
|
|
19
|
+
*/
|
|
20
|
+
changePortingStatus: async ({ portingId, status, description, options = {} }) => {
|
|
21
|
+
this.client._require({ portingId, status });
|
|
22
|
+
const safeId = encodeURIComponent(portingId);
|
|
23
|
+
return this.client(`/number/portin/${safeId}/status`, {
|
|
24
|
+
method: 'PUT',
|
|
25
|
+
body: { status, description },
|
|
26
|
+
...options,
|
|
27
|
+
});
|
|
28
|
+
},
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Approve a port-in request, setting its status to SUCCESS (signalhouse only)
|
|
32
|
+
* @async
|
|
33
|
+
* @roles signalhouse
|
|
34
|
+
* @param {Object} params - The parameters for approving the request
|
|
35
|
+
* @param {string} params.portingId - The _id of the port-in request
|
|
36
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
37
|
+
* @returns {Promise<Object>} A promise that resolves to the updated port-in request
|
|
38
|
+
*/
|
|
39
|
+
approvePortRequest: async ({ portingId, options = {} }) => {
|
|
40
|
+
this.client._require({ portingId });
|
|
41
|
+
const safeId = encodeURIComponent(portingId);
|
|
42
|
+
return this.client(`/number/portin/${safeId}/approve`, {
|
|
43
|
+
method: 'POST',
|
|
44
|
+
...options,
|
|
45
|
+
});
|
|
46
|
+
},
|
|
47
|
+
/**
|
|
48
|
+
* List campaign-bound Short Code acquisition requests for staff.
|
|
49
|
+
* @async
|
|
50
|
+
* @roles signalhouse
|
|
51
|
+
* @param {Object} [params] - Queue filter parameters.
|
|
52
|
+
* @param {string} [params.status] - PENDING, FULFILLED, or CANCELLED.
|
|
53
|
+
* @param {string} [params.search] - Request or associated identifier search.
|
|
54
|
+
* @param {number} [params.page] - One-based page number.
|
|
55
|
+
* @param {number} [params.limit] - Page size.
|
|
56
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options.
|
|
57
|
+
* @returns {Promise<Object>} Paginated acquisition requests.
|
|
58
|
+
*/
|
|
59
|
+
getShortCodeAcquisitionRequests: async ({ status, search, page, limit, options = {} } = {}) => {
|
|
60
|
+
const queryString = this.client._getQueryString({ status, search, page, limit });
|
|
61
|
+
return this.client(`/number/short-code/requests${queryString}`, { method: 'GET', ...options });
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
49
66
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
/**
|
|
68
|
+
* Get a list of phone numbers with optional filters such as campaignId, brandId, subgroupId, groupId, and pagination parameters
|
|
69
|
+
* @async
|
|
70
|
+
* @roles api, admin, developer, billing, user
|
|
71
|
+
* @param {Object} params - The parameters for filtering the phone numbers
|
|
72
|
+
* @param {string} [params.phoneNumber] - Filter by phone number (partial match)
|
|
73
|
+
* @param {string} [params.campaignId] - Filter by campaign ID
|
|
74
|
+
* @param {string} [params.brandId] - Filter by brand ID
|
|
75
|
+
* @param {string} [params.subgroupId] - Filter by subgroup ID
|
|
76
|
+
* @param {string} [params.groupId] - Filter by group ID
|
|
77
|
+
* @param {number} [params.page] - The page number for pagination (default: 1)
|
|
78
|
+
* @param {number} [params.limit] - The number of items per page for pagination (default: 20)
|
|
79
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
80
|
+
* @returns {Promise<Object>} A promise that resolves to the list of phone numbers
|
|
81
|
+
*/
|
|
82
|
+
async getPhoneNumbers({ phoneNumber, campaignId, brandId, subgroupId, groupId, page, limit, options = {} }) {
|
|
83
|
+
const filters = { phoneNumber, campaignId, brandId, subgroupId, groupId, page, limit };
|
|
84
|
+
const queryString = this.client._getQueryString(filters);
|
|
85
|
+
return this.client(`/number${queryString}`, { method: 'GET', ...options });
|
|
86
|
+
}
|
|
70
87
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
88
|
+
/**
|
|
89
|
+
* Get the portal-parity health score (1–10) for an owned phone number over 7-day and 30-day windows
|
|
90
|
+
* @async
|
|
91
|
+
* @roles api, admin, developer, billing, user
|
|
92
|
+
* @param {Object} params - The parameters for reading number health
|
|
93
|
+
* @param {string} params.phoneNumber - Owned phone number to score (11 digits, no + prefix)
|
|
94
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
95
|
+
* @throws {Error} Throws an error if the phoneNumber parameter is missing
|
|
96
|
+
* @returns {Promise<Object>} A promise that resolves to `{ phoneNumber, groupId, sevenDay, thirtyDay }`
|
|
97
|
+
*/
|
|
98
|
+
async getNumberHealth({ phoneNumber, options = {} }) {
|
|
99
|
+
this.client._require({ phoneNumber });
|
|
100
|
+
const queryString = this.client._getQueryString({ phoneNumber });
|
|
101
|
+
return this.client(`/number/health${queryString}`, { method: 'GET', ...options });
|
|
102
|
+
}
|
|
86
103
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
104
|
+
/**
|
|
105
|
+
* Get a list of available phone numbers for purchase with optional filters
|
|
106
|
+
* @async
|
|
107
|
+
* @roles api, admin, developer, billing, user
|
|
108
|
+
* @param {Object} params - The parameters for filtering the available phone numbers
|
|
109
|
+
* @param {boolean} [params.smsEnabled] - Filter for phone numbers that are SMS enabled
|
|
110
|
+
* @param {boolean} [params.mmsEnabled] - Filter for phone numbers that are MMS enabled
|
|
111
|
+
* @param {boolean} [params.voiceEnabled] - Filter for phone numbers that are voice enabled
|
|
112
|
+
* @param {string} [params.country] - Filter by country code (e.g., "US")
|
|
113
|
+
* @param {string} [params.state] - Filter by state code (e.g., "CA")
|
|
114
|
+
* @param {string} [params.npa] - Filter by NPA (area code)
|
|
115
|
+
* @param {string} [params.nxx] - Filter by NXX (central office code) - the first three digits of the local phone number after the area code
|
|
116
|
+
* @param {string} [params.phoneNumber] - Filter by phone number
|
|
117
|
+
* @param {number} [params.limit] - The number of items per page for pagination
|
|
118
|
+
* @param {number} [params.page] - The page number for pagination
|
|
119
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
120
|
+
* @returns {Promise<Object>} A promise that resolves to the list of available phone numbers
|
|
121
|
+
*/
|
|
122
|
+
async getAvailablePhoneNumbers({
|
|
123
|
+
smsEnabled,
|
|
124
|
+
mmsEnabled,
|
|
125
|
+
voiceEnabled,
|
|
126
|
+
country,
|
|
127
|
+
state,
|
|
128
|
+
npa,
|
|
129
|
+
nxx,
|
|
130
|
+
phoneNumber,
|
|
131
|
+
limit,
|
|
132
|
+
page,
|
|
133
|
+
options = {},
|
|
134
|
+
}) {
|
|
135
|
+
const filters = { smsEnabled, mmsEnabled, voiceEnabled, country, state, npa, nxx, phoneNumber, limit, page };
|
|
136
|
+
const queryString = this.client._getQueryString(filters);
|
|
137
|
+
return this.client(`/number/available${queryString}`, { method: 'GET', ...options });
|
|
138
|
+
}
|
|
110
139
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
140
|
+
/**
|
|
141
|
+
* Purchase phone numbers by providing a list of phone numbers and the subgroup ID to assign them to.
|
|
142
|
+
*
|
|
143
|
+
* Each requested number is queued and processed independently. Per-number success or failure is
|
|
144
|
+
* delivered via `NUMBER_PURCHASE_SUCCESSFUL` / `NUMBER_PURCHASE_FAILED` webhooks — not in this response.
|
|
145
|
+
* @async
|
|
146
|
+
* @roles api, admin, developer, billing, user
|
|
147
|
+
* @param {Object} params - The parameters for purchasing phone numbers
|
|
148
|
+
* @param {string[]} params.phoneNumbers - The list of phone numbers to purchase
|
|
149
|
+
* @param {string} params.subgroupId - The ID of the subgroup to assign the purchased phone numbers to
|
|
150
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
151
|
+
* @throws {Error} Throws an error if the phoneNumbers or subgroupId parameter is missing
|
|
152
|
+
* @returns {Promise<Object>} A promise that resolves to `{ message }` once the request is queued.
|
|
153
|
+
*/
|
|
154
|
+
async purchasePhoneNumber({ phoneNumbers, subgroupId, options = {} }) {
|
|
155
|
+
this.client._require({ phoneNumbers, subgroupId });
|
|
156
|
+
return this.client(`/number`, { method: 'POST', body: { phoneNumbers, subgroupId }, ...options });
|
|
157
|
+
}
|
|
129
158
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
159
|
+
/**
|
|
160
|
+
* Purchase one or more Toll-Free numbers via the asynchronous resource-request flow.
|
|
161
|
+
*
|
|
162
|
+
* Toll-Free numbers are ordered by quantity (not picked individually) and provisioned asynchronously;
|
|
163
|
+
* per-number completion is delivered via webhook/polling, not in this response. The returned `orderId`
|
|
164
|
+
* can be polled with {@link Numbers#getTollFreeOrderStatus} for the order's outcome.
|
|
165
|
+
* @async
|
|
166
|
+
* @roles api, admin, developer, billing, user
|
|
167
|
+
* @param {Object} params - The parameters for purchasing toll-free numbers
|
|
168
|
+
* @param {number} params.quantity - The number of toll-free numbers to purchase (1-10)
|
|
169
|
+
* @param {string} params.subgroupId - The subgroup the purchased numbers are assigned to
|
|
170
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
171
|
+
* @throws {Error} Throws an error if the quantity or subgroupId parameter is missing
|
|
172
|
+
* @returns {Promise<Object>} A promise that resolves to `{ message, orderId }` once the request is queued.
|
|
173
|
+
*/
|
|
174
|
+
async purchaseTollFreeNumbers({ quantity, subgroupId, options = {} }) {
|
|
175
|
+
this.client._require({ quantity, subgroupId });
|
|
176
|
+
return this.client(`/number/toll-free`, { method: 'POST', body: { quantity, subgroupId }, ...options });
|
|
177
|
+
}
|
|
149
178
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
179
|
+
/**
|
|
180
|
+
* Request a campaign-bound Short Code acquisition or register a customer-owned Registry lease.
|
|
181
|
+
* An inventory request soft-holds an existing unassigned Short Code. Random and vanity requests remain pending
|
|
182
|
+
* until Signal House staff fulfill them. An external lease creates a pending Short Code number immediately; it
|
|
183
|
+
* becomes READY only when its campaign becomes ACTIVE.
|
|
184
|
+
* @async
|
|
185
|
+
* @roles api, admin, developer, billing, user
|
|
186
|
+
* @param {Object} params - Short Code acquisition parameters.
|
|
187
|
+
* @param {string} params.subgroupId - The owning subgroup ID.
|
|
188
|
+
* @param {string} params.brandId - The owning Short Code brand ID.
|
|
189
|
+
* @param {string} params.campaignId - The owning Short Code campaign ID.
|
|
190
|
+
* @param {'INVENTORY'|'RANDOM'|'VANITY'|'EXTERNAL_LEASE'} params.requestType - Acquisition path.
|
|
191
|
+
* @param {string} [params.existingPhoneNumber] - Required existing five- or six-digit Short Code for INVENTORY.
|
|
192
|
+
* @param {number} [params.leaseTermMonths] - Required 3, 6, or 12-month term for RANDOM/VANITY.
|
|
193
|
+
* @param {string} [params.requestedVanityCode] - Required five- or six-digit desired code for VANITY.
|
|
194
|
+
* @param {string} [params.actualCode] - Required customer-owned five- or six-digit code for EXTERNAL_LEASE.
|
|
195
|
+
* @param {string} [params.orderId] - Required Registry order ID for EXTERNAL_LEASE.
|
|
196
|
+
* @param {string|Date} [params.leaseEndDate] - Required future Registry lease end date for EXTERNAL_LEASE.
|
|
197
|
+
* @param {Buffer|Blob|File} [params.leaseReceiptFile] - Required PNG, JPEG, or PDF lease receipt for EXTERNAL_LEASE.
|
|
198
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request.
|
|
199
|
+
* @returns {Promise<Object>} A pending acquisition request or pending external-lease number.
|
|
200
|
+
*/
|
|
201
|
+
async requestShortCodeAcquisition({
|
|
202
|
+
subgroupId,
|
|
203
|
+
brandId,
|
|
204
|
+
campaignId,
|
|
205
|
+
requestType,
|
|
206
|
+
existingPhoneNumber,
|
|
207
|
+
requestedVanityCode,
|
|
208
|
+
leaseTermMonths,
|
|
209
|
+
actualCode,
|
|
210
|
+
orderId,
|
|
211
|
+
leaseEndDate,
|
|
212
|
+
leaseReceiptFile,
|
|
213
|
+
options = {},
|
|
214
|
+
}) {
|
|
215
|
+
this.client._require({ subgroupId, brandId, campaignId, requestType });
|
|
216
|
+
const formData = new FormData();
|
|
217
|
+
formData.append(
|
|
218
|
+
'acquisitionData',
|
|
219
|
+
JSON.stringify({ subgroupId, brandId, campaignId, requestType, existingPhoneNumber, requestedVanityCode, leaseTermMonths, actualCode, orderId, leaseEndDate }),
|
|
220
|
+
);
|
|
221
|
+
if (leaseReceiptFile) formData.append('leaseReceipt', leaseReceiptFile);
|
|
222
|
+
return this.multipartClient(`/number/short-code`, {
|
|
223
|
+
method: 'POST',
|
|
224
|
+
body: formData,
|
|
225
|
+
...options,
|
|
226
|
+
});
|
|
227
|
+
}
|
|
169
228
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
method: "PUT",
|
|
190
|
-
body: updateData,
|
|
191
|
-
...options
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Submit a port-in request for one or more phone numbers from another provider
|
|
197
|
-
* @async
|
|
198
|
-
* @roles api, admin, developer, billing, user
|
|
199
|
-
* @param {Object} params - The parameters for the port-in request
|
|
200
|
-
* @param {Object} params.numberData - The port-in request data including owner info, address, phone numbers, and signature
|
|
201
|
-
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
202
|
-
* @throws {Error} Throws an error if the numberData parameter is missing
|
|
203
|
-
* @returns {Promise<Object>} A promise that resolves to the created port-in request
|
|
204
|
-
*/
|
|
205
|
-
async portInPhoneNumber({ numberData, options = {} }) {
|
|
206
|
-
this.client._require({ numberData });
|
|
207
|
-
return this.client(`/number/portin`, { method: "POST", body: numberData, ...options });
|
|
208
|
-
}
|
|
229
|
+
/**
|
|
230
|
+
* Read the outcome of a Toll-Free number purchase by the `orderId` returned from
|
|
231
|
+
* {@link Numbers#purchaseTollFreeNumbers}. Reports per-number status as ready / provisioning / failed
|
|
232
|
+
* counts (plus failure reasons) so a client can poll until the order reaches a terminal state, and
|
|
233
|
+
* returns the provisioned phone numbers for the order so a client can act on exactly those numbers.
|
|
234
|
+
* `numbers` is empty until each number is provisioned (it fills in as the order completes).
|
|
235
|
+
* @async
|
|
236
|
+
* @roles api, admin, developer, billing, user
|
|
237
|
+
* @param {Object} params - The parameters for reading the order status
|
|
238
|
+
* @param {string} params.orderId - The order id returned by `purchaseTollFreeNumbers`
|
|
239
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
240
|
+
* @throws {Error} Throws an error if the orderId parameter is missing
|
|
241
|
+
* @returns {Promise<Object>} A promise that resolves to `{ orderId, counts: { ready, provisioning, failed }, failures: [{ reason }], numbers: string[] }`.
|
|
242
|
+
*/
|
|
243
|
+
async getTollFreeOrderStatus({ orderId, options = {} }) {
|
|
244
|
+
this.client._require({ orderId });
|
|
245
|
+
const safeOrderId = encodeURIComponent(orderId);
|
|
246
|
+
return this.client(`/number/toll-free/order/${safeOrderId}`, { method: 'GET', ...options });
|
|
247
|
+
}
|
|
209
248
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
const filters = { groupId, phoneNumber, status, page, limit };
|
|
225
|
-
const queryString = this.client._getQueryString(filters);
|
|
226
|
-
return this.client(`/number/portin${queryString}`, { method: "GET", ...options });
|
|
227
|
-
}
|
|
249
|
+
/**
|
|
250
|
+
* Update an existing phone number's details (e.g., setting a friendly name)
|
|
251
|
+
* @async
|
|
252
|
+
* @roles api, admin, developer, user
|
|
253
|
+
* @param {Object} params - The parameters for updating the phone number
|
|
254
|
+
* @param {string} params.phoneNumber - The phone number to update
|
|
255
|
+
* @param {Object} params.updateData - The data to update for the phone number
|
|
256
|
+
* @param {string} [params.updateData.friendlyName] - An optional friendly name for the phone number
|
|
257
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
258
|
+
* @throws {Error} Throws an error if the phoneNumber or updateData parameter is missing
|
|
259
|
+
* @returns {Promise<Object>} A promise that resolves to the updated phone number object
|
|
260
|
+
*/
|
|
261
|
+
async updatePhoneNumber({ phoneNumber, updateData, options = {} }) {
|
|
262
|
+
this.client._require({ phoneNumber, updateData });
|
|
228
263
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
* @async
|
|
232
|
-
* @roles api, admin, developer, billing, user
|
|
233
|
-
* @param {Object} params - The parameters for getting the port request
|
|
234
|
-
* @param {string} params.id - The _id of the port-in request
|
|
235
|
-
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
236
|
-
* @returns {Promise<Object>} A promise that resolves to the port-in request object
|
|
237
|
-
*/
|
|
238
|
-
async getPortRequestById({ id, options = {} }) {
|
|
239
|
-
this.client._require({ id });
|
|
240
|
-
const safeId = encodeURIComponent(id);
|
|
241
|
-
return this.client(`/number/portin/${safeId}`, { method: "GET", ...options });
|
|
242
|
-
}
|
|
264
|
+
// Safely encode the phone number for the URL path
|
|
265
|
+
const safePhoneNumber = encodeURIComponent(phoneNumber);
|
|
243
266
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
* @param {number} [params.page] - Page number for pagination (used when listing)
|
|
251
|
-
* @param {number} [params.limit] - Items per page (used when listing)
|
|
252
|
-
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
253
|
-
* @returns {Promise<Object>} A promise that resolves to the port-in request(s)
|
|
254
|
-
*/
|
|
255
|
-
async getPortingRequests({ portingId, page, limit, options = {} } = {}) {
|
|
256
|
-
if (portingId) {
|
|
257
|
-
return this.getPortRequestById({ id: portingId, options });
|
|
258
|
-
}
|
|
259
|
-
return this.getPortRequests({ page, limit, options });
|
|
260
|
-
}
|
|
267
|
+
return this.client(`/number/${safePhoneNumber}`, {
|
|
268
|
+
method: 'PUT',
|
|
269
|
+
body: updateData,
|
|
270
|
+
...options,
|
|
271
|
+
});
|
|
272
|
+
}
|
|
261
273
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
return this.client(`/number/assign/${safeCampaignId}`, { method: "POST", body: { phoneNumbers }, ...options });
|
|
277
|
-
}
|
|
274
|
+
/**
|
|
275
|
+
* Submit a port-in request for one or more phone numbers from another provider
|
|
276
|
+
* @async
|
|
277
|
+
* @roles api, admin, developer, billing, user
|
|
278
|
+
* @param {Object} params - The parameters for the port-in request
|
|
279
|
+
* @param {Object} params.numberData - The port-in request data including owner info, address, phone numbers, and signature
|
|
280
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
281
|
+
* @throws {Error} Throws an error if the numberData parameter is missing
|
|
282
|
+
* @returns {Promise<Object>} A promise that resolves to the created port-in request
|
|
283
|
+
*/
|
|
284
|
+
async portInPhoneNumber({ numberData, options = {} }) {
|
|
285
|
+
this.client._require({ numberData });
|
|
286
|
+
return this.client(`/number/portin`, { method: 'POST', body: numberData, ...options });
|
|
287
|
+
}
|
|
278
288
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
289
|
+
/**
|
|
290
|
+
* Get port-in requests with optional filters. Signal House staff can view all requests; regular users see only their group's requests.
|
|
291
|
+
* @async
|
|
292
|
+
* @roles api, admin, developer, billing, user
|
|
293
|
+
* @param {Object} [params] - The parameters for filtering port-in requests
|
|
294
|
+
* @param {string} [params.groupId] - Filter by group ID
|
|
295
|
+
* @param {string} [params.phoneNumber] - Filter by phone number
|
|
296
|
+
* @param {string} [params.status] - Filter by status (PENDING, IN_PROGRESS, COMPLETED, REJECTED, CANCELLED)
|
|
297
|
+
* @param {number} [params.page] - The page number for pagination (default: 1)
|
|
298
|
+
* @param {number} [params.limit] - The number of items per page (default: 20)
|
|
299
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
300
|
+
* @returns {Promise<Object>} A promise that resolves to the paginated list of port-in requests
|
|
301
|
+
*/
|
|
302
|
+
async getPortRequests({ groupId, phoneNumber, status, page, limit, options = {} } = {}) {
|
|
303
|
+
const filters = { groupId, phoneNumber, status, page, limit };
|
|
304
|
+
const queryString = this.client._getQueryString(filters);
|
|
305
|
+
return this.client(`/number/portin${queryString}`, { method: 'GET', ...options });
|
|
306
|
+
}
|
|
293
307
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
+
/**
|
|
309
|
+
* Get a single port-in request by its ID
|
|
310
|
+
* @async
|
|
311
|
+
* @roles api, admin, developer, billing, user
|
|
312
|
+
* @param {Object} params - The parameters for getting the port request
|
|
313
|
+
* @param {string} params.id - The _id of the port-in request
|
|
314
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
315
|
+
* @returns {Promise<Object>} A promise that resolves to the port-in request object
|
|
316
|
+
*/
|
|
317
|
+
async getPortRequestById({ id, options = {} }) {
|
|
318
|
+
this.client._require({ id });
|
|
319
|
+
const safeId = encodeURIComponent(id);
|
|
320
|
+
return this.client(`/number/portin/${safeId}`, { method: 'GET', ...options });
|
|
321
|
+
}
|
|
308
322
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
+
/**
|
|
324
|
+
* Get porting requests - fetches a single request by portingId, or delegates to getPortRequests for listing
|
|
325
|
+
* @async
|
|
326
|
+
* @roles api, admin, developer, billing, user
|
|
327
|
+
* @param {Object} params - The parameters
|
|
328
|
+
* @param {string} [params.portingId] - If provided, fetches a single port request by ID
|
|
329
|
+
* @param {number} [params.page] - Page number for pagination (used when listing)
|
|
330
|
+
* @param {number} [params.limit] - Items per page (used when listing)
|
|
331
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
332
|
+
* @returns {Promise<Object>} A promise that resolves to the port-in request(s)
|
|
333
|
+
*/
|
|
334
|
+
async getPortingRequests({ portingId, page, limit, options = {} } = {}) {
|
|
335
|
+
if (portingId) {
|
|
336
|
+
return this.getPortRequestById({ id: portingId, options });
|
|
337
|
+
}
|
|
338
|
+
return this.getPortRequests({ page, limit, options });
|
|
339
|
+
}
|
|
323
340
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
341
|
+
/**
|
|
342
|
+
* Assign phone numbers to a campaign by providing the campaign ID and a list of phone numbers to assign
|
|
343
|
+
* @async
|
|
344
|
+
* @roles api, admin, developer, billing, user
|
|
345
|
+
* @param {Object} params - The parameters for assigning phone numbers to a campaign
|
|
346
|
+
* @param {string} params.campaignId - The ID of the campaign to assign phone numbers to
|
|
347
|
+
* @param {string[]} params.phoneNumbers - The list of phone numbers to assign to the campaign
|
|
348
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
349
|
+
* @throws {Error} Throws an error if the campaignId or phoneNumbers parameter is missing
|
|
350
|
+
* @returns {Promise<Object>} A promise that resolves to the result of the assignment operation
|
|
351
|
+
*/
|
|
352
|
+
async assignPhoneNumberToCampaign({ campaignId, phoneNumbers, options = {} }) {
|
|
353
|
+
this.client._require({ campaignId, phoneNumbers });
|
|
354
|
+
const safeCampaignId = encodeURIComponent(campaignId);
|
|
355
|
+
return this.client(`/number/assign/${safeCampaignId}`, { method: 'POST', body: { phoneNumbers }, ...options });
|
|
356
|
+
}
|
|
338
357
|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
358
|
+
/**
|
|
359
|
+
* Unassign phone numbers from a campaign by providing a list of phone numbers to unassign. Note: This operation will unassign the specified phone numbers from any campaign they are currently assigned to.
|
|
360
|
+
* @async
|
|
361
|
+
* @roles api, admin, developer, billing, user
|
|
362
|
+
* @param {Object} params - The parameters for unassigning phone numbers from campaigns
|
|
363
|
+
* @param {string[]} params.phoneNumbers - The list of phone numbers to unassign from campaigns
|
|
364
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
365
|
+
* @throws {Error} Throws an error if the phoneNumbers parameter is missing
|
|
366
|
+
* @returns {Promise<Object>} A promise that resolves to the result of the unassignment operation
|
|
367
|
+
*/
|
|
368
|
+
async unassignPhoneNumbersFromCampaigns({ phoneNumbers, options = {} }) {
|
|
369
|
+
this.client._require({ phoneNumbers });
|
|
370
|
+
return this.client(`/number/unassign`, { method: 'POST', body: { phoneNumbers }, ...options });
|
|
371
|
+
}
|
|
352
372
|
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
*/
|
|
368
|
-
async searchNpaNxx({ country, state, city, npa, nxx, options = {} }) {
|
|
369
|
-
const queryString = this.client._getQueryString({ country, state, city, npa, nxx });
|
|
370
|
-
return this.client(`/number/lookup${queryString}`, { method: "GET", ...options });
|
|
371
|
-
}
|
|
373
|
+
/**
|
|
374
|
+
* Delete a list of phone numbers (mark them as RELEASED). The phone numbers will no longer be active or usable but they will still be visible in the system with a status of "RELEASED". Note: This operation is irreversible and should be used with caution.
|
|
375
|
+
* @async
|
|
376
|
+
* @roles api, admin, developer, billing, user
|
|
377
|
+
* @param {Object} params - The parameters for deleting phone numbers
|
|
378
|
+
* @param {string[]} params.phoneNumbers - The list of phone numbers to delete
|
|
379
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
380
|
+
* @throws {Error} Throws an error if the phoneNumbers parameter is missing
|
|
381
|
+
* @returns {Promise<Object>} A promise that resolves to the result of the deletion operation
|
|
382
|
+
*/
|
|
383
|
+
async deletePhoneNumbers({ phoneNumbers, options = {} }) {
|
|
384
|
+
this.client._require({ phoneNumbers });
|
|
385
|
+
return this.client(`/number`, { method: 'DELETE', body: { phoneNumbers }, ...options });
|
|
386
|
+
}
|
|
372
387
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
388
|
+
/**
|
|
389
|
+
* Deactivate one or more phone numbers. Numbers must be in READY status to be deactivated. Deactivated numbers will not be able to send or receive messages but will remain assigned to their subgroup and campaign.
|
|
390
|
+
* @async
|
|
391
|
+
* @roles api, admin, developer, billing, user
|
|
392
|
+
* @param {Object} params - The parameters for deactivating phone numbers
|
|
393
|
+
* @param {string[]} params.phoneNumbers - The list of phone numbers to deactivate
|
|
394
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
395
|
+
* @throws {Error} Throws an error if the phoneNumbers parameter is missing
|
|
396
|
+
* @returns {Promise<Object>} A promise that resolves to an array of updated phone number objects
|
|
397
|
+
*/
|
|
398
|
+
async deactivatePhoneNumbers({ phoneNumbers, options = {} }) {
|
|
399
|
+
this.client._require({ phoneNumbers });
|
|
400
|
+
return this.client(`/number/deactivate`, { method: 'POST', body: { phoneNumbers }, ...options });
|
|
401
|
+
}
|
|
385
402
|
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
403
|
+
/**
|
|
404
|
+
* Reactivate one or more previously deactivated phone numbers. Numbers must be in DEACTIVATED status to be reactivated. Reactivated numbers will return to PENDING or IN_PROGRESS status depending on their campaign assignment.
|
|
405
|
+
* @async
|
|
406
|
+
* @roles api, admin, developer, billing, user
|
|
407
|
+
* @param {Object} params - The parameters for reactivating phone numbers
|
|
408
|
+
* @param {string[]} params.phoneNumbers - The list of phone numbers to reactivate
|
|
409
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
410
|
+
* @throws {Error} Throws an error if the phoneNumbers parameter is missing
|
|
411
|
+
* @returns {Promise<Object>} A promise that resolves to an array of updated phone number objects
|
|
412
|
+
*/
|
|
413
|
+
async reactivatePhoneNumbers({ phoneNumbers, options = {} }) {
|
|
414
|
+
this.client._require({ phoneNumbers });
|
|
415
|
+
return this.client(`/number/reactivate`, { method: 'POST', body: { phoneNumbers }, ...options });
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* Transfer unassigned phone numbers from one subgroup to another.
|
|
420
|
+
* @async
|
|
421
|
+
* @param {Object} params - The parameters for transferring phone numbers
|
|
422
|
+
* @param {string[]} params.phoneNumbers - The list of phone numbers to transfer
|
|
423
|
+
* @param {string} params.newSubgroupId - The ID of the new subgroup to transfer the phone numbers to
|
|
424
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
425
|
+
* @returns {Promise<Object>} A promise that resolves to the result of the transfer operation
|
|
426
|
+
*/
|
|
427
|
+
async transferPhoneNumbers({ phoneNumbers, newSubgroupId, options = {} }) {
|
|
428
|
+
this.client._require({ phoneNumbers, newSubgroupId });
|
|
429
|
+
return this.client(`/number/transfer`, { method: 'POST', body: { phoneNumbers, newSubgroupId }, ...options });
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* Search NPA/NXX lookup data with optional filters.
|
|
434
|
+
* At least one search parameter is required.
|
|
435
|
+
* Location filters (country, state, city) cannot be combined with NPA/NXX filters.
|
|
436
|
+
* @async
|
|
437
|
+
* @roles api, admin, developer, billing, user
|
|
438
|
+
* @param {Object} params - The parameters for searching NPA/NXX data
|
|
439
|
+
* @param {string} [params.country] - Filter by country code
|
|
440
|
+
* @param {string} [params.state] - Filter by state code (2 characters)
|
|
441
|
+
* @param {string} [params.city] - Filter by city name (prefix match, case-insensitive; requires country and state)
|
|
442
|
+
* @param {string} [params.npa] - Area code filter (1-3 digits; cannot combine with location filters)
|
|
443
|
+
* @param {string} [params.nxx] - Central office code filter (1-3 digits; cannot combine with location filters)
|
|
444
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
445
|
+
* @returns {Promise<Object>} A promise that resolves to matching NPA/NXX records or unique NPA/NXX arrays
|
|
446
|
+
*/
|
|
447
|
+
async searchNpaNxx({ country, state, city, npa, nxx, options = {} }) {
|
|
448
|
+
const queryString = this.client._getQueryString({ country, state, city, npa, nxx });
|
|
449
|
+
return this.client(`/number/lookup${queryString}`, { method: 'GET', ...options });
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* Batch lookup city/state for NPA/NXX pairs
|
|
454
|
+
* @async
|
|
455
|
+
* @roles api, admin, developer, billing, user
|
|
456
|
+
* @param {Object} params - The parameters for the lookup
|
|
457
|
+
* @param {Array<{npa: string, nxx: string}>} params.entries - NPA/NXX pairs to look up (max 50)
|
|
458
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
459
|
+
* @returns {Promise<Object>} A promise that resolves to an array of {npa, nxx, city, state} objects
|
|
460
|
+
*/
|
|
461
|
+
async lookupLocations({ entries, options = {} }) {
|
|
462
|
+
return this.client('/number/lookup/location', { method: 'POST', body: { entries }, ...options });
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* Migrate a phone number (or all numbers in a campaign/group) from v1 to v2
|
|
467
|
+
* @async
|
|
468
|
+
* @roles api, admin, developer, billing, user, signalhouse_api, signalhouse_admin, signalhouse_user
|
|
469
|
+
* @param {Object} params - The parameters for migration
|
|
470
|
+
* @param {string} [params.phoneNumber] - The phone number to migrate
|
|
471
|
+
* @param {string} [params.campaignId] - Campaign ID to migrate all numbers for
|
|
472
|
+
* @param {string} [params.groupId] - Group ID to migrate all numbers for
|
|
473
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
474
|
+
* @returns {Promise<Object>} A promise that resolves to a confirmation with count of queued numbers
|
|
475
|
+
*/
|
|
476
|
+
async migratePhoneNumberToV2({ phoneNumber, campaignId, groupId, options = {} }) {
|
|
477
|
+
return this.client(`/number/migrate`, { method: 'POST', body: { phoneNumber, campaignId, groupId }, ...options });
|
|
478
|
+
}
|
|
479
|
+
}
|