@unboundcx/sdk 2.2.5 → 2.3.0
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/services/phoneNumbers.js +165 -43
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unboundcx/sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
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",
|
package/services/phoneNumbers.js
CHANGED
|
@@ -188,16 +188,29 @@ export class PhoneNumbersService {
|
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
async getRoutingOptions() {
|
|
191
|
-
const result = await this.sdk._fetch(
|
|
191
|
+
const result = await this.sdk._fetch(
|
|
192
|
+
'/phoneNumbers/routing-options',
|
|
193
|
+
'GET',
|
|
194
|
+
);
|
|
192
195
|
return result;
|
|
193
196
|
}
|
|
194
197
|
|
|
195
198
|
async getSupportedCountries() {
|
|
196
|
-
const result = await this.sdk._fetch(
|
|
199
|
+
const result = await this.sdk._fetch(
|
|
200
|
+
'/phoneNumbers/supported-countries',
|
|
201
|
+
'GET',
|
|
202
|
+
);
|
|
197
203
|
return result;
|
|
198
204
|
}
|
|
199
205
|
|
|
200
206
|
// Porting Methods
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Check portability of phone numbers
|
|
210
|
+
* @param {Object} params
|
|
211
|
+
* @param {string[]} params.phoneNumbers - Array of +E.164 formatted phone numbers
|
|
212
|
+
* @returns {Promise<Object>} Portability check results
|
|
213
|
+
*/
|
|
201
214
|
async checkPortability({ phoneNumbers }) {
|
|
202
215
|
this.sdk.validateParams(
|
|
203
216
|
{ phoneNumbers },
|
|
@@ -206,39 +219,80 @@ export class PhoneNumbersService {
|
|
|
206
219
|
},
|
|
207
220
|
);
|
|
208
221
|
|
|
209
|
-
const result = await this.sdk._fetch(
|
|
210
|
-
|
|
211
|
-
|
|
222
|
+
const result = await this.sdk._fetch(
|
|
223
|
+
'/phoneNumbers/porting/portability-check',
|
|
224
|
+
'POST',
|
|
225
|
+
{
|
|
226
|
+
body: { phoneNumbers },
|
|
227
|
+
},
|
|
228
|
+
);
|
|
212
229
|
return result;
|
|
213
230
|
}
|
|
214
231
|
|
|
232
|
+
/**
|
|
233
|
+
* Create a draft porting order (no validation - can be built incrementally)
|
|
234
|
+
* @param {Object} params
|
|
235
|
+
* @param {string[]} [params.phoneNumbers] - Array of +E.164 formatted phone numbers
|
|
236
|
+
* @param {Object[]} [params.phoneNumberBlocks] - Array of phone number blocks
|
|
237
|
+
* @param {string} [params.customerReference] - Customer-specified reference number
|
|
238
|
+
* @param {Object} [params.endUser] - End user information
|
|
239
|
+
* @param {Object} [params.endUser.admin] - Admin contact info
|
|
240
|
+
* @param {string} [params.endUser.admin.entityName] - Business/entity name
|
|
241
|
+
* @param {string} [params.endUser.admin.authPersonName] - Authorized person name
|
|
242
|
+
* @param {string} [params.endUser.admin.billingPhoneNumber] - Billing phone number
|
|
243
|
+
* @param {string} [params.endUser.admin.accountNumber] - Account number with current provider
|
|
244
|
+
* @param {string} [params.endUser.admin.taxIdentifier] - Tax identification number (EU)
|
|
245
|
+
* @param {string} [params.endUser.admin.pinPasscode] - PIN/passcode for account access
|
|
246
|
+
* @param {string} [params.endUser.admin.businessIdentifier] - Business identifier (EU)
|
|
247
|
+
* @param {Object} [params.endUser.location] - Location information
|
|
248
|
+
* @param {string} [params.endUser.location.streetAddress] - Street address
|
|
249
|
+
* @param {string} [params.endUser.location.extendedAddress] - Apt/suite/etc
|
|
250
|
+
* @param {string} [params.endUser.location.locality] - City
|
|
251
|
+
* @param {string} [params.endUser.location.administrativeArea] - State/province
|
|
252
|
+
* @param {string} [params.endUser.location.postalCode] - ZIP/postal code
|
|
253
|
+
* @param {string} [params.endUser.location.countryCode] - 2-letter country code
|
|
254
|
+
* @param {Object} [params.activationSettings] - Activation preferences
|
|
255
|
+
* @param {string} [params.activationSettings.focDatetimeRequested] - Requested FOC date/time
|
|
256
|
+
* @param {string} [params.activationSettings.focDatetimeActual] - Actual FOC date/time
|
|
257
|
+
* @param {boolean} [params.activationSettings.fastPortEligible] - Fast port eligibility
|
|
258
|
+
* @param {string} [params.activationSettings.activationStatus] - Activation status
|
|
259
|
+
* @param {Object} [params.phoneNumberConfiguration] - Phone number config
|
|
260
|
+
* @param {string} [params.phoneNumberConfiguration.billingGroupId] - Billing group ID
|
|
261
|
+
* @param {string} [params.phoneNumberConfiguration.connectionId] - Connection ID
|
|
262
|
+
* @param {string} [params.phoneNumberConfiguration.messagingProfileId] - Messaging profile ID
|
|
263
|
+
* @param {string} [params.phoneNumberConfiguration.emergencyAddressId] - Emergency address ID
|
|
264
|
+
* @param {string} [params.phoneNumberConfiguration.phoneNumberType] - Phone number type
|
|
265
|
+
* @param {string} [params.phoneNumberConfiguration.description] - Description
|
|
266
|
+
* @param {string[]} [params.tags] - Array of tags for organization
|
|
267
|
+
* @returns {Promise<Object>} Created draft porting order with ID and status 'draft'
|
|
268
|
+
*/
|
|
215
269
|
async createPortingOrder({
|
|
216
270
|
phoneNumbers,
|
|
217
271
|
phoneNumberBlocks,
|
|
218
272
|
customerReference,
|
|
219
273
|
endUser,
|
|
220
274
|
activationSettings,
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
}) {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
const body = {
|
|
229
|
-
...additionalData
|
|
230
|
-
};
|
|
275
|
+
phoneNumberConfiguration,
|
|
276
|
+
tags
|
|
277
|
+
} = {}) {
|
|
278
|
+
// No validation - creates draft order that can be built incrementally
|
|
279
|
+
const body = {};
|
|
231
280
|
|
|
232
281
|
if (phoneNumbers) body.phoneNumbers = phoneNumbers;
|
|
233
282
|
if (phoneNumberBlocks) body.phoneNumberBlocks = phoneNumberBlocks;
|
|
234
283
|
if (customerReference) body.customerReference = customerReference;
|
|
235
284
|
if (endUser) body.endUser = endUser;
|
|
236
285
|
if (activationSettings) body.activationSettings = activationSettings;
|
|
237
|
-
if (
|
|
286
|
+
if (phoneNumberConfiguration) body.phoneNumberConfiguration = phoneNumberConfiguration;
|
|
287
|
+
if (tags) body.tags = tags;
|
|
238
288
|
|
|
239
|
-
const result = await this.sdk._fetch(
|
|
240
|
-
|
|
241
|
-
|
|
289
|
+
const result = await this.sdk._fetch(
|
|
290
|
+
'/phoneNumbers/porting/orders',
|
|
291
|
+
'POST',
|
|
292
|
+
{
|
|
293
|
+
body: body,
|
|
294
|
+
},
|
|
295
|
+
);
|
|
242
296
|
return result;
|
|
243
297
|
}
|
|
244
298
|
|
|
@@ -248,20 +302,24 @@ export class PhoneNumbersService {
|
|
|
248
302
|
status,
|
|
249
303
|
customerReference,
|
|
250
304
|
sort,
|
|
251
|
-
limit
|
|
305
|
+
limit,
|
|
252
306
|
} = {}) {
|
|
253
307
|
const params = new URLSearchParams();
|
|
254
|
-
|
|
308
|
+
|
|
255
309
|
if (page) params.append('page', page);
|
|
256
|
-
if (includePhoneNumbers !== undefined)
|
|
310
|
+
if (includePhoneNumbers !== undefined)
|
|
311
|
+
params.append('includePhoneNumbers', includePhoneNumbers);
|
|
257
312
|
if (status) params.append('status', status);
|
|
258
|
-
if (customerReference)
|
|
313
|
+
if (customerReference)
|
|
314
|
+
params.append('customerReference', customerReference);
|
|
259
315
|
if (sort) params.append('sort', sort);
|
|
260
316
|
if (limit) params.append('limit', limit);
|
|
261
317
|
|
|
262
318
|
const queryString = params.toString();
|
|
263
|
-
const url = queryString
|
|
264
|
-
|
|
319
|
+
const url = queryString
|
|
320
|
+
? `/phoneNumbers/porting/orders?${queryString}`
|
|
321
|
+
: '/phoneNumbers/porting/orders';
|
|
322
|
+
|
|
265
323
|
const result = await this.sdk._fetch(url, 'GET');
|
|
266
324
|
return result;
|
|
267
325
|
}
|
|
@@ -275,27 +333,85 @@ export class PhoneNumbersService {
|
|
|
275
333
|
);
|
|
276
334
|
|
|
277
335
|
const params = new URLSearchParams();
|
|
278
|
-
if (includePhoneNumbers !== undefined)
|
|
279
|
-
|
|
336
|
+
if (includePhoneNumbers !== undefined)
|
|
337
|
+
params.append('includePhoneNumbers', includePhoneNumbers);
|
|
338
|
+
|
|
280
339
|
const queryString = params.toString();
|
|
281
|
-
const url = queryString
|
|
282
|
-
|
|
340
|
+
const url = queryString
|
|
341
|
+
? `/phoneNumbers/porting/orders/${id}?${queryString}`
|
|
342
|
+
: `/phoneNumbers/porting/orders/${id}`;
|
|
343
|
+
|
|
283
344
|
const result = await this.sdk._fetch(url, 'GET');
|
|
284
345
|
return result;
|
|
285
346
|
}
|
|
286
347
|
|
|
287
|
-
|
|
348
|
+
/**
|
|
349
|
+
* Update a draft porting order (same parameters as createPortingOrder)
|
|
350
|
+
* @param {string} id - Porting order ID
|
|
351
|
+
* @param {Object} params - Same parameters as createPortingOrder
|
|
352
|
+
* @returns {Promise<Object>} Updated porting order
|
|
353
|
+
*/
|
|
354
|
+
async updatePortingOrder(id, {
|
|
355
|
+
phoneNumbers,
|
|
356
|
+
phoneNumberBlocks,
|
|
357
|
+
customerReference,
|
|
358
|
+
endUser,
|
|
359
|
+
activationSettings,
|
|
360
|
+
phoneNumberConfiguration,
|
|
361
|
+
tags
|
|
362
|
+
} = {}) {
|
|
288
363
|
this.sdk.validateParams(
|
|
289
|
-
{ id
|
|
364
|
+
{ id },
|
|
290
365
|
{
|
|
291
366
|
id: { type: 'string', required: true },
|
|
292
|
-
updateData: { type: 'object', required: true },
|
|
293
367
|
},
|
|
294
368
|
);
|
|
295
369
|
|
|
296
|
-
const
|
|
297
|
-
|
|
298
|
-
|
|
370
|
+
const body = {};
|
|
371
|
+
|
|
372
|
+
if (phoneNumbers) body.phoneNumbers = phoneNumbers;
|
|
373
|
+
if (phoneNumberBlocks) body.phoneNumberBlocks = phoneNumberBlocks;
|
|
374
|
+
if (customerReference) body.customerReference = customerReference;
|
|
375
|
+
if (endUser) body.endUser = endUser;
|
|
376
|
+
if (activationSettings) body.activationSettings = activationSettings;
|
|
377
|
+
if (phoneNumberConfiguration) body.phoneNumberConfiguration = phoneNumberConfiguration;
|
|
378
|
+
if (tags) body.tags = tags;
|
|
379
|
+
|
|
380
|
+
const result = await this.sdk._fetch(
|
|
381
|
+
`/phoneNumbers/porting/orders/${id}`,
|
|
382
|
+
'PUT',
|
|
383
|
+
{
|
|
384
|
+
body: body,
|
|
385
|
+
},
|
|
386
|
+
);
|
|
387
|
+
return result;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* Submit a draft porting order for processing (validates all required fields)
|
|
392
|
+
* @param {string} id - Porting order ID
|
|
393
|
+
* @returns {Promise<Object>} Submitted porting order with Telnyx status
|
|
394
|
+
*/
|
|
395
|
+
async submitPortingOrder(id) {
|
|
396
|
+
this.sdk.validateParams(
|
|
397
|
+
{ id },
|
|
398
|
+
{
|
|
399
|
+
id: { type: 'string', required: true },
|
|
400
|
+
},
|
|
401
|
+
);
|
|
402
|
+
|
|
403
|
+
// Submit the draft order (status is implied)
|
|
404
|
+
const body = {
|
|
405
|
+
status: 'submit',
|
|
406
|
+
};
|
|
407
|
+
|
|
408
|
+
const result = await this.sdk._fetch(
|
|
409
|
+
`/phoneNumbers/porting/orders/${id}`,
|
|
410
|
+
'PUT',
|
|
411
|
+
{
|
|
412
|
+
body: body,
|
|
413
|
+
},
|
|
414
|
+
);
|
|
299
415
|
return result;
|
|
300
416
|
}
|
|
301
417
|
|
|
@@ -304,7 +420,7 @@ export class PhoneNumbersService {
|
|
|
304
420
|
fileContent,
|
|
305
421
|
contentType = 'application/pdf',
|
|
306
422
|
documentType = 'loa',
|
|
307
|
-
portingOrderId
|
|
423
|
+
portingOrderId,
|
|
308
424
|
}) {
|
|
309
425
|
this.sdk.validateParams(
|
|
310
426
|
{ filename, fileContent },
|
|
@@ -318,14 +434,18 @@ export class PhoneNumbersService {
|
|
|
318
434
|
filename,
|
|
319
435
|
fileContent,
|
|
320
436
|
contentType,
|
|
321
|
-
documentType
|
|
437
|
+
documentType,
|
|
322
438
|
};
|
|
323
439
|
|
|
324
440
|
if (portingOrderId) body.portingOrderId = portingOrderId;
|
|
325
441
|
|
|
326
|
-
const result = await this.sdk._fetch(
|
|
327
|
-
|
|
328
|
-
|
|
442
|
+
const result = await this.sdk._fetch(
|
|
443
|
+
'/phoneNumbers/porting/documents',
|
|
444
|
+
'POST',
|
|
445
|
+
{
|
|
446
|
+
body: body,
|
|
447
|
+
},
|
|
448
|
+
);
|
|
329
449
|
return result;
|
|
330
450
|
}
|
|
331
451
|
|
|
@@ -340,10 +460,12 @@ export class PhoneNumbersService {
|
|
|
340
460
|
const params = new URLSearchParams();
|
|
341
461
|
if (page) params.append('page', page);
|
|
342
462
|
if (limit) params.append('limit', limit);
|
|
343
|
-
|
|
463
|
+
|
|
344
464
|
const queryString = params.toString();
|
|
345
|
-
const url = queryString
|
|
346
|
-
|
|
465
|
+
const url = queryString
|
|
466
|
+
? `/phoneNumbers/porting/orders/${id}/events?${queryString}`
|
|
467
|
+
: `/phoneNumbers/porting/orders/${id}/events`;
|
|
468
|
+
|
|
347
469
|
const result = await this.sdk._fetch(url, 'GET');
|
|
348
470
|
return result;
|
|
349
471
|
}
|