diff --git a/CHANGELOG.md b/CHANGELOG.md index 7386495..19c5b5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,25 @@ # Change Log -## [4.18.0](https://github.com/plivo/plivo-node/releases/tag/v4.18.0)(2021-05-28) -- New Send Message interface along with existing interface support. +## [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). + +## [v4.19.2](https://github.com/plivo/plivo-node/tree/v4.19.2) (2021-07-08) +- MPC SDK fixes to pass params in a user-friendly manner. + +## [v4.19.1](https://github.com/plivo/plivo-node/tree/v4.19.1) (2021-07-05) +- **WARNING**: Removed the total_count parameter in meta data for list MDR response + +## [4.19.0](https://github.com/plivo/plivo-node/releases/tag/v4.19.0)(2021-07-02) +- Added CallerName param in AddParticpant +- Added support for Parallel behaviour of RingTimeout and Delaydial. +- Added support for Recording at Member Level + +## [4.18.1](https://github.com/plivo/plivo-node/releases/tag/v4.18.1)(2021-06-25) +- Fixed the mms media upload functionality + +## [4.18.0](https://github.com/plivo/plivo-node/releases/tag/v4.18.0)(2021-06-15) +- Added stir verification param as part of Get CDR and live call APIs ## [4.17.1](https://github.com/plivo/plivo-node/releases/tag/v4.17.1)(2021-05-06) - Added Fix for Adaptive Powerpack Create & Update functions diff --git a/lib/resources/call.js b/lib/resources/call.js index 625c375..d4f4c01 100644 --- a/lib/resources/call.js +++ b/lib/resources/call.js @@ -75,6 +75,7 @@ export class GetLiveCallResponse { this.requestUuid = params.requestUuid; this.sessionStart = params.sessionStart; this.to = params.to; + this.stirVerification = params.stirVerification; } } export class RetrieveCallResponse { @@ -100,6 +101,7 @@ export class RetrieveCallResponse { this.toNumber = params.toNumber; this.totalAmount = params.totalAmount; this.totalRate = params.totalRate; + this.stirVerification = params.stirVerification; } } @@ -125,6 +127,7 @@ export class ListAllCallsResponse { this.toNumber = params.toNumber; this.totalAmount = params.totalAmount; this.totalRate = params.totalRate; + this.stirVerification = params.stirVerification; } } diff --git a/lib/resources/media.js b/lib/resources/media.js index ad027a7..aa229ed 100644 --- a/lib/resources/media.js +++ b/lib/resources/media.js @@ -97,7 +97,7 @@ export class MediaInterface extends PlivoResourceInterface { params.file = files let client = this[clientKey]; - + params.multipart = true; return new Promise((resolve, reject) => { client('POST', action, params) .then(response => { diff --git a/lib/resources/messages.js b/lib/resources/messages.js index ab5bc93..545c474 100644 --- a/lib/resources/messages.js +++ b/lib/resources/messages.js @@ -42,6 +42,7 @@ export class MessageGetResponse { this.totalAmount = params.totalAmount; this.totalRate = params.totalRate; this.units = params.units; + this.powerpackID = params.powerpackId } } @@ -60,6 +61,7 @@ export class MessageListResponse { this.totalAmount = params.totalAmount; this.totalRate = params.totalRate; this.units = params.units; + this.powerpackID = params.powerpackId; } } diff --git a/lib/resources/multiPartyCall.js b/lib/resources/multiPartyCall.js index 0ffe665..0fe35c6 100644 --- a/lib/resources/multiPartyCall.js +++ b/lib/resources/multiPartyCall.js @@ -7,7 +7,8 @@ import { validDateFormat, validRange, validMultipleDestinationNos, - isOneAmongStringUrl, multiValidParam + validMultipleDestinationIntegers, + isOneAmongStringUrl, multiValidParam, InvalidRequestError } from '../rest/utils.js' const clientKey = Symbol(); @@ -61,6 +62,11 @@ export class MultiPartyCall extends PlivoResource{ validParam('callUuid', params.callUuid, [String], false) } + if(params.callerName){ + validParam('callerName', params.callerName, [String], false) + validRange('callerName', params.callerName.length, false, 1, 50) + } + if(params.callStatusCallbackUrl){ validUrl('callStatusCallbackUrl', params.callStatusCallbackUrl, false) } @@ -99,11 +105,29 @@ export class MultiPartyCall extends PlivoResource{ } if(params.ringTimeout || params.ringTimeout === 0){ - validRange('ringTimeout', params.ringTimeout, false, 15, 120) + validParam('ringTimeout', params.ringTimeout, [String, Number], false) + if(Number.isInteger(params.ringTimeout)){ + validRange('RingTimeout', params.ringTimeout, false, 15, 120) + } + else{ + validMultipleDestinationIntegers('ringTimeout', params.ringTimeout) + } } 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{ + validMultipleDestinationIntegers('delayDial', params.delayDial) + } + } + else { + params.delayDial = 0 + } if(params.maxDuration || params.maxDuration === 0){ validRange('maxDuration', params.maxDuration, false, 300, 28800) @@ -234,7 +258,7 @@ export class MultiPartyCall extends PlivoResource{ params.hold = 'false' } - if(params.startMpcOnEnter){ + if(params.startMpcOnEnter!=null){ validParam('startMpcOnEnter', params.startMpcOnEnter, [Boolean, String], false) } else { @@ -283,11 +307,18 @@ export class MultiPartyCall extends PlivoResource{ params.exitSoundMethod = 'GET' } params.isVoiceRequest = 'true'; + params.callerName = params.callerName || params.from; return super.executeAction(this.id + '/Participant/', 'POST', params) } - start(){ - return super.executeAction(this.id + '/', 'POST', {'status' : 'active', 'isVoiceRequest' : 'true'}) + start(params){ + if(params.status) { + validParam('status', params.status.toLowerCase(), [String], true, 'active') + } + else{ + throw new InvalidRequestError("status is a mandatory parameter"); + } + return super.executeAction(this.id + '/', 'POST', {'status' : params.status.toLowerCase(), 'isVoiceRequest' : 'true'}) } stop(){ @@ -376,6 +407,39 @@ export class MultiPartyCallParticipant extends PlivoSecondaryResource{ getParticipant(){ return super.executeAction(this.id, this.secondaryId, 'GET',{'isVoiceRequest' : 'true'}) } + startParticipantRecording(params = {}){ + if(params.fileFormat){ + validParam('fileFormat', params.fileFormat, [String], false, ['mp3', 'wav']) + } + else { + params.fileFormat = 'mp3' + } + + if(params.statusCallbackUrl){ + validUrl('statusCallbackUrl', params.statusCallbackUrl, false) + } + + if(params.statusCallbackMethod){ + validParam('statusCallbackMethod', params.statusCallbackMethod.toUpperCase(), [String], false, ['GET', 'POST']) + } + else { + params.statusCallbackMethod = 'POST' + } + params.isVoiceRequest = 'true'; + return super.executeAction(this.id , this.secondaryId + '/Record', 'POST', params) + } + + stopParticipantRecording(){ + return super.executeAction(this.id , this.secondaryId +'/Record', 'DELETE',{'isVoiceRequest' : 'true'}) + } + + pauseParticipantRecording(){ + return super.executeAction(this.id , this.secondaryId + '/Record/Pause', 'POST',{'isVoiceRequest' : 'true'}) + } + + resumeParticipantRecording(){ + return super.executeAction(this.id , this.secondaryId + '/Record/Resume', 'POST',{'isVoiceRequest' : 'true'}) + } } @@ -451,14 +515,16 @@ export class MultiPartyCallInterface extends PlivoResourceInterface{ return super.list(params); } - get(uuid = null, friendlyName = null){ - if(uuid){ - validParam('uuid', uuid, [String], false) + get(params={}){ + if(params.uuid){ + validParam('uuid', params.uuid, [String], false) } - if(friendlyName){ - validParam('friendlyName', friendlyName, [String], false) + if(params.friendlyName){ + validParam('friendlyName', params.friendlyName, [String], false) } - let mpcId = this.makeMpcId(uuid, friendlyName) + let mpcId = this.makeMpcId(params.uuid, params.friendlyName) + delete params.uuid + delete params.friendlyName return new MultiPartyCall(this[clientKey], {id: mpcId[0] + mpcId[1]}).get(); } @@ -476,116 +542,192 @@ export class MultiPartyCallInterface extends PlivoResourceInterface{ return new MultiPartyCall(this[clientKey], {id: mpcId[0] + mpcId[1]}).addParticipant(params) } - start(uuid = null, friendlyName = null){ - if(uuid){ - validParam('uuid', uuid, [String], false) + start(params = {}){ + if(params.uuid){ + validParam('uuid', params.uuid, [String], false) } - if(friendlyName){ - validParam('friendlyName', friendlyName, [String], false) + if(params.friendlyName){ + validParam('friendlyName', params.friendlyName, [String], false) } - let mpcId = this.makeMpcId(uuid, friendlyName) - return new MultiPartyCall(this[clientKey], {id: mpcId[0] + mpcId[1]}).start() + let mpcId = this.makeMpcId(params.uuid, params.friendlyName) + delete params.uuid + delete params.friendlyName + return new MultiPartyCall(this[clientKey], {id: mpcId[0] + mpcId[1]}).start(params) } - stop(uuid = null, friendlyName = null){ - if(uuid){ - validParam('uuid', uuid, [String], false) + stop(params = {}){ + if(params.uuid){ + validParam('uuid', params.uuid, [String], false) } - if(friendlyName){ - validParam('friendlyName', friendlyName, [String], false) + if(params.friendlyName){ + validParam('friendlyName', params.friendlyName, [String], false) } - let mpcId = this.makeMpcId(uuid, friendlyName) + let mpcId = this.makeMpcId(params.uuid, params.friendlyName) + delete params.uuid + delete params.friendlyName return new MultiPartyCall(this[clientKey], {id: mpcId[0] + mpcId[1]}).stop() } - startRecording(uuid = null, friendlyName = null, params){ - if(uuid){ - validParam('uuid', uuid, [String], false) + startRecording(params={}){ + if(params.uuid){ + validParam('uuid', params.uuid, [String], false) } - if(friendlyName){ - validParam('friendlyName', friendlyName, [String], false) + if(params.friendlyName){ + validParam('friendlyName', params.friendlyName, [String], false) } - let mpcId = this.makeMpcId(uuid, friendlyName) + let mpcId = this.makeMpcId(params.uuid, params.friendlyName) + delete params.uuid + delete params.friendlyName return new MultiPartyCall(this[clientKey], {id: mpcId[0] + mpcId[1]}).startRecording(params) } - stopRecording(uuid = null, friendlyName = null){ - if(uuid){ - validParam('uuid', uuid, [String], false) + stopRecording(params={}){ + if(params.uuid){ + validParam('uuid', params.uuid, [String], false) } - if(friendlyName){ - validParam('friendlyName', friendlyName, [String], false) + if(params.friendlyName){ + validParam('friendlyName', params.friendlyName, [String], false) } - let mpcId = this.makeMpcId(uuid, friendlyName) + let mpcId = this.makeMpcId(params.uuid, params.friendlyName) + delete params.uuid + delete params.friendlyName return new MultiPartyCall(this[clientKey], {id: mpcId[0] + mpcId[1]}).stopRecording() } - pauseRecording(uuid = null, friendlyName = null){ - if(uuid){ - validParam('uuid', uuid, [String], false) + pauseRecording(params={}){ + if(params.uuid){ + validParam('uuid', params.uuid, [String], false) } - if(friendlyName){ - validParam('friendlyName', friendlyName, [String], false) + if(params.friendlyName){ + validParam('friendlyName', params.friendlyName, [String], false) } - let mpcId = this.makeMpcId(uuid, friendlyName) + let mpcId = this.makeMpcId(params.uuid, params.friendlyName) + delete params.uuid + delete params.friendlyName return new MultiPartyCall(this[clientKey], {id: mpcId[0] + mpcId[1]}).pauseRecording() } - resumeRecording(uuid = null, friendlyName = null){ - if(uuid){ - validParam('uuid', uuid, [String], false) + resumeRecording(params={}){ + if(params.uuid){ + validParam('uuid', params.uuid, [String], false) } - if(friendlyName){ - validParam('friendlyName', friendlyName, [String], false) + if(params.friendlyName){ + validParam('friendlyName', params.friendlyName, [String], false) } - let mpcId = this.makeMpcId(uuid, friendlyName) + let mpcId = this.makeMpcId(params.uuid, params.friendlyName) + delete params.uuid + delete params.friendlyName return new MultiPartyCall(this[clientKey], {id: mpcId[0] + mpcId[1]}).resumeRecording() } - listParticipants(uuid = null, friendlyName = null, params){ - if(uuid){ - validParam('uuid', uuid, [String], false) + startParticipantRecording(participantId, params={}){ + validParam('participantId', participantId, [String, Number], true) + if(params.uuid){ + validParam('uuid', params.uuid, [String], false) } - if(friendlyName){ - validParam('friendlyName', friendlyName, [String], false) + if(params.friendlyName){ + validParam('friendlyName', params.friendlyName, [String], false) } - let mpcId = this.makeMpcId(uuid, friendlyName) + let mpcId = this.makeMpcId(params.uuid, params.friendlyName) + delete params.uuid + delete params.friendlyName + return new MultiPartyCallParticipant(this[clientKey], {id: mpcId[0] + mpcId[1], secondaryId: participantId}).startParticipantRecording(params) + } + + stopParticipantRecording(participantId, params={}){ + validParam('participantId', participantId, [String, Number], true) + if(params.uuid){ + validParam('uuid', params.uuid, [String], false) + } + if(params.friendlyName){ + validParam('friendlyName', params.friendlyName, [String], false) + } + let mpcId = this.makeMpcId(params.uuid, params.friendlyName) + delete params.uuid + delete params.friendlyName + return new MultiPartyCallParticipant(this[clientKey], {id: mpcId[0] + mpcId[1], secondaryId: participantId}).stopParticipantRecording() + } + + pauseParticipantRecording(participantId, params={}){ + validParam('participantId', participantId, [String, Number], true) + if(params.uuid){ + validParam('uuid', params.uuid, [String], false) + } + if(params.friendlyName){ + validParam('friendlyName', params.friendlyName, [String], false) + } + let mpcId = this.makeMpcId(params.uuid, params.friendlyName) + delete params.uuid + delete params.friendlyName + return new MultiPartyCallParticipant(this[clientKey], {id: mpcId[0] + mpcId[1], secondaryId: participantId}).pauseParticipantRecording() + } + + resumeParticipantRecording(participantId, params={}){ + validParam('participantId', participantId, [String, Number], true) + if(params.uuid){ + validParam('uuid', params.uuid, [String], false) + } + if(params.friendlyName){ + validParam('friendlyName', params.friendlyName, [String], false) + } + let mpcId = this.makeMpcId(params.uuid, params.friendlyName) + delete params.uuid + delete params.friendlyName + return new MultiPartyCallParticipant(this[clientKey], {id: mpcId[0] + mpcId[1], secondaryId: participantId}).resumeParticipantRecording() + } + + listParticipants(params={}){ + if(params.uuid){ + validParam('uuid', params.uuid, [String], false) + } + if(params.friendlyName){ + validParam('friendlyName', params.friendlyName, [String], false) + } + let mpcId = this.makeMpcId(params.uuid, params.friendlyName) + delete params.uuid + delete params.friendlyName return new MultiPartyCall(this[clientKey], {id: mpcId[0] + mpcId[1]}).listParticipants(params) } - updateParticipant(participantId, uuid= null, friendlyName = null, params){ + updateParticipant(participantId, params={}){ validParam('participantId', participantId, [String, Number], true) - if(uuid){ - validParam('uuid', uuid, [String], false) + if(params.uuid){ + validParam('uuid', params.uuid, [String], false) } - if(friendlyName){ - validParam('friendlyName', friendlyName, [String], false) + if(params.friendlyName){ + validParam('friendlyName', params.friendlyName, [String], false) } - let mpcId = this.makeMpcId(uuid, friendlyName) + let mpcId = this.makeMpcId(params.uuid, params.friendlyName) + delete params.uuid + delete params.friendlyName return new MultiPartyCallParticipant(this[clientKey], {id: mpcId[0] + mpcId[1], secondaryId: participantId}).updateParticipant(params) } - kickParticipant(participantId, uuid = null, friendlyName = null){ + kickParticipant(participantId, params={}){ validParam('participantId', participantId, [String, Number], true) - if(uuid){ - validParam('uuid', uuid, [String], false) + if(params.uuid){ + validParam('uuid', params.uuid, [String], false) } - if(friendlyName){ - validParam('friendlyName', friendlyName, [String], false) + if(params.friendlyName){ + validParam('friendlyName', params.friendlyName, [String], false) } - let mpcId = this.makeMpcId(uuid, friendlyName) + let mpcId = this.makeMpcId(params.uuid, params.friendlyName) + delete params.uuid + delete params.friendlyName return new MultiPartyCallParticipant(this[clientKey], {id: mpcId[0] + mpcId[1], secondaryId: participantId}).kickParticipant() } - getParticipant(participantId, uuid = null, friendlyName = null){ + getParticipant(participantId, params={}){ validParam('participantId', participantId, [String, Number], true) - if(uuid){ - validParam('uuid', uuid, [String], false) + if(params.uuid){ + validParam('uuid', params.uuid, [String], false) } - if(friendlyName){ - validParam('friendlyName', friendlyName, [String], false) + if(params.friendlyName){ + validParam('friendlyName', params.friendlyName, [String], false) } - let mpcId = this.makeMpcId(uuid, friendlyName) + let mpcId = this.makeMpcId(params.uuid, params.friendlyName) + delete params.uuid + delete params.friendlyName return new MultiPartyCallParticipant(this[clientKey], {id: mpcId[0] + mpcId[1], secondaryId: participantId}).getParticipant() } diff --git a/lib/rest/axios.js b/lib/rest/axios.js index 61f8cde..5316274 100644 --- a/lib/rest/axios.js +++ b/lib/rest/axios.js @@ -46,7 +46,14 @@ export function Axios(config) { if (key != 'file') { multipartParams.append(key, params[key]); } else { - multipartParams.append(key, require('fs').createReadStream(params[key])); + // In case files are in array + if (Array.isArray(params.file)) { + for (let index = 0; index < params.file.length; index++) { + multipartParams.append(key, require('fs').createReadStream(params.file[index])); + } + }else{ + multipartParams.append(key, require('fs').createReadStream(params[key])); + } } } @@ -87,6 +94,10 @@ export function Axios(config) { }); }) .catch(function (error) { + //client side exception like file not found case + if (error.response == undefined){ + reject(error.stack ); + } const exceptionClass = { 400: Exceptions.InvalidRequestError, 401: Exceptions.AuthenticationError, diff --git a/lib/rest/request-test.js b/lib/rest/request-test.js index 9f60e97..18e1791 100644 --- a/lib/rest/request-test.js +++ b/lib/rest/request-test.js @@ -1158,8 +1158,7 @@ export function Request(config) { limit: 20, next: '/v1/Account/{auth_id}/Message/?limit=20&error_code=200&offset=20', offset: 0, - previous: null, - total_count: 22 + previous: null }, objects: [ { diff --git a/lib/rest/utils.js b/lib/rest/utils.js index 9facdc5..8a7538c 100644 --- a/lib/rest/utils.js +++ b/lib/rest/utils.js @@ -112,6 +112,26 @@ export function validMultipleDestinationNos(paramName, paramValue, options = {}) } } +export function validMultipleDestinationIntegers(paramName, paramValue){ + let val = paramValue.split("<"); + for (let i=0; i