Doodle3D-API/src/api/sketch.js

25 lines
648 B
JavaScript
Raw Normal View History

2017-11-30 17:23:13 +01:00
import { parseFetch } from '../utils.js';
2015-07-15 15:06:18 +02:00
2016-04-21 15:44:20 +02:00
export default class Sketch {
2016-04-21 15:52:23 +02:00
constructor(api) {
this.api = api;
}
getSketch(id) {
2017-11-30 17:23:13 +01:00
return fetch(`${this.api}sketch/?id=${id}`, { method: 'GET' }).then(parseFetch);
2016-04-21 15:52:23 +02:00
}
set(data = '') {
2018-01-25 17:29:51 +01:00
const body = new URLSearchParams();
body.append('data', data);
return fetch(`${this.api}sketch`, { method: 'POST', body }).then(parseFetch);
2016-04-21 15:52:23 +02:00
}
status() {
2017-11-30 17:23:13 +01:00
return fetch(`${this.api}sketch/status`, { method: 'GET' }).then(parseFetch);
2016-04-21 15:52:23 +02:00
}
clear() {
2018-01-25 17:29:51 +01:00
const body = new URLSearchParams();
return fetch(`${this.api}sketch/clear`, { method: 'POST', body }).then(parseFetch);
2016-04-21 15:52:23 +02:00
}
}