use crate::client::{url_encode, AriClient};
use crate::error::Result;
#[derive(Debug, Clone, serde::Deserialize)]
pub struct DeviceState {
pub name: String,
pub state: String,
}
pub async fn list(client: &AriClient) -> Result<Vec<DeviceState>> {
client.get("/deviceStates").await
}
pub async fn get(client: &AriClient, name: &str) -> Result<DeviceState> {
client
.get(&format!("/deviceStates/{}", url_encode(name)))
.await
}
pub async fn update(client: &AriClient, name: &str, state: &str) -> Result<()> {
client
.post_empty(&format!(
"/deviceStates/{}?deviceState={}",
url_encode(name),
url_encode(state)
))
.await
}
pub async fn delete(client: &AriClient, name: &str) -> Result<()> {
client
.delete(&format!("/deviceStates/{}", url_encode(name)))
.await
}