83 lines
2.8 KiB
JavaScript
83 lines
2.8 KiB
JavaScript
class ContactMgrModel extends EICModel {
|
|
|
|
constructor(privileges) {
|
|
super('/contactMgr', privileges)
|
|
Object.assign(this, app.helpers.validators)
|
|
}
|
|
|
|
async list() {
|
|
if(!this.hasPrivilege('list')) return( new Promise((resolve, reject) => reject()))
|
|
let endpoint = this.getApiEndpoint('list')
|
|
return (
|
|
this.request(endpoint.uri, endpoint.method)
|
|
.then( async serverData => serverData.payload)
|
|
)
|
|
}
|
|
|
|
async get(qcid){
|
|
if(!this.hasPrivilege('get')) return( new Promise((resolve, reject) => reject()))
|
|
let endpoint = this.getApiEndpoint('get')
|
|
endpoint.uri = endpoint.uri.replace('{qcid}', qcid)
|
|
return (
|
|
this.request(endpoint.uri, endpoint.method)
|
|
.then( async serverData => serverData.payload)
|
|
)
|
|
}
|
|
|
|
async getField(qcid, fieldid){
|
|
if(!this.hasPrivilege('getFields')) return( new Promise((resolve, reject) => reject()))
|
|
const endpoint = this.getApiEndpoint('getFields')
|
|
endpoint.uri = endpoint.uri.replace('{qcid}', qcid)
|
|
const payload = {
|
|
fieldid: fieldid
|
|
}
|
|
return (
|
|
this.request(endpoint.uri, endpoint.method, payload)
|
|
.then( async serverData => serverData.payload)
|
|
)
|
|
}
|
|
|
|
async getSample(qcid, values){
|
|
if(!this.hasPrivilege('execute')) return( new Promise((resolve, reject) => reject()))
|
|
let endpoint = this.getApiEndpoint('execute')
|
|
endpoint.uri = endpoint.uri.replace('{qcid}', qcid)
|
|
return (
|
|
this.request(endpoint.uri, endpoint.method, {
|
|
sample: true,
|
|
sampleSize: 10,
|
|
values: values,
|
|
})
|
|
.then( async serverData => serverData.payload)
|
|
)
|
|
}
|
|
|
|
async execute(qcid, values){
|
|
if(!this.hasPrivilege('execute')) return( new Promise((resolve, reject) => reject()))
|
|
let endpoint = this.getApiEndpoint('execute')
|
|
endpoint.uri = endpoint.uri.replace('{qcid}', qcid)
|
|
return (
|
|
this.request(endpoint.uri, endpoint.method, {
|
|
sample: false,
|
|
values: values,
|
|
})
|
|
.then( async serverData => serverData.payload)
|
|
)
|
|
}
|
|
|
|
async probe(qcid, values, probe){
|
|
if(!this.hasPrivilege('execute')) return( new Promise((resolve, reject) => reject()))
|
|
let endpoint = this.getApiEndpoint('execute')
|
|
endpoint.uri = endpoint.uri.replace('{qcid}', qcid)
|
|
return (
|
|
this.request(endpoint.uri, endpoint.method, {
|
|
sample: false,
|
|
probe: probe,
|
|
values: values,
|
|
})
|
|
.then( async serverData => serverData.payload)
|
|
)
|
|
}
|
|
|
|
}
|
|
|
|
app.registerClass('ContactMgrModel', ContactMgrModel); |