Doodle3D-API/src/api/network.js

47 lines
934 B
JavaScript
Raw Normal View History

2016-04-21 15:32:11 +02:00
import * as rest from '../rest.js';
2015-07-15 15:06:18 +02:00
2016-04-21 15:44:20 +02:00
export default class Network {
constructor(api) {
this.api = api;
2015-07-15 15:06:18 +02:00
}
2016-04-21 15:44:20 +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
}
2016-04-21 15:44:20 +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
}
2016-04-21 15:44:20 +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
}
2016-04-21 15:44:20 +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
}
2016-04-21 15:44: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
}
2016-04-21 15:44:20 +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
}
2016-04-21 15:44:20 +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
}
2016-04-21 15:44:20 +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-21 15:44:20 +02:00
async alive() {
2016-04-16 18:05:35 +02:00
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
}
}