@twilio/flex-plugins-library-utils
Advanced tools
Comparing version 1.1.5 to 1.1.6
@@ -22,3 +22,2 @@ # Changelog | ||
## 1.1.0 | ||
@@ -29,2 +28,3 @@ | ||
This release is focused on adding `Conversation` module to the library along with enhancing other modules. | ||
### Added | ||
@@ -55,7 +55,7 @@ | ||
- Added 5 new methods in the ProgrammableVoiceUtils | ||
- `listOutgoingCallerIds` | ||
- `fetchRecordingMedia` | ||
- `fetchRecording` | ||
- `fetchVoiceQueue` | ||
- `updateCall` | ||
- `listOutgoingCallerIds` | ||
- `fetchRecordingMedia` | ||
- `fetchRecording` | ||
- `fetchVoiceQueue` | ||
- `updateCall` | ||
@@ -69,2 +69,3 @@ ## 1.1.3 | ||
### Fixed | ||
- Authentication for `ProgrammableVoiceUtils` class | ||
@@ -79,5 +80,18 @@ | ||
### Added | ||
- Following three parameters are added to `getAllTasksFromWorkspace` method of `TaskRouterUtils` | ||
- `workflowSid`: the workflow SID to filter by | ||
- `assignmentStatus`: the assignment status of tasks to filter by | ||
- `ordering`: the desired ordering of the resulting taskList (e.g. DateCreated:desc) | ||
- `workflowSid`: the workflow SID to filter by | ||
- `assignmentStatus`: the assignment status of tasks to filter by | ||
- `ordering`: the desired ordering of the resulting taskList (e.g. DateCreated:desc) | ||
## 1.1.6 | ||
**v1.1.6** of **`@twilio/flex-plugins-library-utils`**! is released | ||
### Added | ||
- Added a `listOutgoingCallerIds` method to `PhoneNumberUtils` class to support retrieving the list of outgoing-only caller IDs (validated non-Twilio phone numbers). | ||
### Fixed | ||
- Removed the default limit of 1000 imposed on the `listPhoneNumbers` method of `PhoneNumberUtils` as the library automatically fetches all pages without specifying a limit. |
@@ -5,2 +5,3 @@ import { Twilio } from 'twilio'; | ||
import { IncomingPhoneNumberInstance } from 'twilio/lib/rest/api/v2010/account/incomingPhoneNumber'; | ||
import { OutgoingCallerIdInstance } from 'twilio/lib/rest/api/v2010/account/outgoingCallerId'; | ||
import { PluginUtils } from '../../common/BaseClasses/PluginUtils'; | ||
@@ -31,2 +32,11 @@ import { PhoneNumberInstance } from 'twilio/lib/rest/lookups/v2/phoneNumber'; | ||
* @param {number} parameters.attempts the number of retry attempts performed | ||
* @returns {Array<PhoneNumber>} An array of outbound caller ids for the account | ||
* @description the following method is used to robustly retrieve | ||
* the outbound caller ids for the account | ||
*/ | ||
listOutgoingCallerIds(parameters: Parameters): Promise<ApiReturnType & { | ||
callerIds?: Array<OutgoingCallerIdInstance>; | ||
}>; | ||
/** | ||
* @param {number} parameters.attempts the number of retry attempts performed | ||
* @param {string} parameters.phoneNumber the phone number to validate | ||
@@ -33,0 +43,0 @@ * @returns {object} https://www.twilio.com/docs/lookup/v2-api#making-a-request |
@@ -46,5 +46,3 @@ "use strict"; | ||
} | ||
const phoneNumbers = yield this.client.incomingPhoneNumbers.list({ | ||
limit: parameters.limit || 1000, | ||
}); | ||
const phoneNumbers = yield this.client.incomingPhoneNumbers.list(Object.assign({}, (parameters.limit && { limit: parameters.limit }))); | ||
return { success: true, phoneNumbers, status: statusCodes_1.HttpErrorCode.OK }; | ||
@@ -66,2 +64,33 @@ } | ||
* @param {number} parameters.attempts the number of retry attempts performed | ||
* @returns {Array<PhoneNumber>} An array of outbound caller ids for the account | ||
* @description the following method is used to robustly retrieve | ||
* the outbound caller ids for the account | ||
*/ | ||
listOutgoingCallerIds(parameters) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const parameterChecks = { | ||
attempts: 'number', | ||
}; | ||
try { | ||
const inputError = PluginUtilsErrorManager_1.PluginUtilsErrorManager.checkInvalidParameters(parameters, parameterChecks); | ||
if (inputError) { | ||
throw new PluginUtilsErrorManager_1.PluginUtilsErrorManager(inputError, statusCodes_1.HttpErrorCode.BadRequest); | ||
} | ||
const callerIds = yield this.client.outgoingCallerIds.list(Object.assign({}, (parameters.limit && { limit: parameters.limit }))); | ||
return { success: true, callerIds, status: statusCodes_1.HttpErrorCode.OK }; | ||
} | ||
catch (error) { | ||
if (error.code === statusCodes_1.HttpErrorCode.BadRequest) { | ||
return { | ||
success: false, | ||
status: statusCodes_1.HttpErrorCode.BadRequest, | ||
message: error.message, | ||
}; | ||
} | ||
return (0, retryHandler_1.retryHandler)(this.config, error, parameters, this.listOutgoingCallerIds); | ||
} | ||
}); | ||
} | ||
/** | ||
* @param {number} parameters.attempts the number of retry attempts performed | ||
* @param {string} parameters.phoneNumber the phone number to validate | ||
@@ -68,0 +97,0 @@ * @returns {object} https://www.twilio.com/docs/lookup/v2-api#making-a-request |
{ | ||
"name": "@twilio/flex-plugins-library-utils", | ||
"version": "1.1.5", | ||
"version": "1.1.6", | ||
"description": "Flex Plugins Library Utils", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -6,2 +6,3 @@ import { Twilio } from 'twilio'; | ||
import { IncomingPhoneNumberInstance } from 'twilio/lib/rest/api/v2010/account/incomingPhoneNumber'; | ||
import { OutgoingCallerIdInstance } from 'twilio/lib/rest/api/v2010/account/outgoingCallerId'; | ||
import { isNumber } from 'lodash'; | ||
@@ -51,3 +52,3 @@ import { PluginUtils } from '../../common/BaseClasses/PluginUtils'; | ||
const phoneNumbers = await this.client.incomingPhoneNumbers.list({ | ||
limit: parameters.limit || 1000, | ||
...(parameters.limit && { limit: parameters.limit }), | ||
}); | ||
@@ -70,2 +71,38 @@ | ||
* @param {number} parameters.attempts the number of retry attempts performed | ||
* @returns {Array<PhoneNumber>} An array of outbound caller ids for the account | ||
* @description the following method is used to robustly retrieve | ||
* the outbound caller ids for the account | ||
*/ | ||
public async listOutgoingCallerIds( | ||
parameters: Parameters, | ||
): Promise<ApiReturnType & { callerIds?: Array<OutgoingCallerIdInstance> }> { | ||
const parameterChecks = { | ||
attempts: 'number', | ||
}; | ||
try { | ||
const inputError = PluginUtilsErrorManager.checkInvalidParameters<Parameters>(parameters, parameterChecks); | ||
if (inputError) { | ||
throw new PluginUtilsErrorManager(inputError, HttpErrorCode.BadRequest); | ||
} | ||
const callerIds = await this.client.outgoingCallerIds.list({ | ||
...(parameters.limit && { limit: parameters.limit }), | ||
}); | ||
return { success: true, callerIds, status: HttpErrorCode.OK }; | ||
} catch (error) { | ||
if (error.code === HttpErrorCode.BadRequest) { | ||
return { | ||
success: false, | ||
status: HttpErrorCode.BadRequest, | ||
message: error.message, | ||
}; | ||
} | ||
return retryHandler(this.config, error, parameters, this.listOutgoingCallerIds); | ||
} | ||
} | ||
/** | ||
* @param {number} parameters.attempts the number of retry attempts performed | ||
* @param {string} parameters.phoneNumber the phone number to validate | ||
@@ -72,0 +109,0 @@ * @returns {object} https://www.twilio.com/docs/lookup/v2-api#making-a-request |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
311578
5521