Create API routes to request relay information
This commit is contained in:
central_frontend/src
@ -1,5 +1,5 @@
|
||||
import { APIClient } from "./ApiClient";
|
||||
import { DeviceRelay } from "./DeviceApi";
|
||||
import { Device, DeviceRelay } from "./DeviceApi";
|
||||
|
||||
export class RelayApi {
|
||||
/**
|
||||
@ -13,4 +13,29 @@ export class RelayApi {
|
||||
})
|
||||
).data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new relay
|
||||
*/
|
||||
static async Create(device: Device, relay: DeviceRelay): Promise<void> {
|
||||
await APIClient.exec({
|
||||
method: "POST",
|
||||
uri: "/relay/create",
|
||||
jsonData: {
|
||||
...relay,
|
||||
device_id: device.id,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a relay information
|
||||
*/
|
||||
static async Update(relay: DeviceRelay): Promise<void> {
|
||||
await APIClient.exec({
|
||||
method: "PUT",
|
||||
uri: `/relay/${relay.id}`,
|
||||
jsonData: relay,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user