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.

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

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

impl<'a> CardStepsService<'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 step on a card
    ///
    /// `POST /card_tables/cards/{cardId}/steps.json` — not idempotent, sent exactly once.
    pub async fn create(
        &self,
        card_id: i64,
        body: &CreateCardStepRequestContent,
    ) -> Result<CreateCardStepResponseContent, Error> {
        let mut operation = self
            .client
            .operation(&routes::CREATE_CARD_STEP, &[&card_id]);
        operation.json(body)?;
        self.client.send(operation).await
    }

    /// Get a step by ID
    ///
    /// `GET /card_tables/steps/{stepId}` — idempotent; retries up to 3 attempt(s) on 429, 503.
    pub async fn get(&self, step_id: i64) -> Result<GetCardStepResponseContent, Error> {
        let operation = self.client.operation(&routes::GET_CARD_STEP, &[&step_id]);
        self.client.send(operation).await
    }

    /// Reposition a step within a card
    ///
    /// `POST /card_tables/cards/{cardId}/positions.json` — not idempotent, sent exactly once.
    pub async fn reposition(
        &self,
        card_id: i64,
        body: &RepositionCardStepRequestContent,
    ) -> Result<(), Error> {
        let mut operation = self
            .client
            .operation(&routes::REPOSITION_CARD_STEP, &[&card_id]);
        operation.json(body)?;
        self.client.send_unit(operation).await
    }

    /// Set card step completion status (PUT with completion: "on" to complete, "" to uncomplete)
    ///
    /// `PUT /card_tables/steps/{stepId}/completions.json` — idempotent; retries up to 3 attempt(s) on 429, 503.
    pub async fn set_completion(
        &self,
        step_id: i64,
        body: &SetCardStepCompletionRequestContent,
    ) -> Result<SetCardStepCompletionResponseContent, Error> {
        let mut operation = self
            .client
            .operation(&routes::SET_CARD_STEP_COMPLETION, &[&step_id]);
        operation.json(body)?;
        self.client.send(operation).await
    }

    /// Update an existing step
    ///
    /// `PUT /card_tables/steps/{stepId}` — idempotent; retries up to 3 attempt(s) on 429, 503.
    pub async fn update(
        &self,
        step_id: i64,
        body: &UpdateCardStepRequestContent,
    ) -> Result<UpdateCardStepResponseContent, Error> {
        let mut operation = self
            .client
            .operation(&routes::UPDATE_CARD_STEP, &[&step_id]);
        operation.json(body)?;
        self.client.send(operation).await
    }
}