updated node response and added types

This commit is contained in:
huzaif 2020-12-24 17:27:11 +05:30
parent 8f161d1bcb
commit 6884ba55f9
42 changed files with 6071 additions and 3255 deletions

View file

@ -1,4 +1,6 @@
import { extend } from './utils/common.js';
import {
extend
} from './utils/common.js';
let actionKey = Symbol('api action');
let klassKey = Symbol('constructor');
@ -7,182 +9,187 @@ let clientKey = Symbol('make api call');
export class PlivoGenericResponse {
constructor(params, idString) {
params = params || {};
if (typeof idString !== 'undefined' && (idString in params)) {
this.id = params[idString];
} else if ('request_uuid' in params) {
this.id = params.request_uuid;
}
extend(this, params);
params = params || {};
if (typeof idString !== 'undefined' && (idString in params)) {
this.id = params[idString];
} else if ('request_uuid' in params) {
this.id = params.request_uuid;
}
extend(this, params);
}
}
export class PlivoResource {
constructor(action, klass, idField, request) {
this[actionKey] = action;
this[klassKey] = klass;
this[idKey] = idField;
this[clientKey] = request;
this[actionKey] = action;
this[klassKey] = klass;
this[idKey] = idField;
this[clientKey] = request;
}
update(params, id) {
let client = this[clientKey];
let action = this[actionKey];
let that = this;
id = typeof id !== 'undefined' ? id : that.id;
let client = this[clientKey];
let action = this[actionKey];
let that = this;
id = typeof id !== 'undefined' ? id : that.id;
return new Promise((resolve, reject) => {
client('POST', action + id + '/', params)
.then(response => {
extend(that, response.body);
if (params.hasOwnProperty('isVoiceRequest')){
delete params.isVoiceRequest;
}
extend(that, params);
resolve(that);
})
.catch(error => {
reject(error);
});
});
return new Promise((resolve, reject) => {
client('POST', action + id + '/', params)
.then(response => {
extend(that, response.body);
if (params.hasOwnProperty('isVoiceRequest')) {
delete params.isVoiceRequest;
}
extend(that, params);
resolve(that);
})
.catch(error => {
reject(error);
});
});
}
delete(params) {
let client = this[clientKey];
let action = this[actionKey];
let id = this.id;
let client = this[clientKey];
let action = this[actionKey];
let id = this.id;
return new Promise((resolve, reject) => {
client('DELETE', action + id + '/', params)
.then(() => {
resolve(true);
})
.catch(error => {
reject(error);
});
});
return new Promise((resolve, reject) => {
client('DELETE', action + id + '/', params)
.then(() => {
resolve(true);
})
.catch(error => {
reject(error);
});
});
}
executeAction(task = '', method = 'GET', params = {}, action) {
let client = this[clientKey];
action = action == null ? this[actionKey] : action;
let idField = this[idKey];
let client = this[clientKey];
action = action == null ? this[actionKey] : action;
let idField = this[idKey];
return new Promise((resolve, reject) => {
client(method, action + task, params)
.then(response => {
resolve(new PlivoGenericResponse(response.body, idField));
})
.catch(error => {
reject(error);
});
});
return new Promise((resolve, reject) => {
client(method, action + task, params)
.then(response => {
resolve(new PlivoGenericResponse(response.body, idField));
})
.catch(error => {
reject(error);
});
});
}
customexecuteAction(url, method = 'GET', params = {}) {
let client = this[clientKey];
let idField = this[idKey];
return new Promise((resolve, reject) => {
client(method, url, params)
.then(response => {
resolve(new PlivoGenericResponse(response.body, idField));
})
.catch(error => {
reject(error);
});
});
let client = this[clientKey];
let idField = this[idKey];
return new Promise((resolve, reject) => {
client(method, url, params)
.then(response => {
resolve(new PlivoGenericResponse(response.body, idField));
})
.catch(error => {
reject(error);
});
});
}
customexecuteGetNumberAction(url, method = 'GET', params = {}) {
let client = this[clientKey];
let idField = this[idKey];
let number = "";
let promise = client(method, url, params).then(response => {
number = response.body.objects[0].number;
return number;
}).catch(error => {
console.log(error);
return error;
});
return promise;
let client = this[clientKey];
let idField = this[idKey];
let number = "";
let promise = client(method, url, params).then(response => {
number = response.body.objects[0].number;
return number;
}).catch(error => {
console.log(error);
return error;
});
return promise;
}
getMetaResponse(url, method = 'GET', params = {}) {
let client = this[clientKey];
let idField = this[idKey];
let count = 0;
return new Promise((resolve, reject) => {
client(method, url, params)
.then(response => {
count = response.body.meta.totalCount;
resolve(count);
})
.catch(error => {
reject(error);
});
});
let client = this[clientKey];
let idField = this[idKey];
let count = 0;
return new Promise((resolve, reject) => {
client(method, url, params)
.then(response => {
count = response.body.meta.totalCount;
resolve(count);
})
.catch(error => {
reject(error);
});
});
}
}
export class PlivoResourceInterface {
constructor(action, klass, idField, request) {
this[actionKey] = action;
this[klassKey] = klass;
this[idKey] = idField;
this[clientKey] = request;
this[actionKey] = action;
this[klassKey] = klass;
this[idKey] = idField;
this[clientKey] = request;
}
get(id, params = {}) {
let client = this[clientKey];
let action = this[actionKey];
let Klass = this[klassKey];
let client = this[clientKey];
let action = this[actionKey];
let Klass = this[klassKey];
return new Promise((resolve, reject) => {
if (action !== '' && !id) {
reject(new Error(this[idKey] + ' must be set'));
}
return new Promise((resolve, reject) => {
if (action !== '' && !id) {
reject(new Error(this[idKey] + ' must be set'));
}
client('GET', action + (id ? id + '/' : ''), params)
.then(response => {
resolve(new Klass(client, response.body));
})
.catch(error => {
reject(error);
});
});
client('GET', action + (id ? id + '/' : ''), params)
.then(response => {
resolve(new Klass(client, response.body));
})
.catch(error => {
reject(error);
});
});
}
list(params) {
let client = this[clientKey];
let action = this[actionKey];
let Klass = this[klassKey];
let client = this[clientKey];
let action = this[actionKey];
let Klass = this[klassKey];
return new Promise((resolve, reject) => {
client('GET', action, params)
.then(response => {
let objects = [];
Object.defineProperty(objects, 'meta', { value: response.body.meta, enumerable: true });
response.body.objects.forEach(item => {
objects.push(new Klass(client, item));
});
resolve(objects);
})
.catch(error => {
reject(error);
});
});
return new Promise((resolve, reject) => {
client('GET', action, params)
.then(response => {
let objects = [];
Object.defineProperty(objects, 'meta', {
value: response.body.meta,
enumerable: true
});
response.body.objects.forEach(item => {
objects.push(new Klass(client, item));
});
resolve(objects);
})
.catch(error => {
reject(error);
});
});
}
create(params) {
let client = this[clientKey];
let idField = this[idKey];
let action = this[actionKey] + (this.id ? this.id + '/' : '');
let client = this[clientKey];
let idField = this[idKey];
let action = this[actionKey] + (this.id ? this.id + '/' : '');
return new Promise((resolve, reject) => {
client('POST', action, params)
.then(response => {
resolve(new PlivoGenericResponse(response.body, idField));
})
.catch(error => {
reject(error);
});
});
return new Promise((resolve, reject) => {
client('POST', action, params)
.then(response => {
resolve(new PlivoGenericResponse(response.body, idField));
})
.catch(error => {
reject(error);
});
});
}
}
}

View file

