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::*;
use crate::pagination::Page;

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

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

    /// Get recordings for a calendar
    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
    }

    /// List calendars
    pub async fn list(&self) -> Result<ListCalendarsResponseContent, Error> {
        let operation = self.client.operation(&routes::LIST_CALENDARS, &[]);
        self.client.send(operation).await
    }

    /// Switch a calendar in or out of the reader's selection, and answer the selection it
    /// left behind. The selection is what every period read is scoped to, so a toggle is how
    /// a client changes which calendars a day, week or year is drawn from.
    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
    }
}