mirror of
https://github.com/donl/plivo-node.git
synced 2026-05-25 22:07:10 -06:00
Integrate node apis for compliance
This commit is contained in:
parent
7a640a43ec
commit
980634eb02
20 changed files with 1778 additions and 2 deletions
45
examples/complianceApplications.js
Normal file
45
examples/complianceApplications.js
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
var Plivo = require('../dist/rest/client.js');
|
||||
var client = new Plivo.Client();
|
||||
|
||||
var createParams = {
|
||||
countryIso2: "US",
|
||||
numberType: "local",
|
||||
endUserType: "individual"
|
||||
};
|
||||
|
||||
var listParams = {
|
||||
countryIso2: "US",
|
||||
numberType: "local",
|
||||
endUserType: "individual",
|
||||
limit: 10,
|
||||
offset: 5
|
||||
};
|
||||
|
||||
var updateParams = {
|
||||
documentIds: [ "test-1", "test-2"],
|
||||
};
|
||||
|
||||
client.complianceApplications.create(createParams)
|
||||
.then(function(complianceApplication) {
|
||||
console.log("\n============ created ===========\n", complianceApplication)
|
||||
return client.complianceApplications.update(complianceApplication.id, updateParams);
|
||||
})
|
||||
.then(function(complianceApplication) {
|
||||
console.log("\n============ updated ===========\n", complianceApplication)
|
||||
return client.complianceApplications.get(complianceApplication.id);
|
||||
})
|
||||
.then(function(complianceApplication){
|
||||
console.log("\n============ list with id ===========\n", complianceApplication)
|
||||
return complianceApplications.delete(complianceApplication.id);
|
||||
})
|
||||
.then(function(result){
|
||||
console.log("\n============ deleted ===========\n", result)
|
||||
return client.complianceApplications.list(listParams)
|
||||
})
|
||||
.then(function(complianceApplications){
|
||||
console.log("\n============ list all ===========\n", complianceApplications)
|
||||
})
|
||||
.catch(function(response) {
|
||||
console.log("\n============ Error :: ===========\n", response);
|
||||
});
|
||||
|
||||
21
examples/complianceDocumentTypes.js
Normal file
21
examples/complianceDocumentTypes.js
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
var Plivo = require('../dist/rest/client.js');
|
||||
var client = new Plivo.Client();
|
||||
|
||||
var listParams = {
|
||||
documentName: "Test",
|
||||
proofRequired: "passport"
|
||||
};
|
||||
|
||||
client.complianceDocumentTypes.get("some-fake-id")
|
||||
.then(function(complianceDocumentType) {
|
||||
console.log("\n============ Fetch by ID ===========\n", complianceDocumentType)
|
||||
return client.complianceDocumentTypes.list(listParams);
|
||||
})
|
||||
.then(function(complianceDocumentTypes) {
|
||||
console.log("\n============ list all ===========\n", complianceDocumentTypes)
|
||||
})
|
||||
.catch(function(response) {
|
||||
console.log("\n============ Error :: ===========\n", response);
|
||||
});
|
||||
|
||||
|
||||
34
examples/complianceDocuments.js
Normal file
34
examples/complianceDocuments.js
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
var Plivo = require('../dist/rest/client.js');
|
||||
var client = new Plivo.Client();
|
||||
|
||||
var createParams = {
|
||||
alias: "testing",
|
||||
documentTypeId: "testing",
|
||||
complianceDocumentId: "test",
|
||||
metaInformation: "test meta",
|
||||
file: "test path to file"
|
||||
};
|
||||
|
||||
var updateDocument = {
|
||||
alias: "alias update"
|
||||
};
|
||||
|
||||
client.complianceDocuments.create(createParams)
|
||||
.then(function(complianceDocument) {
|
||||
console.log("\n============ created ===========\n", complianceDocument)
|
||||
return client.complianceDocuments.update(complianceDocument.id, updateDocument);
|
||||
})
|
||||
.then(function(complianceDocument){
|
||||
return complianceDocuments.delete();
|
||||
})
|
||||
.then(function(result){
|
||||
console.log("\n============ deleted ===========\n", result)
|
||||
return client.complianceDocuments.list()
|
||||
})
|
||||
.then(function(complianceDocuments){
|
||||
console.log("\n============ list all ===========\n", complianceDocuments)
|
||||
})
|
||||
.catch(function(response) {
|
||||
console.log("\n============ Error :: ===========\n", response);
|
||||
});
|
||||
|
||||
22
examples/complianceRequirements.js
Normal file
22
examples/complianceRequirements.js
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
var Plivo = require('../dist/rest/client.js');
|
||||
var client = new Plivo.Client();
|
||||
|
||||
var listParams = {
|
||||
countryIso2: "US",
|
||||
numberType: "local",
|
||||
endUserType: "individual"
|
||||
};
|
||||
|
||||
client.complianceRequirements.get("some-fake-id")
|
||||
.then(function(complianceRequirement) {
|
||||
console.log("\n============ Fetch by ID ===========\n", complianceRequirement)
|
||||
return client.complianceRequirements.list(listParams);
|
||||
})
|
||||
.then(function(complianceRequirements) {
|
||||
console.log("\n============ list all ===========\n", complianceRequirements)
|
||||
})
|
||||
.catch(function(response) {
|
||||
console.log("\n============ Error :: ===========\n", response);
|
||||
});
|
||||
|
||||
|
||||
37
examples/endUsers.js
Normal file
37
examples/endUsers.js
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
var Plivo = require('../dist/rest/client.js');
|
||||
var client = new Plivo.Client();
|
||||
|
||||
var createParams = {
|
||||
name: "testing name",
|
||||
lastName: "testing lastname",
|
||||
endUserType: "business"
|
||||
};
|
||||
|
||||
var updateParams = {
|
||||
endUserType: "individual"
|
||||
};
|
||||
|
||||
client.endUsers.create(createParams)
|
||||
.then(function(endUser) {
|
||||
console.log("\n============ created ===========\n", endUser)
|
||||
return client.endUsers.update(endUser.id, updateParams);
|
||||
})
|
||||
.then(function(endUser) {
|
||||
console.log("\n============ updated ===========\n", endUser)
|
||||
return client.endUsers.get(endUser.id);
|
||||
})
|
||||
.then(function(endUser){
|
||||
console.log("\n============ list with id ===========\n", endUser)
|
||||
return endUsers.delete();
|
||||
})
|
||||
.then(function(result){
|
||||
console.log("\n============ deleted ===========\n", result)
|
||||
return client.endUsers.list()
|
||||
})
|
||||
.then(function(endUsers){
|
||||
console.log("\n============ list all ===========\n", endUsers)
|
||||
})
|
||||
.catch(function(response) {
|
||||
console.log("\n============ Error :: ===========\n", response);
|
||||
});
|
||||
|
||||
281
lib/resources/complianceApplications.js
Normal file
281
lib/resources/complianceApplications.js
Normal file
|
|
@ -0,0 +1,281 @@
|
|||
import {
|
||||
PlivoResource,
|
||||
PlivoResourceInterface
|
||||
} from '../base';
|
||||
import {
|
||||
extend,
|
||||
validate
|
||||
} from '../utils/common.js';
|
||||
|
||||
const clientKey = Symbol();
|
||||
const action = 'ComplianceApplication/';
|
||||
const idField = 'complianceApplicationId';
|
||||
|
||||
export class ComplianceApplicationResponse {
|
||||
constructor(params) {
|
||||
params = params || {};
|
||||
this.apiId = params.apiId;
|
||||
this.complianceApplicationId = params.complianceApplicationId;
|
||||
this.alias = params.alias;
|
||||
this.status = params.status;
|
||||
this.endUserType = params.endUserType;
|
||||
this.endUserId = params.endUserId;
|
||||
this.countryIso2 = params.countryIso2;
|
||||
this.numberType = params.numberType;
|
||||
this.complianceRequirementId= params.complianceRequirementId;
|
||||
this.documents = params.documents;
|
||||
this.createdAt = params.createdAt;
|
||||
}
|
||||
}
|
||||
|
||||
export class CreateComplianceApplicationResponse {
|
||||
constructor(params) {
|
||||
params = params || {};
|
||||
this.apiId = params.apiId;
|
||||
this.complianceApplicationId = params.complianceApplicationId;
|
||||
this.alias = params.alias;
|
||||
this.status = params.status;
|
||||
this.endUserType = params.endUserType;
|
||||
this.endUserId = params.endUserId;
|
||||
this.countryIso2 = params.countryIso2;
|
||||
this.numberType = params.numberType;
|
||||
this.message = params.message;
|
||||
this.complianceRequirementId= params.complianceRequirementId;
|
||||
this.documents = params.documents;
|
||||
this.createdAt = params.createdAt;
|
||||
}
|
||||
}
|
||||
|
||||
export class ListComplianceApplicationResponse {
|
||||
constructor(params) {
|
||||
params = params || {};
|
||||
this.apiId = params.apiId;
|
||||
this.meta = params.meta;
|
||||
this.objects = params.objects;
|
||||
}
|
||||
}
|
||||
|
||||
export class UpdateComplianceApplicationResponse {
|
||||
constructor(params) {
|
||||
params = params || {};
|
||||
this.apiId = params.apiId;
|
||||
this.message = params.message;
|
||||
}
|
||||
}
|
||||
|
||||
export class ComplianceApplication extends PlivoResource {
|
||||
constructor(client, data = {}) {
|
||||
super(action, ComplianceApplication, idField, client);
|
||||
if (idField in data) {
|
||||
this.id = data[idField];
|
||||
}
|
||||
this[clientKey] = client;
|
||||
extend(this, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* update ComplianceApplication
|
||||
* @method
|
||||
* @param {string} id - id to update
|
||||
* @param {object} params
|
||||
* @param {string} [params.documentIds] - Document IDs
|
||||
* @promise {object} return {@link ComplianceApplication} object if success
|
||||
* @fail {Error} return Error
|
||||
*/
|
||||
update(params, id) {
|
||||
let client = this[clientKey];
|
||||
let that = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
client('POST', action + id + '/', params)
|
||||
.then(response => {
|
||||
extend(that, response.body);
|
||||
extend(that, params);
|
||||
resolve(new UpdateComplianceApplicationResponse(that));
|
||||
})
|
||||
.catch(error => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* delete an Compliance application
|
||||
* @method
|
||||
* @param {string} id - id to delete
|
||||
* @promise {boolean} return true if success
|
||||
* @fail {Error} return Error
|
||||
*/
|
||||
delete() {
|
||||
let client = this[clientKey];
|
||||
let id = this.id;
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
client('DELETE', action + id + '/')
|
||||
.then(() => {
|
||||
resolve(true);
|
||||
})
|
||||
.catch(error => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a Compliance Application interface
|
||||
* @constructor
|
||||
* @param {function} client - make api call
|
||||
* @param {object} [data] - data of call
|
||||
*/
|
||||
export class ComplianceApplicationInterface extends PlivoResourceInterface {
|
||||
|
||||
constructor(client, data = {}) {
|
||||
super(action, ComplianceApplication, idField, client);
|
||||
extend(this, data);
|
||||
this[clientKey] = client;
|
||||
}
|
||||
|
||||
/**
|
||||
* get application by given id
|
||||
* @method
|
||||
* @param {string} id - id of application
|
||||
* @promise {object} return {@link EndUser} object
|
||||
* @fail {Error} return Error
|
||||
*/
|
||||
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 ComplianceApplicationResponse(response.body, client));
|
||||
})
|
||||
.catch(error => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* list all applications
|
||||
* @method
|
||||
* @param {object} params - params to list endusers
|
||||
* @param {string} [params.status] - Status of the application
|
||||
* @param {string} [params.endUserId] - End user ID related to application
|
||||
* @param {string} [params.numberType] -Number Type related to application
|
||||
* @param {integer} [params.offset] - No of value items by which results should be offset
|
||||
* @param {integer} [params.limit] - 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 => {
|
||||
resolve(new ListComplianceApplicationResponse(response.body, client));
|
||||
})
|
||||
.catch(error => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a complaince application
|
||||
* @method
|
||||
* @param {object} params
|
||||
* @param {string} [params.complianceRequirementId] - compliance requirement ID.
|
||||
* @param {string} [params.endUserId] - End user ID.
|
||||
* @param {string} [params.alias] - Alias
|
||||
* @param {string} [params.documentIds] - Document IDs
|
||||
* @param {string} [params.endUserType] - End user type
|
||||
* @param {string} [params.countryIso2] - CountryISo2
|
||||
* @param {string} [params.numberType] - Number Type
|
||||
* @fail {Error} return Error
|
||||
*/
|
||||
create(params = {}) {
|
||||
let client = this[clientKey];
|
||||
return new Promise((resolve, reject) => {
|
||||
client('POST', action, params)
|
||||
.then(response => {
|
||||
resolve(new CreateComplianceApplicationResponse(response.body, idField));
|
||||
})
|
||||
.catch(error => {
|
||||
reject(error);
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* update ComplianceApplication
|
||||
* @method
|
||||
* @param {string} id - id to update
|
||||
* @param {object} params
|
||||
* @param {string} [params.documentIds] - Document IDs
|
||||
* @promise {object} return {@link ComplianceApplication} object if success
|
||||
* @fail {Error} return Error
|
||||
*/
|
||||
update(id, params) {
|
||||
let errors = validate([{
|
||||
field: 'id',
|
||||
value: id,
|
||||
validators: ['isRequired']
|
||||
}]);
|
||||
|
||||
if (errors) {
|
||||
return errors;
|
||||
}
|
||||
return new ComplianceApplication(this[clientKey], {
|
||||
id: id
|
||||
}).update(params, id);
|
||||
}
|
||||
|
||||
/**
|
||||
* delete ComplianceApplication
|
||||
* @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']
|
||||
}]);
|
||||
|
||||
if (errors) {
|
||||
return errors;
|
||||
}
|
||||
return new ComplianceApplication(this[clientKey], {
|
||||
id: id
|
||||
}).delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* submit an application by given id
|
||||
* @method
|
||||
* @param {string} id - id of application
|
||||
* @fail {Error} return Error
|
||||
*/
|
||||
submit(id) {
|
||||
let client = this[clientKey];
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
if (action !== '' && !id) {
|
||||
reject(new Error(this[idKey] + ' must be set'));
|
||||
}
|
||||
|
||||
client('POST', action + (id ? id + '/Submit/' : ''))
|
||||
.then(response => {
|
||||
resolve(new ComplianceApplicationResponse(response.body, client));
|
||||
})
|
||||
.catch(error => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
110
lib/resources/complianceDocumentTypes.js
Normal file
110
lib/resources/complianceDocumentTypes.js
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
import {
|
||||
PlivoResource,
|
||||
PlivoResourceInterface
|
||||
} from '../base';
|
||||
import {
|
||||
extend,
|
||||
validate
|
||||
} from '../utils/common.js';
|
||||
|
||||
const clientKey = Symbol();
|
||||
const action = 'ComplianceDocumentType/';
|
||||
const idField = 'documentTypeID';
|
||||
|
||||
export class ComplianceDocumentTypeResponse {
|
||||
constructor(params) {
|
||||
params = params || {};
|
||||
this.apiId = params.apiId;
|
||||
this.documentTypeId = params.documentTypeId;
|
||||
this.documentName = params.documentName;
|
||||
this.description = params.description;
|
||||
this.information = params.information;
|
||||
this.proofRequired = params.proofRequired;
|
||||
this.createdAt = params.createdAt;
|
||||
}
|
||||
}
|
||||
|
||||
export class ListComplianceDocumentTypeResponse {
|
||||
constructor(params) {
|
||||
params = params || {};
|
||||
this.apiId = params.apiId;
|
||||
this.meta = params.meta;
|
||||
this.objects = params.objects;
|
||||
}
|
||||
}
|
||||
|
||||
export class ComplianceDocumentType extends PlivoResource {
|
||||
constructor(client, data = {}) {
|
||||
super(action, ComplianceDocumentType, idField, client);
|
||||
if (idField in data) {
|
||||
this.id = data[idField];
|
||||
}
|
||||
this[clientKey] = client;
|
||||
extend(this, data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a Compliance Document Type interface
|
||||
* @constructor
|
||||
* @param {function} client - make api call
|
||||
* @param {object} [data] - data of call
|
||||
*/
|
||||
export class ComplianceDocumentTypeInterface extends PlivoResourceInterface {
|
||||
|
||||
constructor(client, data = {}) {
|
||||
super(action, ComplianceDocumentType, idField, client);
|
||||
extend(this, data);
|
||||
this[clientKey] = client;
|
||||
}
|
||||
|
||||
/**
|
||||
* get compliance document types by id
|
||||
* @method
|
||||
* @param {string} id - id of the compliane document type.
|
||||
* @promise {object} return {@link ComplianceDocumentType} object
|
||||
* @fail {Error} return Error
|
||||
*/
|
||||
get(id) {
|
||||
let params = {}
|
||||
params.isVoiceRequest = 'false'
|
||||
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 ComplianceDocumentTypeResponse(response.body, client));
|
||||
})
|
||||
.catch(error => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* list compliance document types
|
||||
* @method
|
||||
* @param {object} params - params to list endusers
|
||||
* @param {string} [params.documentTypeID] - Document Type ID of the document id.
|
||||
* @param {string} [params.documentName] - Document name of the document if present.
|
||||
* @param {string} [params.description] - Description of the document type.
|
||||
* @param {string} [params.information] - Information about the document type.
|
||||
* @param {string} [params.proofRequired] - Proofs required for the document.
|
||||
*/
|
||||
list(params = {}) {
|
||||
let client = this[clientKey];
|
||||
return new Promise((resolve, reject) => {
|
||||
client('GET', action, params)
|
||||
.then(response => {
|
||||
resolve(new ListComplianceDocumentTypeResponse(response.body, client));
|
||||
})
|
||||
.catch(error => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
262
lib/resources/complianceDocuments.js
Normal file
262
lib/resources/complianceDocuments.js
Normal file
|
|
@ -0,0 +1,262 @@
|
|||
import {
|
||||
PlivoResource,
|
||||
PlivoResourceInterface
|
||||
} from '../base';
|
||||
import {
|
||||
extend,
|
||||
validate
|
||||
} from '../utils/common.js';
|
||||
|
||||
const clientKey = Symbol();
|
||||
const action = 'ComplianceDocument/';
|
||||
const idField = 'complianceDocumentId';
|
||||
|
||||
export class ComplianceDocumentResponse {
|
||||
constructor(params) {
|
||||
params = params || {};
|
||||
this.apiId = params.apiId;
|
||||
this.documentTypeId = params.documentTypeId;
|
||||
this.documentId = params.documentId;
|
||||
this.endUserId = params.endUserId;
|
||||
this.alias = params.alias;
|
||||
this.metaInformation = params.metaInformation;
|
||||
this.fileName = params.fileName,
|
||||
this.createdAt = params.createdAt;
|
||||
}
|
||||
}
|
||||
|
||||
export class CreateComplianceDocumentResponse {
|
||||
constructor(params) {
|
||||
params = params || {};
|
||||
this.apiId = params.apiId;
|
||||
this.documentTypeId = params.documentTypeId;
|
||||
this.documentId = params.documentId;
|
||||
this.endUserId = params.endUserId;
|
||||
this.alias = params.alias;
|
||||
this.message = params.message;
|
||||
this.metaInformation = params.metaInformation;
|
||||
this.fileName = params.fileName,
|
||||
this.createdAt = params.createdAt;
|
||||
}
|
||||
}
|
||||
|
||||
export class ListComplianceDocumentsResponse {
|
||||
constructor(params) {
|
||||
params = params || {};
|
||||
this.apiId = params.apiId;
|
||||
this.meta = params.meta;
|
||||
this.objects = params.objects;
|
||||
}
|
||||
}
|
||||
|
||||
export class UpdateComplianceDocumentResponse {
|
||||
constructor(params) {
|
||||
params = params || {};
|
||||
this.apiId = params.apiId;
|
||||
this.message = params.message;
|
||||
}
|
||||
}
|
||||
|
||||
export class ComplianceDocument extends PlivoResource {
|
||||
constructor(client, data = {}) {
|
||||
super(action, ComplianceDocument, idField, client);
|
||||
if (idField in data) {
|
||||
this.id = data[idField];
|
||||
}
|
||||
this[clientKey] = client;
|
||||
extend(this, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* update Compliance Document
|
||||
* @method
|
||||
* @param {string} id - compliance document id of the document.
|
||||
* @param {object} params - optional params array of updated values
|
||||
* @promise {object} return {@link ComplianceDocument} object if success
|
||||
* @fail {Error} return Error
|
||||
*/
|
||||
update(params, id) {
|
||||
let client = this[clientKey];
|
||||
let that = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
if ((params.file) != 'undefined') {
|
||||
params.multipart = true;
|
||||
}
|
||||
|
||||
client('POST', action + id + '/', params)
|
||||
.then(response => {
|
||||
extend(that, response.body);
|
||||
extend(that, params);
|
||||
resolve(new UpdateComplianceDocumentResponse(that));
|
||||
})
|
||||
.catch(error => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* delete an Compliance Document
|
||||
* @method
|
||||
* @param {string} id - id to delete
|
||||
* @promise {boolean} return true if success
|
||||
* @fail {Error} return Error
|
||||
*/
|
||||
delete() {
|
||||
let client = this[clientKey];
|
||||
let id = this.id;
|
||||
return new Promise((resolve, reject) => {
|
||||
client('DELETE', action + id + '/')
|
||||
.then(() => {
|
||||
resolve(true);
|
||||
})
|
||||
.catch(error => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a Compliance Application interface
|
||||
* @constructor
|
||||
* @param {function} client - make api call
|
||||
* @param {object} [data] - data of call
|
||||
*/
|
||||
export class ComplianceDocumentInterface extends PlivoResourceInterface {
|
||||
constructor(client, data = {}) {
|
||||
super(action, ComplianceDocument, idField, client);
|
||||
extend(this, data);
|
||||
this[clientKey] = client;
|
||||
}
|
||||
|
||||
/**
|
||||
* get compliance document by given id
|
||||
* @method
|
||||
* @param {string} id - id of the document
|
||||
* @promise {object} return {@link ComplianceDocument} object
|
||||
* @fail {Error} return Error
|
||||
*/
|
||||
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 => {
|
||||
let object = new ComplianceDocumentResponse(response.body, client);
|
||||
Object.keys(object).forEach(key => object[key] === undefined && delete object[key]);
|
||||
resolve(object);
|
||||
})
|
||||
.catch(error => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* list all documents
|
||||
* @method
|
||||
* @param {object} params - params containing options to list compliance documents by.
|
||||
*/
|
||||
list(params = {}) {
|
||||
let client = this[clientKey];
|
||||
return new Promise((resolve, reject) => {
|
||||
client('GET', action, params)
|
||||
.then(response => {
|
||||
resolve(new ListComplianceDocumentsResponse(response.body, idField));
|
||||
})
|
||||
.catch(error => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a complaince document
|
||||
* @method
|
||||
* @param {object} params
|
||||
* @param {string} [params.complianceRequirementId] - compliance requirement ID.
|
||||
* @param {string} [params.endUserId] - End user ID.
|
||||
* @param {string} [params.alias] - Alias
|
||||
* @param {string} [params.documentTypeId] - Document Type ID
|
||||
* @param {string} [params.file] - File array of the files to be uploaded
|
||||
* @fail {Error} return Error
|
||||
*/
|
||||
create(params = {}) {
|
||||
let client = this[clientKey];
|
||||
let errors = validate([
|
||||
{ field: 'endUserId', value: params.endUserId, validators: ['isRequired', 'isString'] }
|
||||
]);
|
||||
|
||||
errors = validate([
|
||||
{ field: 'documentTypeId', value: params.documentTypeId, validators: ['isRequired', 'isString'] }
|
||||
]);
|
||||
|
||||
errors = validate([
|
||||
{ field: 'alias', value: params.alias, validators: ['isRequired', 'isString'] }
|
||||
]);
|
||||
|
||||
if (errors) {
|
||||
return errors;
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
params.multipart = true;
|
||||
client('POST', action, params)
|
||||
.then(response => {
|
||||
resolve(new CreateComplianceDocumentResponse(response.body, idField));
|
||||
})
|
||||
.catch(error => {
|
||||
reject(error);
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* update Compliance Document
|
||||
* @method
|
||||
* @param {string} id - compliance document id of the document.
|
||||
* @param {object} params - optional params array of updated values
|
||||
* @promise {object} return {@link ComplianceDocument} object if success
|
||||
* @fail {Error} return Error
|
||||
*/
|
||||
update(id, params) {
|
||||
let errors = validate([{
|
||||
field: 'id',
|
||||
value: id,
|
||||
validators: ['isRequired']
|
||||
}]);
|
||||
|
||||
if (errors) {
|
||||
return errors;
|
||||
}
|
||||
return new ComplianceDocument(this[clientKey], {
|
||||
id: id
|
||||
}).update(params, id);
|
||||
}
|
||||
|
||||
/**
|
||||
* delete a Compliance Document
|
||||
* @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']
|
||||
}]);
|
||||
|
||||
if (errors) {
|
||||
return errors;
|
||||
}
|
||||
return new ComplianceDocument(this[clientKey], {
|
||||
id: id
|
||||
}).delete();
|
||||
}
|
||||
}
|
||||
100
lib/resources/complianceRequirements.js
Normal file
100
lib/resources/complianceRequirements.js
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
import {
|
||||
PlivoResource,
|
||||
PlivoResourceInterface
|
||||
} from '../base';
|
||||
import {
|
||||
extend,
|
||||
validate
|
||||
} from '../utils/common.js';
|
||||
|
||||
const clientKey = Symbol();
|
||||
const action = 'ComplianceRequirement/';
|
||||
const idField = 'ComplianceRequirementId';
|
||||
|
||||
|
||||
export class ComplianceRequirementResponse {
|
||||
constructor(params) {
|
||||
params = params || {};
|
||||
this.apiId = params.apiId;
|
||||
this.complianceRequirementId = params.complianceRequirementId;
|
||||
this.countryIso2 = params.countryIso2;
|
||||
this.numberType = params.numberType;
|
||||
this.endUserType = params.endUserType;
|
||||
this.acceptableDocumentTypes = params.acceptableDocumentTypes;
|
||||
}
|
||||
}
|
||||
|
||||
export class ComplianceRequirement extends PlivoResource {
|
||||
constructor(client, data = {}) {
|
||||
super(action, ComplianceRequirement, idField, client);
|
||||
if (idField in data) {
|
||||
this.id = data[idField];
|
||||
}
|
||||
this[clientKey] = client;
|
||||
extend(this, data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a Compliance Requirement
|
||||
* @constructor
|
||||
* @param {function} client - make api call
|
||||
* @param {object} [data] - data of call
|
||||
*/
|
||||
export class ComplianceRequirementInterface extends PlivoResourceInterface {
|
||||
|
||||
constructor(client, data = {}) {
|
||||
super(action, ComplianceRequirement, idField, client);
|
||||
extend(this, data);
|
||||
this[clientKey] = client;
|
||||
}
|
||||
|
||||
/**
|
||||
* get compliance requirement by given id
|
||||
* @method
|
||||
* @param {string} id - id of the compliance requirement
|
||||
* @promise {object} return {@link ComplianceRequirement} object
|
||||
* @fail {Error} return Error
|
||||
*/
|
||||
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 ComplianceRequirementResponse(response.body, client));
|
||||
})
|
||||
.catch(error => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* list compliance requirements
|
||||
* @method
|
||||
* @param {object} params - params to list endusers
|
||||
* @param {string} [params.countryIso2] - Document Type ID of the document id.
|
||||
* @param {string} [params.numberType] - Document name of the document if present.
|
||||
* @param {string} [params.phoneNumber] - Description of the document type.
|
||||
* @param {string} [params.endUserType] - Information about the document type.
|
||||
* A combination of countryIso2, numberType, endUserType OR
|
||||
* phoneNumber, endUserType can be used to fetch compliance requirements.
|
||||
*/
|
||||
list(params = {}) {
|
||||
let client = this[clientKey];
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
client('GET', action, params)
|
||||
.then(response => {
|
||||
resolve(new ComplianceRequirementResponse(response.body, client));
|
||||
})
|
||||
.catch(error => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
254
lib/resources/endUsers.js
Normal file
254
lib/resources/endUsers.js
Normal file
|
|
@ -0,0 +1,254 @@
|
|||
import {
|
||||
PlivoResource,
|
||||
PlivoResourceInterface
|
||||
} from '../base';
|
||||
import {
|
||||
extend,
|
||||
validate
|
||||
} from '../utils/common.js';
|
||||
|
||||
const clientKey = Symbol();
|
||||
const action = 'EndUser/';
|
||||
const idField = 'endUserId';
|
||||
|
||||
export class EndUsersResponse {
|
||||
constructor(params) {
|
||||
params = params || {};
|
||||
this.apiId = params.apiId;
|
||||
this.endUserId = params.endUserId;
|
||||
this.endUserType = params.endUserType;
|
||||
this.name = params.name;
|
||||
this.lastName = params.lastName;
|
||||
this.createdAt = params.createdAt;
|
||||
}
|
||||
}
|
||||
|
||||
export class CreateEndUsersResponse {
|
||||
constructor(params) {
|
||||
params = params || {};
|
||||
this.apiId = params.apiId;
|
||||
this.endUserId = params.endUserId;
|
||||
this.endUserType = params.endUserType;
|
||||
this.name = params.name;
|
||||
this.lastName = params.lastName;
|
||||
this.message = params.message;
|
||||
this.createdAt = params.createdAt;
|
||||
}
|
||||
}
|
||||
|
||||
export class ListEndUsersResponse {
|
||||
constructor(params) {
|
||||
params = params || {};
|
||||
this.apiId = params.apiId;
|
||||
this.meta = params.meta;
|
||||
this.objects = params.objects;
|
||||
}
|
||||
}
|
||||
|
||||
export class UpdateEndUsersResponse {
|
||||
constructor(params) {
|
||||
params = params || {};
|
||||
this.apiId = params.apiId;
|
||||
this.message = params.message;
|
||||
}
|
||||
}
|
||||
|
||||
export class EndUser extends PlivoResource {
|
||||
constructor(client, data = {}) {
|
||||
super(action, EndUser, idField, client);
|
||||
if (idField in data) {
|
||||
this.id = data[idField];
|
||||
}
|
||||
this[clientKey] = client;
|
||||
extend(this, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* update end user
|
||||
* @method
|
||||
* @param {object} params - to update end user
|
||||
* @param {string} [params.name] - Name of the endUser if present.
|
||||
* @param {string} [params.last_name] - Last name of the endUser if present.
|
||||
* @param {string} [params.end_user_type] - Type of the end user.
|
||||
* @fail {Error} return Error
|
||||
*/
|
||||
update(params, id) {
|
||||
let client = this[clientKey];
|
||||
let that = this;
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
client('POST', action + id + '/', params)
|
||||
.then(response => {
|
||||
extend(that, response.body);
|
||||
extend(that, params);
|
||||
resolve(new UpdateEndUsersResponse(that));
|
||||
})
|
||||
.catch(error => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* delete an EndUser
|
||||
* @method
|
||||
* @param {string} id - id to delete
|
||||
* @promise {boolean} return true if success
|
||||
* @fail {Error} return Error
|
||||
*/
|
||||
delete() {
|
||||
let client = this[clientKey];
|
||||
let id = this.id;
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
client('DELETE', action + id + '/')
|
||||
.then(() => {
|
||||
resolve(true);
|
||||
})
|
||||
.catch(error => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a End Users interface
|
||||
* @constructor
|
||||
* @param {function} client - make api call
|
||||
* @param {object} [data] - data of call
|
||||
*/
|
||||
export class EndUserInterface extends PlivoResourceInterface {
|
||||
|
||||
constructor(client, data = {}) {
|
||||
super(action, EndUser, idField, client);
|
||||
extend(this, data);
|
||||
this[clientKey] = client;
|
||||
}
|
||||
|
||||
/**
|
||||
* get an enduser by given id
|
||||
* @method
|
||||
* @param {string} id - id of the endUser
|
||||
* @promise {object} return {@link EndUser} object
|
||||
* @fail {Error} return Error
|
||||
*/
|
||||
get(id) {
|
||||
let errors = validate([
|
||||
{field: 'id', value: id, validators: ['isRequired']}
|
||||
]);
|
||||
|
||||
if (errors) {
|
||||
return errors;
|
||||
}
|
||||
|
||||
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 EndUsersResponse(response.body, client));
|
||||
})
|
||||
.catch(error => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* list EndUsers
|
||||
* @method
|
||||
* @param {object} params - params to list endusers
|
||||
* @param {string} [params.name] - Name of the endUser, if present.
|
||||
* @param {string} [params.lastName] - Last name of the endUser, if present.
|
||||
* @param {string} [params.endUserType] - Type of an end user.
|
||||
* @param {integer} [params.offset] - No of value items by which results should be offset
|
||||
* @param {integer} [params.limit] - 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 => {
|
||||
resolve(new ListEndUsersResponse(response.body, client));
|
||||
})
|
||||
.catch(error => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create end user
|
||||
* @method
|
||||
* @param {object} params - to update end user
|
||||
* @param {string} [params.name] - Name of the endUser if present.
|
||||
* @param {string} [params.lastName] - Last name of the endUser if present.
|
||||
* @param {string} [params.endUserType] - Type of the end user.
|
||||
* @fail {Error} return Error
|
||||
*/
|
||||
create(params = {}) {
|
||||
let client = this[clientKey];
|
||||
return new Promise((resolve, reject) => {
|
||||
client('POST', action, params)
|
||||
.then(response => {
|
||||
resolve(new CreateEndUsersResponse(response.body, idField));
|
||||
})
|
||||
.catch(error => {
|
||||
reject(error);
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* update end user
|
||||
* @method
|
||||
* @param {object} params - to update end user
|
||||
* @param {string} [params.name] - Name of the endUser if present.
|
||||
* @param {string} [params.lastName] - Last name of the endUser if present.
|
||||
* @param {string} [params.endUserType] - Type of the end user.
|
||||
* @fail {Error} return Error
|
||||
*/
|
||||
update(id, params) {
|
||||
let errors = validate([{
|
||||
field: 'id',
|
||||
value: id,
|
||||
validators: ['isRequired']
|
||||
}]);
|
||||
|
||||
if (errors) {
|
||||
return errors;
|
||||
}
|
||||
|
||||
return new EndUser(this[clientKey], {
|
||||
id: id
|
||||
}).update(params, id);
|
||||
}
|
||||
|
||||
/**
|
||||
* delete EndUser
|
||||
* @method
|
||||
* @param {string} id - id to delete an enduser with
|
||||
* @promise {boolean} return true if success
|
||||
* @fail {Error} return Error
|
||||
*/
|
||||
delete(id) {
|
||||
let errors = validate([{
|
||||
field: 'id',
|
||||
value: id,
|
||||
validators: ['isRequired']
|
||||
}]);
|
||||
|
||||
if (errors) {
|
||||
return errors;
|
||||
}
|
||||
|
||||
return new EndUser(this[clientKey], {
|
||||
id: id
|
||||
}).delete();
|
||||
}
|
||||
}
|
||||
|
|
@ -295,7 +295,7 @@ export class NumberInterface extends PlivoResourceInterface {
|
|||
|
||||
let params = optionalParams || {};
|
||||
params.country_iso = countryISO;
|
||||
return new PhoneNumberInterface(this[clientKey]).list(countryISO, params);
|
||||
return new PhoneNumberInterface(this[clientKey]).list(params);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -30,6 +30,65 @@ export function Axios(config) {
|
|||
}
|
||||
|
||||
return (method, action, params) => {
|
||||
let configuration = config;
|
||||
// Add support fot multipart requests.
|
||||
if (typeof (params) != 'undefined' && params.multipart == true) {
|
||||
return new Promise((resolve, reject) => {
|
||||
delete params.multipart;
|
||||
|
||||
var FormData = require('form-data');
|
||||
var multipartParams = new FormData();
|
||||
|
||||
for(const key in params) {
|
||||
if (key != 'file') {
|
||||
multipartParams.append(key, params[key]);
|
||||
} else {
|
||||
multipartParams.append(key, require('fs').createReadStream(params[key]));
|
||||
}
|
||||
}
|
||||
|
||||
let headers = multipartParams.getHeaders();
|
||||
|
||||
var config = {
|
||||
method: method,
|
||||
url: configuration.url + '/' + action,
|
||||
headers: {
|
||||
'Authorization': 'Basic ' + new Buffer(configuration.authId + ':' + configuration.authToken).toString('base64'),
|
||||
'User-Agent': configuration.userAgent,
|
||||
'content-type': headers['content-type']
|
||||
},
|
||||
data : multipartParams
|
||||
};
|
||||
|
||||
axios(config).then(response => {
|
||||
const exceptionClass = {
|
||||
400: Exceptions.InvalidRequestError,
|
||||
401: Exceptions.AuthenticationError,
|
||||
404: Exceptions.ResourceNotFoundError,
|
||||
405: Exceptions.InvalidRequestError,
|
||||
500: Exceptions.ServerError,
|
||||
} [response.status] || Error;
|
||||
|
||||
if (!_.inRange(response.status, 200, 300)) {
|
||||
let body = response.data;
|
||||
if (typeof body === 'object') {
|
||||
reject(new exceptionClass(JSON.stringify(body)));
|
||||
}
|
||||
else {
|
||||
reject(new exceptionClass(body));
|
||||
}
|
||||
}
|
||||
resolve({
|
||||
response: response,
|
||||
body: response.data
|
||||
});
|
||||
})
|
||||
.catch(function (error) {
|
||||
reject(error.stack+ "\r\n" + JSON.stringify(error.response.data));
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
if (typeof (params) != 'undefined' && typeof (params.file) != 'undefined') {
|
||||
let files = [];
|
||||
if (Array.isArray(params.file)) {
|
||||
|
|
@ -41,6 +100,7 @@ export function Axios(config) {
|
|||
}
|
||||
params.file = files;
|
||||
}
|
||||
|
||||
let options = {
|
||||
url: config.url + '/' + action,
|
||||
method: method,
|
||||
|
|
|
|||
|
|
@ -20,6 +20,11 @@ import { validateV3Signature } from "../utils/v3Security";
|
|||
import { stringify } from "./../utils/jsonStrinfigier";
|
||||
import { CallFeedbackInterface } from "../resources/callFeedback";
|
||||
import { MediaInterface } from "../resources/media.js";
|
||||
import { EndUserInterface } from "../resources/endUsers";
|
||||
import { ComplianceDocumentTypeInterface } from "../resources/complianceDocumentTypes";
|
||||
import { ComplianceDocumentInterface} from "../resources/complianceDocuments";
|
||||
import { ComplianceRequirementInterface } from "../resources/complianceRequirements";
|
||||
import { ComplianceApplicationInterface } from "../resources/complianceApplications";
|
||||
|
||||
exports.Response = function() {
|
||||
return new Response();
|
||||
|
|
@ -82,6 +87,11 @@ export class Client {
|
|||
this.recordings = new RecordingInterface(client);
|
||||
this.callFeedback = new CallFeedbackInterface(client);
|
||||
this.media = new MediaInterface(client);
|
||||
this.endUsers = new EndUserInterface(client);
|
||||
this.complianceDocumentTypes = new ComplianceDocumentTypeInterface(client);
|
||||
this.complianceDocuments = new ComplianceDocumentInterface(client);
|
||||
this.complianceRequirements = new ComplianceRequirementInterface(client);
|
||||
this.complianceApplications = new ComplianceApplicationInterface(client);
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
|
|
|
|||
|
|
@ -47,7 +47,8 @@ export function camelCaseRequestWrapper(requestFunc) {
|
|||
.replace('_greater_or_equal', '__gte')
|
||||
.replace('_less_or_equal', '__lte')
|
||||
.replace('_equal', '')
|
||||
.replace('_equals', '');
|
||||
.replace('_equals', '')
|
||||
.replace('country_iso_2', 'country_iso2');
|
||||
});
|
||||
|
||||
return requestFunc(method, action, params).then(res => {
|
||||
|
|
|
|||
146
types/resources/complianceApplications.d.ts
vendored
Normal file
146
types/resources/complianceApplications.d.ts
vendored
Normal file
|
|
@ -0,0 +1,146 @@
|
|||
export class ComplianceApplicationResponse {
|
||||
constructor(params: object);
|
||||
apiId: string;
|
||||
complianceApplicationId: string;
|
||||
endUserID: string;
|
||||
endUserType: string;
|
||||
alias: string;
|
||||
status: string;
|
||||
countryIso2: string;
|
||||
numberType: string;
|
||||
complianceRequirementId: string;
|
||||
documents: Array<Object>;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export class CreateComplianceApplicationResponse {
|
||||
constructor(params: object);
|
||||
apiId: string;
|
||||
complianceApplicationId: string;
|
||||
endUserID: string;
|
||||
endUserType: string;
|
||||
alias: string;
|
||||
status: string;
|
||||
countryIso2: string;
|
||||
numberType: string;
|
||||
complianceRequirementId: string;
|
||||
documents: Array<Object>;
|
||||
createdAt: string;
|
||||
message: string;
|
||||
}
|
||||
|
||||
export class UpdateComplianceApplicationResponse {
|
||||
constructor(params: object);
|
||||
apiId: string;
|
||||
message: string;
|
||||
}
|
||||
|
||||
export class ListComplianceApplicationResponse {
|
||||
constructor(params: object);
|
||||
apiId: string;
|
||||
meta: Object;
|
||||
objects: Array<Object>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a ComplianceApplication
|
||||
* @constructor
|
||||
* @param {function} client - make api call
|
||||
* @param {object} [data] - data of call
|
||||
*/
|
||||
export class ComplianceApplication extends PlivoResource {
|
||||
constructor(client: Function, data?: {});
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* update ComplianceApplication
|
||||
* @method
|
||||
* @param {string} id - id to update
|
||||
* @param {object} params
|
||||
* @param {string} [params.documentIds] - Document IDs
|
||||
* @promise {object} return {@link ComplianceApplication} object if success
|
||||
* @fail {Error} return Error
|
||||
*/
|
||||
update(params: object, id: string): Promise<UpdateComplianceApplicationResponse>;
|
||||
|
||||
/**
|
||||
* delete an Compliance application
|
||||
* @method
|
||||
* @param {string} id - id to delete
|
||||
* @promise {boolean} return true if success
|
||||
* @fail {Error} return Error
|
||||
*/
|
||||
delete(): Promise<unknown>;
|
||||
[clientKey]: symbol;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a ComplianceApplication Interface
|
||||
* @constructor
|
||||
* @param {function} client - make api call
|
||||
* @param {object} [data] - data of call
|
||||
*/
|
||||
export class ComplianceApplicationInterface extends PlivoResourceInterface {
|
||||
constructor(client: Function, data?: {});
|
||||
/**
|
||||
* get application by given id
|
||||
* @method
|
||||
* @param {string} id - id of application
|
||||
* @promise {object} return {@link EndUser} object
|
||||
* @fail {Error} return Error
|
||||
*/
|
||||
get(id: string): Promise<ComplianceApplicationResponse>;
|
||||
|
||||
/**
|
||||
* list all applications
|
||||
* @method
|
||||
* @param {object} params - params to list endusers
|
||||
* @param {string} [params.status] - Status of the application
|
||||
* @param {string} [params.endUserId] - End user ID related to application
|
||||
* @param {string} [params.numberType] -Number Type related to application
|
||||
* @param {integer} [params.offset] - No of value items by which results should be offset
|
||||
* @param {integer} [params.limit] - No of value items by which results should be offset
|
||||
*/
|
||||
list(params: object): Promise<ListComplianceApplicationResponse>;
|
||||
|
||||
/**
|
||||
* Create a complaince application
|
||||
* @method
|
||||
* @param {object} params
|
||||
* @param {string} [params.complianceRequirementId] - compliance requirement ID.
|
||||
* @param {string} [params.endUserId] - End user ID.
|
||||
* @param {string} [params.alias] - Alias
|
||||
* @param {string} [params.documentIds] - Document IDs
|
||||
* @param {string} [params.endUserType] - End user type
|
||||
* @param {string} [params.countryIso2] - CountryISo2
|
||||
* @param {string} [params.numberType] - Number Type
|
||||
* @fail {Error} return Error
|
||||
*/
|
||||
create(params: object): Promise<CreateComplianceApplicationResponse>;
|
||||
|
||||
/**
|
||||
* update ComplianceApplication
|
||||
* @method
|
||||
* @param {string} id - id to update
|
||||
* @param {object} params
|
||||
* @param {string} [params.documentIds] - Document IDs
|
||||
* @promise {object} return {@link ComplianceApplication} object if success
|
||||
* @fail {Error} return Error
|
||||
*/
|
||||
update(id: string, params: object): Promise<UpdateComplianceApplicationResponse>;
|
||||
|
||||
/**
|
||||
* delete a ComplianceApplication
|
||||
* @method
|
||||
* @param {string} id - id to delete
|
||||
* @promise {boolean} return true if success
|
||||
* @fail {Error} return Error
|
||||
*/
|
||||
delete(id: string): any;
|
||||
[clientKey]: symbol;
|
||||
}
|
||||
|
||||
import { PlivoResource } from "../base";
|
||||
declare const clientKey: unique symbol;
|
||||
import { PlivoResourceInterface } from "../base";
|
||||
export {};
|
||||
65
types/resources/complianceDocumentTypes.d.ts
vendored
Normal file
65
types/resources/complianceDocumentTypes.d.ts
vendored
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
export class ComplianceDocumentTypeResponse {
|
||||
constructor(params: object);
|
||||
apiId: string;
|
||||
documentTypeID: string;
|
||||
documentName: string;
|
||||
description: string;
|
||||
information: object;
|
||||
proofRequired: string;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export class ListComplianceDocumentTypeResponse {
|
||||
constructor(params: object);
|
||||
apiId: string;
|
||||
objects: Array<Object>;
|
||||
meta: Object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a Compliance Document Type.
|
||||
* @constructor
|
||||
* @param {function} client - make api call
|
||||
* @param {object} [data] - data of call
|
||||
*/
|
||||
export class ComplianceDocumentType extends PlivoResource {
|
||||
constructor(client: Function, data?: {});
|
||||
[clientKey]: symbol;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a ComplianceDocumentTypeInterface Interface
|
||||
* @constructor
|
||||
* @param {function} client - make api call
|
||||
* @param {object} [data] - data of call
|
||||
*/
|
||||
export class ComplianceDocumentTypeInterface extends PlivoResourceInterface {
|
||||
constructor(client: Function, data?: {});
|
||||
|
||||
/**
|
||||
* get compliance document types by id
|
||||
* @method
|
||||
* @param {string} id - id of the compliane document type.
|
||||
* @promise {object} return {@link ComplianceDocumentType} object
|
||||
* @fail {Error} return Error
|
||||
*/
|
||||
get(id: string): Promise<ComplianceDocumentTypeResponse>;
|
||||
|
||||
|
||||
/**
|
||||
* list compliance document types
|
||||
* @method
|
||||
* @param {object} params - params to list endusers
|
||||
* @param {string} [params.documentTypeID] - Document Type ID of the document id.
|
||||
* @param {string} [params.documentName] - Document name of the document if present.
|
||||
* @param {string} [params.description] - Description of the document type.
|
||||
* @param {string} [params.information] - Information about the document type.
|
||||
* @param {string} [params.proofRequired] - Proofs required for the document.
|
||||
*/
|
||||
list(params: object): Promise<ListComplianceDocumentTypeResponse>;
|
||||
}
|
||||
|
||||
import { PlivoResource } from "../base";
|
||||
declare const clientKey: unique symbol;
|
||||
import { PlivoResourceInterface } from "../base";
|
||||
export {};
|
||||
134
types/resources/complianceDocuments.d.ts
vendored
Normal file
134
types/resources/complianceDocuments.d.ts
vendored
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
export class ComplianceDocumentResponse {
|
||||
constructor(params: object);
|
||||
apiId: string;
|
||||
documentTypeId: string;
|
||||
complianceDocumentId: string;
|
||||
documentId: string;
|
||||
alias: string;
|
||||
metaInformation: string;
|
||||
file: string;
|
||||
fileName: string;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export class CreateComplianceDocumentResponse {
|
||||
constructor(params: object);
|
||||
apiId: string;
|
||||
documentTypeId: string;
|
||||
complianceDocumentId: string;
|
||||
documentId: string;
|
||||
endUserId: string;
|
||||
alias: string;
|
||||
message: string;
|
||||
metaInformation: string;
|
||||
fileName: string;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export class ListComplianceDocumentResponse {
|
||||
constructor(params: object);
|
||||
apiId: string;
|
||||
meta: Object;
|
||||
objects: Array<Object>;
|
||||
}
|
||||
|
||||
export class UpdateComplianceDocumentResponse {
|
||||
constructor(params: object);
|
||||
apiId: string;
|
||||
message: string;
|
||||
}
|
||||
/**
|
||||
* Represents a Compliance Document
|
||||
* @constructor
|
||||
* @param {function} client - make api call
|
||||
* @param {object} [data] - data of call
|
||||
*/
|
||||
export class ComplianceDocument extends PlivoResource {
|
||||
constructor(client: Function, data?: {});
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* update Compliance Document
|
||||
* @method
|
||||
* @param {string} id - compliance document id of the document.
|
||||
* @param {object} params - optional params array of updated values
|
||||
* @promise {object} return {@link ComplianceDocument} object if success
|
||||
* @fail {Error} return Error
|
||||
*/
|
||||
update(params: object, id: string): Promise<UpdateComplianceDocumentResponse>;
|
||||
|
||||
/**
|
||||
* delete an Compliance Document
|
||||
* @method
|
||||
* @param {string} id - id to delete
|
||||
* @promise {boolean} return true if success
|
||||
* @fail {Error} return Error
|
||||
*/
|
||||
delete(): Promise<unknown>;
|
||||
[clientKey]: symbol;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a ComplianceDocument Interface
|
||||
* @constructor
|
||||
* @param {function} client - make api call
|
||||
* @param {object} [data] - data of call
|
||||
*/
|
||||
export class ComplianceDocumentInterface extends PlivoResourceInterface {
|
||||
constructor(client: Function, data?: {});
|
||||
|
||||
/**
|
||||
* get compliance document by given id
|
||||
* @method
|
||||
* @param {string} id - id of the document
|
||||
* @promise {object} return {@link ComplianceDocument} object
|
||||
* @fail {Error} return Error
|
||||
*/
|
||||
get(id: string): Promise<ComplianceDocumentResponse>;
|
||||
|
||||
|
||||
/**
|
||||
* list all documents
|
||||
* @method
|
||||
* @param {object} params - params containing options to list compliance documents by.
|
||||
*/
|
||||
list(params: object): Promise<ListComplianceDocumentResponse>;
|
||||
|
||||
/**
|
||||
* Create a complaince document
|
||||
* @method
|
||||
* @param {object} params
|
||||
* @param {string} [params.complianceRequirementId] - compliance requirement ID.
|
||||
* @param {string} [params.endUserId] - End user ID.
|
||||
* @param {string} [params.alias] - Alias
|
||||
* @param {string} [params.documentTypeId] - Document Type ID
|
||||
* @param {string} [params.file] - File array of the files to be uploaded
|
||||
* @fail {Error} return Error
|
||||
*/
|
||||
create(params: object): Promise<CreateComplianceDocumentResponse>;
|
||||
|
||||
/**
|
||||
* update Compliance Document
|
||||
* @method
|
||||
* @param {string} id - compliance document id of the document.
|
||||
* @param {object} params - optional params array of updated values
|
||||
* @promise {object} return {@link ComplianceDocument} object if success
|
||||
* @fail {Error} return Error
|
||||
*/
|
||||
update(id: string, params: object): Promise<UpdateComplianceDocumentResponse>;
|
||||
|
||||
/**
|
||||
* delete a Compliance Document
|
||||
* @method
|
||||
* @param {string} id - id to delete
|
||||
* @promise {boolean} return true if success
|
||||
* @fail {Error} return Error
|
||||
*/
|
||||
delete(id: string): any;
|
||||
[clientKey]: symbol;
|
||||
}
|
||||
|
||||
import { PlivoResource } from "../base";
|
||||
declare const clientKey: unique symbol;
|
||||
import { PlivoResourceInterface } from "../base";
|
||||
export {};
|
||||
58
types/resources/complianceRequirements.d.ts
vendored
Normal file
58
types/resources/complianceRequirements.d.ts
vendored
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
export class ComplianceRequirementResponse {
|
||||
constructor(params: object);
|
||||
apiId: string;
|
||||
ComplianceRequirementId: string;
|
||||
countryIso2: string;
|
||||
numberType: string;
|
||||
endUserType: object;
|
||||
acceptableDocumentTypes: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a Compliance Requirement
|
||||
* @constructor
|
||||
* @param {function} client - make api call
|
||||
* @param {object} [data] - data of call
|
||||
*/
|
||||
export class ComplianceRequirement extends PlivoResource {
|
||||
constructor(client: Function, data?: {});
|
||||
[clientKey]: symbol;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a Compliance Requirement
|
||||
* @constructor
|
||||
* @param {function} client - make api call
|
||||
* @param {object} [data] - data of call
|
||||
*/
|
||||
export class ComplianceRequirementInterface extends PlivoResourceInterface {
|
||||
constructor(client: Function, data?: {});
|
||||
|
||||
/**
|
||||
* get compliance requirement by given id
|
||||
* @method
|
||||
* @param {string} id - id of the compliance requirement
|
||||
* @promise {object} return {@link ComplianceRequirement} object
|
||||
* @fail {Error} return Error
|
||||
*/
|
||||
get(id: string): Promise<ComplianceRequirementResponse>;
|
||||
|
||||
|
||||
/**
|
||||
* list compliance requirements
|
||||
* @method
|
||||
* @param {object} params - params to list endusers
|
||||
* @param {string} [params.countryIso2] - Document Type ID of the document id.
|
||||
* @param {string} [params.numberType] - Document name of the document if present.
|
||||
* @param {string} [params.phoneNumber] - Description of the document type.
|
||||
* @param {string} [params.endUserType] - Information about the document type.
|
||||
* A combination of country_iso2, number_type, end_user_type OR
|
||||
* phone_number, end_user_type can be used to fetch compliance requirements.
|
||||
*/
|
||||
list(params: object): Promise<ComplianceRequirementResponse>;
|
||||
}
|
||||
|
||||
import { PlivoResource } from "../base";
|
||||
declare const clientKey: unique symbol;
|
||||
import { PlivoResourceInterface } from "../base";
|
||||
export {};
|
||||
131
types/resources/endUsers.d.ts
vendored
Normal file
131
types/resources/endUsers.d.ts
vendored
Normal file
|
|
@ -0,0 +1,131 @@
|
|||
export class EndUsersResponse {
|
||||
constructor(params: object);
|
||||
apiId: string;
|
||||
endUserId: string;
|
||||
endUserType: string;
|
||||
name: string;
|
||||
lastName: string;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export class CreateEndUsersResponse {
|
||||
constructor(params: object);
|
||||
apiId: string;
|
||||
endUserId: string;
|
||||
endUserType: string;
|
||||
name: string;
|
||||
lastName: string;
|
||||
createdAt: string;
|
||||
message: string;
|
||||
}
|
||||
|
||||
export class UpdateEndUsersResponse {
|
||||
constructor(params: object);
|
||||
apiId: string;
|
||||
message: string;
|
||||
}
|
||||
|
||||
export class ListEndUsersResponse {
|
||||
constructor(params: object);
|
||||
apiId: string;
|
||||
meta: Object;
|
||||
objects: Array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents an EndUser
|
||||
* @constructor
|
||||
* @param {function} client - make api call
|
||||
* @param {object} [data] - data of call
|
||||
*/
|
||||
export class EndUser extends PlivoResource {
|
||||
constructor(client: Function, data?: {});
|
||||
id: string;
|
||||
/**
|
||||
* update end user
|
||||
* @method
|
||||
* @param {object} params - to update end user
|
||||
* @param {string} [params.name] - Name of the endUser if present.
|
||||
* @param {string} [params.last_name] - Last name of the endUser if present.
|
||||
* @param {string} [params.end_user_type] - Type of the end user.
|
||||
* @fail {Error} return Error
|
||||
*/
|
||||
|
||||
update(params: object, id: string): Promise<UpdateEndUsersResponse>;
|
||||
/**
|
||||
* delete EndUser
|
||||
* @method
|
||||
* @promise {boolean} return true if success
|
||||
* @fail {Error} return Error
|
||||
*/
|
||||
delete(): Promise<unknown>;
|
||||
[clientKey]: symbol;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a EndUser Interface
|
||||
* @constructor
|
||||
* @param {function} client - make api call
|
||||
* @param {object} [data] - data of call
|
||||
*/
|
||||
export class EndUserInterface extends PlivoResourceInterface {
|
||||
constructor(client: Function, data?: {});
|
||||
/**
|
||||
* get EndUser by given id
|
||||
* @method
|
||||
* @param {string} id - id of the end user.
|
||||
* @promise {object} return {@link EndUser} object
|
||||
* @fail {Error} return Error
|
||||
*/
|
||||
get(id: string): Promise<EndUsersResponse>;
|
||||
|
||||
|
||||
/**
|
||||
* list endUsers
|
||||
* @method
|
||||
* @param {object} params - params to list endusers
|
||||
* @param {string} [params.name] - Name of the endUser if present.
|
||||
* @param {string} [params.last_name] - Last name of the endUser if present.
|
||||
* @param {string} [params.end_user_type] - Type of the end user.
|
||||
* @param {integer} [params.offset] - No of value items by which results should be offset
|
||||
* @param {integer} [params.limit] - No of value items by which results should be offset
|
||||
*/
|
||||
list(params: object): Promise<ListEndUsersResponse>;
|
||||
|
||||
/**
|
||||
* Create end user
|
||||
* @method
|
||||
* @param {object} params - to update end user
|
||||
* @param {string} [params.name] - Name of the endUser if present.
|
||||
* @param {string} [params.last_name] - Last name of the endUser if present.
|
||||
* @param {string} [params.end_user_type] - Type of the end user.
|
||||
* @fail {Error} return Error
|
||||
*/
|
||||
create(params: object): Promise<CreateEndUsersResponse>;
|
||||
|
||||
/**
|
||||
* update end user
|
||||
* @method
|
||||
* @param {object} params - to update end user
|
||||
* @param {string} [params.name] - Name of the endUser if present.
|
||||
* @param {string} [params.last_name] - Last name of the endUser if present.
|
||||
* @param {string} [params.end_user_type] - Type of the end user.
|
||||
* @fail {Error} return Error
|
||||
*/
|
||||
update(id: string, params: object): Promise<UpdateEndUsersResponse>;
|
||||
|
||||
/**
|
||||
* delete an EndUser
|
||||
* @method
|
||||
* @param {string} id - id to delete
|
||||
* @promise {boolean} return true if success
|
||||
* @fail {Error} return Error
|
||||
*/
|
||||
delete(id: string): any;
|
||||
[clientKey]: symbol;
|
||||
}
|
||||
|
||||
import { PlivoResource } from "../base";
|
||||
declare const clientKey: unique symbol;
|
||||
import { PlivoResourceInterface } from "../base";
|
||||
export {};
|
||||
5
types/rest/client.d.ts
vendored
5
types/rest/client.d.ts
vendored
|
|
@ -23,6 +23,11 @@ export class Client {
|
|||
recordings: RecordingInterface;
|
||||
callFeedback: CallFeedbackInterface;
|
||||
media: MediaInterface;
|
||||
endUsers: EndUserInterface;
|
||||
complianceDocumentTypes: ComplianceDocumentTypeInterface;
|
||||
complianceDocuments: ComplianceDocumentInterface;
|
||||
complianceRequirements: ComplianceRequirementInterface;
|
||||
complianceApplications: ComplianceApplicationInterface;
|
||||
toJSON(...args: any[]): any;
|
||||
}
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue