#![allow(clippy::too_many_arguments)]
use crate::client::Client;
use crate::error::Error;
use crate::generated::routes;
use crate::generated::types::*;
#[derive(Debug, Clone, Default, PartialEq)]
pub struct ListStickiesParams {
pub limit: Option<i32>,
}
pub struct Stickies<'a> {
client: &'a Client,
}
impl<'a> Stickies<'a> {
pub(crate) fn new(client: &'a Client) -> Self {
Self { client }
}
pub fn client(&self) -> &'a Client {
self.client
}
pub async fn create(
&self,
body: &StickyRequestContent,
) -> Result<CreateStickyResponseContent, Error> {
let mut operation = self.client.operation(&routes::CREATE_STICKY, &[]);
operation.json(body)?;
self.client.send(operation).await
}
pub async fn delete(&self, sticky_id: i64) -> Result<(), Error> {
let mut operation = self.client.operation(&routes::DELETE_STICKY, &[&sticky_id]);
operation.resource_id(sticky_id);
self.client.send_unit(operation).await
}
pub async fn list(
&self,
params: &ListStickiesParams,
) -> Result<ListStickiesResponseContent, Error> {
let mut operation = self.client.operation(&routes::LIST_STICKIES, &[]);
operation.query_optional("limit", params.limit.as_ref());
self.client.send(operation).await
}
pub async fn move_sticky(&self, body: &MoveStickyRequestContent) -> Result<(), Error> {
let mut operation = self.client.operation(&routes::MOVE_STICKY, &[]);
operation.json(body)?;
self.client.send_unit(operation).await
}
pub async fn update(
&self,
sticky_id: i64,
body: &StickyRequestContent,
) -> Result<UpdateStickyResponseContent, Error> {
let mut operation = self.client.operation(&routes::UPDATE_STICKY, &[&sticky_id]);
operation.resource_id(sticky_id);
operation.json(body)?;
self.client.send(operation).await
}
}