use crate::v4::JsonService;
use crate::{Device, Transport};
use serde::{Deserialize, Serialize};
pub struct BasicDeviceInfo<'a, T: Transport>(JsonService<'a, T>);
#[derive(Debug, Deserialize, Clone, Eq, PartialEq)]
pub struct Properties {
#[serde(rename = "Brand")]
pub brand: String,
#[serde(rename = "HardwareID")]
pub hardware_id: String,
#[serde(rename = "ProdFullName")]
pub product_full_name: String,
#[serde(rename = "ProdNbr")]
pub product_number: String,
#[serde(rename = "ProdShortName")]
pub product_short_name: String,
#[serde(rename = "ProdType")]
pub product_type: String,
#[serde(rename = "ProdVariant")]
pub product_variant: String,
#[serde(rename = "SerialNumber")]
pub serial_number: String,
#[serde(rename = "Soc")]
pub soc: String,
#[serde(rename = "Architecture")]
pub soc_architecture: String,
#[serde(rename = "SocSerialNumber")]
pub soc_serial_number: String,
#[serde(rename = "BuildDate")]
pub firmware_build_date: String,
#[serde(rename = "Version")]
pub firmware_version: String,
#[serde(rename = "WebURL")]
pub web_url: String,
}
impl<'a, T: Transport> BasicDeviceInfo<'a, T> {
pub(crate) fn new(device: &'a Device<T>, api_version: String) -> Self {
Self(JsonService::new(
device,
"/axis-cgi/basicdeviceinfo.cgi",
api_version,
))
}
pub async fn properties(&self) -> Result<Properties, crate::Error<T::Error>> {
#[derive(Serialize)]
#[serde(rename_all = "camelCase")]
struct Req<'a> {
property_list: &'a [&'a str],
}
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
struct Resp {
property_list: Properties,
}
let resp: Resp = self
.0
.call_method(
"getProperties",
Req {
property_list: &[
"Architecture",
"Brand",
"BuildDate",
"HardwareID",
"ProdFullName",
"ProdNbr",
"ProdShortName",
"ProdType",
"ProdVariant",
"SerialNumber",
"Soc",
"SocSerialNumber",
"Version",
"WebURL",
],
},
)
.await?;
Ok(resp.property_list)
}
}