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.

//! Recordings 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::*;
use crate::pagination::Page;

/// Optional query parameters for `ListRecordings`.
#[derive(Debug, Clone, Default, PartialEq)]
pub struct ListRecordingsParams {
    /// `bucket`.
    pub bucket: Option<String>,
    /// active|archived|trashed
    pub status: Option<String>,
    /// created_at|updated_at
    pub sort: Option<String>,
    /// asc|desc
    pub direction: Option<String>,
    /// Page number for paginating through results. Defaults to 1. A positive value selects exactly that page, not a starting offset; see SPEC section 8.
    pub page: Option<i32>,
}

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

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

    /// Archive a recording; bc3 answers 403 for types it never lets be archived, timesheet entries among them
    ///
    /// `PUT /recordings/{recordingId}/status/archived.json` — idempotent; retries up to 3 attempt(s) on 429, 503.
    pub async fn archive(&self, recording_id: i64) -> Result<(), Error> {
        let operation = self
            .client
            .operation(&routes::ARCHIVE_RECORDING, &[&recording_id]);
        self.client.send_unit(operation).await
    }

    /// List recordings of a given type across projects
    ///
    /// **Pagination**: Uses Link header (RFC5988). Follow the `next` rel URL
    /// to fetch additional pages. X-Total-Count header provides total count.
    ///
    /// `GET /projects/recordings.json` — idempotent; retries up to 3 attempt(s) on 429, 503.
    pub async fn list(
        &self,
        r#type: &str,
        params: &ListRecordingsParams,
    ) -> Result<Page<ListRecordingsResponseContent>, Error> {
        let mut operation = self.client.operation(&routes::LIST_RECORDINGS, &[]);
        operation.query("type", r#type);
        operation.query_optional("bucket", params.bucket.as_ref());
        operation.query_optional("status", params.status.as_ref());
        operation.query_optional("sort", params.sort.as_ref());
        operation.query_optional("direction", params.direction.as_ref());
        operation.query_optional("page", params.page.as_ref());
        self.client.send_page(operation).await
    }

    /// Move a document, upload or vault into another vault in its project, or reorder it in its own vault.
    ///
    /// Passing the vault it is already in changes only its position. The
    /// recording moves in place: its id, comments, bookmarks and history stay with
    /// it, and a vault takes everything inside it along. A destination in another
    /// project is 404; moves to another project are not this operation. 404, 403 and
    /// some 422s carry no body.
    ///
    /// 403 when the caller may not move the recording (an account can restrict moves
    /// to admins and creators). 422 when position is not a positive whole number, the
    /// destination is not a vault or is not active, the recording is not active, or a
    /// vault would move into one of its own vaults; only the position and vault-cycle
    /// refusals carry an `error` message.
    ///
    /// `POST /recordings/{recordingId}/filing.json` — not idempotent, sent exactly once.
    pub async fn move_to_vault(
        &self,
        recording_id: i64,
        body: &MoveRecordingToVaultRequestContent,
    ) -> Result<(), Error> {
        let mut operation = self
            .client
            .operation(&routes::MOVE_RECORDING_TO_VAULT, &[&recording_id]);
        operation.json(body)?;
        self.client.send_unit(operation).await
    }

    /// Put a recording's card in the spotlight area on its project or template home page.
    /// Idempotent: spotlighting an already-spotlighted recording still returns 201.
    ///
    /// `POST /recordings/{recordingId}/spotlight.json` — idempotent; retries up to 3 attempt(s) on 429, 503.
    pub async fn spotlight(
        &self,
        recording_id: i64,
    ) -> Result<SpotlightRecordingResponseContent, Error> {
        let operation = self
            .client
            .operation(&routes::SPOTLIGHT_RECORDING, &[&recording_id]);
        self.client.send(operation).await
    }

    /// Trash a recording; bc3 answers 403 for types it never lets be trashed, timesheet entries among them (DestroyTimesheetEntry removes those, permanently)
    ///
    /// `PUT /recordings/{recordingId}/status/trashed.json` — idempotent; retries up to 3 attempt(s) on 429, 503.
    pub async fn trash(&self, recording_id: i64) -> Result<(), Error> {
        let operation = self
            .client
            .operation(&routes::TRASH_RECORDING, &[&recording_id]);
        self.client.send_unit(operation).await
    }

    /// Unarchive a recording (restore to active status)
    ///
    /// `PUT /recordings/{recordingId}/status/active.json` — idempotent; retries up to 3 attempt(s) on 429, 503.
    pub async fn unarchive(&self, recording_id: i64) -> Result<(), Error> {
        let operation = self
            .client
            .operation(&routes::UNARCHIVE_RECORDING, &[&recording_id]);
        self.client.send_unit(operation).await
    }

    /// Remove a recording from the spotlight area.
    /// Idempotent: removing an absent spotlight also returns 204.
    ///
    /// `DELETE /recordings/{recordingId}/spotlight.json` — idempotent; retries up to 3 attempt(s) on 429, 503.
    pub async fn unspotlight(&self, recording_id: i64) -> Result<(), Error> {
        let operation = self
            .client
            .operation(&routes::UNSPOTLIGHT_RECORDING, &[&recording_id]);
        self.client.send_unit(operation).await
    }
}