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 `ListStickies`.
#[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 }
    }

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

    /// Write a new sticky
    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
    }

    /// Throw a sticky away
    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
    }

    /// List stickies, newest position first
    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
    }

    /// Reposition a sticky on the board
    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
    }

    /// Edit a sticky
    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
    }
}