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::*;

pub struct CalendarTodos<'a> {
    client: &'a Client,
}

impl<'a> CalendarTodos<'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
    }

    /// Complete a calendar todo
    pub async fn complete(
        &self,
        todo_id: i64,
    ) -> Result<CompleteCalendarTodoResponseContent, Error> {
        let mut operation = self
            .client
            .operation(&routes::COMPLETE_CALENDAR_TODO, &[&todo_id]);
        operation.resource_id(todo_id);
        self.client.send(operation).await
    }

    /// Create a calendar todo
    pub async fn create(
        &self,
        body: &CreateCalendarTodoRequestContent,
    ) -> Result<CreateCalendarTodoResponseContent, Error> {
        let mut operation = self.client.operation(&routes::CREATE_CALENDAR_TODO, &[]);
        operation.json(body)?;
        self.client.send(operation).await
    }

    /// Delete a calendar todo
    pub async fn delete(&self, todo_id: i64) -> Result<(), Error> {
        let mut operation = self
            .client
            .operation(&routes::DELETE_CALENDAR_TODO, &[&todo_id]);
        operation.resource_id(todo_id);
        self.client.send_unit(operation).await
    }

    /// Uncomplete a calendar todo
    pub async fn uncomplete(
        &self,
        todo_id: i64,
    ) -> Result<UncompleteCalendarTodoResponseContent, Error> {
        let mut operation = self
            .client
            .operation(&routes::UNCOMPLETE_CALENDAR_TODO, &[&todo_id]);
        operation.resource_id(todo_id);
        self.client.send(operation).await
    }

    /// Edit a calendar todo. todoId is the recording's id, and every field of the payload
    /// is optional: haystack's `wrap_parameters` accepts title, focused and starts_at, and
    /// changes only what is sent.
    pub async fn update(
        &self,
        todo_id: i64,
        body: &UpdateCalendarTodoRequestContent,
    ) -> Result<UpdateCalendarTodoResponseContent, Error> {
        let mut operation = self
            .client
            .operation(&routes::UPDATE_CALENDAR_TODO, &[&todo_id]);
        operation.resource_id(todo_id);
        operation.json(body)?;
        self.client.send(operation).await
    }
}