use super::Client;
use crate::endpoints::schedule::UpdateScheduleOptions;
use crate::envelope::Envelope;
use crate::error::Error;
use serde_json::Value;
impl Client {
pub async fn get_schedules(
&self,
profile_id: &str,
network_id: Option<&str>,
) -> Result<Envelope, Error> {
let network_id = self.ensure_network_id(network_id, false).await?;
self.api
.schedule()
.get_schedules(&network_id, profile_id, None)
.await
}
#[allow(clippy::too_many_arguments)] pub async fn create_schedule(
&self,
profile_id: &str,
name: &str,
days: &[&str],
start: &str,
end: &str,
enabled: bool,
network_id: Option<&str>,
) -> Result<Envelope, Error> {
let network_id = self.ensure_network_id(network_id, false).await?;
self.api
.schedule()
.create_schedule(
&network_id,
profile_id,
name,
days,
start,
end,
enabled,
None,
)
.await
}
pub async fn update_schedule(
&self,
schedule: &str,
options: &UpdateScheduleOptions<'_>,
parent: Option<&Value>,
) -> Result<Envelope, Error> {
self.api
.schedule()
.update_schedule(schedule, options, parent)
.await
}
pub async fn delete_schedule(
&self,
schedule: &str,
parent: Option<&Value>,
) -> Result<Envelope, Error> {
self.api.schedule().delete_schedule(schedule, parent).await
}
pub async fn clear_profile_schedule(
&self,
profile_id: &str,
network_id: Option<&str>,
) -> Result<Vec<Envelope>, Error> {
let network_id = self.ensure_network_id(network_id, false).await?;
self.api
.schedule()
.clear_profile_schedule(&network_id, profile_id, None)
.await
}
pub async fn enable_bedtime(
&self,
profile_id: &str,
start_time: &str,
end_time: &str,
days: Option<&[&str]>,
network_id: Option<&str>,
) -> Result<Envelope, Error> {
let network_id = self.ensure_network_id(network_id, false).await?;
self.api
.schedule()
.enable_bedtime(&network_id, profile_id, start_time, end_time, days, None)
.await
}
}