From 76ce2092762213cff0b73bc0cdf6048f50e67e86 Mon Sep 17 00:00:00 2001 From: Manish Chand Kaushik Date: Wed, 5 Sep 2018 14:58:41 +0530 Subject: [PATCH 1/4] get queued call details --- lib/resources/call.js | 77 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/lib/resources/call.js b/lib/resources/call.js index 070b8e8f..77b8601e 100644 --- a/lib/resources/call.js +++ b/lib/resources/call.js @@ -201,6 +201,7 @@ export class Call extends PlivoResource { } const liveCallInterfaceKey = Symbol('liveCallInterface'); +const queuedCallInterfaceKey = Symbol('queuedCallInterface'); /** * Represents a Call Interface @@ -216,6 +217,7 @@ export class CallInterface extends PlivoResourceInterface { this[clientKey] = client; this[liveCallInterfaceKey] = new LiveCallInterface(client); + this[queuedCallInterfaceKey] = new QueuedCallInterface(client); } /** @@ -515,6 +517,14 @@ export class CallInterface extends PlivoResourceInterface { getLiveCall(id) { return this[liveCallInterfaceKey].get(id); } + + listQueuedCalls() { + return this[queuedCallInterfaceKey].list(); + } + + getQueuedCall() { + return this[queuedCallInterfaceKey].get(id) + } } export class LiveCallResource extends PlivoResource { @@ -530,6 +540,19 @@ export class LiveCallResource extends PlivoResource { } } +export class QueuedCallResource extends PlivoResource { + constructor(client, data = {}) { + super(action, QueuedCallResource, idField, client); + + if (idField in data) { + this.id = data[idField]; + } + + extend(this, data); + this[clientKey] = client; + } +} + /** * Represents a LiveCall interface * @constructor @@ -582,3 +605,57 @@ class LiveCallInterface extends PlivoResourceInterface { }); } } + + +/** + * Represents a QueuedCall interface + * @constructor + * @param {function} client - make api call + * @param {object} [data] - data of call + */ +class QueuedCallInterface extends PlivoResourceInterface { + constructor(client, data = {}) { + super(action, QueuedCallResource, idField, client); + extend(this, data); + + this[clientKey] = client; + } + + /** + * Get A Queued Call Detail + * @method + * @param {string} id - call uuid to get information of. + * @promise {object} returns QueuedCallResource Object + * @fail {Error} returns Error + */ + get(id) { + let errors = validate([{field: 'id', value: id, validators: ['isRequired']}]); + + if (errors) { + return errors; + } + return super.get(id, { + status: 'queued', + }); + } + + list() { + let client = this[clientKey]; + + return new Promise((resolve, reject) => { + client('GET', action, {status: 'queued'}) + .then(response => { + let calls = []; + response.body.calls.forEach(callUuid => { + calls.push(new QueuedCallResource(client, { + callUuid: callUuid + })); + }); + resolve(calls); + }) + .catch(error => { + reject(error); + }); + }); + } +} From 05360ae1bb3a26aae4bfab557471a250e45d453d Mon Sep 17 00:00:00 2001 From: Manish Chand Kaushik Date: Wed, 5 Sep 2018 15:01:38 +0530 Subject: [PATCH 2/4] fix --- lib/resources/call.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/resources/call.js b/lib/resources/call.js index 77b8601e..89bb706a 100644 --- a/lib/resources/call.js +++ b/lib/resources/call.js @@ -523,7 +523,7 @@ export class CallInterface extends PlivoResourceInterface { } getQueuedCall() { - return this[queuedCallInterfaceKey].get(id) + return this[queuedCallInterfaceKey].get(id); } } From d31a15022c0c8fdd3c6b1a7123840d931f903295 Mon Sep 17 00:00:00 2001 From: Manish Chand Kaushik Date: Thu, 6 Sep 2018 13:11:44 +0530 Subject: [PATCH 3/4] include id in queued call --- lib/resources/call.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/resources/call.js b/lib/resources/call.js index 89bb706a..edb99a08 100644 --- a/lib/resources/call.js +++ b/lib/resources/call.js @@ -522,7 +522,7 @@ export class CallInterface extends PlivoResourceInterface { return this[queuedCallInterfaceKey].list(); } - getQueuedCall() { + getQueuedCall(id) { return this[queuedCallInterfaceKey].get(id); } } From cf51569488719106aa0c2e4a8dc02f49365f7483 Mon Sep 17 00:00:00 2001 From: suresach Date: Tue, 18 Sep 2018 14:16:31 +0530 Subject: [PATCH 4/4] bump version to 4.0.3 --- CHANGELOG.md | 4 ++++ lib/resources/applications.js | 4 ++++ package.json | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c91eba7b..af9e5699 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## [4.0.3](https://github.com/plivo/plivo-node/releases/tag/v4.0.3)(2018-09-18) +- Queued status added for filtering calls in queued status. +- Added log_incoming_messages parameter to application create and update. + ## [4.0.2](https://github.com/plivo/plivo-node/releases/tag/v4.0.2)(2018-08-14) - Add Powerpack option for sending messages. diff --git a/lib/resources/applications.js b/lib/resources/applications.js index afcbfa75..59af9bb6 100644 --- a/lib/resources/applications.js +++ b/lib/resources/applications.js @@ -37,6 +37,8 @@ export class Application extends PlivoResource { * @param {boolean} [params.defaultNumberApp] If set to true, associates all newly created Plivo numbers that have not specified an app_id, to this application. * @param {boolean} [params.defaultEndpointApp] If set to true, associates all newly created Plivo endpoints that have not specified an app_id, to this application. * @param {string} [params.subaccount] Id of the subaccount, in case only subaccount applications are needed. + * @param {boolean} [params.logIncomingMessages] flag to control incoming message logs. + * @promise {object} return {@link Application} object * @fail {Error} return Error */ @@ -99,6 +101,7 @@ export class ApplicationInterface extends PlivoResourceInterface { * @param {boolean} [params.defaultNumberApp] If set to true, associates all newly created Plivo numbers that have not specified an app_id, to this application. * @param {boolean} [params.defaultEndpointApp] If set to true, associates all newly created Plivo endpoints that have not specified an app_id, to this application. * @param {string} [params.subaccount] Id of the subaccount, in case only subaccount applications are needed. + * @param {boolean} [params.logIncomingMessages] flag to control incoming message logs. * @promise {object} return {@link PlivoGenericResponse} object * @fail {Error} return Error */ @@ -133,6 +136,7 @@ export class ApplicationInterface extends PlivoResourceInterface { * @param {boolean} [params.defaultNumberApp] If set to true, associates all newly created Plivo numbers that have not specified an app_id, to this application. * @param {boolean} [params.defaultEndpointApp] If set to true, associates all newly created Plivo endpoints that have not specified an app_id, to this application. * @param {string} [params.subaccount] Id of the subaccount, in case only subaccount applications are needed. + * @param {boolean} [params.logIncomingMessages] flag to control incoming message logs. * @promise {object} return {@link Application} object * @fail {Error} return Error */ diff --git a/package.json b/package.json index 8bf70366..5ed6548c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "plivo", - "version": "4.0.2", + "version": "4.0.3", "description": "A Node.js SDK to make voice calls & send SMS using Plivo and to generate Plivo XML", "homepage": "https://github.com/plivo/plivo-node", "files": [