hey-sdk 0.31.0

Rust client for the HEY API, generated from a Smithy model of the API
Documentation
// Generated by hey-sdk-generator from openapi.json and behavior-model.json. DO NOT EDIT.

#![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::*;

/// Optional query parameters for `ListCalendarDays`.
#[derive(Debug, Clone, Default, PartialEq)]
pub struct ListCalendarDaysParams {
    pub starts_at: Option<String>,
}

/// Optional query parameters for `ListCalendarWeeks`.
#[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 }
    }

    /// The client this service sends through.
    pub fn client(&self) -> &'a Client {
        self.client
    }

    /// Get one day
    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
    }

    /// Get one week
    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
    }

    /// Get one year as the grid it is drawn as
    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
    }

    /// List the days from a date onwards. The server picks how many, so this is a window
    /// rather than a page: read the next one by asking from the last day's date.
    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
    }

    /// List the weeks around a date — nine of them, centered on it.
    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
    }
}