unclean SPARC
This commit is contained in:
@@ -0,0 +1,119 @@
|
||||
class SoeModel extends EICModel {
|
||||
|
||||
latestProject = null;
|
||||
|
||||
constructor(privileges) {
|
||||
super('/soe', privileges);
|
||||
}
|
||||
|
||||
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 => {
|
||||
return serverData.payload;
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
members() {
|
||||
if(!this.hasPrivilege('list')) return( new Promise((resolve, reject) => reject()))
|
||||
|
||||
let endpoint = this.getApiEndpoint('members');
|
||||
|
||||
return (
|
||||
this.request(endpoint.uri, endpoint.method)
|
||||
.then( async serverData => {
|
||||
return serverData.payload;
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
fundings(companyId, projectId) {
|
||||
if(!this.hasPrivilege('list')) return( new Promise((resolve, reject) => reject()))
|
||||
|
||||
let endpoint = this.getApiEndpoint('project');
|
||||
endpoint.uri = endpoint.uri.replace('{pic}', companyId);
|
||||
endpoint.uri = endpoint.uri.replace('{projectId}', projectId);
|
||||
|
||||
return (
|
||||
this.request(endpoint.uri, endpoint.method)
|
||||
.then( async serverData => {
|
||||
this.latestProject = serverData.payload;
|
||||
return this.latestProject;
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
getFeedback(id) {
|
||||
return this.latestProject ? this.latestProject.fundings.find(item => item.id == id) : null;
|
||||
}
|
||||
|
||||
item(companyId, projectId, fundingId) {
|
||||
if(!this.hasPrivilege('list')) return( new Promise((resolve, reject) => reject()))
|
||||
|
||||
let endpoint = this.getApiEndpoint('read');
|
||||
endpoint.uri = endpoint.uri.replace('{pic}', companyId);
|
||||
endpoint.uri = endpoint.uri.replace('{projectId}', projectId);
|
||||
endpoint.uri = endpoint.uri.replace('{fundingId}', fundingId);
|
||||
|
||||
return (
|
||||
this.request(endpoint.uri, endpoint.method)
|
||||
.then( async serverData => {
|
||||
return serverData.payload;
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
create(companyId, projectId, payload) {
|
||||
if(!this.hasPrivilege('create')) return( new Promise((resolve, reject) => reject()))
|
||||
|
||||
let endpoint = this.getApiEndpoint('create');
|
||||
endpoint.uri = endpoint.uri.replace('{pic}', companyId);
|
||||
endpoint.uri = endpoint.uri.replace('{projectId}', projectId);
|
||||
|
||||
return (
|
||||
this.request(endpoint.uri, endpoint.method, payload)
|
||||
.then( async serverData => {
|
||||
return serverData.payload;
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
update(companyId, projectId, fundingId, payload) {
|
||||
if(!this.hasPrivilege('update')) return( new Promise((resolve, reject) => reject()))
|
||||
|
||||
let endpoint = this.getApiEndpoint('update');
|
||||
endpoint.uri = endpoint.uri.replace('{pic}', companyId);
|
||||
endpoint.uri = endpoint.uri.replace('{projectId}', projectId);
|
||||
endpoint.uri = endpoint.uri.replace('{fundingId}', fundingId);
|
||||
|
||||
return (
|
||||
this.request(endpoint.uri, endpoint.method, payload)
|
||||
.then( async serverData => {
|
||||
return serverData.payload;
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
delete(companyId, projectId, fundingId) {
|
||||
if(!this.hasPrivilege('delete')) return( new Promise((resolve, reject) => reject()))
|
||||
|
||||
let endpoint = this.getApiEndpoint('delete');
|
||||
endpoint.uri = endpoint.uri.replace('{pic}', companyId);
|
||||
endpoint.uri = endpoint.uri.replace('{projectId}', projectId);
|
||||
endpoint.uri = endpoint.uri.replace('{fundingId}', fundingId);
|
||||
|
||||
return (
|
||||
this.request(endpoint.uri, endpoint.method)
|
||||
.then( async serverData => {
|
||||
return serverData.payload;
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
app.registerClass('SoeModel', SoeModel);
|
||||
Reference in New Issue
Block a user