mirror of
https://github.com/Doodle3D/Doodle3D-API
synced 2024-10-05 01:18:39 +02:00
38 lines
677 B
JavaScript
38 lines
677 B
JavaScript
|
import rest from 'src/restapi';
|
||
|
|
||
|
export default class {
|
||
|
constructor (localIP) {
|
||
|
this.localIP = localIP;
|
||
|
this.api = 'http://' + localIP + '/d3dapi/';
|
||
|
}
|
||
|
|
||
|
get (keys, callback) {
|
||
|
rest.get(this.api + 'config/?' + keys.join('=&') + '=', callback);
|
||
|
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
getAll (callback) {
|
||
|
rest.get(this.api + 'config/all', callback);
|
||
|
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
set (data, callback) {
|
||
|
var scope = this;
|
||
|
|
||
|
rest.post(this.api + 'config', data, function (response) {
|
||
|
/*for (var i in response.validation) {
|
||
|
if (response.validation[i] === 'ok') {
|
||
|
scope[i] = data[i];
|
||
|
}
|
||
|
}*/
|
||
|
|
||
|
if (callback !== undefined) {
|
||
|
callback(response);
|
||
|
}
|
||
|
});
|
||
|
|
||
|
return this;
|
||
|
}
|
||
|
}
|