Skip to content

Commit

Permalink
Merge pull request #85 from plivo/sept_2018_release
Browse files Browse the repository at this point in the history
Sept 2018 release
  • Loading branch information
Sachin Kulshrestha authored Sep 18, 2018
2 parents 058cff6 + cf51569 commit 59c445b
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
4 changes: 4 additions & 0 deletions lib/resources/applications.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
*/
Expand Down
77 changes: 77 additions & 0 deletions lib/resources/call.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ export class Call extends PlivoResource {
}

const liveCallInterfaceKey = Symbol('liveCallInterface');
const queuedCallInterfaceKey = Symbol('queuedCallInterface');

/**
* Represents a Call Interface
Expand All @@ -216,6 +217,7 @@ export class CallInterface extends PlivoResourceInterface {

this[clientKey] = client;
this[liveCallInterfaceKey] = new LiveCallInterface(client);
this[queuedCallInterfaceKey] = new QueuedCallInterface(client);
}

/**
Expand Down Expand Up @@ -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 {
Expand All @@ -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
Expand Down Expand Up @@ -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);
});
});
}
}
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.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": [
Expand Down

0 comments on commit 59c445b

Please sign in to comment.