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.

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

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

impl<'a> WormholesService<'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
    }

    /// Add a wormhole to a card table: a standing shortcut that sends cards to a column on another card table, usually in another project.
    ///
    /// A wormhole's id is a valid `column_id` for MoveCard, teleporting the card to
    /// its destination column. It is not needed for a one-off move: MoveCard goes to
    /// any column in the card's project directly, and MoveRecording moves a card to
    /// another project's card table. Create one only when the card table should keep
    /// that shortcut. A card table holds at most four wormholes.
    /// `destinationRecordingId` is the id of a column on another accessible card table.
    ///
    /// `POST /buckets/{bucketId}/card_tables/{cardTableId}/wormholes.json` — not idempotent, sent exactly once.
    pub async fn create(
        &self,
        bucket_id: i64,
        card_table_id: i64,
        body: &CreateWormholeRequestContent,
    ) -> Result<CreateWormholeResponseContent, Error> {
        let mut operation = self
            .client
            .operation(&routes::CREATE_WORMHOLE, &[&bucket_id, &card_table_id]);
        operation.json(body)?;
        self.client.send(operation).await
    }

    /// Permanently delete a card table's wormhole, the shortcut that sends cards to another card table.
    ///
    /// It does not go to the trash and cannot be restored.
    ///
    /// `DELETE /buckets/{bucketId}/card_tables/wormholes/{wormholeId}` — idempotent; retries up to 3 attempt(s) on 429, 503.
    pub async fn delete(&self, bucket_id: i64, wormhole_id: i64) -> Result<(), Error> {
        let operation = self
            .client
            .operation(&routes::DELETE_WORMHOLE, &[&bucket_id, &wormhole_id]);
        self.client.send_unit(operation).await
    }

    /// Point a card table's wormhole, its shortcut for sending cards to another card table, at a different destination column
    ///
    /// `PUT /buckets/{bucketId}/card_tables/wormholes/{wormholeId}` — idempotent; retries up to 3 attempt(s) on 429, 503.
    pub async fn update(
        &self,
        bucket_id: i64,
        wormhole_id: i64,
        body: &UpdateWormholeRequestContent,
    ) -> Result<UpdateWormholeResponseContent, Error> {
        let mut operation = self
            .client
            .operation(&routes::UPDATE_WORMHOLE, &[&bucket_id, &wormhole_id]);
        operation.json(body)?;
        self.client.send(operation).await
    }
}