#![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::*;
#[derive(Debug, Clone, Default, PartialEq)]
pub struct ListCalendarDaysParams {
pub starts_at: Option<String>,
}
#[derive(Debug, Clone, Default, PartialEq)]
pub struct ListCalendarWeeksParams {
pub starts_at: Option<String>,
pub centered_at: Option<String>,
}
pub struct CalendarPeriods<'a> {
client: &'a Client,
}
impl<'a> CalendarPeriods<'a> {
pub(crate) fn new(client: &'a Client) -> Self {
Self { client }
}
pub fn client(&self) -> &'a Client {
self.client
}
pub async fn get_day(&self, day: &str) -> Result<GetCalendarDayResponseContent, Error> {
let operation = self.client.operation(&routes::GET_CALENDAR_DAY, &[&day]);
self.client.send(operation).await
}
pub async fn get_week(&self, week: &str) -> Result<GetCalendarWeekResponseContent, Error> {
let operation = self.client.operation(&routes::GET_CALENDAR_WEEK, &[&week]);
self.client.send(operation).await
}
pub async fn get_year(&self, year: &str) -> Result<GetCalendarYearResponseContent, Error> {
let operation = self.client.operation(&routes::GET_CALENDAR_YEAR, &[&year]);
self.client.send(operation).await
}
pub async fn list_days(
&self,
params: &ListCalendarDaysParams,
) -> Result<ListCalendarDaysResponseContent, Error> {
let mut operation = self.client.operation(&routes::LIST_CALENDAR_DAYS, &[]);
operation.query_optional("starts_at", params.starts_at.as_ref());
self.client.send(operation).await
}
pub async fn list_weeks(
&self,
params: &ListCalendarWeeksParams,
) -> Result<ListCalendarWeeksResponseContent, Error> {
let mut operation = self.client.operation(&routes::LIST_CALENDAR_WEEKS, &[]);
operation.query_optional("starts_at", params.starts_at.as_ref());
operation.query_optional("centered_at", params.centered_at.as_ref());
self.client.send(operation).await
}
}