mirror of
https://github.com/donl/plivo-node.git
synced 2026-05-31 14:22:22 -06:00
* 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
94 lines
2.3 KiB
JavaScript
94 lines
2.3 KiB
JavaScript
import { extend, validate } from '../utils/common.js';
|
|
import { PlivoResource, PlivoResourceInterface } from '../base';
|
|
import { PhloMultiPartyCall, PhloMultiPartyCallInterface } from "../resources/phloMultipartyCall";
|
|
import * as _ from "lodash";
|
|
|
|
const clientKey = Symbol();
|
|
const action = 'phlo/';
|
|
const idField = 'phloUuid';
|
|
|
|
/**
|
|
* Represents a Phlo
|
|
* @constructor
|
|
* @param {function} client - make api call
|
|
* @param {object} [data] - data of phlo
|
|
*/
|
|
export class Phlo extends PlivoResource {
|
|
constructor(client, data = {}) {
|
|
super(action, Phlo, idField, client);
|
|
extend(this, data);
|
|
|
|
this.client = client;
|
|
|
|
// Define multiparty call getters
|
|
let item = this;
|
|
this.multiPartyCall = function (nodeId) {
|
|
let dd = new PhloMultiPartyCall(client, { phloId: item.phloId, nodeId: nodeId });
|
|
return dd;
|
|
};
|
|
|
|
this.multiPartyCall.get = function (nodeId) {
|
|
let dd = new PhloMultiPartyCallInterface(client, { phloId: item.phloId, nodeId: nodeId });
|
|
return dd.get(item.phloId, nodeId);
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* run phlo
|
|
* @method
|
|
* @promise {Boolean} return true if phlo is complete
|
|
* @fail {Error} return Error
|
|
*/
|
|
run(params) {
|
|
|
|
//Url for phlo running
|
|
// https://phlorunner.plivo.com/v1/account/{AUTH_ID}/phlo/{PHLO_ID}
|
|
let action = 'account/' + this.authId + '/phlo/' + this.phloId;
|
|
return super.executeAction(action, 'POST', params, '');
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* Represents a Phlo Interface
|
|
* @constructor
|
|
* @param {function} client - make api call
|
|
* @param {object} [data] - data of call
|
|
*/
|
|
export class PhloInterface extends PlivoResourceInterface {
|
|
|
|
constructor(client, data = {}) {
|
|
super(action, Phlo, idField, client);
|
|
extend(this, data);
|
|
}
|
|
|
|
/**
|
|
* Get A Phlo Detail
|
|
* @method
|
|
* @param {string} id - phlo uuid to get information of.
|
|
* @promise {object} returns Phlo Object
|
|
* @fail {Error} returns Error
|
|
*/
|
|
get(id) {
|
|
|
|
//Validate id first
|
|
let errors = validate([{
|
|
field: 'id',
|
|
value: id,
|
|
validators: ['isRequired']
|
|
}]);
|
|
|
|
if (errors) {
|
|
return errors;
|
|
}
|
|
|
|
let params = {
|
|
phlo_id: id
|
|
};
|
|
|
|
// Url pattern for getting phlo resource by id
|
|
// https://phlorunner.plivo.com/v1/phlo/{phlo_id}
|
|
return super.get(id, params);
|
|
}
|
|
}
|