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.

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

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

impl<'a> LineupService<'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 new lineup marker. Returns the created marker.
    ///
    /// `POST /lineup/markers.json` — not idempotent, sent exactly once.
    pub async fn create(
        &self,
        body: &CreateLineupMarkerRequestContent,
    ) -> Result<CreateLineupMarkerResponseContent, Error> {
        let mut operation = self.client.operation(&routes::CREATE_LINEUP_MARKER, &[]);
        operation.json(body)?;
        self.client.send(operation).await
    }

    /// Delete a lineup marker
    ///
    /// `DELETE /lineup/markers/{markerId}` — idempotent; retries up to 3 attempt(s) on 429, 503.
    pub async fn delete(&self, marker_id: i64) -> Result<(), Error> {
        let operation = self
            .client
            .operation(&routes::DELETE_LINEUP_MARKER, &[&marker_id]);
        self.client.send_unit(operation).await
    }

    /// List all lineup markers for the account
    ///
    /// `GET /lineup/markers.json` — idempotent; retries up to 3 attempt(s) on 429, 503.
    pub async fn list_lineup_markers(&self) -> Result<ListLineupMarkersResponseContent, Error> {
        let operation = self.client.operation(&routes::LIST_LINEUP_MARKERS, &[]);
        self.client.send(operation).await
    }

    /// Update an existing lineup marker. Returns the updated marker.
    ///
    /// `PUT /lineup/markers/{markerId}` — idempotent; retries up to 3 attempt(s) on 429, 503.
    pub async fn update(
        &self,
        marker_id: i64,
        body: &UpdateLineupMarkerRequestContent,
    ) -> Result<UpdateLineupMarkerResponseContent, Error> {
        let mut operation = self
            .client
            .operation(&routes::UPDATE_LINEUP_MARKER, &[&marker_id]);
        operation.json(body)?;
        self.client.send(operation).await
    }
}