Doodle3D-API/src/api/printer.js

40 lines
732 B
JavaScript
Raw Normal View History

import * as rest from './restapi.js';
2015-07-15 15:06:18 +02:00
export default class {
constructor (api) {
this.api = api;
2015-07-15 15:06:18 +02:00
}
temperature () {
2016-04-21 15:09:49 +02:00
return rest.get(`${ this.api }printer/temperature`);
2015-07-15 15:06:18 +02:00
}
progress () {
2016-04-21 15:09:49 +02:00
return rest.get(`${ this.api }printer/progress`);
2015-07-15 15:06:18 +02:00
}
state () {
2016-04-21 15:09:49 +02:00
return rest.get(`${ this.api }printer/state`);
2015-07-15 15:06:18 +02:00
}
listAll () {
2016-04-21 15:09:49 +02:00
return rest.get(`${ this.api }printer/listall`);
2015-07-15 15:06:18 +02:00
}
heatup () {
2016-04-21 15:09:49 +02:00
return rest.post(`${ this.api }printer/heatup`, {});
}
print (gcode = '', first = false, start = false, last) {
2016-04-16 18:05:15 +02:00
const data = { gcode, first, start, last };
2016-04-21 15:09:49 +02:00
return rest.post(`${ this.api }printer/print`, data);
2015-07-15 15:06:18 +02:00
}
stop (gcode = '') {
2016-04-16 18:05:15 +02:00
const data = { gcode };
2016-04-21 15:09:49 +02:00
return rest.post(`${ this.api }printer/stop`, data);
2015-07-15 15:06:18 +02:00
}
}