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.

//! CardColumns 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::*;

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

impl<'a> CardColumnsService<'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 column in a card table
    ///
    /// `POST /card_tables/{cardTableId}/columns.json` — not idempotent, sent exactly once.
    pub async fn create(
        &self,
        card_table_id: i64,
        body: &CreateCardColumnRequestContent,
    ) -> Result<CreateCardColumnResponseContent, Error> {
        let mut operation = self
            .client
            .operation(&routes::CREATE_CARD_COLUMN, &[&card_table_id]);
        operation.json(body)?;
        self.client.send(operation).await
    }

    /// Disable on-hold section in a column
    ///
    /// `DELETE /buckets/{bucketId}/card_tables/columns/{columnId}/on_hold.json` — idempotent; retries up to 3 attempt(s) on 429, 503.
    pub async fn disable_on_hold(
        &self,
        bucket_id: i64,
        column_id: i64,
    ) -> Result<DisableCardColumnOnHoldResponseContent, Error> {
        let operation = self.client.operation(
            &routes::DISABLE_CARD_COLUMN_ON_HOLD,
            &[&bucket_id, &column_id],
        );
        self.client.send(operation).await
    }

    /// Enable on-hold section in a column
    ///
    /// `POST /buckets/{bucketId}/card_tables/columns/{columnId}/on_hold.json` — idempotent; retries up to 2 attempt(s) on 429, 503.
    pub async fn enable_on_hold(
        &self,
        bucket_id: i64,
        column_id: i64,
    ) -> Result<EnableCardColumnOnHoldResponseContent, Error> {
        let operation = self.client.operation(
            &routes::ENABLE_CARD_COLUMN_ON_HOLD,
            &[&bucket_id, &column_id],
        );
        self.client.send(operation).await
    }

    /// Get a card column by ID
    ///
    /// `GET /card_tables/columns/{columnId}` — idempotent; retries up to 3 attempt(s) on 429, 503.
    pub async fn get(&self, column_id: i64) -> Result<GetCardColumnResponseContent, Error> {
        let operation = self
            .client
            .operation(&routes::GET_CARD_COLUMN, &[&column_id]);
        self.client.send(operation).await
    }

    /// Move a column to a slot within its card table. target_id is the card table's own id (the same as cardTableId), not a column; position is the 1-based slot among the columns, not counting Triage, Not Now or Done.
    ///
    /// `POST /card_tables/{cardTableId}/moves.json` — not idempotent, sent exactly once.
    pub async fn move_column(
        &self,
        card_table_id: i64,
        body: &MoveCardColumnRequestContent,
    ) -> Result<(), Error> {
        let mut operation = self
            .client
            .operation(&routes::MOVE_CARD_COLUMN, &[&card_table_id]);
        operation.json(body)?;
        self.client.send_unit(operation).await
    }

    /// Set the color of a column
    ///
    /// `PUT /buckets/{bucketId}/card_tables/columns/{columnId}/color.json` — idempotent; retries up to 3 attempt(s) on 429, 503.
    pub async fn set_color(
        &self,
        bucket_id: i64,
        column_id: i64,
        body: &SetCardColumnColorRequestContent,
    ) -> Result<SetCardColumnColorResponseContent, Error> {
        let mut operation = self
            .client
            .operation(&routes::SET_CARD_COLUMN_COLOR, &[&bucket_id, &column_id]);
        operation.json(body)?;
        self.client.send(operation).await
    }

    /// Subscribe to a card column (watch for changes)
    ///
    /// `POST /card_tables/lists/{columnId}/subscription.json` — idempotent; retries up to 3 attempt(s) on 429, 503.
    pub async fn subscribe_to_column(&self, column_id: i64) -> Result<(), Error> {
        let operation = self
            .client
            .operation(&routes::SUBSCRIBE_TO_CARD_COLUMN, &[&column_id]);
        self.client.send_unit(operation).await
    }

    /// Unsubscribe from a card column (stop watching for changes)
    ///
    /// `DELETE /card_tables/lists/{columnId}/subscription.json` — idempotent; retries up to 3 attempt(s) on 429, 503.
    pub async fn unsubscribe_from_column(&self, column_id: i64) -> Result<(), Error> {
        let operation = self
            .client
            .operation(&routes::UNSUBSCRIBE_FROM_CARD_COLUMN, &[&column_id]);
        self.client.send_unit(operation).await
    }

    /// Update an existing column
    ///
    /// `PUT /card_tables/columns/{columnId}` — idempotent; retries up to 3 attempt(s) on 429, 503.
    pub async fn update(
        &self,
        column_id: i64,
        body: &UpdateCardColumnRequestContent,
    ) -> Result<UpdateCardColumnResponseContent, Error> {
        let mut operation = self
            .client
            .operation(&routes::UPDATE_CARD_COLUMN, &[&column_id]);
        operation.json(body)?;
        self.client.send(operation).await
    }
}