mirror of
https://github.com/Doodle3D/Doodle3D-API
synced 2024-12-22 13:53:48 +01:00
fix posts
This commit is contained in:
parent
5b7f8300bd
commit
5a11fafb0c
@ -11,10 +11,11 @@ export default class Config {
|
||||
return fetch(`${this.api}config/all`, { method: 'GET' }).then(parseFetch);
|
||||
}
|
||||
set(data) {
|
||||
return fetch(`${this.api}config`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data)
|
||||
}).then(parseFetch);
|
||||
const body = new URLSearchParams();
|
||||
for (const key in data) {
|
||||
body.append(key, data[key]);
|
||||
}
|
||||
|
||||
return fetch(`${this.api}config`, { method: 'POST', body }).then(parseFetch);
|
||||
}
|
||||
}
|
||||
|
@ -14,34 +14,30 @@ export default class Network {
|
||||
return fecth(`${this.api}network/status`, { method: 'GET' }).then(parseFetch);
|
||||
}
|
||||
assosiate(ssid, phrase, recreate = false) {
|
||||
return fetch(`${this.api}network/associate`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ ssid, phrase, recreate })
|
||||
}).then(parseFetch);
|
||||
const body = new URLSearchParams();
|
||||
body.append('ssid', ssid);
|
||||
body.append('phrase', phrase);
|
||||
body.append('recreate', recreate);
|
||||
|
||||
return fetch(`${this.api}network/associate`, { method: 'POST', body }).then(parseFetch);
|
||||
}
|
||||
disassociate() {
|
||||
//not tested
|
||||
return fetch(`${this.api}network/disassociate`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({})
|
||||
}).then(parseFetch);
|
||||
const body = new URLSearchParams();
|
||||
|
||||
return fetch(`${this.api}network/disassociate`, { method: 'POST', body }).then(parseFetch);
|
||||
}
|
||||
openAccesPoint() {
|
||||
//not tested
|
||||
return fetch(`${this.api}network/openap`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({})
|
||||
}).then(parseFetch);
|
||||
const body = new URLSearchParams();
|
||||
|
||||
return fetch(`${this.api}network/openap`, { method: 'POST', body }).then(parseFetch);
|
||||
}
|
||||
remove(ssid) {
|
||||
return fetch(`${this.api}network/remove`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ ssid })
|
||||
}).then(parseFetch);
|
||||
const body = new URLSearchParams();
|
||||
body.append('ssid', ssid);
|
||||
|
||||
return fetch(`${this.api}network/remove`, { method: 'POST', body }).then(parseFetch);
|
||||
}
|
||||
signin() {
|
||||
return fecth(`${this.api}network/signin`, { method: 'GET' }).then(parseFetch);
|
||||
|
@ -17,25 +17,32 @@ export default class Printer {
|
||||
return fetch(`${this.api}printer/listall`, { method: 'GET' }).then(parseFetch);
|
||||
}
|
||||
heatup() {
|
||||
return fetch(`${this.api}printer/heatup`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({})
|
||||
}).then(parseFetch);
|
||||
const body = new URLSearchParams();
|
||||
|
||||
return fetch(`${this.api}printer/heatup`, { method: 'POST', body }).then(parseFetch);
|
||||
}
|
||||
fetch(id, startCode = 'g28', endCode = 'g28') {
|
||||
const body = new URLSearchParams();
|
||||
body.append('id', id);
|
||||
body.append('start_code', startCode);
|
||||
body.append('end_code', endCode);
|
||||
|
||||
return fetch(`${this.api}printer/fetch`, { method: 'POST', body }).then(parseFetch);
|
||||
}
|
||||
print(gcode = '', first = false, start = false, last) {
|
||||
return fetch(`${this.api}printer/print`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ gcode, first, start, last })
|
||||
}).then(parseFetch);
|
||||
const body = new URLSearchParams();
|
||||
body.append('gcode', gcode);
|
||||
body.append('first', first);
|
||||
body.append('start', start);
|
||||
body.append('last', last);
|
||||
|
||||
return fetch(`${this.api}printer/print`, { method: 'POST', body }).then(parseFetch);
|
||||
}
|
||||
stop(gcode = '') {
|
||||
return fetch(`${this.api}printer/stop`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ gcode, first, start, last })
|
||||
}).then(parseFetch);
|
||||
const body = new URLSearchParams();
|
||||
body.append('gcode', gcode);
|
||||
|
||||
return fetch(`${this.api}printer/stop`, { method: 'POST', body }).then(parseFetch);
|
||||
}
|
||||
async _sendBatch(gcode, start, index) {
|
||||
try {
|
||||
|
@ -8,20 +8,17 @@ export default class Sketch {
|
||||
return fetch(`${this.api}sketch/?id=${id}`, { method: 'GET' }).then(parseFetch);
|
||||
}
|
||||
set(data = '') {
|
||||
return fetch(`${this.api}sketch`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ data })
|
||||
}).then(parseFetch);
|
||||
const body = new URLSearchParams();
|
||||
body.append('data', data);
|
||||
|
||||
return fetch(`${this.api}sketch`, { method: 'POST', body }).then(parseFetch);
|
||||
}
|
||||
status() {
|
||||
return fetch(`${this.api}sketch/status`, { method: 'GET' }).then(parseFetch);
|
||||
}
|
||||
clear() {
|
||||
return fetch(`${this.api}sketch/clear`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({})
|
||||
}).then(parseFetch);
|
||||
const body = new URLSearchParams();
|
||||
|
||||
return fetch(`${this.api}sketch/clear`, { method: 'POST', body }).then(parseFetch);
|
||||
}
|
||||
}
|
||||
|
@ -9,26 +9,20 @@ export default class Update {
|
||||
}
|
||||
download() {
|
||||
//not tested
|
||||
return fetch(`${this.api}update/download`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({})
|
||||
}).then(parseFetch);
|
||||
const body = new URLSearchParams();
|
||||
|
||||
return fetch(`${this.api}update/download`, { method: 'POST', body }).then(parseFetch);
|
||||
}
|
||||
install() {
|
||||
//not tested
|
||||
return fetch(`${this.api}update/install`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({})
|
||||
}).then(parseFetch);
|
||||
const body = new URLSearchParams();
|
||||
|
||||
return fetch(`${this.api}update/install`, { method: 'POST', body }).then(parseFetch);
|
||||
}
|
||||
clear() {
|
||||
//not tested
|
||||
return fetch(`${this.api}update/clear`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({})
|
||||
}).then(parseFetch);
|
||||
const body = new URLSearchParams();
|
||||
|
||||
return fetch(`${this.api}update/clear`, { method: 'POST', body }).then(parseFetch);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user