basecamp-sdk 0.26.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
    }

    /// Delete a tool (trash it)
    ///
    /// `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
    }
}