plivo-node/lib/resources/phloMultiPartyCallMember.js
nixonsam a4e3f9fd47
Add PHLO support (#112)
* Added phlo client.

* Finished implementaiton of initializing phlo client.

* Finished logic for v2 methods of multiparty call(not members).

* Added test cases for multiparty call.

* Finished logic for phlo get api.

* Added member method structure.

* Finished implementation of phlo.run().

* Finished api calls for multi party(except abort transfer).

* Deleted old rest.js file.

* Finished abortTranfer implementation with test cases.

* Finished implementation of member.resumeCall().

* Finished all member functions.

* Reverted debugging logic.

* Removed console.log

* Added samples for all apis. method structure change for abort transfer.

* Resolved nsp issue.

* Audit fix.

* Package Lock Fix.

* Added test proxy for test cases.

* Resolved issue in request.js json format.

* Improved comments.

* Added test cases for .get() methods.

* Removed async await to support older browsers.

* Modified examples of phlo, removed async await.

* Resolved example issues, remove auth credentials.

* Removed es6 declaration syntaxes from phlo example.

* Added logic to pass payload.

* changed beta version 4.1-beta.1

* changed beta version 4.1-beta.1

* changed beta version 4.1-beta.1

* changes in changelog & readme- Add PHLO support
2019-03-11 15:43:57 +05:30

85 lines
2.1 KiB
JavaScript

import { extend, validate } from '../utils/common.js';
import { PlivoResource, PlivoResourceInterface } from '../base';
const clientKey = Symbol();
const action = 'Phlo/';
const idField = 'phloUuid';
/**
* Represents a Multiparty Call Member
* @constructor
* @param {function} client - make api call
* @param {object} [data] - data of phlo
*/
export class PhloMultiPartyCallMember extends PlivoResource {
constructor(client, data = {}) {
let action = 'phlo/' + data.phloId + '/multi_party_call/' + data.nodeId + '/members/';
super(action, PhloMultiPartyCallMember, idField, client);
extend(this, data);
this.action = action;
this.client = client;
}
resumeCall() {
return this.update('resume_call');
}
voicemailDrop() {
return this.update('voicemail_drop');
}
hangup() {
return this.update('hangup');
}
hold() {
return this.update('hold');
}
unhold() {
return this.update('unhold');
}
update(action) {
let params = {
action: action
};
// Build Url
// https://phlorunner.plivo.com/v1/phlo/{PHLO_ID}/multi_party_call/{NODE_ID}/members/{MemberAddress}
let task = this.action + this.memberAddress;
return super.executeAction(task, 'POST', params, '');
}
}
export class PhloMultiPartyCallMemberInterface extends PlivoResourceInterface {
constructor(client, data = {}) {
let action = 'phlo/' + data.phloId + '/multi_party_call/' + data.nodeId + '/members/';
super(action, PhloMultiPartyCallMember, idField, client);
extend(this, data);
this.action = action;
this.client = client;
}
get(phloId, nodeId, memberAddress) {
//Validate memberAddress first
let errors = validate([{
field: 'memberAddress',
value: memberAddress,
validators: ['isRequired']
}]);
if (errors) {
return errors;
}
return new PhloMultiPartyCallMember(this.client, { phloId: phloId, nodeId: nodeId, memberAddress: memberAddress });
}
}