@ -1,8 +1,10 @@
import {extend, validate} from '../utils/common.js';
import {PlivoResource, PlivoResourceInterface} from '../base';
import {extend, validate} from '../utils/common.js';
import { PlivoGenericResponse } from '../../dist/base';
const clientKey = Symbol();
const action = '';
const action = 'Subaccount/';
const idField = 'authId';
/**
@ -11,10 +13,77 @@ const idField = 'authId';
* @param {function} client - make api call
* @param {object} [data] - data of call
*/
export class GetAccountDetails
{
constructor(params) {
params = params || {};
this.accountType= params.accountType;
this.address = params.address;
this.apiId = params.apiId;
this.autoRecharge = params.autoRecharge;
this.billingMode = params.billingMode;
this.cashCredits = params.cashCredits;
this.city = params.city;
this.name = params.name;
this.resourceUri = params.resourceUri;
this.state = params.state;
this.timezone = params.timezone;
}
}
export class CreateSubAccountResponse
{
constructor(params) {
params = params || {};
this.apiId= params.apiId;
this.authId = params.authId;
this.authToken = params.authToken;
this.message = params.message;
}
}
export class UpdateSubAccountDetails
{
constructor(params) {
params = params || {};
this.apiId= params.apiId;
this.message = params.message;
}
}
export class UpdateAccountDetailsResponse
{
constructor(params) {
params = params || {};
this.apiId= params.apiId;
this.message = params.message;
}
}
export class GetSubAccountDetails {
constructor(params) {
params = params || {};
this.account= params.account;
this.apiId = params.apiId;
this.authId = params.authId;
this.authToken = params.authToken;
this.created = params.created;
this.enabled = params.enabled;
this.modified = params.modified;
this.name = params.name;
this.resourceUri = params.resourceUri;
}
}
export class Subaccount extends PlivoResource {
constructor(client, data = {}) {
super('Subaccount/', Subaccount, idField, client);
this[clientKey] = client;
if (idField in data) {
this.id = data[idField];
}
@ -47,7 +116,22 @@ export class Subaccount extends PlivoResource {
params.enabled = enabled.toString();
}
return super.update(params);
let client = this[clientKey];
let that = this;
return new Promise((resolve, reject) => {
client('POST', action + that.id + '/', params)
.then(response => {
extend(that, response.body);
if (params.hasOwnProperty('isVoiceRequest')){
delete params.isVoiceRequest;
}
extend(that, params);
resolve(new UpdateSubAccountDetails(that));
})
.catch(error => {
reject(error);
});
});
}
/**
@ -57,18 +141,29 @@ export class Subaccount extends PlivoResource {
* @promise {boolean} return true if subaccount deleted
* @fail {Error} return Error
*/
delete(cascade) {
delete(cascade)
{
let params = {};
if (typeof cascade === 'boolean') {
params.cascade = cascade.toString();
}
return super.delete(params);
let client = this[clientKey];
let id = this.id;
return new Promise((resolve, reject) => {
client('DELETE', action + id + '/', params)
.then(() => {
resolve(true);
})
.catch(error => {
reject(error);
});
});
}
}
/**
* Represents a Subaccount Interface
* @constructor
@ -98,7 +193,20 @@ export class SubaccountInterface extends PlivoResourceInterface {
if (errors) {
return errors;
}
return super.get(id);
let client = this[clientKey];
return new Promise((resolve, reject) => {
if (action !== '' && !id) {
reject(new Error(this[idKey] + ' must be set'));
}
client('GET', action + (id ? id + '/' : ''))
.then(response => {
resolve(new GetSubAccountDetails(response.body,client));
})
.catch(error => {
reject(error);
});
});
}
/**
@ -125,8 +233,16 @@ export class SubaccountInterface extends PlivoResourceInterface {
if (typeof enabled === 'boolean') {
params.enabled = enabled.toString();
}
return super.create(params);
let client = this[clientKey];
return new Promise((resolve, reject) => {
client('POST', action + (this.id ? this.id + '/' : ''), params)
.then(response => {
resolve(new CreateSubAccountResponse(response.body, idField));
})
.catch(error => {
reject(error);
});
})
}
/**
@ -197,10 +313,12 @@ export class Account extends PlivoResource {
* @promise {PlivoGenericResponse} return PlivoGenericResponse object
* @fail {Error} return Error
*/
get() {
return new AccountInterface(this[clientKey])
.get();
}
get() {
return new AccountInterface(this[clientKey])
.get();
}
/**
* update account detail
@ -213,7 +331,23 @@ export class Account extends PlivoResource {
* @fail {Error} return Error
*/
update(params) {
return super.update(params, '');
let client = this[clientKey];
let that = this;
return new Promise((resolve, reject) => {
client('POST', '/', params)
.then(response => {
extend(that, response.body);
if (params.hasOwnProperty('isVoiceRequest')){
delete params.isVoiceRequest;
}
extend(that, params);
resolve(new UpdateAccountDetailsResponse(that));
})
.catch(error => {
reject(error);
});
});
}
}
@ -238,8 +372,17 @@ export class AccountInterface extends PlivoResourceInterface {
* @fail {Error} return Error
*/
get() {
return super.get();
}
let client = this[clientKey];
return new Promise((resolve, reject) => {
client('GET', '/')
.then(response => {
resolve(new GetAccountDetails(response.body, client));
})
.catch(error => {
reject(error);
});
});
}
/**
* update account detail

View file

@ -1,5 +1,11 @@
import {extend, validate} from '../utils/common.js';
import {PlivoResource, PlivoResourceInterface} from '../base';
import {
PlivoResource,
PlivoResourceInterface
} from '../base';
import {
extend,
validate
} from '../utils/common.js';
const clientKey = Symbol();
const action = 'Application/';
@ -11,60 +17,144 @@ const idField = 'appId';
* @param {function} client - make api call
* @param {object} [data] - data of call
*/
export class Application extends PlivoResource {
constructor(client, data = {}) {
super(action, Application, idField, client);
if (idField in data) {
this.id = data[idField];
export class UpdateApplicationResponse {
constructor(params) {
params = params || {};
this.apiId = params.apiId;
this.message = params.message;
}
extend(this, data);
}
/**
* update application
* @method
* @param {object} params - to update application
* @param {string} [params.answerUrl] The URL invoked by Plivo when a call executes this application.
* @param {string} [params.answerMethod] The method used to call the answer_url. Defaults to POST.
* @param {string} [params.hangupUrl] The URL that is notified by Plivo when the call hangs up.
* @param {string} [params.hangupMethod] The method used to call the hangup_url. Defaults to POST
* @param {string} [params.fallbackAnswerUrl] Invoked by Plivo only if answer_url is unavailable or the XML response is invalid. Should contain a XML response.
* @param {string} [params.fallbackMethod] The method used to call the fallback_answer_url. Defaults to POST.
* @param {string} [params.messageUrl] The URL that is notified by Plivo when an inbound message is received. Defaults not set.
* @param {string} [params.messageMethod] The method used to call the message_url. Defaults to POST.
* @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
*/
update(params) {
params.isVoiceRequest = 'true';
return super.update(params);
}
/**
* delete application
* @method
* @param {object} params - params to delete application
* @param {boolean} [params.cascade] - delete associated endpoints
* @param {string} [params.newEndpointApplication] - link associated endpoints with app
* @promise {object} return true on success
* @fail {Error} return Error
*/
delete(params) {
if (typeof params.cascade === 'boolean') {
params.cascade = params.cascade.toString();
}
params.isVoiceRequest = 'true';
return super.delete(params);
}
}
export class CreateApplicationResponse {
constructor(params) {
params = params || {};
this.apiId = params.apiId;
this.appId = params.appId;
this.message = params.message;
}
}
export class RetrieveApplicationResponse {
constructor(params) {
params = params || {};
this.answerMethod = params.answerMethod;
this.answerUrl = params.answerUrl;
this.apiId = params.apiId;
this.appId = params.appId;
this.appName = params.appName;
this.applicationType = params.applicationType;
this.defaultApp = params.defaultApp;
this.defaultEndpointApp = params.defaultEndpointApp;
this.enabled = params.enabled;
this.fallbackAnswerUrl = params.fallbackAnswerUrl;
this.fallbackMethod = params.fallbackMethod;
this.hangupMethod = params.hangupMethod;
this.logIncomingMessage = params.logIncomingMessage;
this.messageMethod = params.messageMethod;
this.resourceUri = params.resourceUri;
this.sipUri = params.sipUri;
this.subAccount = params.subAccount;
}
}
export class ListAllApplicationResponse {
constructor(params) {
params = params || {};
this.answerMethod = params.answerMethod;
this.answerUrl = params.answerUrl;
this.apiId = params.apiId;
this.appId = params.appId;
this.appName = params.appName;
this.applicationType = params.applicationType;
this.defaultApp = params.defaultApp;
this.defaultEndpointApp = params.defaultEndpointApp;
this.enabled = params.enabled;
this.fallbackAnswerUrl = params.fallbackAnswerUrl;
this.fallbackMethod = params.fallbackMethod;
this.hangupMethod = params.hangupMethod;
this.logIncomingMessage = params.logIncomingMessage;
this.messageMethod = params.messageMethod;
this.resourceUri = params.resourceUri;
this.sipUri = params.sipUri;
this.subAccount = params.subAccount;
}
}
export class Application extends PlivoResource {
constructor(client, data = {}) {
super(action, Application, idField, client);
if (idField in data) {
this.id = data[idField];
}
this[clientKey] = client;
extend(this, data);
}
/**
* update application
* @method
* @param {object} params - to update application
* @param {string} [params.answerUrl] The URL invoked by Plivo when a call executes this application.
* @param {string} [params.answerMethod] The method used to call the answer_url. Defaults to POST.
* @param {string} [params.hangupUrl] The URL that is notified by Plivo when the call hangs up.
* @param {string} [params.hangupMethod] The method used to call the hangup_url. Defaults to POST
* @param {string} [params.fallbackAnswerUrl] Invoked by Plivo only if answer_url is unavailable or the XML response is invalid. Should contain a XML response.
* @param {string} [params.fallbackMethod] The method used to call the fallback_answer_url. Defaults to POST.
* @param {string} [params.messageUrl] The URL that is notified by Plivo when an inbound message is received. Defaults not set.
* @param {string} [params.messageMethod] The method used to call the message_url. Defaults to POST.
* @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
*/
update(params) {
params.isVoiceRequest = 'true';
let client = this[clientKey];
let that = this;
return new Promise((resolve, reject) => {
client('POST', action + that.id + '/', params)
.then(response => {
extend(that, response.body);
if (params.hasOwnProperty('isVoiceRequest')) {
delete params.isVoiceRequest;
}
extend(that, params);
resolve(new UpdateApplicationResponse(that));
})
.catch(error => {
reject(error);
});
});
}
/**
* delete application
* @method
* @param {object} params - params to delete application
* @param {boolean} [params.cascade] - delete associated endpoints
* @param {string} [params.newEndpointApplication] - link associated endpoints with app
* @promise {object} return true on success
* @fail {Error} return Error
*/
delete(params, id) {
let client = this[clientKey];
return new Promise((resolve, reject) => {
client('DELETE', action + id + '/', params)
.then(() => {
resolve(true);
})
.catch(error => {
reject(error);
});
});
}
}
/**
* Represents a Application interface
* @constructor
@ -73,126 +163,165 @@ export class Application extends PlivoResource {
*/
export class ApplicationInterface extends PlivoResourceInterface {
constructor(client, data = {}) {
super(action, Application, idField, client);
extend(this, data);
this[clientKey] = client;
}
/**
* get application by given id
* @method
* @param {string} id - id of application
* @promise {object} return {@link Application} object
* @fail {Error} return Error
*/
get(id) {
let params = {}
params.isVoiceRequest = 'true'
return super.get(id, params);
}
/**
* list applications
* @method
* @param {object} params - params to list applications
* @param {string} [params.subaccount] - ID of the subaccount if present
* @param {integer} [params.limit] - To display no of results per page
* @param {integer} [params.offset] - No of value items by which results should be offset
*/
list(params= {}) {
params.isVoiceRequest = 'true';
return super.list(params);
}
/**
* create Application
* @method
* @param {string} appName - name of application
* @param {object} params - params to create application
* @param {string} [params.answerUrl] - answer url
* @param {string} [params.appName] The name of your application
* @param {string} [params.answerUrl] The URL invoked by Plivo when a call executes this application.
* @param {string} [params.answerMethod] The method used to call the answer_url. Defaults to POST.
* @param {string} [params.hangupUrl] The URL that is notified by Plivo when the call hangs up.
* @param {string} [params.hangupMethod] The method used to call the hangup_url. Defaults to POST
* @param {string} [params.fallbackAnswerUrl] Invoked by Plivo only if answer_url is unavailable or the XML response is invalid. Should contain a XML response.
* @param {string} [params.fallbackMethod] The method used to call the fallback_answer_url. Defaults to POST.
* @param {string} [params.messageUrl] The URL that is notified by Plivo when an inbound message is received. Defaults not set.
* @param {string} [params.messageMethod] The method used to call the message_url. Defaults to POST.
* @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
*/
create(appName, params = {}) {
let errors = validate([
{field: 'app_name', value: appName, validators: ['isRequired', 'isString']}
]);
if (errors) {
return errors;
constructor(client, data = {}) {
super(action, Application, idField, client);
extend(this, data);
this[clientKey] = client;
}
params.app_name = appName;
params.isVoiceRequest = 'true';
return super.create(params);
}
/**
* get application by given id
* @method
* @param {string} id - id of application
* @promise {object} return {@link Application} object
* @fail {Error} return Error
*/
get(id) {
let params = {}
params.isVoiceRequest = 'true'
let client = this[clientKey];
/**
* update Application
* @method
* @param {string} id - id of application
* @param {object} params - to update application
* @param {string} [params.answerUrl] The URL invoked by Plivo when a call executes this application.
* @param {string} [params.answerMethod] The method used to call the answer_url. Defaults to POST.
* @param {string} [params.hangupUrl] The URL that is notified by Plivo when the call hangs up.
* @param {string} [params.hangupMethod] The method used to call the hangup_url. Defaults to POST
* @param {string} [params.fallbackAnswerUrl] Invoked by Plivo only if answer_url is unavailable or the XML response is invalid. Should contain a XML response.
* @param {string} [params.fallbackMethod] The method used to call the fallback_answer_url. Defaults to POST.
* @param {string} [params.messageUrl] The URL that is notified by Plivo when an inbound message is received. Defaults not set.
* @param {string} [params.messageMethod] The method used to call the message_url. Defaults to POST.
* @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
*/
update(id, params) {
let errors = validate([
{field: 'id', value: id, validators: ['isRequired']}
]);
if (errors) {
return errors;
}
return new Application(this[clientKey], {
id: id
}).update(params);
}
/**
* delete Application
* @method
* @param {string} id - id of application
* @param {object} params - params to delete application
* @param {boolean} [params.cascade] - delete associated endpoints
* @param {string} [params.newEndpointApplication] - link associated endpoints with app
* @promise {object} return true on success
* @fail {Error} return Error
*/
delete(id, params = {}) {
if (typeof params.cascade === 'boolean') {
params.cascade = params.cascade.toString();
return new Promise((resolve, reject) => {
if (action !== '' && !id) {
reject(new Error(this[idKey] + ' must be set'));
}
client('GET', action + (id ? id + '/' : ''), params)
.then(response => {
resolve(new RetrieveApplicationResponse(response.body, client));
})
.catch(error => {
reject(error);
});
});
}
return new Application(this[clientKey], {
id: id
}).delete(params);
}
}
/**
* list applications
* @method
* @param {object} params - params to list applications
* @param {string} [params.subaccount] - ID of the subaccount if present
* @param {integer} [params.limit] - To display no of results per page
* @param {integer} [params.offset] - No of value items by which results should be offset
*/
list(params = {}) {
let client = this[clientKey];
return new Promise((resolve, reject) => {
client('GET', action, params)
.then(response => {
let objects = [];
Object.defineProperty(objects, 'meta', {
value: response.body.meta,
enumerable: true
});
response.body.objects.forEach(item => {
objects.push(new ListAllApplicationResponse(item, client));
});
resolve(objects);
})
.catch(error => {
reject(error);
});
});
}
/**
* create Application
* @method
* @param {string} appName - name of application
* @param {object} params - params to create application
* @param {string} [params.answerUrl] - answer url
* @param {string} [params.appName] The name of your application
* @param {string} [params.answerUrl] The URL invoked by Plivo when a call executes this application.
* @param {string} [params.answerMethod] The method used to call the answer_url. Defaults to POST.
* @param {string} [params.hangupUrl] The URL that is notified by Plivo when the call hangs up.
* @param {string} [params.hangupMethod] The method used to call the hangup_url. Defaults to POST
* @param {string} [params.fallbackAnswerUrl] Invoked by Plivo only if answer_url is unavailable or the XML response is invalid. Should contain a XML response.
* @param {string} [params.fallbackMethod] The method used to call the fallback_answer_url. Defaults to POST.
* @param {string} [params.messageUrl] The URL that is notified by Plivo when an inbound message is received. Defaults not set.
* @param {string} [params.messageMethod] The method used to call the message_url. Defaults to POST.
* @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
*/
create(appName, params = {}) {
let errors = validate([{
field: 'app_name',
value: appName,
validators: ['isRequired', 'isString']
}]);
if (errors) {
return errors;
}
params.app_name = appName;
let client = this[clientKey];
return new Promise((resolve, reject) => {
console.log(action, params)
client('POST', action, params)
.then(response => {
resolve(new CreateApplicationResponse(response.body, idField));
})
.catch(error => {
reject(error);
});
})
}
/**
* update Application
* @method
* @param {string} id - id of application
* @param {object} params - to update application
* @param {string} [params.answerUrl] The URL invoked by Plivo when a call executes this application.
* @param {string} [params.answerMethod] The method used to call the answer_url. Defaults to POST.
* @param {string} [params.hangupUrl] The URL that is notified by Plivo when the call hangs up.
* @param {string} [params.hangupMethod] The method used to call the hangup_url. Defaults to POST
* @param {string} [params.fallbackAnswerUrl] Invoked by Plivo only if answer_url is unavailable or the XML response is invalid. Should contain a XML response.
* @param {string} [params.fallbackMethod] The method used to call the fallback_answer_url. Defaults to POST.
* @param {string} [params.messageUrl] The URL that is notified by Plivo when an inbound message is received. Defaults not set.
* @param {string} [params.messageMethod] The method used to call the message_url. Defaults to POST.
* @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
*/
update(id, params) {
let errors = validate([{
field: 'id',
value: id,
validators: ['isRequired']
}]);
if (errors) {
return errors;
}
return new Application(this[clientKey], {
id: id
}).update(params);
}
/**
* delete Application
* @method
* @param {string} id - id of application
* @param {object} params - params to delete application
* @param {boolean} [params.cascade] - delete associated endpoints
* @param {string} [params.newEndpointApplication] - link associated endpoints with app
* @promise {object} return true on success
* @fail {Error} return Error
*/
delete(id, params = {}) {
if (typeof params.cascade === 'boolean') {
params.cascade = params.cascade.toString();
}
return new Application(this[clientKey], {
id: id
}).delete(params, id);
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,7 +1,24 @@
import {extend, validate} from '../utils/common.js';
import {PlivoResource, PlivoResourceInterface} from '../base';
import * as _ from "lodash";
import {
PlivoResource,
PlivoResourceInterface
} from '../base';
import {
extend,
validate
} from '../utils/common.js';
export class CallFeedbackResponse {
constructor(params) {
params = params || {};
this.apiId = params.apiId;
this.message = params.message;
this.status = params.status;
}
}
const clientKey = Symbol();
const action = 'Call/';
const idField = 'callUuid';
@ -10,14 +27,14 @@ const CALLINSIGHTS_BASE_URL = 'https://stats.plivo.com/'
export class CallFeedback extends PlivoResource {
constructor(client, data = {}) {
super(action, Call, idField, client);
if (idField in data) {
this.id = data[idField];
this.id = data[idField];
}
extend(this, data);
this[clientKey] = client;
}
}
}
/**
@ -30,15 +47,22 @@ export class CallFeedbackInterface extends PlivoResourceInterface {
constructor(client, data = {}) {
super(action, CallFeedback, idField, client);
extend(this, data);
this[clientKey] = client;
}
create(callUUID, rating, issues=[], notes="") {
let errors = validate([
{field: 'callUUId', value: callUUID, validators: ['isRequired']},
{field: 'rating', value: rating, validators: ['isRequired']}
]);
}
create(callUUID, rating, issues = [], notes = "") {
let errors = validate([{
field: 'callUUId',
value: callUUID,
validators: ['isRequired']
},
{
field: 'rating',
value: rating,
validators: ['isRequired']
}
]);
if (errors) {
return errors;
@ -55,7 +79,17 @@ export class CallFeedbackInterface extends PlivoResourceInterface {
params.isCallInsightsRequest = "";
params.CallInsightsBaseUrl = CALLINSIGHTS_BASE_URL;
params.CallInsightsRequestPath = `v1/Call/${callUUID}/Feedback/`;
return super.create(params);
let client = this[clientKey];
return new Promise((resolve, reject) => {
client('POST', action, params)
.then(response => {
resolve(new CallFeedbackResponse(response.body, idField));
})
.catch(error => {
reject(error);
});
});
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,168 +1,314 @@
import {extend, validate} from '../utils/common.js';
import {PlivoResource, PlivoResourceInterface} from '../base';
import {
PlivoResource,
PlivoResourceInterface
} from '../base';
import {
extend,
validate
} from '../utils/common.js';
const clientKey = Symbol();
const action = 'Endpoint/';
const idField = 'endpointId';
export class UpdateEndpointResponse {
constructor(params) {
params = params || {};
this.apiId = params.apiId;
this.message = params.message;
this.alias = params.alias;
}
}
export class RetrieveEndpointResponse {
constructor(params) {
params = params || {};
this.apiId = params.apiId;
this.alias = params.alias;
this.application = params.application;
this.endpointId = params.endpointId;
this.password = params.password;
this.resourceUri = params.resourceUri;
this.sipRegistered = params.sipRegistered;
this.sipUri = params.sipUri;
this.subAccount = params.subAccount;
this.username = params.username;
}
}
export class ListAllEndpointResponse {
constructor(params) {
params = params || {};
this.alias = params.alias;
this.application = params.application;
this.endpointId = params.endpointId;
this.password = params.password;
this.resourceUri = params.resourceUri;
this.sipRegistered = params.sipRegistered;
this.sipUri = params.sipUri;
this.subAccount = params.subAccount;
this.username = params.username;
}
}
export class CreateEndpointResponse {
constructor(params) {
params = params || {};
this.alias = params.alias;
this.apiId = params.apiId;
this.endpointId = params.endpointId;
this.message = params.message;
this.username = params.username;
}
}
/**
* Represents a Endpoint
* @constructor
* @param {function} client - make api call
* @param {object} [data] - data of call
*/
* Represents a Endpoint
* @constructor
* @param {function} client - make api call
* @param {object} [data] - data of call
*/
export class Endpoint extends PlivoResource {
constructor(client, data = {}) {
super(action, Endpoint, idField, client);
super(action, Endpoint, idField, client);
if (idField in data) {
this.id = data[idField];
}
if (idField in data) {
this.id = data[idField];
}
extend(this, data);
this[clientKey] = client;
extend(this, data);
this[clientKey] = client;
}
/**
* update Endpoint
* @method
* @param {object} params
* @param {string} [params.username] - username to update
* @param {string} [params.password] - password to update
* @param {string} [params.alias] - alias to update
* @param {string} [params.appId] - app id to update
* @promise {object} return {@link Endpoint} object if success
* @fail {Error} return Error
*/
update(params) {
params.isVoiceRequest = 'true';
return super.update(params);
/**
* update Endpoint
* @method
* @param {object} params
* @param {string} [params.username] - username to update
* @param {string} [params.password] - password to update
* @param {string} [params.alias] - alias to update
* @param {string} [params.appId] - app id to update
* @promise {object} return {@link Endpoint} object if success
* @fail {Error} return Error
*/
update(params, id) {
params.isVoiceRequest = 'true';
let client = this[clientKey];
let that = this;
return new Promise((resolve, reject) => {
client('POST', action + id + '/', params)
.then(response => {
extend(that, response.body);
if (params.hasOwnProperty('isVoiceRequest')) {
delete params.isVoiceRequest;
}
extend(that, params);
resolve(new UpdateEndpointResponse(that));
})
.catch(error => {
reject(error);
});
});
}
/**
* delete Endpoint
* @method
* @promise {boolean} return true if success
* @fail {Error} return Error
*/
/**
* delete Endpoint
* @method
* @promise {boolean} return true if success
* @fail {Error} return Error
*/
delete() {
let params = {};
params.isVoiceRequest = 'true';
return super.delete(params);
let params = {};
params.isVoiceRequest = 'true';
let client = this[clientKey];
let id = this.id;
return new Promise((resolve, reject) => {
client('DELETE', action + id + '/', params)
.then(() => {
resolve(true);
})
.catch(error => {
reject(error);
});
});
}
}
/**
* Represents a Endpoint Interface
* @constructor
* @param {function} client - make api call
* @param {object} [data] - data of call
*/
* Represents a Endpoint Interface
* @constructor
* @param {function} client - make api call
* @param {object} [data] - data of call
*/
export class EndpointInterface extends PlivoResourceInterface {
constructor(client, data = {}) {
super(action, Endpoint, idField, client);
extend(this, data);
super(action, Endpoint, idField, client);
extend(this, data);
this[clientKey] = client;
this[clientKey] = client;
}
/**
* Get Endpoint by given id
* @method
* @param {string} id - id of endpoint
* @promise {object} return {@link Endpoint} object if success
* @fail {Error} return Error
*/
/**
* Get Endpoint by given id
* @method
* @param {string} id - id of endpoint
* @promise {object} return {@link Endpoint} object if success
* @fail {Error} return Error
*/
get(id) {
let params = {};
params.isVoiceRequest = 'true';
return super.get(id, params);
let params = {};
params.isVoiceRequest = 'true';
let client = this[clientKey];
return new Promise((resolve, reject) => {
if (action !== '' && !id) {
reject(new Error(this[idKey] + ' must be set'));
}
client('GET', action + (id ? id + '/' : ''), params)
.then(response => {
resolve(new RetrieveEndpointResponse(response.body, client));
})
.catch(error => {
reject(error);
});
});
}
list() {
let params = {};
params.isVoiceRequest = 'true';
return super.list(params);
let params = {};
params.isVoiceRequest = 'true';
let client = this[clientKey];
return new Promise((resolve, reject) => {
client('GET', action, params)
.then(response => {
let objects = [];
Object.defineProperty(objects, 'meta', {
value: response.body.meta,
enumerable: true
});
response.body.objects.forEach(item => {
objects.push(new ListAllEndpointResponse(item, client));
});
console.log(objects)
resolve(objects);
})
.catch(error => {
reject(error);
});
});
}
/**
* Create Endpoint
* @method
* @param {string} username - username to create
* @param {string} passwowrd - password to create
* @param {string} alias - alias to create
* @param {string} appId - app id to create
* @promise {object} return {@link PlivoGenericResponse} object if success
* @fail {Error} return Error
*/
/**
* Create Endpoint
* @method
* @param {string} username - username to create
* @param {string} passwowrd - password to create
* @param {string} alias - alias to create
* @param {string} appId - app id to create
* @promise {object} return {@link PlivoGenericResponse} object if success
* @fail {Error} return Error
*/
create(username, password, alias, appId) {
let params = {};
let params = {};
let errors = validate([
{field: 'username', value: username, validators: ['isRequired']},
{field: 'password', value: password, validators: ['isRequired']},
{field: 'alias', value: alias, validators: ['isRequired']}
]);
let errors = validate([{
field: 'username',
value: username,
validators: ['isRequired']
},
{
field: 'password',
value: password,
validators: ['isRequired']
},
{
field: 'alias',
value: alias,
validators: ['isRequired']
}
]);
if (errors) {
return errors;
}
params.username = username;
params.password = password;
params.alias = alias;
if (appId) {
params.app_id = appId;
}
params.isVoiceRequest = 'true';
let client = this[clientKey];
return new Promise((resolve, reject) => {
client('POST', action, params)
.then(response => {
resolve(new CreateEndpointResponse(response.body, idField));
})
.catch(error => {
reject(error);
});
});
if (errors) {
return errors;
}
params.username = username;
params.password = password;
params.alias = alias;
if (appId) {
params.app_id = appId;
}
params.isVoiceRequest = 'true';
return super.create(params);
}
/**
* update Endpoint
* @method
* @param {string} id - id to update
* @param {object} params
* @param {string} [params.username] - username to update
* @param {string} [params.password] - password to update
* @param {string} [params.alias] - alias to update
* @param {string} [params.appId] - app id to update
* @promise {object} return {@link Endpoint} object if success
* @fail {Error} return Error
*/
/**
* update Endpoint
* @method
* @param {string} id - id to update
* @param {object} params
* @param {string} [params.username] - username to update
* @param {string} [params.password] - password to update
* @param {string} [params.alias] - alias to update
* @param {string} [params.appId] - app id to update
* @promise {object} return {@link Endpoint} object if success
* @fail {Error} return Error
*/
update(id, params) {
let errors = validate([
{field: 'id', value: id, validators: ['isRequired']}
]);
let errors = validate([{
field: 'id',
value: id,
validators: ['isRequired']
}]);
if (errors) {
return errors;
}
return new Endpoint(this[clientKey], {
id: id
}).update(params);
if (errors) {
return errors;
}
return new Endpoint(this[clientKey], {
id: id
}).update(params, id);
}
/**
* delete Endpoint
* @method
* @param {string} id - id to delete
* @promise {boolean} return true if success
* @fail {Error} return Error
*/
/**
* delete Endpoint
* @method
* @param {string} id - id to delete
* @promise {boolean} return true if success
* @fail {Error} return Error
*/
delete(id) {
let errors = validate([
{field: 'id', value: id, validators: ['isRequired']}
]);
let errors = validate([{
field: 'id',
value: id,
validators: ['isRequired']
}]);
if (errors) {
return errors;
}
return new Endpoint(this[clientKey], {
id: id
}).delete();
if (errors) {
return errors;
}
return new Endpoint(this[clientKey], {
id: id
}).delete();
}
}
}

View file

@ -1,20 +1,32 @@
import {
extend,
validate
} from '../utils/common.js';
import * as _ from "lodash";
import {
PlivoResource,
PlivoResourceInterface
} from '../base';
import * as _ from "lodash";
import {
extend,
validate
} from '../utils/common.js';
const clientKey = Symbol();
const action = 'Number/'; // unused as it is overridden, only for unit tests
const idField = 'OVERRIDDEN';
const LOOKUP_API_BASE_URL = 'https://lookup.plivo.com/v1/Number'
export class LookupResponse {
constructor(params) {
params = params || {};
this.apiId = params.apiId;
this.phoneNumber = params.phoneNumber;
this.country = params.country;
this.format = params.format;
this.carrier = params.carrier;
this.resourceUri = params.resourceUri;
}
}
export class Number extends PlivoResource {
constructor(client, data = {}) {
super(action, Number, idField, client);
@ -46,6 +58,15 @@ export class LookupInterface extends PlivoResourceInterface {
overrideUrl: `${LOOKUP_API_BASE_URL}/${number}`,
};
return super.get(number, params);
let client = this[clientKey];
return new Promise((resolve, reject) => {
client('GET', action + '/', params)
.then(response => {
resolve(new LookupResponse(response.body, client));
})
.catch(error => {
reject(error);
});
});
}
}
}

View file

@ -1,18 +1,52 @@
import {
extend,
validate
} from '../utils/common.js';
import {
PlivoResource,
PlivoResourceInterface
} from '../base';
import * as _ from 'lodash';
import {
PlivoGenericResponse,
PlivoResource,
PlivoResourceInterface
} from '../base';
import {
extend,
validate
} from '../utils/common.js';
var fs = require('fs');
const clientKey = Symbol();
const action = 'Media/';
const idField = 'media_id';
export class UploadMediaResponse {
constructor(params) {
params = params || {};
this.apiId = params.apiId;
this.objects = params.objects;
}
}
export class RetrieveMediaResponse {
constructor(params) {
params = params || {};
this.apiId = params.apiId;
this.contentType = params.contentType;
this.fileName = params.fileName;
this.mediaId = params.mediaId;
this.mediaUrl = params.mediaUrl;
this.size = params.size;
this.uploadTime = params.uploadTime;
}
}
export class ListMediaResponse {
constructor(params) {
params = params || {};
this.apiId = params.apiId;
this.meta = params.meta;
this.objects = params.objects;
}
}
/**
* Represents a Message
* @constructor
@ -20,15 +54,15 @@ const idField = 'media_id';
* @param {object} [data] - data of call
*/
export class Media extends PlivoResource {
constructor(client, data = {}) {
super(action, Media, idField, client);
constructor(client, data = {}) {
super(action, Media, idField, client);
if (idField in data) {
this.id = data[idField];
if (idField in data) {
this.id = data[idField];
}
extend(this, data);
}
extend(this, data);
}
}
/**
* Represents a Media Interface
@ -38,61 +72,106 @@ export class Media extends PlivoResource {
*/
export class MediaInterface extends PlivoResourceInterface {
constructor(client, data = {}) {
super(action, Media, idField, client);
extend(this, data);
this[clientKey] = client;
}
/**
* Upload Media
* @method
* @fail {Error} return Error
*/
upload(files) {
let errors = validate([{
field: 'files',
value: files,
validators: ['isRequired']
}]);
if (errors) {
return errors;
}
let params = {}
params.file = files
return super.create(params);
}
/**
* Get Media by given id
* @method
* @param {string} media_id - id of media
* @promise {object} return {@link Media} object if success
* @fail {Error} return Error
*/
get(media_id) {
let errors = validate([{
field: 'media_id',
value: media_id,
validators: ['isRequired']
}]);
if (errors) {
return errors;
constructor(client, data = {}) {
super(action, Media, idField, client);
extend(this, data);
this[clientKey] = client;
}
return super.get(media_id);
}
/**
* Upload Media
* @method
* @fail {Error} return Error
*/
upload(files) {
let errors = validate([{
field: 'files',
value: files,
validators: ['isRequired']
}]);
/**
* Get All Media Detail
* @method
* @param {object} params - params to get all media details.
* @promise {object[]} returns list of Media Object
* @fail {Error} returns Error
*/
list(params) {
return super.list(params);
}
}
if (errors) {
return errors;
}
let params = {}
params.file = files
let client = this[clientKey];
return new Promise((resolve, reject) => {
client('POST', action, params)
.then(response => {
resolve(new UploadMediaResponse(response.body, idField));
})
.catch(error => {
reject(error);
});
});
}
/**
* Get Media by given id
* @method
* @param {string} media_id - id of media
* @promise {object} return {@link Media} object if success
* @fail {Error} return Error
*/
get(media_id) {
let errors = validate([{
field: 'media_id',
value: media_id,
validators: ['isRequired']
}]);
if (errors) {
return errors;
}
let client = this[clientKey];
return new Promise((resolve, reject) => {
if (action !== '' && !media_id) {
reject(new Error(this[idKey] + ' must be set'));
}
client('GET', action + (media_id ? media_id + '/' : ''))
.then(response => {
resolve(new RetrieveMediaResponse(response.body, client));
})
.catch(error => {
reject(error);
});
});
}
/**
* Get All Media Detail
* @method
* @param {object} params - params to get all media details.
* @promise {object[]} returns list of Media Object
* @fail {Error} returns Error
*/
list(params) {
//return super.list(params);
let client = this[clientKey];
return new Promise((resolve, reject) => {
client('GET', action, params)
.then(response => {
let objects = [];
Object.defineProperty(objects, 'meta', {
value: response.body.meta,
enumerable: true
});
response.body.objects.forEach(item => {
objects.push(new PlivoGenericResponse(item, client));
});
resolve(objects);
})
.catch(error => {
reject(error);
});
});
}
}

View file

@ -1,16 +1,15 @@
import * as _ from "lodash";
import {
PlivoGenericResponse,
PlivoResource,
PlivoResourceInterface
PlivoGenericResponse,
PlivoResource,
PlivoResourceInterface
} from '../base';
import {
extend,
validate
extend,
validate
} from '../utils/common.js';
const action = 'Message/';
const idField = 'messageUuid';
let actionKey = Symbol('api action');
@ -19,14 +18,78 @@ let idKey = Symbol('id filed');
let clientKey = Symbol('make api call');
export class MessageResponse {
constructor(params) {
params = params || {};
this.apiId= params.apiId;
this.message = params.message;
this.messageUuid = params.messageUuid;
constructor(params) {
params = params || {};
this.apiId = params.apiId;
this.message = params.message;
this.messageUuid = params.messageUuid;
}
}
}
export class MessageGetResponse {
constructor(params) {
params = params || {};
this.apiId = params.apiId;
this.errorCode = params.errorCode;
this.fromNumber = params.fromNumber;
this.messageDirection = params.messageDirection;
this.messageState = params.messageState;
this.messageTime = params.messageTime;
this.messageType = params.messageType;
this.messageUuid = params.messageUuid;
this.resourceUri = params.resourceUri;
this.toNumber = params.toNumber;
this.totalAmount = params.totalAmount;
this.totalRate = params.totalRate;
this.units = params.units;
}
}
export class MessageListResponse {
constructor(params) {
params = params || {};
this.errorCode = params.errorCode;
this.fromNumber = params.fromNumber;
this.messageDirection = params.messageDirection;
this.messageState = params.messageState;
this.messageTime = params.messageTime;
this.messageType = params.messageType;
this.messageUuid = params.messageUuid;
this.resourceUri = params.resourceUri;
this.toNumber = params.toNumber;
this.totalAmount = params.totalAmount;
this.totalRate = params.totalRate;
this.units = params.units;
}
}
export class MMSMediaResponse {
constructor(params) {
params = params || {};
this.apiId = params.apiId;
let MMSMediaList = []
params.objects.forEach(item => {
MMSMediaList.push(new MMSMedia(item));
});
this.objects = MMSMediaList;
}
}
export class MMSMedia {
constructor(params) {
params = params || {};
this.contentType = params.contentType;
this.fileName = params.fileName;
this.mediaId = params.mediaId;
this.mediaUrl = params.mediaUrl;
this.messageUuid = params.messageUuid;
this.size = params.size;
this.uploadTime = params.uploadTime;
}
}
/**
* Represents a Message
* @constructor
@ -34,19 +97,31 @@ export class MessageResponse {
* @param {object} [data] - data of call
*/
export class Message extends PlivoResource {
constructor(client, data = {}) {
super(action, Message, idField, client);
constructor(client, data = {}) {
super(action, Message, idField, client);
this[actionKey] = action;
this[clientKey] = client;
if (idField in data) {
this.id = data[idField];
};
if (idField in data) {
this.id = data[idField];
};
extend(this, data);
}
extend(this, data);
}
listMedia() {
return super.executeAction(this.id + '/Media/', 'Get', {});
}
listMedia() {
//return super.executeAction(this.id + '/Media/', 'Get', {});
let client = this[clientKey];
let idField = this[idKey];
return new Promise((resolve, reject) => {
client('Get', this[actionKey] + this.id + '/Media/', {})
.then(response => {
resolve(new MMSMediaResponse(response.body, idField));
})
.catch(error => {
reject(error);
});
});
}
}
/**
@ -58,125 +133,161 @@ export class Message extends PlivoResource {
export class MessageInterface extends PlivoResourceInterface {
constructor(client, data = {}) {
super(action, Message, idField, client);
extend(this, data);
this[clientKey] = client;
this[actionKey] = action;
this[klassKey] = Message;
this[idKey] = idField;
constructor(client, data = {}) {
super(action, Message, idField, client);
extend(this, data);
this[clientKey] = client;
this[actionKey] = action;
this[klassKey] = Message;
this[idKey] = idField;
}
/**
* Send Message
* @method
* @param {string} src - source number
* @param {string} dst - destination number
* @param {string} text - text to send
* @param {object} optionalParams - Optional Params to send message
* @param {string} [optionalParams.type] - The type of message. Should be `sms` or `mms`. Defaults to `sms`.
* @param {string} [optionalParams.url] The URL to which with the status of the message is sent.
* @param {string} [optionalParams.method] The method used to call the url. Defaults to POST.
* @param {list} [optionalParams.media_urls] For sending mms, specify the media urls in list of string
* @param {boolean} [optionalParams.log] If set to false, the content of this message will not be logged on the Plivo infrastructure and the dst value will be masked (e.g., 141XXXXX528). Default is set to true.
* @promise {object} return {@link PlivoGenericMessage} object if success
* @fail {Error} return Error
*/
send(src, dst, text, optionalParams) {
return this.create(src, dst, text, optionalParams);
}
/**
* Create Message
* @method
* @param {string} src - source number
* @param {string} dst - destination number
* @param {string} text - text to send
* @param {object} optionalParams - Optional Params to send message
* @param {string} [optionalParams.type] - The type of message. Should be `sms` or `mms`. Defaults to `sms`.
* @param {string} [optionalParams.url] The URL to which with the status of the message is sent.
* @param {string} [optionalParams.method] The method used to call the url. Defaults to POST.
* @param {boolean} [optionalParams.log] If set to false, the content of this message will not be logged on the Plivo infrastructure and the dst value will be masked (e.g., 141XXXXX528). Default is set to true.
* @param {Array} [optionalParams.media_urls] For sending mms, specify the media urls in list of string
* @promise {object} return {@link MessageResponse} object if success
* @fail {Error} return Error
*/
createtest(src, dst, text, optionalParams, powerpackUUID) {
let errors = validate([{
field: 'dst',
value: dst,
validators: ['isRequired']
}]);
if (errors) {
return errors;
}
if (!src && !powerpackUUID) {
let errorText = 'Neither of src or powerpack uuid present, either one is required'
return new Promise(function (resolve, reject) {
reject(new Error(errorText));
});
/**
* Send Message
* @method
* @param {string} src - source number
* @param {string} dst - destination number
* @param {string} text - text to send
* @param {object} optionalParams - Optional Params to send message
* @param {string} [optionalParams.type] - The type of message. Should be `sms` or `mms`. Defaults to `sms`.
* @param {string} [optionalParams.url] The URL to which with the status of the message is sent.
* @param {string} [optionalParams.method] The method used to call the url. Defaults to POST.
* @param {list} [optionalParams.media_urls] For sending mms, specify the media urls in list of string
* @param {boolean} [optionalParams.log] If set to false, the content of this message will not be logged on the Plivo infrastructure and the dst value will be masked (e.g., 141XXXXX528). Default is set to true.
* @promise {object} return {@link PlivoGenericMessage} object if success
* @fail {Error} return Error
*/
send(src, dst, text, optionalParams) {
return this.create(src, dst, text, optionalParams);
}
if (src && powerpackUUID) {
let errorText = 'Either of src or powerpack uuid, both of them are present'
return new Promise(function (resolve, reject) {
reject(new Error(errorText));
})
}
/**
* Create Message
* @method
* @param {string} src - source number
* @param {string} dst - destination number
* @param {string} text - text to send
* @param {object} optionalParams - Optional Params to send message
* @param {string} [optionalParams.type] - The type of message. Should be `sms` or `mms`. Defaults to `sms`.
* @param {string} [optionalParams.url] The URL to which with the status of the message is sent.
* @param {string} [optionalParams.method] The method used to call the url. Defaults to POST.
* @param {boolean} [optionalParams.log] If set to false, the content of this message will not be logged on the Plivo infrastructure and the dst value will be masked (e.g., 141XXXXX528). Default is set to true.
* @param {Array} [optionalParams.media_urls] For sending mms, specify the media urls in list of string
* @promise {object} return {@link MessageResponse} object if success
* @fail {Error} return Error
*/
create(src, dst, text, optionalParams, powerpackUUID) {
let errors = validate([{
field: 'dst',
value: dst,
validators: ['isRequired']
}]);
let params = optionalParams || {};
if (src) {
params.src = src;
}
params.dst = _.isArray(dst) ? _.join(dst, '<') : dst;
params.text = text;
if (powerpackUUID) {
params.powerpackUUID = powerpackUUID;
}
if (errors) {
return errors;
}
let client = this[clientKey];
let idField = this[idKey];
let action = this[actionKey] + (this.id ? this.id + '/' : '');
if (!src && !powerpackUUID) {
let errorText = 'Neither of src or powerpack uuid present, either one is required'
return new Promise(function(resolve, reject) {
reject(new Error(errorText));
});
}
return new Promise((resolve, reject) => {
client('POST', action, params)
.then(response => {
resolve(new MessageResponse(response.body, idField));
if (src && powerpackUUID) {
let errorText = 'Either of src or powerpack uuid, both of them are present'
return new Promise(function(resolve, reject) {
reject(new Error(errorText));
})
}
let params = optionalParams || {};
if (src) {
params.src = src;
}
params.dst = _.isArray(dst) ? _.join(dst, '<') : dst;
params.text = text;
if (powerpackUUID) {
params.powerpackUUID = powerpackUUID;
}
let client = this[clientKey];
let idField = this[idKey];
let action = this[actionKey] + (this.id ? this.id + '/' : '');
return new Promise((resolve, reject) => {
client('POST', action, params)
.then(response => {
resolve(new MessageResponse(response.body, idField));
})
.catch(error => {
reject(error);
});
})
.catch(error => {
reject(error);
});
})
}
/**
* Get Message by given id
* @method
* @param {string} id - id of message
* @promise {object} return {@link Message} object if success
* @fail {Error} return Error
*/
get(id) {
let errors = validate([{
field: 'id',
value: id,
validators: ['isRequired']
}]);
if (errors) {
return errors;
}
return super.get(id);
}
/**
* Get Message by given id
* @method
* @param {string} id - id of message
* @promise {object} return {@link Message} object if success
* @fail {Error} return Error
*/
get(id) {
let errors = validate([{
field: 'id',
value: id,
validators: ['isRequired']
}]);
listMedia(messageUUID) {
return new Message(this[clientKey], {
id: messageUUID
}).listMedia();
}
if (errors) {
return errors;
}
}
let client = this[clientKey];
let action = this[actionKey];
return new Promise((resolve, reject) => {
if (action !== '' && !id) {
reject(new Error(this[idKey] + ' must be set'));
}
client('GET', action + (id ? id + '/' : ''))
.then(response => {
resolve(new MessageGetResponse(response.body, client));
})
.catch(error => {
reject(error);
});
});
}
list(params) {
let client = this[clientKey];
let action = this[actionKey];
return new Promise((resolve, reject) => {
client('GET', action, params)
.then(response => {
let objects = [];
Object.defineProperty(objects, 'meta', {
value: response.body.meta,
enumerable: true
});
response.body.objects.forEach(item => {
objects.push(new MessageListResponse(item, client));
});
resolve(objects);
})
.catch(error => {
reject(error);
});
});
}
listMedia(messageUUID) {
return new Message(this[clientKey], {
id: messageUUID
}).listMedia();
}
}

View file

@ -1,10 +1,35 @@
import {extend, validate} from '../utils/common.js';
import {PlivoResource, PlivoResourceInterface} from '../base';
import {
PlivoResource,
PlivoResourceInterface
} from '../base';
import {
extend,
validate
} from '../utils/common.js';
const clientKey = Symbol();
const action = 'Number/';
const idField = 'number';
export class BuyNumberResponse {
constructor(params) {
params = params || {};
this.apiId = params.apiId;
this.numbers = params.numbers;
this.status = params.status;
}
}
export class UpdateNumberResponse {
constructor(params) {
params = params || {};
this.apiId = params.apiId;
this.message = params.message;
}
}
/**
* Represents a PhoneNumber
* @constructor
@ -12,29 +37,29 @@ const idField = 'number';
* @param {object} [data] - data of call
*/
export class PhoneNumber extends PlivoResource {
constructor(client, data = {}) {
super('PhoneNumber/', PhoneNumber, idField, client);
constructor(client, data = {}) {
super('PhoneNumber/', PhoneNumber, idField, client);
if (idField in data) {
this.id = data[idField];
if (idField in data) {
this.id = data[idField];
}
extend(this, data);
this[clientKey] = client;
}
extend(this, data);
this[clientKey] = client;
}
/**
* Buy Phone Number
* @method
* @param {string} appId - app id
* @promise {@link PlivoGenericResponse} return PlivoGenericResponse Object if success
* @fail {Error} return Error
*/
buy(appId) {
return new PhoneNumberInterface(this[clientKey], {
id: this.id
}).buy(appId);
}
/**
* Buy Phone Number
* @method
* @param {string} appId - app id
* @promise {@link PlivoGenericResponse} return PlivoGenericResponse Object if success
* @fail {Error} return Error
*/
buy(appId) {
return new PhoneNumberInterface(this[clientKey], {
id: this.id
}).buy(appId);
}
}
/**
@ -45,27 +70,37 @@ export class PhoneNumber extends PlivoResource {
* @param {string} [data.test] - test data
*/
export class PhoneNumberInterface extends PlivoResourceInterface {
constructor(client, data = {}) {
super('PhoneNumber/', PhoneNumber, idField, client);
constructor(client, data = {}) {
super('PhoneNumber/', PhoneNumber, idField, client);
extend(this, data);
this[clientKey] = client;
}
/**
* Buy Phone Number
* @method
* @param {string} appId - app id
* @promise {@link PlivoGenericResponse} return PlivoGenericResponse Object if success
* @fail {Error} return Error
*/
buy(appId) {
let params = {};
if (appId) {
params.app_id = appId;
extend(this, data);
this[clientKey] = client;
}
/**
* Buy Phone Number
* @method
* @param {string} appId - app id
* @promise {@link PlivoGenericResponse} return PlivoGenericResponse Object if success
* @fail {Error} return Error
*/
buy(number, appId) {
let params = {};
if (appId) {
params.app_id = appId;
}
let client = this[clientKey];
return new Promise((resolve, reject) => {
client('POST', action + number + '/', params)
.then(response => {
resolve(new BuyNumberResponse(response.body, idField));
})
.catch(error => {
reject(error);
});
});
}
return super.create(params);
}
}
/**
@ -75,38 +110,68 @@ export class PhoneNumberInterface extends PlivoResourceInterface {
* @param {object} [data] - data of call
*/
export class NumberResource extends PlivoResource {
constructor(client, data = {}) {
super(action, NumberResource, idField, client);
constructor(client, data = {}) {
super(action, NumberResource, idField, client);
if (idField in data) {
this.id = data[idField];
if (idField in data) {
this.id = data[idField];
}
extend(this, data);
this[clientKey] = client;
}
extend(this, data);
}
/**
* Unrent Number
* @method
* @promise {boolean} return true if success
* @fail {Error} return Error
*/
unrent() {
return super.delete();
}
/**
* Unrent Number
* @method
* @promise {boolean} return true if success
* @fail {Error} return Error
*/
unrent(number) {
let client = this[clientKey];
let action = 'Number/';
return new Promise((resolve, reject) => {
client('DELETE', action + number + '/')
.then(() => {
resolve(true);
})
.catch(error => {
reject(error);
});
});
}
/**
* Update Number
* @method
* @param {object} params
* @param {string} [params.appId] - app id
* @param {string} [params.subAccount] - auth_id of subaccount
* @param {string} [params.alias] - textual name of number
* @promise {@link NumberResource} return NumberResource Object if success
* @fail {Error} return Error
*/
update(number, params) {
let client = this[clientKey];
let action = 'Number/';
let that = this;
return new Promise((resolve, reject) => {
client('POST', action + number + '/', params)
.then(response => {
extend(that, response.body);
if (params.hasOwnProperty('isVoiceRequest')) {
delete params.isVoiceRequest;
}
extend(that, params);
resolve(new UpdateNumberResponse(that));
})
.catch(error => {
reject(error);
});
});
}
/**
* Update Number
* @method
* @param {object} params
* @param {string} [params.appId] - app id
* @param {string} [params.subAccount] - auth_id of subaccount
* @param {string} [params.alias] - textual name of number
* @promise {@link NumberResource} return NumberResource Object if success
* @fail {Error} return Error
*/
update(params) {
return super.update(params);
}
}
/**
@ -117,125 +182,143 @@ export class NumberResource extends PlivoResource {
*/
export class NumberInterface extends PlivoResourceInterface {
constructor(client) {
super(action, NumberResource, idField, client);
this[clientKey] = client;
}
/**
* Buy Phone Number
* @method
* @param {string} number - number to buy
* @param {string} appId - app id
* @promise {@link PlivoGenericResponse} return PlivoGenericResponse Object if success
* @fail {Error} return Error
*/
buy(number, appId) {
let errors = validate([
{field: 'number', value: number, validators: ['isRequired']}
]);
if (errors) {
return errors;
}
return new PhoneNumber(this[clientKey], {
id: number
}).buy(appId);
}
/**
* Add own number from carrier
* @method
* @param {string} numbers - A comma separated list of numbers that need to be added for the carrier.
* @param {string} carrier - The carrier_id of the IncomingCarrier that the number is associated with.
* @param {string} region - region that is associated with the Number
* @param {string} optionaParams - optional params
* @promise {@link PlivoGenericResponse} return PlivoGenericResponse Object if success
* @fail {Error} return Error
*/
addOwnNumber(numbers, carrier, region, optionalParams) {
let errors = validate([
{field: 'numbers', value: numbers, validators: ['isRequired']},
{field: 'carrier', value: carrier, validators: ['isRequired']},
{field: 'region', value: region, validators: ['isRequired']}
]);
if (errors) {
return errors;
}
let params = optionalParams || {};
params.numbers = numbers;
params.carrier = carrier;
params.region = region;
return super.create(params);
}
/**
* Add own number from carrier
* @method
* @param {string} countryISO - The ISO code A2 of the country
* @param {string} optionaParams - optional params
* @promise {@link PhoneNumberInterface} return PhoneNumbers Object if success
* @fail {Error} return Error
*/
search(countryISO, optionalParams) {
let errors = validate([
{field: 'country_iso', value: countryISO, validators: ['isRequired']}
]);
if (errors) {
return errors;
constructor(client) {
super(action, NumberResource, idField, client);
this[clientKey] = client;
}
let params = optionalParams || {};
params.country_iso = countryISO;
return new PhoneNumberInterface(this[clientKey])
.list(params);
}
/**
* Buy Phone Number
* @method
* @param {string} number - number to buy
* @param {string} appId - app id
* @promise {@link PlivoGenericResponse} return PlivoGenericResponse Object if success
* @fail {Error} return Error
*/
buy(number, appId) {
let errors = validate([{
field: 'number',
value: number,
validators: ['isRequired']
}]);
/**
* Update Number
* @method
* @param {string} number - number to update
* @param {object} params
* @param {string} [params.appId] - app id
* @param {string} [params.subAccount] - auth_id of subaccount
* @param {string} [params.alias] - textual name of number
* @promise {@link NumberResource} return NumberResource Object if success
* @fail {Error} return Error
*/
update(number, params) {
let errors = validate([
{field: 'number', value: number, validators: ['isRequired']}
]);
if (errors) {
return errors;
if (errors) {
return errors;
}
return new PhoneNumber(this[clientKey], {
id: number
}).buy(number, appId);
}
return new NumberResource(this[clientKey], {
id: number
}).update(params);
}
/**
* Unrent Number
* @method
* @param {string} number - number to unrent
* @promise {boolean} return true if success
* @fail {Error} return Error
*/
unrent(number) {
let errors = validate([
{field: 'number', value: number, validators: ['isRequired']}
]);
/**
* Add own number from carrier
* @method
* @param {string} numbers - A comma separated list of numbers that need to be added for the carrier.
* @param {string} carrier - The carrier_id of the IncomingCarrier that the number is associated with.
* @param {string} region - region that is associated with the Number
* @param {string} optionaParams - optional params
* @promise {@link PlivoGenericResponse} return PlivoGenericResponse Object if success
* @fail {Error} return Error
*/
addOwnNumber(numbers, carrier, region, optionalParams) {
let errors = validate([{
field: 'numbers',
value: numbers,
validators: ['isRequired']
},
{
field: 'carrier',
value: carrier,
validators: ['isRequired']
},
{
field: 'region',
value: region,
validators: ['isRequired']
}
]);
if (errors) {
return errors;
if (errors) {
return errors;
}
let params = optionalParams || {};
params.numbers = numbers;
params.carrier = carrier;
params.region = region;
return super.create(params);
}
return new NumberResource(this[clientKey], {
id: number
}).unrent();
}
}
/**
* Add own number from carrier
* @method
* @param {string} countryISO - The ISO code A2 of the country
* @param {string} optionaParams - optional params
* @promise {@link PhoneNumberInterface} return PhoneNumbers Object if success
* @fail {Error} return Error
*/
search(countryISO, optionalParams) {
let errors = validate([{
field: 'country_iso',
value: countryISO,
validators: ['isRequired']
}]);
if (errors) {
return errors;
}
let params = optionalParams || {};
params.country_iso = countryISO;
return new PhoneNumberInterface(this[clientKey]).list(countryISO, params);
}
/**
* Update Number
* @method
* @param {string} number - number to update
* @param {object} params
* @param {string} [params.appId] - app id
* @param {string} [params.subAccount] - auth_id of subaccount
* @param {string} [params.alias] - textual name of number
* @promise {@link NumberResource} return NumberResource Object if success
* @fail {Error} return Error
*/
update(number, params) {
let errors = validate([{
field: 'number',
value: number,
validators: ['isRequired']
}]);
if (errors) {
return errors;
}
return new NumberResource(this[clientKey], {
id: number
}).update(number, params);
}
/**
* Unrent Number
* @method
* @param {string} number - number to unrent
* @promise {boolean} return true if success
* @fail {Error} return Error
*/
unrent(number) {
let errors = validate([{
field: 'number',
value: number,
validators: ['isRequired']
}]);
if (errors) {
return errors;
}
return new NumberResource(this[clientKey], {
id: number
}).unrent(number);
}
}

View file

@ -1,12 +1,44 @@
import { extend, validate } from '../utils/common.js';
import { PlivoResource, PlivoResourceInterface } from '../base';
import { PhloMultiPartyCall, PhloMultiPartyCallInterface } from "../resources/phloMultipartyCall";
import * as _ from "lodash";
import {
PhloMultiPartyCall,
PhloMultiPartyCallInterface
} from "../resources/phloMultipartyCall";
import {
PlivoResource,
PlivoResourceInterface
} from '../base';
import {
extend,
validate
} from '../utils/common.js';
const clientKey = Symbol();
const action = 'phlo/';
const idField = 'phloUuid';
export class RunPHLOResponse {
constructor(params) {
params = params || {};
this.apiId = params.apiId;
this.phloId = params.phloId;
this.message = params.message;
}
}
export class RetrievePHLOResponse {
constructor(params) {
params = params || {};
this.apiId = params.apiId;
this.phloId = params.phloId;
this.name = params.name;
this.createdOn = params.createdOn;
}
}
/**
* Represents a Phlo
* @constructor
@ -14,39 +46,58 @@ const idField = 'phloUuid';
* @param {object} [data] - data of phlo
*/
export class Phlo extends PlivoResource {
constructor(client, data = {}) {
super(action, Phlo, idField, client);
extend(this, data);
constructor(client, data = {}) {
super(action, Phlo, idField, client);
extend(this, data);
this.client = client;
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;
};
// 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);
}
this[clientKey] = client;
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) {
/**
* 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;
let client = this[clientKey];
action = action == null ? this[actionKey] : action;
//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, '');
}
return new Promise((resolve, reject) => {
client('POST', action, params)
.then(response => {
resolve(new RunPHLOResponse(response.body, idField));
})
.catch(error => {
reject(error);
});
});
}
}
@ -58,37 +109,52 @@ export class Phlo extends PlivoResource {
*/
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;
constructor(client, data = {}) {
super(action, Phlo, idField, client);
extend(this, data);
this[clientKey] = client;
}
let params = {
phlo_id: id
};
/**
* 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) {
// Url pattern for getting phlo resource by id
// https://phlorunner.plivo.com/v1/phlo/{phlo_id}
return super.get(id, params);
}
}
//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}
let client = this[clientKey];
return new Promise((resolve, reject) => {
if (action !== '' && !id) {
reject(new Error(this[idKey] + ' must be set'));
}
client('GET', action + (id ? id + '/' : ''), params)
.then(response => {
resolve(new RetrievePHLOResponse(response.body, client));
})
.catch(error => {
reject(error);
});
});
}
}

View file

@ -1,5 +1,11 @@
import { extend, validate } from '../utils/common.js';
import { PlivoResource, PlivoResourceInterface } from '../base';
import {
PlivoResource,
PlivoResourceInterface
} from '../base';
import {
extend,
validate
} from '../utils/common.js';
const clientKey = Symbol();
const action = 'Phlo/';
@ -11,6 +17,14 @@ const idField = 'phloUuid';
* @param {function} client - make api call
* @param {object} [data] - data of phlo
*/
export class UpdateMemberResponse {
constructor(params) {
params = params || {};
this.apiId = params.apiId;
this.error = params.error;
}
}
export class PhloMultiPartyCallMember extends PlivoResource {
constructor(client, data = {}) {
@ -51,7 +65,16 @@ export class PhloMultiPartyCallMember extends PlivoResource {
// 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, '');
let client = this[clientKey];
return new Promise((resolve, reject) => {
client('POST', task, params)
.then(response => {
resolve(new UpdateMemberResponse(response.body, idField));
})
.catch(error => {
reject(error);
});
});
}
}
@ -79,7 +102,11 @@ export class PhloMultiPartyCallMemberInterface extends PlivoResourceInterface {
return errors;
}
return new PhloMultiPartyCallMember(this.client, { phloId: phloId, nodeId: nodeId, memberAddress: memberAddress });
return new PhloMultiPartyCallMember(this.client, {
phloId: phloId,
nodeId: nodeId,
memberAddress: memberAddress
});
}
}
}

View file

@ -1,10 +1,40 @@
import { extend, validate } from '../utils/common.js';
import { PlivoResource, PlivoResourceInterface } from '../base';
import { PhloMultiPartyCallMemberInterface, PhloMultiPartyCallMember } from './phloMultiPartyCallMember';
import {
PhloMultiPartyCallMember,
PhloMultiPartyCallMemberInterface
} from './phloMultiPartyCallMember';
import {
PlivoResource,
PlivoResourceInterface
} from '../base';
import {
extend,
validate
} from '../utils/common.js';
const clientKey = Symbol();
const idField = 'nodeId';
export class UpdateMultipartyCallResponse {
constructor(params) {
params = params || {};
this.apiId = params.apiId;
this.error = params.error;
}
}
export class RetrieveMultipartyCallResponse {
constructor(params) {
params = params || {};
this.apiId = params.apiId;
this.nodeId = params.nodeId;
this.phloId = params.phloId;
this.name = params.name;
this.nodeType = params.nodeType;
this.createdOn = params.createdOn;
}
}
export class PhloMultiPartyCall extends PlivoResource {
constructor(client, data = {}) {
let action = 'phlo/' + data.phloId + '/multi_party_call/';
@ -12,16 +42,25 @@ export class PhloMultiPartyCall extends PlivoResource {
extend(this, data);
this.action = action;
this.client = client;
this[clientKey] = client;
// Define member getters
let item = this;
this.member = function (memberAddress) {
let dd = new PhloMultiPartyCallMember(client, { phloId: item.phloId, nodeId: item.nodeId, memberAddress: memberAddress });
this.member = function(memberAddress) {
let dd = new PhloMultiPartyCallMember(client, {
phloId: item.phloId,
nodeId: item.nodeId,
memberAddress: memberAddress
});
return dd;
};
this.member.get = function (memberAddress) {
let dd = new PhloMultiPartyCallMemberInterface(client, { phloId: item.phloId, nodeId: item.nodeId, memberAddress: memberAddress });
this.member.get = function(memberAddress) {
let dd = new PhloMultiPartyCallMemberInterface(client, {
phloId: item.phloId,
nodeId: item.nodeId,
memberAddress: memberAddress
});
return dd.get(item.phloId, item.nodeId, memberAddress);
}
@ -53,7 +92,6 @@ export class PhloMultiPartyCall extends PlivoResource {
action: action
};
// Url pattern for mp call update
// https://phlorunnner.plivo.com/v1/phlo/{phlo_id}/{node_type}/{node_id}
let task = this.action + this.nodeId;
@ -65,8 +103,16 @@ export class PhloMultiPartyCall extends PlivoResource {
params.trigger_source = triggerSource;
}
return super.executeAction(task, 'POST', params, '');
let client = this[clientKey];
return new Promise((resolve, reject) => {
client('POST', task, params)
.then(response => {
resolve(new UpdateMultipartyCallResponse(response.body, idField));
})
.catch(error => {
reject(error);
});
});
}
}
@ -78,15 +124,16 @@ export class PhloMultiPartyCallInterface extends PlivoResourceInterface {
let action = 'phlo/' + data.phloId + '/multi_party_call/';
super(action, PhloMultiPartyCall, idField, client);
extend(this, data);
this[clientKey] = client;
}
/**
* Get A Phlo Detail
* @method
* @param {string} id - phlo uuid to get information of.
* @promise {object} returns Phlo Object
* @fail {Error} returns Error
*/
* Get A Phlo Detail
* @method
* @param {string} id - phlo uuid to get information of.
* @promise {object} returns Phlo Object
* @fail {Error} returns Error
*/
get(phloId, id) {
//Validate id first
@ -109,8 +156,18 @@ export class PhloMultiPartyCallInterface extends PlivoResourceInterface {
// Url pattern for getting phlo resource by id
// https://phlorunner.plivo.com/v1/phlo/{phlo_id}
// console.log('get multi party call with ', id, params);
return super.get(id, params);
let client = this[clientKey];
return new Promise((resolve, reject) => {
if (action !== '' && !id) {
reject(new Error(this[idKey] + ' must be set'));
}
client('GET', action + (id ? id + '/' : ''), params)
.then(response => {
resolve(new RetrieveMultipartyCallResponse(client, response.body));
})
.catch(error => {
reject(error);
});
});
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,66 +1,102 @@
import {extend, validate} from '../utils/common.js';
import {PlivoResource, PlivoResourceInterface} from '../base';
import {
PlivoResource,
PlivoResourceInterface
} from '../base';
import {
extend,
validate
} from '../utils/common.js';
const clientKey = Symbol();
const action = 'Pricing/';
const idField = 'countryIso';
/**
* Represents a Pricing
* @constructor
* @param {function} client - make api call
* @param {object} [data] - data of call
*/
* Represents a Pricing
* @constructor
* @param {function} client - make api call
* @param {object} [data] - data of call
*/
export class PricingResponse {
constructor(params) {
params = params || {};
this.apiId = params.apiId;
this.country = params.country;
this.countryCode = params.countryCode;
this.countryIso = params.countryIso;
this.message = params.message;
this.mms = params.mms;
this.phoneNumbers = params.phoneNumbers;
this.voice = params.voice;
}
}
export class Pricing extends PlivoResource {
constructor(client, data = {}) {
super(action, Pricing, idField, client);
extend(this, data);
super(action, Pricing, idField, client);
extend(this, data);
this[clientKey] = client
}
/**
* Get pricings by country
* @method
* @promise {object} return {@link PlivoGenericResponse} object
* @fail {Error} return Error
*/
/**
* Get pricings by country
* @method
* @promise {object} return {@link PlivoGenericResponse} object
* @fail {Error} return Error
*/
get() {
let params = {
country_iso: this.id
};
return super.executeAction('', 'GET', params);
let params = {
country_iso: this.id
};
let client = this[clientKey];
return new Promise((resolve, reject) => {
client('GET', action, params)
.then(response => {
resolve(new PricingResponse(response.body, idField));
})
.catch(error => {
reject(error);
});
});
}
}
/**
* Represents a Pricing Interface
* @constructor
* @param {function} client - make api call
* @param {object} [data] - data of call
*/
* Represents a Pricing Interface
* @constructor
* @param {function} client - make api call
* @param {object} [data] - data of call
*/
export class PricingInterface extends PlivoResourceInterface {
constructor(client, data = {}) {
super(action, Pricing, idField, client);
extend(this, data);
super(action, Pricing, idField, client);
extend(this, data);
this[clientKey] = client;
this[clientKey] = client;
}
/**
* Get pricings by country
* @method
* @param {string} countryISO - country iso to get pricings
* @promise {object} return {@link PlivoGenericResponse} object
* @fail {Error} return Error
*/
/**
* Get pricings by country
* @method
* @param {string} countryISO - country iso to get pricings
* @promise {object} return {@link PlivoGenericResponse} object
* @fail {Error} return Error
*/
get(countryISO) {
let errors = validate([
{field: 'country_iso', value: countryISO, validators: ['isRequired']}
]);
let errors = validate([{
field: 'country_iso',
value: countryISO,
validators: ['isRequired']
}]);
if (errors) {
return errors;
}
return new Pricing(this[clientKey], {
id: countryISO
}).get();
if (errors) {
return errors;
}
return new Pricing(this[clientKey], {
id: countryISO
}).get();
}
}
}

View file

@ -1,73 +1,141 @@
import {extend, validate} from '../utils/common.js';
import {PlivoResource, PlivoResourceInterface} from '../base';
import {
PlivoResource,
PlivoResourceInterface
} from '../base';
import {
extend,
validate
} from '../utils/common.js';
const clientKey = Symbol();
const action = 'Recording/';
const idField = 'recordingId';
export class RetrieveRecordingResponse {
constructor(params) {
params = params || {};
this.addTime = params.addTime;
this.apiId = params.apiId;
this.callUuid = params.callUuid;
this.conferenceName = params.conferenceName;
this.recordingDurationMs = params.recordingDurationMs;
this.recordingEndMs = params.recordingEndMs;
this.recordingFormat = params.recordingFormat;
this.recordingId = params.recordingId;
this.recordingStartMs = params.recordingStartMs;
this.recordingType = params.recordingType;
this.recordingUrl = params.recordingUrl;
this.resourceUri = params.resourceUri;
}
}
export class ListRecordingResponse {
constructor(params) {
params = params || {};
this.addTime = params.addTime;
this.apiId = params.apiId;
this.callUuid = params.callUuid;
this.conferenceName = params.conferenceName;
this.recordingDurationMs = params.recordingDurationMs;
this.recordingEndMs = params.recordingEndMs;
this.recordingFormat = params.recordingFormat;
this.recordingId = params.recordingId;
this.recordingStartMs = params.recordingStartMs;
this.recordingType = params.recordingType;
this.recordingUrl = params.recordingUrl;
this.resourceUri = params.resourceUri;
}
}
/**
* Represents a Recording
* @constructor
* @param {function} client - make api call
* @param {object} [data] - data of call
*/
* Represents a Recording
* @constructor
* @param {function} client - make api call
* @param {object} [data] - data of call
*/
export class Recording extends PlivoResource {
constructor(client, data = {}) {
super(action, Recording, idField, client);
if (idField in data) {
this.id = data[idField];
}
extend(this, data);
super(action, Recording, idField, client);
this[clientKey] = client
if (idField in data) {
this.id = data[idField];
}
extend(this, data);
}
/**
* Delete recording
* @method
* @promise {boolean} return true if success
* @fail {Error} return Error
*/
delete() {
let params = {};
params.isVoiceRequest = 'true';
return super.delete(params);
/**
* Delete recording
* @method
* @promise {boolean} return true if success
* @fail {Error} return Error
*/
delete(id) {
let client = this[clientKey];
return new Promise((resolve, reject) => {
client('DELETE', action + id + '/')
.then(() => {
resolve(true);
})
.catch(error => {
reject(error);
});
});
}
}
/**
* Represents a Recording Interface
* @constructor
* @param {function} client - make api call
* @param {object} [data] - data of call
*/
* Represents a Recording Interface
* @constructor
* @param {function} client - make api call
* @param {object} [data] - data of call
*/
export class RecordingInterface extends PlivoResourceInterface {
constructor(client, data = {}) {
super(action, Recording, idField, client);
extend(this, data);
super(action, Recording, idField, client);
extend(this, data);
this[clientKey] = client;
this[clientKey] = client;
}
/**
* Get recording by id
* @method
* @param {string} id - id to get recording information
* @promise {object} return {@link Pricing} object
* @fail {Error} return Error
*/
/**
* Get recording by id
* @method
* @param {string} id - id to get recording information
* @promise {object} return {@link Pricing} object
* @fail {Error} return Error
*/
get(id) {
let errors = validate([
{field: 'id', value: id, validators: ['isRequired']}
]);
let errors = validate([{
field: 'id',
value: id,
validators: ['isRequired']
}]);
if (errors) {
return errors;
}
let params = {};
params.isVoiceRequest = 'true';
return super.get(id, params);
if (errors) {
return errors;
}
let params = {};
params.isVoiceRequest = 'true';
let client = this[clientKey];
return new Promise((resolve, reject) => {
if (action !== '' && !id) {
reject(new Error(this[idKey] + ' must be set'));
}
client('GET', action + (id ? id + '/' : ''), params)
.then(response => {
resolve(new RetrieveRecordingResponse(response.body, client));
})
.catch(error => {
reject(error);
});
});
}
/**
@ -80,28 +148,47 @@ export class RecordingInterface extends PlivoResourceInterface {
* @param {string} [params.limit] - Display no of results per page
* @param {string} [params.offset] - No of value items by which results should be offset
*/
list(params= {}) {
params.isVoiceRequest = 'true';
return super.list(params);
list(params = {}) {
params.isVoiceRequest = 'true';
let client = this[clientKey];
return new Promise((resolve, reject) => {
client('GET', action, params)
.then(response => {
let objects = [];
Object.defineProperty(objects, 'meta', {
value: response.body.meta,
enumerable: true
});
response.body.objects.forEach(item => {
objects.push(new ListRecordingResponse(item, client));
});
resolve(objects);
})
.catch(error => {
reject(error);
});
});
}
/**
* Delete recording by id
* @method
* @param {string} id - id to delete recording
* @promise {boolean} return true if success
* @fail {Error} return Error
*/
/**
* Delete recording by id
* @method
* @param {string} id - id to delete recording
* @promise {boolean} return true if success
* @fail {Error} return Error
*/
delete(id) {
let errors = validate([
{field: 'id', value: id, validators: ['isRequired']}
]);
let errors = validate([{
field: 'id',
value: id,
validators: ['isRequired']
}]);
if (errors) {
return errors;
}
return new Recording(this[clientKey], {
id: id
}).delete();
if (errors) {
return errors;
}
return new Recording(this[clientKey], {
id: id
}).delete(id);
}
}
}

View file

@ -38,8 +38,8 @@ export function AccessToken(authId, authToken, username, validityOptions = {}, u
this.uid = uid || this.username + "-" + (new Date()).getTime();
}
AccessToken.prototype = {
addVoiceGrants: function(incoming = false, outgoing = false) {
AccessToken.prototype.addVoiceGrants= function(incoming = false, outgoing = false) {
this.grants = {
voice: {
incoming_allow: incoming,
@ -47,7 +47,8 @@ AccessToken.prototype = {
}
};
},
}
AccessToken.prototype = {
toJwt: function() {
let payload = {
jti: this.uid,

View file

@ -2,6 +2,7 @@ var qs = require('querystring');
var xmlBuilder = require('xmlbuilder');
var util = require('util');
var plivoUtils = require('./../rest/utils');
import * as Exceptions from './exceptions';
var jsonStringifier = require('./jsonStrinfigier');

View file

@ -58,6 +58,7 @@
"test": "gulp"
},
"dependencies": {
"@types/node": "^14.14.14",
"base-64": "^0.1.0",
"build-url": "^1.0.10",
"jsonwebtoken": "^8.5.1",

View file

@ -4,9 +4,70 @@
* @param {function} client - make api call
* @param {object} [data] - data of call
*/
export class GetAccountDetails {
constructor(params: object);
accountType: string;
address: string;
apiId: string;
autoRecharge: string;
billingMode: string;
cashCredits: string;
city: string;
name: string;
resourceUri: string;
state: string;
timezone: string;
}
export class CreateSubAccountResponse {
constructor(params: object);
apiId: string;
authId: string;
authToken: string;
message: string;
}
export class UpdateSubAccountDetails {
constructor(params: object);
apiId: stringy;
message: string;
}
export class UpdateAccountDetailsResponse {
constructor(params: object);
apiId: string;
message: string;
}
export class GetSubAccountDetails {
constructor(params: object);
account: string;
apiId: string;
authId: string;
authToken: string;
created: string;
enabled: string;
modified: string;
name: string;
resourceUri: string;
}
export class Subaccount extends PlivoResource {
constructor(client: any, data?: {});
id: any;
/**
* update subaccount
* @method
* @param {string} name - name of subaccount
* @param {boolean} enabled - make account enable or disable
* @promise {Subaccount} return object of subaccount
* @fail {Error} return Error
*/
update(name: string, enabled: boolean): Promise<UpdateSubAccountDetails>;
/**
* delete subaccount
* @method
* @param {boolean} cascade - delete associated applications, phonenumbers & endpoints
* @promise {boolean} return true if subaccount deleted
* @fail {Error} return Error
*/
delete(cascade: any): Promise<unknown>;
[clientKey]: any;
}
/**
* Represents a Subaccount Interface
@ -16,6 +77,23 @@ export class Subaccount extends PlivoResource {
*/
export class SubaccountInterface extends PlivoResourceInterface {
constructor(client: any, data?: {});
/**
* get subaccount by id
* @method
* @param {string} id - id of subaccount
* @promise {Subaccount} return object of subaccount
* @fail {Error} return Error
*/
get(id: string): Promise<GetSubAccountDetails>;
/**
* create subaccount
* @method
* @param {string} name - name of subaccount
* @param {boolean} enabled - enable or disable subaccount
* @promise {PlivoGenericResponse} return object of PlivoGenericObject
* @fail {Error} return Error
*/
create(name: string, enabled: boolean): Promise<CreateSubAccountResponse>;
/**
* update subaccount
* @method
@ -53,6 +131,7 @@ export class Account extends PlivoResource {
* @fail {Error} return Error
*/
get(): Promise<any>;
update(params: any): Promise<UpdateAccountDetailsResponse>;
[clientKey]: any;
}
/**
@ -63,6 +142,13 @@ export class Account extends PlivoResource {
*/
export class AccountInterface extends PlivoResourceInterface {
constructor(client: any, data?: {});
/**
* get account detail
* @method
* @promise {PlivoGenericResponse} return PlivoGenericResponse object
* @fail {Error} return Error
*/
get(): Promise<GetAccountDetails>;
/**
* update account detail
* @method
@ -80,7 +166,7 @@ export class AccountInterface extends PlivoResourceInterface {
}): Promise<any>;
[clientKey]: any;
}
import { PlivoResource } from "../base.js";
import { PlivoResourceInterface } from "../base.js";
import { PlivoResource } from "../base";
declare const clientKey: unique symbol;
import { PlivoResourceInterface } from "../base";
export {};

View file

@ -1,21 +1,112 @@
/**
* Represents a Application
* @constructor
* @param {function} client - make api call
* @param {object} [data] - data of call
*/
* Represents a Application
* @constructor
* @param {function} client - make api call
* @param {object} [data] - data of call
*/
export class UpdateApplicationResponse {
constructor(params: object);
apiId: string;
message: string;
}
export class CreateApplicationResponse {
constructor(params: object);
apiId: string;
appId: string;
message: string;
}
export class RetrieveApplicationResponse {
constructor(params: object);
answerMethod: string;
answerUrl: string;
apiId: string;
appId: string;
appName: string;
applicationType: string;
defaultApp: string;
defaultEndpointApp: string;
enabled: string;
fallbackAnswerUrl: string;
fallbackMethod: string;
hangupMethod: string;
logIncomingMessage: string;
messageMethod: string;
resourceUri: string;
sipUri: string;
subAccount: string;
}
export class ListAllApplicationResponse {
constructor(params: object);
answerMethod: string;
answerUrl: string;
appId: string;
appName: string;
applicationType: string;
defaultApp: string;
defaultEndpointApp: string;
enabled: string;
fallbackAnswerUrl: string;
fallbackMethod: string;
hangupMethod: string;
logIncomingMessage: string;
messageMethod: string;
resourceUri: string;
sipUri: string;
subAccount: string;
}
export class Application extends PlivoResource {
constructor(client: any, data?: {});
id: any;
[clientKey]: any;
}
/**
* Represents a Application interface
* @constructor
* @param {function} client - make api call
* @param {object} [data] - data of call
*/
* Represents a Application interface
* @constructor
* @param {function} client - make api call
* @param {object} [data] - data of call
*/
export class ApplicationInterface extends PlivoResourceInterface {
constructor(client: any, data?: {});
/**
* get application by given id
* @method
* @param {string} id - id of application
* @promise {object} return {@link Application} object
* @fail {Error} return Error
*/
get(id: string): Promise<RetrieveApplicationResponse>;
/**
* list applications
* @method
* @param {object} params - params to list applications
* @param {string} [params.subaccount] - ID of the subaccount if present
* @param {integer} [params.limit] - To display no of results per page
* @param {integer} [params.offset] - No of value items by which results should be offset
*/
list(params?: {}): Promise<ListAllApplicationResponse>;
/**
* create Application
* @method
* @param {string} appName - name of application
* @param {object} params - params to create application
* @param {string} [params.answerUrl] - answer url
* @param {string} [params.appName] The name of your application
* @param {string} [params.answerUrl] The URL invoked by Plivo when a call executes this application.
* @param {string} [params.answerMethod] The method used to call the answer_url. Defaults to POST.
* @param {string} [params.hangupUrl] The URL that is notified by Plivo when the call hangs up.
* @param {string} [params.hangupMethod] The method used to call the hangup_url. Defaults to POST
* @param {string} [params.fallbackAnswerUrl] Invoked by Plivo only if answer_url is unavailable or the XML response is invalid. Should contain a XML response.
* @param {string} [params.fallbackMethod] The method used to call the fallback_answer_url. Defaults to POST.
* @param {string} [params.messageUrl] The URL that is notified by Plivo when an inbound message is received. Defaults not set.
* @param {string} [params.messageMethod] The method used to call the message_url. Defaults to POST.
* @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
*/
create(appName: string, params?: {}): Promise<CreateApplicationResponse>;
/**
* update Application
* @method
@ -66,7 +157,7 @@ export class ApplicationInterface extends PlivoResourceInterface {
}): Promise<any>;
[clientKey]: any;
}
import { PlivoResource } from "../base.js";
import { PlivoResourceInterface } from "../base.js";
import { PlivoResource } from "../base";
declare const clientKey: unique symbol;
import { PlivoResourceInterface } from "../base";
export {};

View file

@ -1,3 +1,116 @@
export class CallTransferResponse {
constructor(params: object);
apiId: string;
callUuids: object;
message: string;
}
export class ListAllQueuedCalls {
constructor(params: object);
apiId: string;
calls: object;
}
export class ListAllLiveCallResponse {
constructor(params: object);
apiId: string;
callUuid: object;
}
export class CreateCallResponse {
constructor(params: object);
apiId: string;
message: string;
requestUuid: string;
}
export class GetQueuedCallResponse {
constructor(params: object);
apiId: string;
direction: string;
from: string;
callStatus: string;
to: string;
callerName: string;
callUuid: string;
requestUuid: string;
}
export class GetLiveCallResponse {
constructor(params: any);
apiId: string;
callStatus: string;
callUuid: string;
callerName: string;
direction: string;
from: string;
requestUuid: string;
sessionStart: string;
to: string;
}
export class RetrieveCallResponse {
constructor(params: object);
apiId: string;
answerTime: string;
billDuration: string;
billedDuration: string;
callDirection: string;
callDuration: string;
callState: string;
callUuid: string;
conferenceUuid: string;
endTime: string;
fromNumber: string;
hangupCauseCode: string;
hangupCauseName: string;
hangupSource: string;
initiationTime: string;
parentCallUuid: string;
resourceUri: string;
toNumber: string;
totalAmount: string;
totalRate: string;
}
export class ListAllCallsResponse {
constructor(params: object);
apiId: string;
answerTime: string;
billDuration: string;
billedDuration: string;
callDirection: string;
callDuration: string;
callState: string;
callUuid: string;
conferenceUuid: string;
endTime: string;
fromNumber: string;
hangupCauseCode: string;
hangupCauseName: string;
hangupSource: string;
initiationTime: string;
parentCallUuid: string;
resourceUri: string;
toNumber: string;
totalAmount: string;
totalRate: string;
}
export class StartPlayingMusicResponse {
constructor(params: object);
apiId: string;
message: string;
}
export class StartSpeakingTextResponse {
constructor(params: object);
apiId: string;
message: string;
}
export class SendDigitsResponse {
constructor(params: object);
apiId: string;
message: string;
}
export class RecordCallResponse {
constructor(params: object);
apiId: string;
message: string;
recordingId: string;
url: string;
}
/**
* Represents a Call
* @constructor
@ -5,125 +118,125 @@
* @param {object} [data] - data of call
*/
export class Call extends PlivoResource {
constructor(client: any, data?: {});
id: any;
/**
* hangup call
* @method
* @promise {Boolean} return true if call hung up
* @fail {Error} return Error
*/
hangup(): Promise<any>;
/**
* transfer call
* @method
* @param {object} params - optional params to transfer a call
* @param {string} [params.legs] aleg, bleg or both Defaults to aleg. aleg will transfer call_uuid ; bleg will transfer the bridged leg (if found) of call_uuid ; both will transfer call_uuid and bridged leg of call_uuid
* @param {string} [params.alegUrl] URL to transfer for aleg, if legs is aleg or both, then aleg_url has to be specified.
* @param {string} [params.alegMethod] HTTP method to invoke aleg_url. Defaults to POST.
* @param {string} [params.blegUrl] URL to transfer for bridged leg, if legs is bleg or both, then bleg_url has to be specified.
* @param {string} [params.blegMethod] HTTP method to invoke bleg_url. Defaults to POST.
* @promise {object} return call object
* @fail {Error} return Error
*/
transfer(params: {
legs: string;
alegUrl: string;
alegMethod: string;
blegUrl: string;
blegMethod: string;
}): Promise<any>;
/**
* record call
* @method
* @param {object} params - to record call
* @promise {object} return PlivoGenericResponse Object
* @fail {Error} return Error
*/
record(params: object): Promise<any>;
/**
* record call
* @method
* @param {object} params - to record call
* @promise {object} return PlivoGenericResponse Object
* @fail {Error} return Error
*/
startRecording(params: object): Promise<any>;
/**
* stop recording call
* @method
* @param {object} params - to stop recording call
* @promise {object} return PlivoGenericResponse Object
* @fail {Error} return Error
*/
stopRecording(params: object): Promise<any>;
/**
* play music for call
* @method
* @param {string} url - url which contains audio to play for call
* @param {object} optionalParams - to stop recording call
* @promise {object} returns PlivoGenericResponse Object
* @fail {Error} returns Error
*/
playMusic(url: string, optionalParams: object): Promise<any>;
/**
* play music for call
* @method
* @param {string} url - url which contains audio to play for call
* @param {object} optionalParams - to stop recording call
* @promise {object} returns PlivoGenericResponse Object
* @fail {Error} returns Error
*/
startPlayingMusic(urls: any, optionalParams: object): Promise<any>;
/**
* stop playing music for call
* @method
* @promise {object} returns PlivoGenericResponse Object
* @fail {Error} returns Error
*/
stopPlayingMusic(): Promise<any>;
/**
* speak text for call
* @method
* @param {string} text - text to speak for call
* @param {object} optionalParams - to speak for call
* @promise {object} returns PlivoGenericResponse Object
* @fail {Error} returns Error
*/
speakText(text: string, optionalParams: object): Promise<any>;
/**
* speak text for call
* @method
* @param {string} text - text to speak for call
* @param {object} optionalParams - to speak for call
* @promise {object} returns PlivoGenericResponse Object
* @fail {Error} returns Error
*/
startSpeakingText(text: string, optionalParams: object): Promise<any>;
/**
* stop speaking text for call
* @method
* @promise {object} returns PlivoGenericResponse Object
* @fail {Error} returns Error
*/
stopSpeakingText(): Promise<any>;
/**
* Send digits on a call
* @method
* @param {number} digits - digits to be send
* @param {object} optionalParams - to send digits for call
* @promise {object} returns PlivoGenericResponse Object
* @fail {Error} returns Error
*/
sendDigits(digits: number, optionalParams: object): Promise<any>;
/**
* Hangup a Call Request
* @method
* @promise {object} returns PlivoGenericResponse Object
* @fail {Error} returns Error
*/
cancel(): Promise<any>;
[clientKey]: any;
constructor(client: any, data ? : {});
id: any;
/**
* hangup call
* @method
* @promise {Boolean} return true if call hung up
* @fail {Error} return Error
*/
hangup(): Promise < any > ;
/**
* transfer call
* @method
* @param {object} params - optional params to transfer a call
* @param {string} [params.legs] aleg, bleg or both Defaults to aleg. aleg will transfer call_uuid ; bleg will transfer the bridged leg (if found) of call_uuid ; both will transfer call_uuid and bridged leg of call_uuid
* @param {string} [params.alegUrl] URL to transfer for aleg, if legs is aleg or both, then aleg_url has to be specified.
* @param {string} [params.alegMethod] HTTP method to invoke aleg_url. Defaults to POST.
* @param {string} [params.blegUrl] URL to transfer for bridged leg, if legs is bleg or both, then bleg_url has to be specified.
* @param {string} [params.blegMethod] HTTP method to invoke bleg_url. Defaults to POST.
* @promise {object} return call object
* @fail {Error} return Error
*/
transfer(params: {
legs: string;
alegUrl: string;
alegMethod: string;
blegUrl: string;
blegMethod: string;
}, callUUID: any): Promise < CallTransferResponse > ;
/**
* record call
* @method
* @param {object} params - to record call
* @promise {object} return PlivoGenericResponse Object
* @fail {Error} return Error
*/
record(params: object): Promise < any > ;
/**
* record call
* @method
* @param {object} params - to record call
* @promise {object} return PlivoGenericResponse Object
* @fail {Error} return Error
*/
startRecording(params: object): Promise < RecordCallResponse > ;
/**
* stop recording call
* @method
* @param {object} params - to stop recording call
* @promise {object} return PlivoGenericResponse Object
* @fail {Error} return Error
*/
stopRecording(params: object): Promise < any > ;
/**
* play music for call
* @method
* @param {string} url - url which contains audio to play for call
* @param {object} optionalParams - to stop recording call
* @promise {object} returns PlivoGenericResponse Object
* @fail {Error} returns Error
*/
playMusic(url: string, optionalParams: object): Promise < any > ;
/**
* play music for call
* @method
* @param {string} url - url which contains audio to play for call
* @param {object} optionalParams - to stop recording call
* @promise {object} returns PlivoGenericResponse Object
* @fail {Error} returns Error
*/
startPlayingMusic(urls: any, optionalParams: object): Promise < StartPlayingMusicResponse > ;
/**
* stop playing music for call
* @method
* @promise {object} returns PlivoGenericResponse Object
* @fail {Error} returns Error
*/
stopPlayingMusic(): Promise < any > ;
/**
* speak text for call
* @method
* @param {string} text - text to speak for call
* @param {object} optionalParams - to speak for call
* @promise {object} returns PlivoGenericResponse Object
* @fail {Error} returns Error
*/
speakText(text: string, optionalParams: object): Promise < any > ;
/**
* speak text for call
* @method
* @param {string} text - text to speak for call
* @param {object} optionalParams - to speak for call
* @promise {object} returns PlivoGenericResponse Object
* @fail {Error} returns Error
*/
startSpeakingText(text: string, optionalParams: object): Promise < StartSpeakingTextResponse > ;
/**
* stop speaking text for call
* @method
* @promise {object} returns PlivoGenericResponse Object
* @fail {Error} returns Error
*/
stopSpeakingText(): Promise < any > ;
/**
* Send digits on a call
* @method
* @param {number} digits - digits to be send
* @param {object} optionalParams - to send digits for call
* @promise {object} returns PlivoGenericResponse Object
* @fail {Error} returns Error
*/
sendDigits(digits: number, optionalParams: object): Promise < SendDigitsResponse > ;
/**
* Hangup a Call Request
* @method
* @promise {object} returns PlivoGenericResponse Object
* @fail {Error} returns Error
*/
cancel(): Promise < any > ;
[clientKey]: any;
}
/**
* Represents a Call Interface
@ -132,129 +245,179 @@ export class Call extends PlivoResource {
* @param {object} [data] - data of call
*/
export class CallInterface extends PlivoResourceInterface {
constructor(client: any, data?: {});
/**
* Hangup A Specific Call
* @method
* @param {string} callUUID - call uuid to hangup call
* @promise {object} returns PlivoGenericResponse Object
* @fail {Error} returns Error
*/
hangup(callUUID: string): Promise<any>;
/**
* Transfer a Call
* @method
* @param {string} callUUID - call uuid to transfer call
* @param {object} params - optional params to transfer a call
* @param {string} [params.legs] aleg, bleg or both Defaults to aleg. aleg will transfer call_uuid ; bleg will transfer the bridged leg (if found) of call_uuid ; both will transfer call_uuid and bridged leg of call_uuid
* @param {string} [params.alegUrl] URL to transfer for aleg, if legs is aleg or both, then aleg_url has to be specified.
* @param {string} [params.alegMethod] HTTP method to invoke aleg_url. Defaults to POST.
* @param {string} [params.blegUrl] URL to transfer for bridged leg, if legs is bleg or both, then bleg_url has to be specified.
* @param {string} [params.blegMethod] HTTP method to invoke bleg_url. Defaults to POST.
* @promise {object} returns PlivoGenericResponse Object
* @fail {Error} returns Error
*/
transfer(callUUID: string, params: {
legs: string;
alegUrl: string;
alegMethod: string;
blegUrl: string;
blegMethod: string;
}): Promise<any>;
/**
* Record a Call
* @method
* @param {string} callUUID - call uuid to record call
* @param {object} optionalParams - optional params to record a call
* @promise {object} returns PlivoGenericResponse Object
* @fail {Error} returns Error
*/
record(callUUID: string, optionalParams: object): Promise<any>;
/**
* Stop Recording a Call
* @method
* @param {string} callUUID - call uuid to stop recording a call
* @param {object} optionalParams - optional params to stop recording a call
* @promise {object} returns PlivoGenericResponse Object
* @fail {Error} returns Error
*/
stopRecording(callUUID: string, optionalParams: object): Promise<any>;
/**
* Play a music file
* @method
* @param {string} callUUID - call uuid to play music file
* @param {string} url - A single URL or a list of comma separated URLs linking to an mp3 or wav file.
* @param {object} optionalParams - optional params to play music file.
* @promise {object} returns PlivoGenericResponse Object
* @fail {Error} returns Error
*/
playMusic(callUUID: string, urls: any, optionalParams: object): Promise<any>;
/**
* Stop Playing a music file
* @method
* @param {string} callUUID - call uuid to stop plaing music file
* @promise {object} returns PlivoGenericResponse Object
* @fail {Error} returns Error
*/
stopPlayingMusic(callUUID: string): Promise<any>;
/**
* Speak text during a call
* @method
* @param {string} callUUID - call uuid to speak text during a call
* @param {string} text - text to be played.
* @param {object} optionalParams - optional params to speak text during a call
* @promise {object} returns PlivoGenericResponse Object
* @fail {Error} returns Error
*/
speakText(callUUID: string, text: string, optionalParams: object): Promise<any>;
/**
* Stop Speaking text during a call
* @method
* @param {string} callUUID - call uuid to stop speaking text during a call
* @param {object} optionalParams - optional params to stop speaking text during a call
* @promise {object} returns PlivoGenericResponse Object
* @fail {Error} returns Error
*/
stopSpeakingText(callUUID: string): Promise<any>;
/**
* Send digits on a call
* @method
* @param {string} callUUID - call uuid to send digits on a call
* @param {number} digits - digits to be send
* @param {object} optionalParams - optional params to send digits
* @promise {object} returns PlivoGenericResponse Object
* @fail {Error} returns Error
*/
sendDigits(callUUID: string, digits: number, optionalParams: object): Promise<any>;
/**
* Hangup a call request
* @method
* @param {string} callUUID - call uuid to send digits on a call
* @promise {object} returns PlivoGenericResponse Object
* @fail {Error} returns Error
*/
cancel(id: any): Promise<any>;
listLiveCalls(params: any): Promise<any>;
getLiveCall(id: any): Promise<any>;
listQueuedCalls(): Promise<any>;
getQueuedCall(id: any): Promise<any>;
[clientKey]: any;
[liveCallInterfaceKey]: LiveCallInterface;
[queuedCallInterfaceKey]: QueuedCallInterface;
constructor(client: any, data ? : {});
/**
* Get A Call Detail
* @method
* @param {string} id - call uuid to get information of.
* @promise {object} returns Call Object
* @fail {Error} returns Error
*/
get(id: string): Promise < RetrieveCallResponse > ;
/**
* Get All Call Detail
* @method
* @param {object} params - params to get all call details.
* @promise {object[]} returns list of Call Object
* @fail {Error} returns Error
*/
list(params: object): Promise < ListAllCallsResponse > ;
/**
* Create a call
* @method
* @param {string} from - The phone number to be used as the caller id (with the country code).For e.g, a USA caller id number could be, 15677654321, with '1' for the country code.
* @param {string} to - The regular number(s) or sip endpoint(s) to call. Regular number must be prefixed with country code but without the + sign). For e.g, to dial a number in the USA, the number could be, 15677654321, with '1' for the country code. Multiple numbers can be sent by using a delimiter. For e.g. 15677654321<12077657621<12047657621. Sip endpoints must be prefixed with sip: E.g., sip:john1234@phone.plivo.com. To make bulk calls, the delimiter < is used. For example, 15677654321<15673464321<sip:john1234@phone.plivo.com Yes, you can mix regular numbers and sip endpoints.
* @param {string} answerUrl - The URL invoked by Plivo when the outbound call is answered.
* @param {object} params - optional params to make a call
* @param {string} [params.answerUrl] The URL invoked by Plivo when a call executes this application.
* @param {string} [params.answerMethod] The method used to call the answer_url. Defaults to POST.
* @param {string} [params.hangupUrl] The URL that is notified by Plivo when the call hangs up.
* @param {string} [params.hangupMethod] The method used to call the hangup_url. Defaults to POST
* @param {string} [params.fallbackAnswerUrl] Invoked by Plivo only if answer_url is unavailable or the XML response is invalid. Should contain a XML response.
* @param {string} [params.fallbackMethod] The method used to call the fallback_answer_url. Defaults to POST.
* @param {string} [params.callerName] Caller name to use with the call.
* @param {string} [params.sendDigits] Each 'w' character waits 0.5 second before sending a digit. Each 'W' character waits 1 second before sending a digit. You can also add the tone duration in ms by appending @duration after the string (default duration is 2000 ms). For example, 1w2w3@1000
* @param {boolean} [params.sendOnPreanswer] If set to true and send_digits is also set, digits are sent when the call is in preanswer state. Defaults to false.
* @param {number} [params.timeLimit] Schedules the call for hangup at a specified time after the call is answered. Value should be an integer > 0(in seconds).
* @param {number} [params.hangupOnRing] Schedules the call for hangup at a specified time after the call starts ringing. Value should be an integer >= 0 (in seconds).
* @param {string} [params.machineDetection] Used to detect if the call has been answered by a machine. The valid values are true and hangup.
* @param {number} [params.machineDetectionTime] Time allotted to analyze if the call has been answered by a machine. It should be an integer >= 2000 and <= 10000 and the unit is ms. The default value is 5000 ms.
* @param {string} [params.machineDetectionUrl] A URL where machine detection parameters will be sent by Plivo. This parameter should be used to make machine detection asynchronous
* @param {string} [params.machineDetectionMethod] The HTTP method which will be used by Plivo to request the machine_detection_url. Defaults to POST.
* @param {string} [params.sipHeaders] List of SIP headers in the form of 'key=value' pairs, separated by commas.
* @param {number} [params.ringTimeout] Determines the time in seconds the call should ring. If the call is not answered within the ring_timeout value or the default value of 120s, it is canceled.
* @param {string} [params.parentCallUuid] The call_uuid of the first leg in an ongoing conference call. It is recommended to use this parameter in scenarios where a member who is already present in the conference intends to add new members by initiating outbound API calls.
* @param {boolean} [params.errorIfParentNotFound] if set to true and the parent_call_uuid cannot be found, the API request would return an error. If set to false, the outbound call API request will be executed even if the parent_call_uuid is not found. Defaults to false.
* @promise {object} returns PlivoGenericResponse Object
* @fail {Error} returns Error
*/
create(from: string, to: string, answerUrl: string, params ? : {}): Promise < CreateCallResponse > ;
/**
* Hangup A Specific Call
* @method
* @param {string} callUUID - call uuid to hangup call
* @promise {object} returns PlivoGenericResponse Object
* @fail {Error} returns Error
*/
hangup(callUUID: string): Promise < any > ;
/**
* Transfer a Call
* @method
* @param {string} callUUID - call uuid to transfer call
* @param {object} params - optional params to transfer a call
* @param {string} [params.legs] aleg, bleg or both Defaults to aleg. aleg will transfer call_uuid ; bleg will transfer the bridged leg (if found) of call_uuid ; both will transfer call_uuid and bridged leg of call_uuid
* @param {string} [params.alegUrl] URL to transfer for aleg, if legs is aleg or both, then aleg_url has to be specified.
* @param {string} [params.alegMethod] HTTP method to invoke aleg_url. Defaults to POST.
* @param {string} [params.blegUrl] URL to transfer for bridged leg, if legs is bleg or both, then bleg_url has to be specified.
* @param {string} [params.blegMethod] HTTP method to invoke bleg_url. Defaults to POST.
* @promise {object} returns PlivoGenericResponse Object
* @fail {Error} returns Error
*/
transfer(callUUID: string, params: {
legs: string;
alegUrl: string;
alegMethod: string;
blegUrl: string;
blegMethod: string;
}): Promise < any > ;
/**
* Record a Call
* @method
* @param {string} callUUID - call uuid to record call
* @param {object} optionalParams - optional params to record a call
* @promise {object} returns PlivoGenericResponse Object
* @fail {Error} returns Error
*/
record(callUUID: string, optionalParams: object): Promise < any > ;
/**
* Stop Recording a Call
* @method
* @param {string} callUUID - call uuid to stop recording a call
* @param {object} optionalParams - optional params to stop recording a call
* @promise {object} returns PlivoGenericResponse Object
* @fail {Error} returns Error
*/
stopRecording(callUUID: string, optionalParams: object): Promise < any > ;
/**
* Play a music file
* @method
* @param {string} callUUID - call uuid to play music file
* @param {string} url - A single URL or a list of comma separated URLs linking to an mp3 or wav file.
* @param {object} optionalParams - optional params to play music file.
* @promise {object} returns PlivoGenericResponse Object
* @fail {Error} returns Error
*/
playMusic(callUUID: string, urls: any, optionalParams: object): Promise < any > ;
/**
* Stop Playing a music file
* @method
* @param {string} callUUID - call uuid to stop plaing music file
* @promise {object} returns PlivoGenericResponse Object
* @fail {Error} returns Error
*/
stopPlayingMusic(callUUID: string): Promise < any > ;
/**
* Speak text during a call
* @method
* @param {string} callUUID - call uuid to speak text during a call
* @param {string} text - text to be played.
* @param {object} optionalParams - optional params to speak text during a call
* @promise {object} returns PlivoGenericResponse Object
* @fail {Error} returns Error
*/
speakText(callUUID: string, text: string, optionalParams: object): Promise < any > ;
/**
* Stop Speaking text during a call
* @method
* @param {string} callUUID - call uuid to stop speaking text during a call
* @param {object} optionalParams - optional params to stop speaking text during a call
* @promise {object} returns PlivoGenericResponse Object
* @fail {Error} returns Error
*/
stopSpeakingText(callUUID: string): Promise < any > ;
/**
* Send digits on a call
* @method
* @param {string} callUUID - call uuid to send digits on a call
* @param {number} digits - digits to be send
* @param {object} optionalParams - optional params to send digits
* @promise {object} returns PlivoGenericResponse Object
* @fail {Error} returns Error
*/
sendDigits(callUUID: string, digits: number, optionalParams: object): Promise < any > ;
/**
* Hangup a call request
* @method
* @param {string} callUUID - call uuid to send digits on a call
* @promise {object} returns PlivoGenericResponse Object
* @fail {Error} returns Error
*/
cancel(id: any): Promise < any > ;
listLiveCalls(params: any): Promise < any > ;
getLiveCall(id: any): Promise < any > ;
listQueuedCalls(): Promise < any > ;
getQueuedCall(id: any): Promise < any > ;
[clientKey]: any;
[liveCallInterfaceKey]: LiveCallInterface;
[queuedCallInterfaceKey]: QueuedCallInterface;
}
export class LiveCallResource extends PlivoResource {
constructor(client: any, data?: {});
id: any;
[clientKey]: any;
constructor(client: any, data ? : {});
id: any;
[clientKey]: any;
}
export class QueuedCallResource extends PlivoResource {
constructor(client: any, data?: {});
id: any;
[clientKey]: any;
constructor(client: any, data ? : {});
id: any;
[clientKey]: any;
}
import { PlivoResource } from "../base.js";
import {
PlivoResource
} from "../base";
declare const clientKey: unique symbol;
import { PlivoResourceInterface } from "../base.js";
import {
PlivoResourceInterface
} from "../base";
declare const liveCallInterfaceKey: unique symbol;
/**
* Represents a LiveCall interface
@ -263,8 +426,8 @@ declare const liveCallInterfaceKey: unique symbol;
* @param {object} [data] - data of call
*/
declare class LiveCallInterface extends PlivoResourceInterface {
constructor(client: any, data?: {});
[clientKey]: any;
constructor(client: any, data ? : {});
[clientKey]: any;
}
declare const queuedCallInterfaceKey: unique symbol;
/**
@ -273,8 +436,11 @@ declare const queuedCallInterfaceKey: unique symbol;
* @param {function} client - make api call
* @param {object} [data] - data of call
*/
declare class QueuedCallInterface extends PlivoResourceInterface {
constructor(client: any, data?: {});
[clientKey]: any;
constructor(client: any, data ? : {});
get(id: any): Promise < GetQueuedCallResponse > ;
list(): Promise < ListAllQueuedCalls > ;
[clientKey]: any;
}
export {};
export {};

View file

@ -1,3 +1,9 @@
export class CallFeedbackResponse {
constructor(params: object);
apiId: string;
message: string;
status: string;
}
export class CallFeedback extends PlivoResource {
constructor(client: any, data?: {});
id: any;
@ -11,9 +17,10 @@ export class CallFeedback extends PlivoResource {
*/
export class CallFeedbackInterface extends PlivoResourceInterface {
constructor(client: any, data?: {});
create(callUUID: string, rating: string, issues?: never[], notes?: string): Promise<CallFeedbackResponse>;
[clientKey]: any;
}
import { PlivoResource } from "../base.js";
import { PlivoResource } from "../base";
declare const clientKey: unique symbol;
import { PlivoResourceInterface } from "../base.js";
import { PlivoResourceInterface } from "../base";
export {};

View file

@ -1,9 +1,53 @@
/**
* Represents a Conference
* @constructor
* @param {function} client - make api call
* @param {object} [data] - data of call
*/
* Represents a Conference
* @constructor
* @param {function} client - make api call
* @param {object} [data] - data of call
*/
export class MuteMemberResponse {
constructor(params: object);
apiId: string;
memberId: string;
message: string;
}
export class StartRecordingConferenceResponse {
constructor(params: object);
apiId: string;
message: string;
recordingId: string;
url: string;
}
export class RetrieveConferenceResponse {
constructor(params: object);
apiId: string;
conferenceMemberCount: string;
conferenceName: string;
conferenceRunTime: string;
members: string;
}
export class ListAllConferenceResponse {
constructor(params: object);
apiId: string;
conferences: string;
}
export class SpeakMemberResponse {
constructor(params: object);
apiId: string;
memberId: string;
message: string;
}
export class PlayAudioMemberResponse {
constructor(params: object);
apiId: string;
memberId: string;
message: string;
}
export class DeafMemberResponse {
constructor(params: string);
apiId: string;
memberId: string;
message: string;
}
export class Conference extends PlivoResource {
constructor(client: any, data?: {});
id: any;
@ -37,7 +81,7 @@ export class Conference extends PlivoResource {
* @promise {PlivoGenericResponse} return PlivoGenericResponse if success
* @fail {Error} return Error
*/
muteMember(memberId: string): Promise<any>;
muteMember(memberId: string): Promise<MuteMemberResponse>;
/**
* unmute member from conference
* @method
@ -53,7 +97,7 @@ export class Conference extends PlivoResource {
* @promise {PlivoGenericResponse} return PlivoGenericResponse if success
* @fail {Error} return Error
*/
deafMember(memberId: string): Promise<any>;
deafMember(memberId: string): Promise<DeafMemberResponse>;
/**
* undeaf member from conference
* @method
@ -70,7 +114,7 @@ export class Conference extends PlivoResource {
* @promise {PlivoGenericResponse} return PlivoGenericResponse if success
* @fail {Error} return Error
*/
playAudioToMember(memberId: string, url: string): Promise<any>;
playAudioToMember(memberId: string, url: string): Promise<PlayAudioMemberResponse>;
/**
* stop playing audio to member
* @method
@ -93,7 +137,7 @@ export class Conference extends PlivoResource {
speakTextToMember(memberId: string, text: string, optionalParams: {
voice: string;
language: string;
}): Promise<any>;
}): Promise<SpeakMemberResponse>;
/**
* stop speaking text to member
* @method
@ -147,7 +191,7 @@ export class Conference extends PlivoResource {
transcriptionMethod: string;
callbackUrl: string;
callbackMethod: string;
}): Promise<any>;
}): Promise<StartRecordingConferenceResponse>;
/**
* stop recording conference
* @method
@ -158,13 +202,29 @@ export class Conference extends PlivoResource {
[clientKey]: any;
}
/**
* Represents a Conference Interface
* @constructor
* @param {function} client - make api call
* @param {object} [data] - data of call
*/
* Represents a Conference Interface
* @constructor
* @param {function} client - make api call
* @param {object} [data] - data of call
*/
export class ConferenceInterface extends PlivoResourceInterface {
constructor(client: any, data?: {});
/**
* get conference by id
* @method
* @param {string} id - id of conference
* @promise {@link Conference} return {@link Conference} object if success
* @fail {Error} return Error
*/
get(id: string): Promise<RetrieveConferenceResponse>;
/**
* get all conferences. returns name of all conferences
* @method
* @promise {@link [Conference]} returns list of {@link Conference} objects if success
* @fail {Error} return Error
*/
list(): Promise<ListAllConferenceResponse>;
/**
* hangup conference
* @method
@ -331,7 +391,7 @@ export class ConferenceInterface extends PlivoResourceInterface {
stopRecording(id: string): Promise<any>;
[clientKey]: any;
}
import { PlivoResource } from "../base.js";
import { PlivoResource } from "../base";
declare const clientKey: unique symbol;
import { PlivoResourceInterface } from "../base.js";
import { PlivoResourceInterface } from "../base";
export {};

View file

@ -1,22 +1,101 @@
export class UpdateEndpointResponse {
constructor(params: object);
apiId: string;
message: string;
alias: string;
}
export class RetrieveEndpointResponse {
constructor(params: object);
apiId: string;
alias: string;
application: string;
endpointId: string;
password: string;
resourceUri: string;
sipRegistered: string;
sipUri: string;
subAccount: string;
username: string;
}
export class ListAllEndpointResponse {
constructor(params: any);
apiId: string;
alias: string;
application: string;
endpointId: string;
password: string;
resourceUri: string;
sipRegistered: string;
sipUri: string;
subAccount: string;
username: string;
}
export class CreateEndpointResponse {
constructor(params: object);
alias: string;
apiId: string;
endpointId: string;
message: string;
username: string;
}
/**
* Represents a Endpoint
* @constructor
* @param {function} client - make api call
* @param {object} [data] - data of call
*/
* Represents a Endpoint
* @constructor
* @param {function} client - make api call
* @param {object} [data] - data of call
*/
export class Endpoint extends PlivoResource {
constructor(client: any, data?: {});
id: any;
/**
* update Endpoint
* @method
* @param {object} params
* @param {string} [params.username] - username to update
* @param {string} [params.password] - password to update
* @param {string} [params.alias] - alias to update
* @param {string} [params.appId] - app id to update
* @promise {object} return {@link Endpoint} object if success
* @fail {Error} return Error
*/
update(params: object, id: string): Promise<UpdateEndpointResponse>;
/**
* delete Endpoint
* @method
* @promise {boolean} return true if success
* @fail {Error} return Error
*/
delete(): Promise<unknown>;
[clientKey]: any;
}
/**
* Represents a Endpoint Interface
* @constructor
* @param {function} client - make api call
* @param {object} [data] - data of call
*/
* Represents a Endpoint Interface
* @constructor
* @param {function} client - make api call
* @param {object} [data] - data of call
*/
export class EndpointInterface extends PlivoResourceInterface {
constructor(client: any, data?: {});
/**
* Get Endpoint by given id
* @method
* @param {string} id - id of endpoint
* @promise {object} return {@link Endpoint} object if success
* @fail {Error} return Error
*/
get(id: string): Promise<RetrieveEndpointResponse>;
list(): Promise<ListAllEndpointResponse>;
/**
* Create Endpoint
* @method
* @param {string} username - username to create
* @param {string} passwowrd - password to create
* @param {string} alias - alias to create
* @param {string} appId - app id to create
* @promise {object} return {@link PlivoGenericResponse} object if success
* @fail {Error} return Error
*/
create(username: string, password: string, alias: string, appId: string): Promise<CreateEndpointResponse>;
/**
* update Endpoint
* @method
@ -29,12 +108,7 @@ export class EndpointInterface extends PlivoResourceInterface {
* @promise {object} return {@link Endpoint} object if success
* @fail {Error} return Error
*/
update(id: string, params: {
username: string;
password: string;
alias: string;
appId: string;
}): Promise<any>;
update(id: string, params: object): any;
/**
* delete Endpoint
* @method
@ -42,10 +116,10 @@ export class EndpointInterface extends PlivoResourceInterface {
* @promise {boolean} return true if success
* @fail {Error} return Error
*/
delete(id: string): Promise<any>;
delete(id: any): any;
[clientKey]: any;
}
import { PlivoResource } from "../base.js";
import { PlivoResource } from "../base";
declare const clientKey: unique symbol;
import { PlivoResourceInterface } from "../base.js";
import { PlivoResourceInterface } from "../base";
export {};

22
types/resources/lookup.d.ts vendored Normal file
View file

@ -0,0 +1,22 @@
export class LookupResponse {
constructor(params: object);
apiId: string;
phoneNumber: string;
country: object;
format: object;
carrier: object;
resourceUri: string;
}
export class Number extends PlivoResource {
constructor(client: any, data?: {});
[clientKey]: any;
}
export class LookupInterface extends PlivoResourceInterface {
constructor(client: any, data?: {});
get(number: string, type?: string): Promise<LookupResponse>;
[clientKey]: any;
}
import { PlivoResource } from "../base";
declare const clientKey: unique symbol;
import { PlivoResourceInterface } from "../base";
export {};

View file

@ -1,3 +1,24 @@
export class UploadMediaResponse {
constructor(params: object);
apiId: string;
objects: object;
}
export class RetrieveMediaResponse {
constructor(params: object);
apiId: string;
contentType: string;
fileName: string;
mediaId: string;
mediaUrl: string;
size: string;
uploadTime: string;
}
export class ListMediaResponse {
constructor(params: object);
apiId: string;
meta: string;
objects: string;
}
/**
* Represents a Message
* @constructor
@ -5,8 +26,8 @@
* @param {object} [data] - data of call
*/
export class Media extends PlivoResource {
constructor(client: any, data?: {});
id: any;
constructor(client: any, data ? : {});
id: any;
}
/**
* Represents a Media Interface
@ -15,16 +36,36 @@ export class Media extends PlivoResource {
* @param {object} [data] - data of call
*/
export class MediaInterface extends PlivoResourceInterface {
constructor(client: any, data?: {});
constructor(client: any, data ? : {});
/**
* Upload Media
* @method
* @fail {Error} return Error
*/
upload(files: any): Promise<UploadMediaResponse>;
/**
* Upload Media
* Get Media by given id
* @method
* @param {string} media_id - id of media
* @promise {object} return {@link Media} object if success
* @fail {Error} return Error
*/
upload(files: any): Promise<any>;
[clientKey]: any;
get(media_id: string): Promise<RetrieveMediaResponse>;
/**
* Get All Media Detail
* @method
* @param {object} params - params to get all media details.
* @promise {object[]} returns list of Media Object
* @fail {Error} returns Error
*/
list(params: object): Promise<any>;
[clientKey]: any;
}
import { PlivoResource } from "../base.js";
import { PlivoResourceInterface } from "../base.js";
import {
PlivoResource
} from "../base";
import {
PlivoResourceInterface
} from "../base";
declare const clientKey: unique symbol;
export {};
export {};

View file

@ -1,21 +1,65 @@
import { PlivoResource, PlivoResourceInterface } from '../base';
export declare class MessageResponse {
constructor(params: object);
apiId: string
message: string
messageUuid: object
export class MessageResponse {
constructor(params: object);
apiId: string;
message: string;
messageUuid: string;
}
export class MessageGetResponse {
constructor(params: object);
apiId: string;
errorCode: string;
fromNumber: string;
messageDirection: string;
messageState: string;
messageTime: string;
messageType: string;
messageUuid: string;
resourceUri: string;
toNumber: string;
totalAmount: string;
totalRate: string;
units: string;
}
export class MessageListResponse {
constructor(params: object);
errorCode: string;
fromNumber: string;
messageDirection: string;
messageState: string;
messageTime: string;
messageType: string;
messageUuid: string;
resourceUri: string;
toNumber: string;
totalAmount: string;
totalRate: string;
units: string;
}
export class MMSMediaResponse {
constructor(params: object);
apiId: any;
objects: MMSMedia[];
}
export class MMSMedia {
constructor(params: object);
contentType: string;
fileName: string;
mediaId: string;
mediaUrl: string;
messageUuid: string;
size: string;
uploadTime: string;
}
/**
* Represents a Message
* @constructor
* @param {function} client - make api call
* @param {object} [data] - data of call
*/
export declare class Message extends PlivoResource {
constructor(client: any, data?: {});
listMedia(): any;
export class Message extends PlivoResource {
constructor(client: any, data ? : {});
id: any;
listMedia(): Promise < any > ;
}
/**
* Represents a Message Interface
@ -23,38 +67,56 @@ export declare class Message extends PlivoResource {
* @param {function} client - make api call
* @param {object} [data] - data of call
*/
export declare class MessageInterface extends PlivoResourceInterface {
constructor(client: any, data?: {});
/**
* Send Message
* @method
* @param {string} src - source number
* @param {string} dst - destination number
* @param {string} text - text to send
* @param {object} optionalParams - Optional Params to send message
* @param {string} [optionalParams.type] - The type of message. Should be `sms` or `mms`. Defaults to `sms`.
* @param {string} [optionalParams.url] The URL to which with the status of the message is sent.
* @param {string} [optionalParams.method] The method used to call the url. Defaults to POST.
* @param {list} [optionalParams.media_urls] For sending mms, specify the media urls in list of string
* @param {boolean} [optionalParams.log] If set to false, the content of this message will not be logged on the Plivo infrastructure and the dst value will be masked (e.g., 141XXXXX528). Default is set to true.
* @promise {object} return {@link PlivoGenericMessage} object if success
* @fail {Error} return Error
*/
send(src: any, dst: string, text: string, optionalParams: object): Promise<MessageResponse>;
/**
* Create Message
* @method
* @param {string} src - source number
* @param {string} dst - destination number
* @param {string} text - text to send
* @param {object} optionalParams - Optional Params to send message
* @param {string} [optionalParams.type] - The type of message. Should be `sms` or `mms`. Defaults to `sms`.
* @param {string} [optionalParams.url] The URL to which with the status of the message is sent.
* @param {string} [optionalParams.method] The method used to call the url. Defaults to POST.
* @param {boolean} [optionalParams.log] If set to false, the content of this message will not be logged on the Plivo infrastructure and the dst value will be masked (e.g., 141XXXXX528). Default is set to true.
* @param {Array} [optionalParams.media_urls] For sending mms, specify the media urls in list of string
* @promise {object} return {@link MessageResponse} object if success
* @fail {Error} return Error
*/
createtest(src: any, dst: string, text: string, optionalParams: object, powerpackUUID: any): Promise<MessageResponse>;
export class MessageInterface extends PlivoResourceInterface {
constructor(client: any, data ? : {});
/**
* Send Message
* @method
* @param {string} src - source number
* @param {string} dst - destination number
* @param {string} text - text to send
* @param {object} optionalParams - Optional Params to send message
* @param {string} [optionalParams.type] - The type of message. Should be `sms` or `mms`. Defaults to `sms`.
* @param {string} [optionalParams.url] The URL to which with the status of the message is sent.
* @param {string} [optionalParams.method] The method used to call the url. Defaults to POST.
* @param {list} [optionalParams.media_urls] For sending mms, specify the media urls in list of string
* @param {boolean} [optionalParams.log] If set to false, the content of this message will not be logged on the Plivo infrastructure and the dst value will be masked (e.g., 141XXXXX528). Default is set to true.
* @promise {object} return {@link PlivoGenericMessage} object if success
* @fail {Error} return Error
*/
send(src: string, dst: string, text: string, optionalParams?: {
type: string;
url: string;
method: string;
media_urls: any;
log: boolean;
}): Promise < MessageResponse > ;
/**
* Create Message
* @method
* @param {string} src - source number
* @param {string} dst - destination number
* @param {string} text - text to send
* @param {object} optionalParams - Optional Params to send message
* @param {string} [optionalParams.type] - The type of message. Should be `sms` or `mms`. Defaults to `sms`.
* @param {string} [optionalParams.url] The URL to which with the status of the message is sent.
* @param {string} [optionalParams.method] The method used to call the url. Defaults to POST.
* @param {boolean} [optionalParams.log] If set to false, the content of this message will not be logged on the Plivo infrastructure and the dst value will be masked (e.g., 141XXXXX528). Default is set to true.
* @param {Array} [optionalParams.media_urls] For sending mms, specify the media urls in list of string
* @promise {object} return {@link MessageResponse} object if success
* @fail {Error} return Error
*/
create(src: any, dst: any, text: string, optionalParams?: object, powerpackUUID?: string ): Promise < MessageResponse >;
get(id: string): Promise<MessageGetResponse>;
list(params: object): Promise < MessageListResponse> ;
listMedia(messageUUID: string): Promise <MMSMediaResponse> ;
}
import {
PlivoResource
} from "../base";
import {
PlivoResourceInterface
} from "../base";

View file

@ -1,3 +1,14 @@
export class BuyNumberResponse {
constructor(params: object);
apiId: string;
numbers: object;
status: string;
}
export class UpdateNumberResponse {
constructor(params: object);
apiId: string;
message: string;
}
/**
* Represents a PhoneNumber
* @constructor
@ -5,17 +16,17 @@
* @param {object} [data] - data of call
*/
export class PhoneNumber extends PlivoResource {
constructor(client: any, data?: {});
id: any;
/**
* Buy Phone Number
* @method
* @param {string} appId - app id
* @promise {@link PlivoGenericResponse} return PlivoGenericResponse Object if success
* @fail {Error} return Error
*/
buy(appId: string): Promise<any>;
[clientKey]: any;
constructor(client: any, data ? : {});
id: any;
/**
* Buy Phone Number
* @method
* @param {string} appId - app id
* @promise {@link PlivoGenericResponse} return PlivoGenericResponse Object if success
* @fail {Error} return Error
*/
buy(appId: string): Promise < any > ;
[clientKey]: any;
}
/**
* Represents a PhoneNumbers Interface
@ -25,16 +36,16 @@ export class PhoneNumber extends PlivoResource {
* @param {string} [data.test] - test data
*/
export class PhoneNumberInterface extends PlivoResourceInterface {
constructor(client: any, data?: {});
/**
* Buy Phone Number
* @method
* @param {string} appId - app id
* @promise {@link PlivoGenericResponse} return PlivoGenericResponse Object if success
* @fail {Error} return Error
*/
buy(appId: string): Promise<any>;
[clientKey]: any;
constructor(client: any, data ? : {});
/**
* Buy Phone Number
* @method
* @param {string} appId - app id
* @promise {@link PlivoGenericResponse} return PlivoGenericResponse Object if success
* @fail {Error} return Error
*/
buy(number: string, appId: string): Promise < BuyNumberResponse > ;
[clientKey]: any;
}
/**
* Represents a Number
@ -43,15 +54,16 @@ export class PhoneNumberInterface extends PlivoResourceInterface {
* @param {object} [data] - data of call
*/
export class NumberResource extends PlivoResource {
constructor(client: any, data?: {});
id: any;
/**
* Unrent Number
* @method
* @promise {boolean} return true if success
* @fail {Error} return Error
*/
unrent(): Promise<any>;
constructor(client: any, data ? : {});
id: any;
/**
* Unrent Number
* @method
* @promise {boolean} return true if success
* @fail {Error} return Error
*/
unrent(number: string): Promise < any > ;
[clientKey]: any;
}
/**
* Represents a Numbers
@ -60,63 +72,67 @@ export class NumberResource extends PlivoResource {
* @param {object} [data] - data of call
*/
export class NumberInterface extends PlivoResourceInterface {
constructor(client: any);
/**
* Buy Phone Number
* @method
* @param {string} number - number to buy
* @param {string} appId - app id
* @promise {@link PlivoGenericResponse} return PlivoGenericResponse Object if success
* @fail {Error} return Error
*/
buy(number: string, appId: string): Promise<any>;
/**
* Add own number from carrier
* @method
* @param {string} numbers - A comma separated list of numbers that need to be added for the carrier.
* @param {string} carrier - The carrier_id of the IncomingCarrier that the number is associated with.
* @param {string} region - region that is associated with the Number
* @param {string} optionaParams - optional params
* @promise {@link PlivoGenericResponse} return PlivoGenericResponse Object if success
* @fail {Error} return Error
*/
addOwnNumber(numbers: string, carrier: string, region: string, optionalParams: any): Promise<any>;
/**
* Add own number from carrier
* @method
* @param {string} countryISO - The ISO code A2 of the country
* @param {string} optionaParams - optional params
* @promise {@link PhoneNumberInterface} return PhoneNumbers Object if success
* @fail {Error} return Error
*/
search(countryISO: string, optionalParams: any): Promise<any>;
/**
* Update Number
* @method
* @param {string} number - number to update
* @param {object} params
* @param {string} [params.appId] - app id
* @param {string} [params.subAccount] - auth_id of subaccount
* @param {string} [params.alias] - textual name of number
* @promise {@link NumberResource} return NumberResource Object if success
* @fail {Error} return Error
*/
update(number: string, params: {
appId: string;
subAccount: string;
alias: string;
}): Promise<any>;
/**
* Unrent Number
* @method
* @param {string} number - number to unrent
* @promise {boolean} return true if success
* @fail {Error} return Error
*/
unrent(number: string): Promise<any>;
[clientKey]: any;
constructor(client: any);
/**
* Buy Phone Number
* @method
* @param {string} number - number to buy
* @param {string} appId - app id
* @promise {@link PlivoGenericResponse} return PlivoGenericResponse Object if success
* @fail {Error} return Error
*/
buy(number: string, appId: string): Promise < any > ;
/**
* Add own number from carrier
* @method
* @param {string} numbers - A comma separated list of numbers that need to be added for the carrier.
* @param {string} carrier - The carrier_id of the IncomingCarrier that the number is associated with.
* @param {string} region - region that is associated with the Number
* @param {string} optionaParams - optional params
* @promise {@link PlivoGenericResponse} return PlivoGenericResponse Object if success
* @fail {Error} return Error
*/
addOwnNumber(numbers: string, carrier: string, region: string, optionalParams: any): Promise < any > ;
/**
* Add own number from carrier
* @method
* @param {string} countryISO - The ISO code A2 of the country
* @param {string} optionaParams - optional params
* @promise {@link PhoneNumberInterface} return PhoneNumbers Object if success
* @fail {Error} return Error
*/
search(countryISO: string, optionalParams: any): Promise < any > ;
/**
* Update Number
* @method
* @param {string} number - number to update
* @param {object} params
* @param {string} [params.appId] - app id
* @param {string} [params.subAccount] - auth_id of subaccount
* @param {string} [params.alias] - textual name of number
* @promise {@link NumberResource} return NumberResource Object if success
* @fail {Error} return Error
*/
update(number: string, params: {
appId: string;
subAccount: string;
alias: string;
}): Promise < any > ;
/**
* Unrent Number
* @method
* @param {string} number - number to unrent
* @promise {boolean} return true if success
* @fail {Error} return Error
*/
unrent(number: string): Promise < any > ;
[clientKey]: any;
}
import { PlivoResource } from "../base.js";
import {
PlivoResource
} from "../base";
declare const clientKey: unique symbol;
import { PlivoResourceInterface } from "../base.js";
export {};
import {
PlivoResourceInterface
} from "../base";
export {};

View file

@ -1,3 +1,16 @@
export class RunPHLOResponse {
constructor(params: any);
apiId: any;
phloId: any;
message: any;
}
export class RetrievePHLOResponse {
constructor(params: any);
apiId: any;
phloId: any;
name: any;
createdOn: any;
}
/**
* Represents a Phlo
* @constructor
@ -5,16 +18,17 @@
* @param {object} [data] - data of phlo
*/
export class Phlo extends PlivoResource {
constructor(client: any, data?: {});
client: any;
multiPartyCall: (nodeId: any) => PhloMultiPartyCall;
/**
* run phlo
* @method
* @promise {Boolean} return true if phlo is complete
* @fail {Error} return Error
*/
run(params: any): Promise<any>;
constructor(client: any, data ? : {});
client: any;
multiPartyCall: (nodeId: any) => PhloMultiPartyCall;
/**
* run phlo
* @method
* @promise {Boolean} return true if phlo is complete
* @fail {Error} return Error
*/
run(params: object): Promise < RunPHLOResponse > ;
[clientKey]: any;
}
/**
* Represents a Phlo Interface
@ -24,7 +38,17 @@ export class Phlo extends PlivoResource {
*/
export class PhloInterface extends PlivoResourceInterface {
constructor(client: any, data?: {});
get(id: string): Promise<RetrievePHLOResponse>;
[clientKey]: any;
}
import { PlivoResource } from "../base.js";
import { PhloMultiPartyCall } from "./phloMultipartyCall.js";
import { PlivoResourceInterface } from "../base.js";
import {
PlivoResource
} from "../base";
import {
PhloMultiPartyCall
} from "./phloMultipartyCall";
declare const clientKey: unique symbol;
import {
PlivoResourceInterface
} from "../base";
export {};

View file

@ -4,20 +4,31 @@
* @param {function} client - make api call
* @param {object} [data] - data of phlo
*/
export class UpdateMemberResponse {
constructor(params: object);
apiId: string;
error: string;
}
export class PhloMultiPartyCallMember extends PlivoResource {
constructor(client: any, data?: {});
action: string;
client: any;
resumeCall(): Promise<any>;
voicemailDrop(): Promise<any>;
hangup(): Promise<any>;
hold(): Promise<any>;
constructor(client: any, data ? : {});
action: string;
client: any;
resumeCall(): Promise < any > ;
voicemailDrop(): Promise < any > ;
hangup(): Promise < any > ;
hold(): Promise < any > ;
unhold(): Promise<any>;
update(action: object): Promise<UpdateMemberResponse>;
}
export class PhloMultiPartyCallMemberInterface extends PlivoResourceInterface {
constructor(client: any, data?: {});
action: string;
constructor(client: any, data ? : {});
action: string;
client: any;
get(phloId: string, nodeId: string, memberAddress: string): any;
}
import { PlivoResource } from "../base.js";
import { PlivoResourceInterface } from "../base.js";
import {
PlivoResource
} from "../base";
import {
PlivoResourceInterface
} from "../base";

View file

@ -1,16 +1,42 @@
export class UpdateMultipartyCallResponse {
constructor(params: object);
apiId: string;
error: string;
}
export class RetrieveMultipartyCallResponse {
constructor(params: object);
apiId: string;
nodeId: string;
phloId: string;
name: string;
nodeType: string;
createdOn: string;
}
export class PhloMultiPartyCall extends PlivoResource {
constructor(client: any, data?: {});
action: string;
client: any;
member: (memberAddress: any) => PhloMultiPartyCallMember;
call(triggerSource: any, to: any, role: any): Promise<any>;
warmTransfer(triggerSource: any, to: any, role: any): Promise<any>;
coldTransfer(triggerSource: any, to: any, role: any): Promise<any>;
constructor(client: any, data ? : {});
action: string;
client: any;
member: (memberAddress: any) => PhloMultiPartyCallMember;
call(triggerSource: any, to: any, role: any): Promise < any > ;
warmTransfer(triggerSource: any, to: any, role: any): Promise < UpdateMultipartyCallResponse > ;
coldTransfer(triggerSource: any, to: any, role: any): Promise < UpdateMultipartyCallResponse > ;
abortTransfer(memberAddress: any): Promise<any>;
update(action: any, triggerSource: any, to: any, role: any): Promise<UpdateMultipartyCallResponse>;
[clientKey]: any;
}
export class PhloMultiPartyCallInterface extends PlivoResourceInterface {
constructor(client: any, data?: {});
get(phloId: string, id: string): Promise<RetrieveMultipartyCallResponse>;
[clientKey]: any;
}
import { PlivoResource } from "../base.js";
import { PhloMultiPartyCallMember } from "./phloMultiPartyCallMember.js";
import { PlivoResourceInterface } from "../base.js";
import {
PlivoResource
} from "../base";
import {
PhloMultiPartyCallMember
} from "./phloMultiPartyCallMember";
declare const clientKey: unique symbol;
import {
PlivoResourceInterface
} from "../base";
export {};

View file

@ -1,3 +1,111 @@
export class ListAllNumbersResponse {
constructor(params: object);
apiId: string;
meta: object;
objects: object;
}
export class CreatePowerpackResponse {
constructor(params: any);
apiId: string;
applicationId: string;
applicationType: string;
createdOn: string;
localConnect: string;
name: string;
numberPool: string;
numberPriority: string;
stickySender: string;
uuid: string;
}
export class UpdatePowerpackResponse {
constructor(params: object);
apiId: string;
applicationId: string;
applicationType: string;
createdOn: string;
localConnect: string;
name: string;
numberPool: string;
stickySender: string;
uuid: string;
}
export class ListShortCodeResponse {
constructor(params: object);
apiId: string;
meta: object;
objects: object;
}
export class ListTollFreeResponse {
constructor(params: object);
apiId: string;
meta: object;
objects: object;
}
export class AddNumberResponse {
constructor(params: object);
apiId: string;
accountPhoneNumberResource: string;
addedOn: string;
countryIso2: string;
number: string;
numberPoolUuid: string;
type: string;
service: string;
}
export class RemoveNumberResponse {
constructor(params: object);
apiId: string;
response: string;
}
export class RemoveTollFreeNumberResponse {
constructor(params: object);
apiId: any;
response: string;
}
export class RemoveShortCodeResponse {
constructor(params: any);
apiId: any;
response: string;
}
export class AddTollFreeNumberresponse {
constructor(params: object);
apiId: string;
accountPhoneNumberResource: string;
addedOn: string;
countryIso2: string;
number: string;
numberPoolUuid: string;
type: string;
service: string;
}
export class RetrieveNumberResponse {
constructor(params: object);
apiId: string;
accountPhoneNumberResource: string;
addedOn: string;
countryIso2: string;
number: string;
numberPoolUuid: string;
type: string;
}
export class RetrieveTollFreeResponse {
constructor(params: object);
apiId: string;
accountPhoneNumberResource: string;
addedOn: string;
countryIso2: string;
number: string;
numberPoolUuid: string;
type: string;
}
export class RetrieveShortCodeResponse {
constructor(params: object);
apiId: string;
addedOn: string;
countryIso2: string;
shortCode: string;
numberPoolUuid: string;
}
/**
* Represents a Powerpack
* @constructor
@ -5,55 +113,56 @@
* @param {object} [data] - data of call
*/
export class Powerpack extends PlivoResource {
constructor(client: any, data?: {});
uuid: any;
number_pool_id: any;
number_pool: NumberPool;
list_numbers(params: any): Promise<any>;
search_query(params: any): string;
count_numbers(params: any): Promise<any>;
find_number(number: any): Promise<any>;
add_number(number: any): Promise<any>;
add_tollfree(tollfree: any): Promise<any>;
remove_number(number: any, unrent?: boolean): Promise<any>;
remove_tollfree(tollfree: any, unrent?: boolean): Promise<any>;
remove_shortcode(shortcode: any): Promise<any>;
list_shortcodes(params: any): Promise<any>;
list_tollfree(params: any): Promise<any>;
find_shortcode(shortcode: any): Promise<any>;
find_tollfree(tollfree: any): Promise<any>;
buy_add_number(params: any): any;
constructor(client: any, data ? : {});
uuid: any;
number_pool_id: any;
number_pool: NumberPool;
list_numbers(params: object): Promise < ListAllNumbersResponse > ;
search_query(params: object): string;
count_numbers(params: object): Promise < any > ;
find_number(number: string): Promise < RetrieveNumberResponse > ;
add_number(number: string, service ? : string): Promise < AddNumberResponse > ;
add_tollfree(tollfree: string, service ? : string): Promise < AddTollFreeNumberresponse > ;
remove_number(number: string, unrent ? : boolean): Promise < RemoveNumberResponse > ;
remove_tollfree(tollfree: string, unrent ? : boolean): Promise < RemoveTollFreeNumberResponse > ;
remove_shortcode(shortcode: string): Promise < RemoveShortCodeResponse > ;
list_shortcodes(params: object): Promise < ListShortCodeResponse > ;
list_tollfree(params: object): Promise < ListTollFreeResponse > ;
find_shortcode(shortcode: object, service ? : string): Promise < RetrieveShortCodeResponse > ;
find_tollfree(tollfree: string, service ? : string): Promise < RetrieveTollFreeResponse > ;
buy_add_number(params: object): any;
[clientKey]: any;
}
export class NumberPool extends PlivoResource {
constructor(client: any, data?: {});
numbers: Numbers;
shortcodes: Shortcode;
tollfree: Tollfree;
constructor(client: any, data ? : {});
numbers: Numbers;
shortcodes: Shortcode;
tollfree: Tollfree;
}
export class Numbers extends PlivoResource {
constructor(client: any, data?: {});
buy_add_number(params: any): any;
list(params: any): Promise<any>;
count(params: any): Promise<any>;
search_query(params: any): string;
find(number: any): Promise<any>;
add(number: any): Promise<any>;
remove(number: any, unrent?: boolean): Promise<any>;
constructor(client: any, data ? : {});
buy_add_number(params: object): any;
list(params: object): Promise < any > ;
count(params: object): Promise < any > ;
search_query(params: object): string;
find(number: object): Promise < any > ;
add(number: string, service ? : string): Promise < any > ;
remove(number: string, unrent ? : boolean): Promise < any > ;
}
export class Shortcode extends PlivoResource {
constructor(client: any, data?: {});
number_pool_id: any;
list(params: any): Promise<any>;
find(shortcode: any): Promise<any>;
remove(shortcode: any): Promise<any>;
constructor(client: any, data ? : {});
number_pool_id: any;
list(params: object): Promise < any > ;
find(shortcode: object): Promise < any > ;
remove(shortcode: object): Promise < any > ;
}
export class Tollfree extends PlivoResource {
constructor(client: any, data?: {});
number_pool_id: any;
add(tollfree: any): Promise<any>;
remove(tollfree: any, unrent?: boolean): Promise<any>;
list(params: any): Promise<any>;
find(tollfree: any): Promise<any>;
constructor(client: any, data ? : {});
number_pool_id: any;
add(tollfree: string): Promise < any > ;
remove(tollfree: string, unrent ? : boolean): Promise < any > ;
list(params: object): Promise < any > ;
find(tollfree: object): Promise < any > ;
}
/**
* Represents a Powerpack interface
@ -62,27 +171,55 @@ export class Tollfree extends PlivoResource {
* @param {object} [data] - data of call
*/
export class PowerpackInterface extends PlivoResourceInterface {
constructor(client: any, data?: {});
constructor(client: any, data ? : {});
/**
* update Powerpack
* @method
* @param {string} uuid - id of Powerpack
* @param {object} params - to update Powerpack
* @param {string} [params.name]
* @param {string} [params.sticky_sender]
* @param {string} [params.local_connect]
* @param {string} [params.application_type]
* @param {string} [params.application_id]
* @promise {object} return {@link Powerpack} object
* @fail {Error} return Error
*/
update(uuid: string, params: {
name: string;
sticky_sender: string;
local_connect: string;
application_type: string;
application_id: string;
}): Promise<any>;
* get Powerpack by given id
* @method
* @param {string} uuid - id of Powerpack
* @promise {object} return {@link Powerpack} object
* @fail {Error} return Error
*/
get(uuid: string): any;
/**
* create Powerpack
* @method
* @param {string} name - name of Powerpack
* @param {object} params - params to create Powerpack
* @param {string} [params.sticky_sender] -
* @param {string} [params.local_connect]
* @param {string} [params.application_type]
* @param {string} [params.application_id]
* @promise {object} return {@link PlivoGenericResponse} object
* @fail {Error} return Error
*/
create(name: string, params?: {}): Promise<CreatePowerpackResponse>;
/**
* update Powerpack
* @method
* @param {string} uuid - id of Powerpack
* @param {object} params - to update Powerpack
* @param {string} [params.name]
* @param {string} [params.sticky_sender]
* @param {string} [params.local_connect]
* @param {string} [params.application_type]
* @param {string} [params.application_id]
* @promise {object} return {@link Powerpack} object
* @fail {Error} return Error
*/
update(uuid: string, params: {
name: string;
sticky_sender: string;
local_connect: string;
application_type: string;
application_id: string;
}): Promise < UpdatePowerpackResponse > ;
[clientKey]: any;
}
import { PlivoResource } from "../base.js";
import { PlivoResourceInterface } from "../base.js";
import {
PlivoResource
} from "../base";
declare const clientKey: unique symbol;
import {
PlivoResourceInterface
} from "../base";
export {};

View file

@ -1,9 +1,20 @@
/**
* Represents a Pricing
* @constructor
* @param {function} client - make api call
* @param {object} [data] - data of call
*/
* Represents a Pricing
* @constructor
* @param {function} client - make api call
* @param {object} [data] - data of call
*/
export class PricingResponse {
constructor(params: any);
apiId: string;
country: string;
countryCode: string;
countryIso: string;
message: object;
mms: object;
phoneNumbers: object;
voice: object;
}
export class Pricing extends PlivoResource {
constructor(client: any, data?: {});
/**
@ -12,19 +23,20 @@ export class Pricing extends PlivoResource {
* @promise {object} return {@link PlivoGenericResponse} object
* @fail {Error} return Error
*/
get(): Promise<any>;
get(): Promise<PricingResponse>;
[clientKey]: any;
}
/**
* Represents a Pricing Interface
* @constructor
* @param {function} client - make api call
* @param {object} [data] - data of call
*/
* Represents a Pricing Interface
* @constructor
* @param {function} client - make api call
* @param {object} [data] - data of call
*/
export class PricingInterface extends PlivoResourceInterface {
constructor(client: any, data?: {});
[clientKey]: any;
}
import { PlivoResource } from "../base.js";
import { PlivoResourceInterface } from "../base.js";
import { PlivoResource } from "../base";
declare const clientKey: unique symbol;
import { PlivoResourceInterface } from "../base";
export {};

View file

@ -1,3 +1,33 @@
export class RetrieveRecordingResponse {
constructor(params: object);
addTime: string;
apiId: string;
callUuid: string;
conferenceName: string;
recordingDurationMs: string;
recordingEndMs: string;
recordingFormat: string;
recordingId: string;
recordingStartMs: string;
recordingType: string;
recordingUrl: string;
resourceUri: string;
}
export class ListRecordingResponse {
constructor(params: object);
addTime: string;
apiId: string;
callUuid: string;
conferenceName: string;
recordingDurationMs: string;
recordingEndMs: string;
recordingFormat: string;
recordingId: string;
recordingStartMs: string;
recordingType: string;
recordingUrl: string;
resourceUri: string;
}
/**
* Represents a Recording
* @constructor
@ -5,8 +35,9 @@
* @param {object} [data] - data of call
*/
export class Recording extends PlivoResource {
constructor(client: any, data?: {});
id: any;
constructor(client: any, data ? : {});
id: any;
[clientKey]: any;
}
/**
* Represents a Recording Interface
@ -15,18 +46,41 @@ export class Recording extends PlivoResource {
* @param {object} [data] - data of call
*/
export class RecordingInterface extends PlivoResourceInterface {
constructor(client: any, data?: {});
constructor(client: any, data ? : {});
/**
* Delete recording by id
* @method
* @param {string} id - id to delete recording
* @promise {boolean} return true if success
* @fail {Error} return Error
*/
delete(id: string): Promise < any > ;
[clientKey]: any;
/**
* Delete recording by id
* Get recording by id
* @method
* @param {string} id - id to delete recording
* @promise {boolean} return true if success
* @param {string} id - id to get recording information
* @promise {object} return {@link Pricing} object
* @fail {Error} return Error
*/
delete(id: string): Promise<any>;
[clientKey]: any;
get(id: string): Promise<RetrieveRecordingResponse>;
/**
* list recordings
* @method
* @param {object} params - params to list recordings
* @param {string} [params.subaccount] - ID of the subaccount if present
* @param {string} [params.callUuid] - Call UUID of the call to filter recordings associated with it
* @param {string} [params.addTime] - Filter based on the timings they were added
* @param {string} [params.limit] - Display no of results per page
* @param {string} [params.offset] - No of value items by which results should be offset
*/
list(params?: {}): Promise<ListRecordingResponse>;
}
import { PlivoResource } from "../base.js";
import { PlivoResourceInterface } from "../base.js";
import {
PlivoResource
} from "../base";
declare const clientKey: unique symbol;
export {};
import {
PlivoResourceInterface
} from "../base";
export {};

View file

@ -7,6 +7,7 @@ export class Client {
conferences: ConferenceInterface;
endpoints: EndpointInterface;
messages: MessageInterface;
lookup: LookupInterface;
powerpacks: PowerpackInterface;
numbers: NumberInterface;
pricings: PricingInterface;
@ -29,6 +30,7 @@ import { ApplicationInterface } from "../resources/applications.js";
import { ConferenceInterface } from "../resources/conferences.js";
import { EndpointInterface } from "../resources/endpoints.js";
import { MessageInterface } from "../resources/messages.js";
import { LookupInterface } from "../resources/lookup.js";
import { PowerpackInterface } from "../resources/powerpacks.js";
import { NumberInterface } from "../resources/numbers.js";
import { PricingInterface } from "../resources/pricings.js";

View file

@ -13,6 +13,7 @@ export class Client {
conferences: ConferenceInterface;
endpoints: EndpointInterface;
messages: MessageInterface;
lookup: LookupInterface;
powerpacks: PowerpackInterface;
numbers: NumberInterface;
pricings: PricingInterface;
@ -37,6 +38,7 @@ import { ApplicationInterface } from "../resources/applications.js";
import { ConferenceInterface } from "../resources/conferences.js";
import { EndpointInterface } from "../resources/endpoints.js";
import { MessageInterface } from "../resources/messages.js";
import { LookupInterface } from "../resources/lookup.js";
import { PowerpackInterface } from "../resources/powerpacks.js";
import { NumberInterface } from "../resources/numbers.js";
import { PricingInterface } from "../resources/pricings.js";

View file

@ -2,6 +2,6 @@ export default Flatted;
export function parse(text: any, reviver: any): any;
export function stringify(value: any, replacer: any, space: any): string;
declare namespace Flatted {
export function parse(text: any, reviver: any): any;
export function stringify(value: any, replacer: any, space: any): string;
function parse(text: any, reviver: any): any;
function stringify(value: any, replacer: any, space: any): string;
}

21
types/utils/jwt.d.ts vendored Normal file
View file

@ -0,0 +1,21 @@
export function AccessToken(authId: any, authToken: any, username: any, validityOptions?: {}, uid?: any): void;
export class AccessToken {
constructor(authId: string, authToken: string, username: string, validityOptions?: {}, uid?: any);
authId: string;
key: string;
username: string;
validFrom: string;
lifetime: string;
uid: string;
}
export function addVoiceGrants(incoming?: boolean, outgoing?: boolean): void;
export class addVoiceGrants {
constructor(incoming?: boolean, outgoing?: boolean);
grants: {
voice: {
incoming_allow: boolean;
outgoing_allow: boolean;
};
};
}
export function toJwt(): any;

View file

@ -1,7 +1,3 @@
export function computeOldSignature(authId: string, uri: string, params: {
[string]: string;
}): string;
export function verifyOldSignature(authId: string, uri: string, params: {
[string]: string;
}, signature: string): boolean;
export function validateSignature(uri: string, nonce: string, signature: string, auth_token: string): boolean;
export function computeOldSignature(authId: any, uri: any, params: any): any;
export function verifyOldSignature(authId: any, uri: any, params: any, signature: any): boolean;
export function validateSignature(uri: any, nonce: any, signature: any, auth_token: any): boolean;

View file

@ -1 +1 @@
export function validateV3Signature(method: string, uri: string, nonce: string, auth_token: string, v3_signature: string, params?: {}): boolean;
export function validateV3Signature(method: any, uri: any, nonce: any, auth_token: any, v3_signature: any, params?: {}): boolean;