#![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 }
}
pub fn client(&self) -> &'a Client {
self.client
}
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
}
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
}
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
}
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
}
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
}
}