From e57a6bec3b52f4632ca34daad3e957d845ec0b7c Mon Sep 17 00:00:00 2001 From: Koushik-Ayila Date: Wed, 7 Oct 2020 16:40:55 +0530 Subject: [PATCH] Incorporated retry logic for MPC APIs and validated voice UTs --- lib/resources/applications.js | 2 +- lib/resources/multiPartyCall.js | 29 +++++++++++++++-------------- lib/rest/utils.js | 2 +- test/calls.js | 1 + 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/lib/resources/applications.js b/lib/resources/applications.js index 7d653f5..8f01b3a 100644 --- a/lib/resources/applications.js +++ b/lib/resources/applications.js @@ -327,4 +327,4 @@ export class ApplicationInterface extends PlivoResourceInterface { id: id }).delete(params, id); } -} \ No newline at end of file +} diff --git a/lib/resources/multiPartyCall.js b/lib/resources/multiPartyCall.js index 4a26f14..e122f13 100644 --- a/lib/resources/multiPartyCall.js +++ b/lib/resources/multiPartyCall.js @@ -30,8 +30,9 @@ export class MultiPartyCall extends PlivoResource{ this[clientKey] = client; } - get(){ - return super.executeAction(this.id, 'GET'); + get(params = {}){ + params.isVoiceRequest = 'true'; + return super.executeAction(this.id, 'GET', params); } addParticipant(params){ @@ -281,16 +282,16 @@ export class MultiPartyCall extends PlivoResource{ else { params.exitSoundMethod = 'GET' } - + params.isVoiceRequest = 'true'; return super.executeAction(this.id + '/Participant/', 'POST', params) } start(){ - return super.executeAction(this.id + '/', 'POST', {'status' : 'active'}) + return super.executeAction(this.id + '/', 'POST', {'status' : 'active', 'isVoiceRequest' : 'true'}) } stop(){ - return super.delete() + return super.delete({'isVoiceRequest' : 'true'}) } startRecording(params = {}){ @@ -311,27 +312,27 @@ export class MultiPartyCall extends PlivoResource{ else { params.statusCallbackMethod = 'POST' } - + params.isVoiceRequest = 'true'; return super.executeAction(this.id + '/Record/', 'POST', params) } stopRecording(){ - return super.executeAction(this.id + '/Record/', 'DELETE') + return super.executeAction(this.id + '/Record/', 'DELETE',{'isVoiceRequest' : 'true'}) } pauseRecording(){ - return super.executeAction(this.id + '/Record/Pause/', 'POST') + return super.executeAction(this.id + '/Record/Pause/', 'POST',{'isVoiceRequest' : 'true'}) } resumeRecording(){ - return super.executeAction(this.id + '/Record/Resume/', 'POST') + return super.executeAction(this.id + '/Record/Resume/', 'POST',{'isVoiceRequest' : 'true'}) } listParticipants(params = {}){ if(params.callUuid){ validParam('callUuid', params.callUuid, [String], false) } - + params.isVoiceRequest = 'true'; return super.executeAction(this.id + '/Participant/', 'GET', params) } } @@ -364,16 +365,16 @@ export class MultiPartyCallParticipant extends PlivoSecondaryResource{ if(params.hold){ validParam('hold', params.hold, [Boolean, String], false) } - + params.isVoiceRequest = 'true'; return super.executeAction(this.id, this.secondaryId, 'POST', params) } kickParticipant(){ - return super.executeAction(this.id, this.secondaryId, 'DELETE') + return super.executeAction(this.id, this.secondaryId, 'DELETE',{'isVoiceRequest' : 'true'}) } getParticipant(){ - return super.executeAction(this.id, this.secondaryId, 'GET') + return super.executeAction(this.id, this.secondaryId, 'GET',{'isVoiceRequest' : 'true'}) } } @@ -446,7 +447,7 @@ export class MultiPartyCallInterface extends PlivoResourceInterface{ if(params.offset){ validRange('offset', params.offset, false, 0) } - + params.isVoiceRequest = 'true'; return super.list(params); } diff --git a/lib/rest/utils.js b/lib/rest/utils.js index 6add094..49996bb 100644 --- a/lib/rest/utils.js +++ b/lib/rest/utils.js @@ -228,7 +228,7 @@ export function validDateFormat(paramName, paramValue, mandatory = false){ return true; } - let response = paramValue.match(/^\d{4}\-\d{2}\-\d{2} \d{2}:\d{2}:\d{2}(\.\d{1,6})?$/); + let response = paramValue.match(/^\d{4}\-\d{2}\-\d{2} \d{2}:\d{2}(:\d{2}(\.\d{1,6})?)?$/); if(response == null){ throw new InvalidRequestError("Invalid Date : Doesn't satisfy the date format") } diff --git a/test/calls.js b/test/calls.js index f60efee..4e623a6 100644 --- a/test/calls.js +++ b/test/calls.js @@ -68,6 +68,7 @@ describe('calls', function () { client.calls.get(1) .then(function(call){ return call.transfer() + done() }) .then(function(call) { assert.equal(call.id, 5)