diff --git a/CHANGELOG.md b/CHANGELOG.md index c91eba7..af9e569 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 afcbfa7..59af9bb 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/lib/resources/call.js b/lib/resources/call.js index 070b8e8..edb99a0 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(id) { + 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); + }); + }); + } +} diff --git a/package.json b/package.json index 8bf7036..5ed6548 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": [