Skip to content

Commit

Permalink
Merge pull request #179 from plivo/SUP-2124
Browse files Browse the repository at this point in the history
Fixed bug on call stop Recording API
  • Loading branch information
huzaif-plivo authored Mar 26, 2021
2 parents 2832528 + 48a227b commit 7a640a4
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 17 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Change Log

## [4.14.3](https://github.com/plivo/plivo-node/releases/tag/v4.14.3)(2021-03-26)
- Fix bug on stopRecording and all voice API flows post Typescript changes.

## [4.14.2](https://github.com/plivo/plivo-node/releases/tag/v4.14.2)(2021-02-17)
- Fix duplicate call issue for make call API.

Expand Down
3 changes: 3 additions & 0 deletions lib/resources/applications.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ export class Application extends PlivoResource {
*/
delete(params, id) {
let client = this[clientKey];
params.isVoiceRequest = 'true';
return new Promise((resolve, reject) => {
client('DELETE', action + id + '/', params)
.then(() => {
Expand Down Expand Up @@ -205,6 +206,7 @@ export class ApplicationInterface extends PlivoResourceInterface {
*/
list(params = {}) {
let client = this[clientKey];
params.isVoiceRequest = true;
return new Promise((resolve, reject) => {
client('GET', action, params)
.then(response => {
Expand Down Expand Up @@ -258,6 +260,7 @@ export class ApplicationInterface extends PlivoResourceInterface {
return errors;
}
params.app_name = appName;
params.isVoiceRequest = 'true';
let client = this[clientKey];
return new Promise((resolve, reject) => {
console.log(action, params)
Expand Down
26 changes: 12 additions & 14 deletions lib/resources/call.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ export class Call extends PlivoResource {
* @promise {object} return PlivoGenericResponse Object
* @fail {Error} return Error
*/
record(params) {
record(params= {}) {
params.isVoiceRequest = 'true';
return this.startRecording(params);
}

Expand Down Expand Up @@ -262,7 +263,7 @@ export class Call extends PlivoResource {
* @promise {object} return PlivoGenericResponse Object
* @fail {Error} return Error
*/
stopRecording(params) {
stopRecording(params= {}) {
params.isVoiceRequest = 'true';
return super.executeAction(this.id + '/Record/', 'DELETE', params);
}
Expand Down Expand Up @@ -642,7 +643,7 @@ export class CallInterface extends PlivoResourceInterface {
* @promise {object} returns PlivoGenericResponse Object
* @fail {Error} returns Error
*/
record(callUUID, optionalParams) {
record(callUUID, optionalParams = {}) {
let errors = validate([{
field: 'call_uuid',
value: callUUID,
Expand All @@ -665,7 +666,7 @@ export class CallInterface extends PlivoResourceInterface {
* @promise {object} returns PlivoGenericResponse Object
* @fail {Error} returns Error
*/
stopRecording(callUUID, optionalParams) {
stopRecording(callUUID, optionalParams= {}) {
let errors = validate([{
field: 'call_uuid',
value: callUUID,
Expand Down Expand Up @@ -916,8 +917,7 @@ class LiveCallInterface extends PlivoResourceInterface {
if (action !== '' && !id) {
reject(new Error(this[idKey] + ' must be set'));
}
client('GET', action + (id ? id + '/' : ''), {
status: 'live',
client('GET', action + (id ? id + '/?status=live' : '') , {
isVoiceRequest: 'true'
})
.then(response => {
Expand All @@ -936,17 +936,17 @@ class LiveCallInterface extends PlivoResourceInterface {
params = {}
}
params.status = 'live'
params.isVoiceRequest = 'true'
params.isVoiceRequest = 'true';
return new Promise((resolve, reject) => {
client('GET', action, params)
client('GET', action+'?status=live', params)
.then(response => {
let calls = [];
response.body.calls.forEach(callUuid => {
calls.push(new LiveCallResource(client, {
callUuid: callUuid
}));
});
resolve(new ListAllLiveCallResponse(calls[0]));
resolve(calls);
})
.catch(error => {
reject(error);
Expand Down Expand Up @@ -994,8 +994,7 @@ class QueuedCallInterface extends PlivoResourceInterface {
reject(new Error(this[idKey] + ' must be set'));
}

client('GET', action + (id ? id + '/' : ''), {
status: 'queued',
client('GET', action + (id ? id + '/?status=queued' : ''), {
isVoiceRequest: 'true'
})
.then(response => {
Expand All @@ -1013,8 +1012,7 @@ class QueuedCallInterface extends PlivoResourceInterface {
let client = this[clientKey];

return new Promise((resolve, reject) => {
client('GET', action, {
status: 'queued',
client('GET', action+'?status=queued', {
isVoiceRequest: 'true'
})
.then(response => {
Expand All @@ -1024,7 +1022,7 @@ class QueuedCallInterface extends PlivoResourceInterface {
callUuid: callUuid
}));
});
resolve(new ListAllQueuedCalls(calls[0]));
resolve(calls);
})
.catch(error => {
reject(error);
Expand Down
6 changes: 4 additions & 2 deletions lib/resources/recordings.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,11 @@ export class Recording extends PlivoResource {
* @fail {Error} return Error
*/
delete(id) {
let params = {};
params.isVoiceRequest = 'true';
let client = this[clientKey];
return new Promise((resolve, reject) => {
client('DELETE', action + id + '/')
client('DELETE', action + id + '/', params)
.then(() => {
resolve(true);
})
Expand Down Expand Up @@ -191,4 +193,4 @@ export class RecordingInterface extends PlivoResourceInterface {
id: id
}).delete(id);
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "plivo",
"version": "4.14.2",
"version": "4.14.3",
"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": [
Expand Down

0 comments on commit 7a640a4

Please sign in to comment.