Doodle3D-API/src/api/network.js

58 lines
949 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
}
scan () {
2016-04-21 15:09:49 +02:00
return rest.get(`${ this.api }network/scan`);
2015-07-15 15:06:18 +02:00
}
known () {
2016-04-21 15:09:49 +02:00
return rest.get(`${ this.api }network/known`);
2015-07-15 15:06:18 +02:00
}
status () {
2016-04-21 15:09:49 +02:00
return rest.get(`${ this.api }network/status`);
2015-07-15 15:06:18 +02:00
}
assosiate (ssid, phrase, recreate = false) {
2016-04-16 18:05:15 +02:00
const data = { ssid, recreate, phrase };
2016-04-21 15:09:49 +02:00
return rest.post(`${ this.api }network/associate`, data);
2015-07-15 15:06:18 +02:00
}
2015-10-12 13:06:20 +02:00
disassociate () {
2015-07-15 15:06:18 +02:00
//not tested
2016-04-21 15:09:49 +02:00
return rest.post(`${ this.api }network/disassociate`, {});
2015-07-15 15:06:18 +02:00
}
openAccesPoint () {
2015-07-15 15:06:18 +02:00
//not tested
2016-04-21 15:09:49 +02:00
return rest.post(`${ this.api }network/openap`, {});
2015-07-15 15:06:18 +02:00
}
remove (ssid) {
2016-04-21 15:09:49 +02:00
return rest.post(`${ this.api }network/remove`, {
2015-07-15 15:06:18 +02:00
'ssid': ssid
});
2015-07-15 15:06:18 +02:00
}
signin () {
2016-04-21 15:09:49 +02:00
return rest.get(`${ this.api }network/signin`);
2015-07-15 15:06:18 +02:00
}
2016-04-16 18:05:35 +02:00
async alive () {
try {
2016-04-21 15:09:49 +02:00
await rest.get(`${ this.api }network/alive`);
2016-04-16 18:05:35 +02:00
return true;
} catch(error) {
return false;
}
2015-07-15 15:06:18 +02:00
}
}