48 lines
1.2 KiB
JavaScript
48 lines
1.2 KiB
JavaScript
class SimsModel extends WindozModel {
|
|
|
|
constructor() {
|
|
super()
|
|
this.ressource = '/sims'
|
|
}
|
|
|
|
async list() {
|
|
let endpoint = {...app.config.api[this.ressource].list}
|
|
return(
|
|
this.request(endpoint.uri, endpoint.method)
|
|
)
|
|
}
|
|
|
|
async get(simId) {
|
|
let endpoint = {...app.config.api[this.ressource].get}
|
|
endpoint.uri = endpoint.uri.replace('{simId}', simId)
|
|
return(
|
|
this.request(endpoint.uri, endpoint.method)
|
|
)
|
|
}
|
|
|
|
async create(simData) {
|
|
let endpoint = {...app.config.api[this.ressource].create}
|
|
return(
|
|
this.request(endpoint.uri, endpoint.method, simData)
|
|
)
|
|
}
|
|
|
|
async start(simId) {
|
|
let endpoint = {...app.config.api[this.ressource].start}
|
|
endpoint.uri = endpoint.uri.replace('{simId}', simId)
|
|
return(
|
|
this.request(endpoint.uri, endpoint.method)
|
|
)
|
|
}
|
|
|
|
async pause(simId) {
|
|
let endpoint = {...app.config.api[this.ressource].pause}
|
|
endpoint.uri = endpoint.uri.replace('{simId}', simId)
|
|
return(
|
|
this.request(endpoint.uri, endpoint.method)
|
|
)
|
|
}
|
|
}
|
|
|
|
app.registerClass('SimsModel', SimsModel)
|