diff --git a/CHANGELOG.md b/CHANGELOG.md index 19c5b5d..b32fdd7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log +## [v4.20.1](https://github.com/plivo/plivo-node/tree/v4.20.1) (2021-07-27) +- Updates to [add a member a multi-party call API](https://www.plivo.com/docs/voice/api/multiparty-call/participants#add-a-participant). + - Remove validation range for `delay` and `ringtimeout` parameters. + - Add appropriate error message for multiple `ringtimeout` and `delaydial` values. +- Updated default HTTP client request timeout to 5 seconds. + ## [v4.20.0](https://github.com/plivo/plivo-node/tree/v4.20.0) (2021-07-13) - Power pack ID has been included to the response for the [list all messages API](https://www.plivo.com/docs/sms/api/message/list-all-messages/) and the [get message details API](https://www.plivo.com/docs/sms/api/message#retrieve-a-message). - Support for filtering messages by Power pack ID has been added to the [list all messages API](https://www.plivo.com/docs/sms/api/message#list-all-messages). diff --git a/lib/resources/multiPartyCall.js b/lib/resources/multiPartyCall.js index 0fe35c6..3fee3f8 100644 --- a/lib/resources/multiPartyCall.js +++ b/lib/resources/multiPartyCall.js @@ -106,24 +106,24 @@ export class MultiPartyCall extends PlivoResource{ if(params.ringTimeout || params.ringTimeout === 0){ validParam('ringTimeout', params.ringTimeout, [String, Number], false) - if(Number.isInteger(params.ringTimeout)){ - validRange('RingTimeout', params.ringTimeout, false, 15, 120) - } - else{ + if(typeof(params.ringTimeout) === 'string'){ validMultipleDestinationIntegers('ringTimeout', params.ringTimeout) } + else if (!Number.isInteger(params.ringTimeout) && typeof(params.ringTimeout) !== 'string'){ + throw new InvalidRequestError("RingTimeout must be of type int or string") + } } else { params.ringTimeout = 45 } if(params.delayDial){ validParam('delayDial', params.delayDial, [String, Number], false) - if(Number.isInteger(params.delayDial)){ - validRange('DelayDial', params.delayDial, false, 1, 120) - } - else{ + if(typeof(params.delayDial) === 'string'){ validMultipleDestinationIntegers('delayDial', params.delayDial) } + else if(!Number.isInteger(params.delayDial) && typeof(params.delayDial) !== 'string'){ + throw new InvalidRequestError("Dealydial must be of type int or string") + } } else { params.delayDial = 0 @@ -306,6 +306,12 @@ export class MultiPartyCall extends PlivoResource{ else { params.exitSoundMethod = 'GET' } + if(params.to && (String(params.ringTimeout).split('<').length > params.to.split('<').length)){ + throw new MPCError("RingTimeout:number of ring_timeout(s) should be same as number of destination(s)") + } + if(params.to && (String(params.delayDial).split('<').length > params.to.split('<').length)){ + throw new MPCError("DelayDial:number of delay_dial(s) should be same as number of destination(s)") + } params.isVoiceRequest = 'true'; params.callerName = params.callerName || params.from; return super.executeAction(this.id + '/Participant/', 'POST', params) diff --git a/lib/rest/axios.js b/lib/rest/axios.js index 5316274..ba74448 100644 --- a/lib/rest/axios.js +++ b/lib/rest/axios.js @@ -175,6 +175,9 @@ export function Axios(config) { if (typeof config.timeout !== 'undefined') { options.timeout = config.timeout; } + else if(typeof config.timeout === 'undefined'){ + options.timeout = 5000; + } return new Promise((resolve, reject) => { if (isVoiceReq) { diff --git a/lib/rest/utils.js b/lib/rest/utils.js index 8a7538c..934836c 100644 --- a/lib/rest/utils.js +++ b/lib/rest/utils.js @@ -115,17 +115,7 @@ export function validMultipleDestinationNos(paramName, paramValue, options = {}) export function validMultipleDestinationIntegers(paramName, paramValue){ let val = paramValue.split("<"); for (let i=0; i