use std::net::IpAddr;
use crate::Error;
use crate::types::DeviceInfo;
pub(crate) struct RestClient {
client: reqwest::Client,
base_url: String,
}
impl RestClient {
pub(crate) fn new(host: IpAddr, client: reqwest::Client) -> Self {
Self {
client,
base_url: format!("http://{host}:8001/api/v2/"),
}
}
pub(crate) async fn get_device_info(&self) -> Result<DeviceInfo, Error> {
let resp = self.client.get(&self.base_url).send().await?;
let info: DeviceInfo = resp.json().await?;
Ok(info)
}
}