basecamp-sdk 0.38.0

Official client for Basecamp - https://basecamp.com
Documentation
// Generated by basecamp-sdk-generator from openapi.json and behavior-model.json. DO NOT EDIT.

//! Tools operations.

#![allow(
    clippy::too_many_arguments,
    clippy::wildcard_imports,
    clippy::doc_markdown
)]

use crate::client::AccountClient;
use crate::error::Error;
use crate::generated::routes;
#[allow(unused_imports)]
use crate::generated::types::*;

/// `Tools` operations, sent through one [`AccountClient`].
#[derive(Debug, Clone, Copy)]
pub struct ToolsService<'a> {
    client: &'a AccountClient,
}

impl<'a> ToolsService<'a> {
    pub(crate) fn new(client: &'a AccountClient) -> Self {
        Self { client }
    }

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

    /// Create a tool in a project dock
    ///
    /// `POST /buckets/{bucketId}/dock/tools.json` — not idempotent, sent exactly once.
    pub async fn create(
        &self,
        bucket_id: i64,
        body: &CreateToolRequestContent,
    ) -> Result<CreateToolResponseContent, Error> {
        let mut operation = self.client.operation(&routes::CREATE_TOOL, &[&bucket_id]);
        operation.json(body)?;
        self.client.send(operation).await
    }

    /// Remove a tool from the dock: deletes an external link or an empty extra tool, and disables any other tool (returns 204 No Content either way).
    /// Deleted: an external link, or a tool that is empty while the project has another
    /// tool of the same type, enabled or disabled. Empty means nothing inside it at all,
    /// not even in the trash; for a Card Table only cards count, not columns. A deleted
    /// tool does not go to the trash: Basecamp permanently destroys it, with everything
    /// inside it, about five days later. Until then, a deleted external link can be
    /// restored in the Basecamp web app.
    /// Disabled: every other tool, such as the only tool of its type or a tool with
    /// anything inside it, archived, draft and trashed items included, exactly as
    /// DisableTool does. It keeps its content, and EnableTool restores it. Items already
    /// in the trash stay there and can still be restored for the rest of their 25 days.
    /// To tell which happened, get the tool afterwards: a deleted tool has status "deleted",
    /// while a disabled one keeps its status and has no position.
    ///
    /// `DELETE /dock/tools/{toolId}` — idempotent; retries up to 3 attempt(s) on 429, 503.
    pub async fn delete(&self, tool_id: i64) -> Result<(), Error> {
        let operation = self.client.operation(&routes::DELETE_TOOL, &[&tool_id]);
        self.client.send_unit(operation).await
    }

    /// Disable a tool (hide it from the project dock)
    ///
    /// `DELETE /recordings/{toolId}/position.json` — idempotent; retries up to 3 attempt(s) on 429, 503.
    pub async fn disable(&self, tool_id: i64) -> Result<(), Error> {
        let operation = self.client.operation(&routes::DISABLE_TOOL, &[&tool_id]);
        self.client.send_unit(operation).await
    }

    /// Enable a tool (show it on the project dock)
    ///
    /// `POST /recordings/{toolId}/position.json` — not idempotent, sent exactly once.
    pub async fn enable(&self, tool_id: i64) -> Result<(), Error> {
        let operation = self.client.operation(&routes::ENABLE_TOOL, &[&tool_id]);
        self.client.send_unit(operation).await
    }

    /// Get a dock tool by id
    ///
    /// `GET /dock/tools/{toolId}` — idempotent; retries up to 3 attempt(s) on 429, 503.
    pub async fn get(&self, tool_id: i64) -> Result<GetToolResponseContent, Error> {
        let operation = self.client.operation(&routes::GET_TOOL, &[&tool_id]);
        self.client.send(operation).await
    }

    /// Reposition a tool on the project dock
    ///
    /// `PUT /recordings/{toolId}/position.json` — idempotent; retries up to 3 attempt(s) on 429, 503.
    pub async fn reposition(
        &self,
        tool_id: i64,
        body: &RepositionToolRequestContent,
    ) -> Result<(), Error> {
        let mut operation = self.client.operation(&routes::REPOSITION_TOOL, &[&tool_id]);
        operation.json(body)?;
        self.client.send_unit(operation).await
    }

    /// Update (rename) an existing tool
    ///
    /// `PUT /dock/tools/{toolId}` — idempotent; retries up to 3 attempt(s) on 429, 503.
    pub async fn update(
        &self,
        tool_id: i64,
        body: &UpdateToolRequestContent,
    ) -> Result<UpdateToolResponseContent, Error> {
        let mut operation = self.client.operation(&routes::UPDATE_TOOL, &[&tool_id]);
        operation.json(body)?;
        self.client.send(operation).await
    }
}