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