use serde::Serialize;
use serde_with::skip_serializing_none;
use validator::Validate;
use crate::client::Client;
use crate::error::RsError;
#[derive(Debug)]
pub struct SystemApi<'a> {
client: &'a Client,
}
impl<'a> SystemApi<'a> {
pub(crate) fn new(client: &'a Client) -> Self {
Self { client }
}
pub async fn get_system_status(&self) -> Result<serde_json::Value, RsError> {
self.client
.send_request("get_system_status", reqwest::Method::GET, ())
.await
}
pub async fn get_daily_stat_summary(
&self,
request: GetDailyStatSummaryRequest,
) -> Result<serde_json::Value, RsError> {
request
.validate()
.map_err(|e| RsError::Validation(e.to_string()))?;
self.client
.send_request("get_daily_stat_summary", reqwest::Method::GET, request)
.await
}
pub async fn get_reports(&self) -> Result<serde_json::Value, RsError> {
todo!("available from RS v11.0")
}
pub async fn do_report(&self) -> Result<serde_json::Value, RsError> {
todo!("available from RS v11.0")
}
}
#[skip_serializing_none]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Validate)]
pub struct GetDailyStatSummaryRequest {
#[validate(range(min = 1, max = 365))]
pub days: Option<u16>,
}
impl GetDailyStatSummaryRequest {
pub fn new() -> Self {
Self::default()
}
pub fn days(mut self, days: u16) -> Self {
self.days = Some(days);
self
}
}