unclean SPARC
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
class BypassCompanyModel extends EICModel {
|
||||
|
||||
constructor(privileges) {
|
||||
super('company', privileges);
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches for a company based on its PIC and retrieves its information and the allocated token if applies
|
||||
* @param {*} endpoint
|
||||
* @param {*} payload
|
||||
* @returns
|
||||
*/
|
||||
search(pic) {
|
||||
if(!this.hasPrivilege('search')) return( new Promise((resolve, reject) => reject()))
|
||||
|
||||
let endpoint = this.getApiEndpoint('search');
|
||||
let uri = endpoint.uri.replace('{pic}', pic);
|
||||
|
||||
return (
|
||||
this.request(uri, endpoint.method)
|
||||
.then( async serverData => this.loadData(serverData.payload))
|
||||
)
|
||||
}
|
||||
|
||||
grant(pic, payload) {
|
||||
if(!this.hasPrivilege('grant')) return( new Promise((resolve, reject) => reject()))
|
||||
|
||||
let endpoint = this.getApiEndpoint('grant');
|
||||
let uri = endpoint.uri.replace('{pic}', pic);
|
||||
|
||||
return (
|
||||
this.request(uri, endpoint.method, payload).then(
|
||||
(reply) => { // Now that we have a token, populate company model with it (was null)
|
||||
this.itemData.token = reply.payload.token
|
||||
return(reply)
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
revoke(pic, payload) {
|
||||
if(!this.hasPrivilege('revoke')) return( new Promise((resolve, reject) => reject()))
|
||||
|
||||
let endpoint = this.getApiEndpoint('revoke');
|
||||
let uri = endpoint.uri.replace('{pic}', pic);
|
||||
|
||||
return this.request(uri, endpoint.method, payload);
|
||||
}
|
||||
}
|
||||
|
||||
app.registerClass('BypassCompanyModel', BypassCompanyModel);
|
||||
Reference in New Issue
Block a user