#![allow(missing_docs, unreachable_pub, clippy::all, clippy::pedantic)]
use crate::client::Client;
use crate::error::Error;
use crate::generated::routes;
use crate::generated::types::*;
use crate::pagination::Page;
#[derive(Debug, Clone, Default, PartialEq)]
pub struct GetCalendarRecordingsParams {
pub starts_on: Option<String>,
pub ends_on: Option<String>,
pub page: Option<String>,
}
pub struct Calendars<'a> {
client: &'a Client,
}
impl<'a> Calendars<'a> {
pub(crate) fn new(client: &'a Client) -> Self {
Self { client }
}
pub fn client(&self) -> &'a Client {
self.client
}
pub async fn get_recordings(
&self,
calendar_id: i64,
params: &GetCalendarRecordingsParams,
) -> Result<Page<GetCalendarRecordingsResponseContent>, Error> {
let mut operation = self
.client
.operation(&routes::GET_CALENDAR_RECORDINGS, &[&calendar_id]);
operation.resource_id(calendar_id);
operation.query_optional("starts_on", params.starts_on.as_ref());
operation.query_optional("ends_on", params.ends_on.as_ref());
operation.query_optional("page", params.page.as_ref());
self.client.send_page(operation).await
}
pub async fn list(&self) -> Result<ListCalendarsResponseContent, Error> {
let operation = self.client.operation(&routes::LIST_CALENDARS, &[]);
self.client.send(operation).await
}
pub async fn toggle(&self, calendar_id: i64) -> Result<ToggleCalendarResponseContent, Error> {
let mut operation = self
.client
.operation(&routes::TOGGLE_CALENDAR, &[&calendar_id]);
operation.resource_id(calendar_id);
self.client.send(operation).await
}
}