From 2124f19ad41b1b59b5ff74c3c31a3a3785e046c9 Mon Sep 17 00:00:00 2001 From: Koushik-Ayila Date: Thu, 28 Oct 2021 15:36:37 +0530 Subject: [PATCH 1/9] Added SDK changes for MPC Enhancements --- lib/resources/multiPartyCall.js | 79 +++++++++++++++++++++++++++++++++ lib/utils/plivoxml.js | 29 +++++++++++- 2 files changed, 107 insertions(+), 1 deletion(-) diff --git a/lib/resources/multiPartyCall.js b/lib/resources/multiPartyCall.js index 3fee3f8..2c7fe6f 100644 --- a/lib/resources/multiPartyCall.js +++ b/lib/resources/multiPartyCall.js @@ -15,6 +15,7 @@ const clientKey = Symbol(); const action = 'MultiPartyCall/'; const idField = 'mpcUuid'; const secondaryAction = 'Participant/'; +const secondaryMemberAction = 'Member/'; const secondaryIdField = 'participantUuid'; export class MPCError extends Error { } @@ -306,6 +307,29 @@ export class MultiPartyCall extends PlivoResource{ else { params.exitSoundMethod = 'GET' } + + if(params.startRecordingAudio){ + validUrl('startRecordingAudio', params.startRecordingAudio, false) + } + + if(params.startRecordingAudioMethod){ + validParam('startRecordingAudioMethod', params.startRecordingAudioMethod.toUpperCase(), [String], false, ['GET', 'POST']) + } + else { + params.startRecordingAudioMethod = 'GET' + } + + if(params.stopRecordingAudio){ + validUrl('stopRecordingAudio', params.stopRecordingAudio, false) + } + + if(params.stopRecordingAudioMethod){ + validParam('stopRecordingAudioMethod', params.stopRecordingAudioMethod.toUpperCase(), [String], false, ['GET', 'POST']) + } + else { + params.stopRecordingAudioMethod = '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)") } @@ -449,6 +473,32 @@ export class MultiPartyCallParticipant extends PlivoSecondaryResource{ } +export class MultiPartyCallMember extends PlivoSecondaryResource{ + constructor(client, data= {}) { + super(action, MultiPartyCall, idField, secondaryMemberAction, MultiPartyCallMember, secondaryIdField, client); + + if (idField in data) { + this.id = data[idField]; + } + + if(secondaryIdField in data){ + this.secondaryId = data[secondaryIdField]; + } + + extend(this, data); + this[clientKey] = client; + } + + startPlayAudio(params){ + params.isVoiceRequest = 'true'; + return super.executeAction(this.id, this.secondaryId + '/Play', 'POST', params) + } + + stopPlayAudio(){ + return super.executeAction(this.id, this.secondaryId +'/Play', 'DELETE',{'isVoiceRequest' : 'true'}) + } +} + export class MultiPartyCallInterface extends PlivoResourceInterface{ constructor(client, data = {}) { super(action, MultiPartyCall, idField, client); @@ -737,4 +787,33 @@ export class MultiPartyCallInterface extends PlivoResourceInterface{ return new MultiPartyCallParticipant(this[clientKey], {id: mpcId[0] + mpcId[1], secondaryId: participantId}).getParticipant() } + startPlayAudio(participantId, url, params = {}){ + validParam('participantId', participantId, [String, Number], true) + validUrl('url', url, 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 + params.url = url + return new MultiPartyCallMember(this[clientKey], {id: mpcId[0] + mpcId[1], secondaryId: participantId}).startPlayAudio(params) + } + + stopPlayAudio(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 MultiPartyCallMember(this[clientKey], {id: mpcId[0] + mpcId[1], secondaryId: participantId}).stopPlayAudio(params) + } } diff --git a/lib/utils/plivoxml.js b/lib/utils/plivoxml.js index f6a30b3..d1009e7 100644 --- a/lib/utils/plivoxml.js +++ b/lib/utils/plivoxml.js @@ -473,6 +473,10 @@ Response.prototype = { * @param {string} [attributes.recordingCallbackUrl] * @param {string} [attributes.statusCallbackUrl] * @param {string} [attributes.customerHoldMusicUrl] + * @param {string} [attributes.startRecordingAudio] + * @param {string} [attributes.stopRecordingAudio] + * @param {string} [attributes.startRecordingAudioMethod] + * @param {string} [attributes.stopRecordingAudioMethod] */ addMultiPartyCall: function (body, attributes){ const VALID_ROLE_VALUES = ['agent', 'supervisor', 'customer'] @@ -664,6 +668,28 @@ Response.prototype = { if(attributes.customerHoldMusicUrl && !plivoUtils.validUrl('customerHoldMusicUrl', attributes.customerHoldMusicUrl, false)){ throw new PlivoXMLError('Invalid attribute value ' + attributes.customerHoldMusicUrl + ' for customerHoldMusicUrl') } + + if(attributes.startRecordingAudio && !plivoUtils.validUrl('startRecordingAudio', attributes.startRecordingAudio, false)){ + throw new PlivoXMLError('Invalid attribute value ' + attributes.startRecordingAudio + ' for startRecordingAudio') + } + + if(attributes.stopRecordingAudio && !plivoUtils.validUrl('stopRecordingAudio', attributes.stopRecordingAudio, false)){ + throw new PlivoXMLError('Invalid attribute value ' + attributes.stopRecordingAudio + ' for stopRecordingAudio') + } + + if(attributes.startRecordingAudioMethod && VALID_METHOD_VALUES.indexOf(attributes.startRecordingAudioMethod.toUpperCase())===-1){ + throw new PlivoXMLError('Invalid attribute value ' + attributes.startRecordingAudioMethod + ' for startRecordingAudioMethod') + } + else if (!attributes.startRecordingAudioMethod){ + attributes.startRecordingAudioMethod = 'GET' + } + + if(attributes.stopRecordingAudioMethod && VALID_METHOD_VALUES.indexOf(attributes.stopRecordingAudioMethod.toUpperCase())===-1){ + throw new PlivoXMLError('Invalid attribute value ' + attributes.stopRecordingAudioMethod + ' for stopRecordingAudioMethod') + } + else if (!attributes.stopRecordingAudioMethod){ + attributes.stopRecordingAudioMethod = 'GET' + } return this.add(new MultiPartyCall(Response), body, attributes); }, @@ -984,6 +1010,7 @@ function MultiPartyCall(Response){ 'statusCallbackEvents', 'statusCallbackUrl', 'statusCallbackMethod', 'stayAlone', 'coachMode', 'mute', 'hold', 'startMpcOnEnter', 'endMpcOnExit', 'enterSound', 'enterSoundMethod', 'exitSound', 'exitSoundMethod', - 'onExitActionUrl', 'onExitActionMethod', 'relayDTMFInputs']; + 'onExitActionUrl', 'onExitActionMethod', 'relayDTMFInputs', + 'startRecordingAudio', 'startRecordingAudioMethod', 'stopRecordingAudio', 'stopRecordingAudioMethod']; } util.inherits(MultiPartyCall, Response); From ceec75278590ad725da33832578fa0ff25de50ea Mon Sep 17 00:00:00 2001 From: Koushik-Ayila Date: Thu, 28 Oct 2021 17:19:58 +0530 Subject: [PATCH 2/9] Added missing MPC UTs --- lib/rest/request-test.js | 54 ++++++++++++++++++++++++++++++++++++++++ test/multiPartyCalls.js | 37 +++++++++++++++++++++++++++ test/xml.js | 2 +- 3 files changed, 92 insertions(+), 1 deletion(-) diff --git a/lib/rest/request-test.js b/lib/rest/request-test.js index 3f0abe0..fc1df28 100644 --- a/lib/rest/request-test.js +++ b/lib/rest/request-test.js @@ -883,6 +883,60 @@ export function Request(config) { }); } + else if (method === 'POST' && action === 'MultiPartyCall/name_TestMPC/Participant/10/Record/'){ + resolve({ + response: {}, + body: { + "api_id": "036c80f3-3721-11ec-a678-0242ac110002", + "message": "MPC: TestMPC participant record started", + "recording_id": "24670db8-c723-4ba2-8521-f10ec41ddf8b", + "recording_url": "https://media-qa.voice.plivodev.com/v1/Account/MAXXXXXXXXXXXX/Recording/XXXXX-XXXX-XXXX-XXXXX.mp3" + } + }); + } + + else if (method === 'DELETE' && action === 'MultiPartyCall/name_TestMPC/Participant/10/Record/'){ + resolve({ + response: {}, + body: {} + }); + } + + else if (method === 'POST' && action === 'MultiPartyCall/name_TestMPC/Participant/10/Record/Pause/'){ + resolve({ + response: {}, + body: {} + }); + } + + else if (method === 'POST' && action === 'MultiPartyCall/name_TestMPC/Participant/10/Record/Resume/'){ + resolve({ + response: {}, + body: {} + }); + } + + else if (method === 'POST' && action === 'MultiPartyCall/name_TestMPC/Member/10/Play/'){ + resolve({ + response: {}, + body: { + "api_id": "c07db813-3721-11ec-8bcd-0242ac110008", + "message": "play queued into MPC", + "mpcMemberId": [ + "1003" + ], + "mpcName": "TestMPC" + } + }); + } + + else if (method === 'DELETE' && action === 'MultiPartyCall/name_TestMPC/Member/10/Play/'){ + resolve({ + response: {}, + body: {} + }); + } + // ============= Numbers =================== else if (method == 'GET' && action == 'Number/+919999999990/') { resolve({ diff --git a/test/multiPartyCalls.js b/test/multiPartyCalls.js index 0e848ec..73cfe30 100644 --- a/test/multiPartyCalls.js +++ b/test/multiPartyCalls.js @@ -92,4 +92,41 @@ describe('multiPartyCalls', function (){ assert.equal(response.resourceUri, '/v1/Account/MAMDJMMTEZOWY0ZMQWM2/MultiPartyCall/uuid_7503f05f-2d6e-4ab3-b9e6-3b0d81ae9087/Participant/2132/') }) }); + + it('should start MPC Participant Recording', function (){ + return client.multiPartyCalls.startParticipantRecording(10, {friendlyName: 'TestMPC'}).then(function (response){ + assert(response.message, "MPC: TestMPC participant record started") + }) + }); + + it('should stop MPC Participant Recording', function (){ + return client.multiPartyCalls.stopParticipantRecording(10,{friendlyName: 'TestMPC'}).then(function (response){ + assert(response instanceof PlivoGenericResponse) + }) + }); + + it('should pause MPC Participant Recording', function (){ + return client.multiPartyCalls.pauseParticipantRecording(10,{friendlyName: 'TestMPC'}).then(function (response){ + assert(response instanceof PlivoGenericResponse) + }) + }); + + it('should resume MPC Participant Recording', function (){ + return client.multiPartyCalls.resumeParticipantRecording(10,{friendlyName: 'TestMPC'}).then(function (response){ + assert(response instanceof PlivoGenericResponse) + }) + }); + + it('should start MPC Play Audio Member', function (){ + return client.multiPartyCalls.startPlayAudio(10,'https://s3.amazonaws.com/XXX/XXX.mp3', + {friendlyName: 'TestMPC'}).then(function (response){ + assert(response.message, "play queued into MPC") + }) + }); + + it('should stop MPC Play Audio Member', function (){ + return client.multiPartyCalls.stopPlayAudio(10,{friendlyName: 'TestMPC'}).then(function (response){ + assert(response instanceof PlivoGenericResponse) + }) + }); }) diff --git a/test/xml.js b/test/xml.js index 061ac5e..cfc587e 100644 --- a/test/xml.js +++ b/test/xml.js @@ -35,7 +35,7 @@ describe('PlivoXML', function () { maxDuration: 1000, statusCallbackEvents: 'participant-speak-events, participant-digit-input-events, add-participant-api-events, participant-state-changes, mpc-state-changes' }); - assert.equal('Nairobi',mpcResponse.toXML()); + assert.equal('Nairobi',mpcResponse.toXML()); done(); }); }); From a2e07c8e01d0cc7a98e611871db4dcd941a53207 Mon Sep 17 00:00:00 2001 From: Koushik-Ayila Date: Wed, 3 Nov 2021 12:10:04 +0530 Subject: [PATCH 3/9] Added SDK versioning --- CHANGELOG.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 927f26a..ceced19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Change Log +## [v4.24.0](https://github.com/plivo/plivo-node/tree/v4.24.0) (2021-11-03) +- Added Voice MPC enhancements. + ## [v4.23.1](https://github.com/plivo/plivo-node/tree/v4.23.1) (2021-10-13) **Bug Fix** - LiveCallInterface. diff --git a/package.json b/package.json index 38d9b64..771a4e4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "plivo", - "version": "4.23.1", + "version": "4.24.0", "description": "A Node.js SDK to make voice calls and send SMS using Plivo and to generate Plivo XML", "homepage": "https://github.com/plivo/plivo-node", "files": [ From 0191fcdc0ac099bbce642ead318a4fef944d6e41 Mon Sep 17 00:00:00 2001 From: Koushik Ayila Date: Fri, 12 Nov 2021 11:33:21 +0530 Subject: [PATCH 4/9] Update CHANGELOG.md --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ceced19..64d6132 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,9 @@ # Change Log ## [v4.24.0](https://github.com/plivo/plivo-node/tree/v4.24.0) (2021-11-03) -- Added Voice MPC enhancements. +**Features - Voice: Multiparty calls** +- The [Add Multiparty Call API](https://www.plivo.com/docs/voice/api/multiparty-call/participants#add-a-participant) allows for greater functionality by accepting options like `start recording audio`, `stop recording audio`, and their HTTP methods. +- [Multiparty Calls](https://www.plivo.com/docs/voice/api/multiparty-call/) now has new APIs to `stop` and `play` audio. ## [v4.23.1](https://github.com/plivo/plivo-node/tree/v4.23.1) (2021-10-13) **Bug Fix** From d0f168bbe7c434e17a74beadb29d6170dad43a65 Mon Sep 17 00:00:00 2001 From: Koushik Ayila Date: Fri, 12 Nov 2021 11:48:34 +0530 Subject: [PATCH 5/9] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 64d6132..9769a2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Change Log -## [v4.24.0](https://github.com/plivo/plivo-node/tree/v4.24.0) (2021-11-03) +## [v4.24.0](https://github.com/plivo/plivo-node/tree/v4.24.0) (2021-11-12) **Features - Voice: Multiparty calls** - The [Add Multiparty Call API](https://www.plivo.com/docs/voice/api/multiparty-call/participants#add-a-participant) allows for greater functionality by accepting options like `start recording audio`, `stop recording audio`, and their HTTP methods. - [Multiparty Calls](https://www.plivo.com/docs/voice/api/multiparty-call/) now has new APIs to `stop` and `play` audio. From 5daae051240201e7b8b7f5a60a9dfc5f45ec142f Mon Sep 17 00:00:00 2001 From: huzaif-plivo Date: Sat, 13 Nov 2021 11:33:48 +0530 Subject: [PATCH 6/9] removed travis.yml as we no longer use --- .travis.yml | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index cbc9852..0000000 --- a/.travis.yml +++ /dev/null @@ -1,10 +0,0 @@ -service_name: travis-ci -language: node_js -node_js: - # - "node" commenting this as we have to find out a solution for node12 & gulp3 - - "lts/*" - - "8" - - "7" - - "6" - - "5" - - "4" From b57d0da9cc0bfb995f430c477279040db1e44f47 Mon Sep 17 00:00:00 2001 From: Abinaya-plivo Date: Tue, 16 Nov 2021 16:54:40 +0530 Subject: [PATCH 7/9] removed code changes of start recording and stop recording announcement on MPC --- CHANGELOG.md | 1 - lib/resources/multiPartyCall.js | 22 ---------------------- lib/utils/plivoxml.js | 29 +---------------------------- test/xml.js | 2 +- 4 files changed, 2 insertions(+), 52 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9769a2a..ed540e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,6 @@ ## [v4.24.0](https://github.com/plivo/plivo-node/tree/v4.24.0) (2021-11-12) **Features - Voice: Multiparty calls** -- The [Add Multiparty Call API](https://www.plivo.com/docs/voice/api/multiparty-call/participants#add-a-participant) allows for greater functionality by accepting options like `start recording audio`, `stop recording audio`, and their HTTP methods. - [Multiparty Calls](https://www.plivo.com/docs/voice/api/multiparty-call/) now has new APIs to `stop` and `play` audio. ## [v4.23.1](https://github.com/plivo/plivo-node/tree/v4.23.1) (2021-10-13) diff --git a/lib/resources/multiPartyCall.js b/lib/resources/multiPartyCall.js index 2c7fe6f..7b8ba72 100644 --- a/lib/resources/multiPartyCall.js +++ b/lib/resources/multiPartyCall.js @@ -308,28 +308,6 @@ export class MultiPartyCall extends PlivoResource{ params.exitSoundMethod = 'GET' } - if(params.startRecordingAudio){ - validUrl('startRecordingAudio', params.startRecordingAudio, false) - } - - if(params.startRecordingAudioMethod){ - validParam('startRecordingAudioMethod', params.startRecordingAudioMethod.toUpperCase(), [String], false, ['GET', 'POST']) - } - else { - params.startRecordingAudioMethod = 'GET' - } - - if(params.stopRecordingAudio){ - validUrl('stopRecordingAudio', params.stopRecordingAudio, false) - } - - if(params.stopRecordingAudioMethod){ - validParam('stopRecordingAudioMethod', params.stopRecordingAudioMethod.toUpperCase(), [String], false, ['GET', 'POST']) - } - else { - params.stopRecordingAudioMethod = '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)") } diff --git a/lib/utils/plivoxml.js b/lib/utils/plivoxml.js index d1009e7..f6a30b3 100644 --- a/lib/utils/plivoxml.js +++ b/lib/utils/plivoxml.js @@ -473,10 +473,6 @@ Response.prototype = { * @param {string} [attributes.recordingCallbackUrl] * @param {string} [attributes.statusCallbackUrl] * @param {string} [attributes.customerHoldMusicUrl] - * @param {string} [attributes.startRecordingAudio] - * @param {string} [attributes.stopRecordingAudio] - * @param {string} [attributes.startRecordingAudioMethod] - * @param {string} [attributes.stopRecordingAudioMethod] */ addMultiPartyCall: function (body, attributes){ const VALID_ROLE_VALUES = ['agent', 'supervisor', 'customer'] @@ -668,28 +664,6 @@ Response.prototype = { if(attributes.customerHoldMusicUrl && !plivoUtils.validUrl('customerHoldMusicUrl', attributes.customerHoldMusicUrl, false)){ throw new PlivoXMLError('Invalid attribute value ' + attributes.customerHoldMusicUrl + ' for customerHoldMusicUrl') } - - if(attributes.startRecordingAudio && !plivoUtils.validUrl('startRecordingAudio', attributes.startRecordingAudio, false)){ - throw new PlivoXMLError('Invalid attribute value ' + attributes.startRecordingAudio + ' for startRecordingAudio') - } - - if(attributes.stopRecordingAudio && !plivoUtils.validUrl('stopRecordingAudio', attributes.stopRecordingAudio, false)){ - throw new PlivoXMLError('Invalid attribute value ' + attributes.stopRecordingAudio + ' for stopRecordingAudio') - } - - if(attributes.startRecordingAudioMethod && VALID_METHOD_VALUES.indexOf(attributes.startRecordingAudioMethod.toUpperCase())===-1){ - throw new PlivoXMLError('Invalid attribute value ' + attributes.startRecordingAudioMethod + ' for startRecordingAudioMethod') - } - else if (!attributes.startRecordingAudioMethod){ - attributes.startRecordingAudioMethod = 'GET' - } - - if(attributes.stopRecordingAudioMethod && VALID_METHOD_VALUES.indexOf(attributes.stopRecordingAudioMethod.toUpperCase())===-1){ - throw new PlivoXMLError('Invalid attribute value ' + attributes.stopRecordingAudioMethod + ' for stopRecordingAudioMethod') - } - else if (!attributes.stopRecordingAudioMethod){ - attributes.stopRecordingAudioMethod = 'GET' - } return this.add(new MultiPartyCall(Response), body, attributes); }, @@ -1010,7 +984,6 @@ function MultiPartyCall(Response){ 'statusCallbackEvents', 'statusCallbackUrl', 'statusCallbackMethod', 'stayAlone', 'coachMode', 'mute', 'hold', 'startMpcOnEnter', 'endMpcOnExit', 'enterSound', 'enterSoundMethod', 'exitSound', 'exitSoundMethod', - 'onExitActionUrl', 'onExitActionMethod', 'relayDTMFInputs', - 'startRecordingAudio', 'startRecordingAudioMethod', 'stopRecordingAudio', 'stopRecordingAudioMethod']; + 'onExitActionUrl', 'onExitActionMethod', 'relayDTMFInputs']; } util.inherits(MultiPartyCall, Response); diff --git a/test/xml.js b/test/xml.js index cfc587e..061ac5e 100644 --- a/test/xml.js +++ b/test/xml.js @@ -35,7 +35,7 @@ describe('PlivoXML', function () { maxDuration: 1000, statusCallbackEvents: 'participant-speak-events, participant-digit-input-events, add-participant-api-events, participant-state-changes, mpc-state-changes' }); - assert.equal('Nairobi',mpcResponse.toXML()); + assert.equal('Nairobi',mpcResponse.toXML()); done(); }); }); From 90ec8af841194f62f9e9773c97f118986952b463 Mon Sep 17 00:00:00 2001 From: Abinaya-plivo Date: Thu, 18 Nov 2021 15:01:36 +0530 Subject: [PATCH 8/9] Revert "removed code changes of start recording and stop recording announcement on MPC" This reverts commit b57d0da9cc0bfb995f430c477279040db1e44f47. --- CHANGELOG.md | 1 + lib/resources/multiPartyCall.js | 22 ++++++++++++++++++++++ lib/utils/plivoxml.js | 29 ++++++++++++++++++++++++++++- test/xml.js | 2 +- 4 files changed, 52 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed540e4..9769a2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## [v4.24.0](https://github.com/plivo/plivo-node/tree/v4.24.0) (2021-11-12) **Features - Voice: Multiparty calls** +- The [Add Multiparty Call API](https://www.plivo.com/docs/voice/api/multiparty-call/participants#add-a-participant) allows for greater functionality by accepting options like `start recording audio`, `stop recording audio`, and their HTTP methods. - [Multiparty Calls](https://www.plivo.com/docs/voice/api/multiparty-call/) now has new APIs to `stop` and `play` audio. ## [v4.23.1](https://github.com/plivo/plivo-node/tree/v4.23.1) (2021-10-13) diff --git a/lib/resources/multiPartyCall.js b/lib/resources/multiPartyCall.js index 7b8ba72..2c7fe6f 100644 --- a/lib/resources/multiPartyCall.js +++ b/lib/resources/multiPartyCall.js @@ -308,6 +308,28 @@ export class MultiPartyCall extends PlivoResource{ params.exitSoundMethod = 'GET' } + if(params.startRecordingAudio){ + validUrl('startRecordingAudio', params.startRecordingAudio, false) + } + + if(params.startRecordingAudioMethod){ + validParam('startRecordingAudioMethod', params.startRecordingAudioMethod.toUpperCase(), [String], false, ['GET', 'POST']) + } + else { + params.startRecordingAudioMethod = 'GET' + } + + if(params.stopRecordingAudio){ + validUrl('stopRecordingAudio', params.stopRecordingAudio, false) + } + + if(params.stopRecordingAudioMethod){ + validParam('stopRecordingAudioMethod', params.stopRecordingAudioMethod.toUpperCase(), [String], false, ['GET', 'POST']) + } + else { + params.stopRecordingAudioMethod = '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)") } diff --git a/lib/utils/plivoxml.js b/lib/utils/plivoxml.js index f6a30b3..d1009e7 100644 --- a/lib/utils/plivoxml.js +++ b/lib/utils/plivoxml.js @@ -473,6 +473,10 @@ Response.prototype = { * @param {string} [attributes.recordingCallbackUrl] * @param {string} [attributes.statusCallbackUrl] * @param {string} [attributes.customerHoldMusicUrl] + * @param {string} [attributes.startRecordingAudio] + * @param {string} [attributes.stopRecordingAudio] + * @param {string} [attributes.startRecordingAudioMethod] + * @param {string} [attributes.stopRecordingAudioMethod] */ addMultiPartyCall: function (body, attributes){ const VALID_ROLE_VALUES = ['agent', 'supervisor', 'customer'] @@ -664,6 +668,28 @@ Response.prototype = { if(attributes.customerHoldMusicUrl && !plivoUtils.validUrl('customerHoldMusicUrl', attributes.customerHoldMusicUrl, false)){ throw new PlivoXMLError('Invalid attribute value ' + attributes.customerHoldMusicUrl + ' for customerHoldMusicUrl') } + + if(attributes.startRecordingAudio && !plivoUtils.validUrl('startRecordingAudio', attributes.startRecordingAudio, false)){ + throw new PlivoXMLError('Invalid attribute value ' + attributes.startRecordingAudio + ' for startRecordingAudio') + } + + if(attributes.stopRecordingAudio && !plivoUtils.validUrl('stopRecordingAudio', attributes.stopRecordingAudio, false)){ + throw new PlivoXMLError('Invalid attribute value ' + attributes.stopRecordingAudio + ' for stopRecordingAudio') + } + + if(attributes.startRecordingAudioMethod && VALID_METHOD_VALUES.indexOf(attributes.startRecordingAudioMethod.toUpperCase())===-1){ + throw new PlivoXMLError('Invalid attribute value ' + attributes.startRecordingAudioMethod + ' for startRecordingAudioMethod') + } + else if (!attributes.startRecordingAudioMethod){ + attributes.startRecordingAudioMethod = 'GET' + } + + if(attributes.stopRecordingAudioMethod && VALID_METHOD_VALUES.indexOf(attributes.stopRecordingAudioMethod.toUpperCase())===-1){ + throw new PlivoXMLError('Invalid attribute value ' + attributes.stopRecordingAudioMethod + ' for stopRecordingAudioMethod') + } + else if (!attributes.stopRecordingAudioMethod){ + attributes.stopRecordingAudioMethod = 'GET' + } return this.add(new MultiPartyCall(Response), body, attributes); }, @@ -984,6 +1010,7 @@ function MultiPartyCall(Response){ 'statusCallbackEvents', 'statusCallbackUrl', 'statusCallbackMethod', 'stayAlone', 'coachMode', 'mute', 'hold', 'startMpcOnEnter', 'endMpcOnExit', 'enterSound', 'enterSoundMethod', 'exitSound', 'exitSoundMethod', - 'onExitActionUrl', 'onExitActionMethod', 'relayDTMFInputs']; + 'onExitActionUrl', 'onExitActionMethod', 'relayDTMFInputs', + 'startRecordingAudio', 'startRecordingAudioMethod', 'stopRecordingAudio', 'stopRecordingAudioMethod']; } util.inherits(MultiPartyCall, Response); diff --git a/test/xml.js b/test/xml.js index 061ac5e..cfc587e 100644 --- a/test/xml.js +++ b/test/xml.js @@ -35,7 +35,7 @@ describe('PlivoXML', function () { maxDuration: 1000, statusCallbackEvents: 'participant-speak-events, participant-digit-input-events, add-participant-api-events, participant-state-changes, mpc-state-changes' }); - assert.equal('Nairobi',mpcResponse.toXML()); + assert.equal('Nairobi',mpcResponse.toXML()); done(); }); }); From dc7deab37abc2c1844341aeb5980cf183b61257f Mon Sep 17 00:00:00 2001 From: Mohammed Huzaif Date: Tue, 30 Nov 2021 13:04:22 +0530 Subject: [PATCH 9/9] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9769a2a..3e5dbff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Change Log -## [v4.24.0](https://github.com/plivo/plivo-node/tree/v4.24.0) (2021-11-12) +## [v4.24.0](https://github.com/plivo/plivo-node/tree/v4.24.0) (2021-11-30) **Features - Voice: Multiparty calls** - The [Add Multiparty Call API](https://www.plivo.com/docs/voice/api/multiparty-call/participants#add-a-participant) allows for greater functionality by accepting options like `start recording audio`, `stop recording audio`, and their HTTP methods. - [Multiparty Calls](https://www.plivo.com/docs/voice/api/multiparty-call/) now has new APIs to `stop` and `play` audio.