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.

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

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

impl<'a> GoogleDocumentsService<'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 Google document in a vault.
    /// An unrecognized `document_type` is rejected before validation with the
    /// field-keyed 422 {"errors": {"document_type": \["is not a valid document
    /// type"\]}} — the enum would otherwise raise rather than add an error.
    /// Omitting `title` is allowed and reads back as "Untitled".
    ///
    /// `POST /buckets/{bucketId}/vaults/{vaultId}/google_documents.json` — not idempotent, sent exactly once.
    pub async fn create_google_document(
        &self,
        bucket_id: i64,
        vault_id: i64,
        body: &CreateGoogleDocumentRequestContent,
    ) -> Result<CreateGoogleDocumentResponseContent, Error> {
        let mut operation = self
            .client
            .operation(&routes::CREATE_GOOGLE_DOCUMENT, &[&bucket_id, &vault_id]);
        operation.json(body)?;
        self.client.send(operation).await
    }

    /// Get a single Google document by id
    ///
    /// `GET /google_documents/{googleDocumentId}` — idempotent; retries up to 3 attempt(s) on 429, 503.
    pub async fn google_document(
        &self,
        google_document_id: i64,
    ) -> Result<GetGoogleDocumentResponseContent, Error> {
        let operation = self
            .client
            .operation(&routes::GET_GOOGLE_DOCUMENT, &[&google_document_id]);
        self.client.send(operation).await
    }

    /// Replace a Google document with a new complete representation.
    /// BC3 builds a brand-new GoogleDocument from the permitted params and swaps
    /// the recordable wholesale, so the request body is the full writable state:
    /// omitting `title` clears it (and the document then reads back as "Untitled"),
    /// and omitting `description` clears it. `url` and `document_type` are required
    /// here — `document_type` because an absent or unrecognized value is a 422, and
    /// `url` because it carries a presence validation.
    /// Subscribers are the exception to omission-clears: a drafted document keeps
    /// its current subscribers when the request addresses neither `subscriptions`
    /// nor `notify`. The creator is always on the list.
    /// The legacy bucket-scoped path
    /// PUT /buckets/{bucketId}/google_documents/{id}.json is also accepted by BC3;
    /// this flat spelling is the documented one.
    ///
    /// `PUT /google_documents/{googleDocumentId}` — idempotent; retries up to 3 attempt(s) on 429, 503.
    pub async fn update_google_document(
        &self,
        google_document_id: i64,
        body: &UpdateGoogleDocumentRequestContent,
    ) -> Result<UpdateGoogleDocumentResponseContent, Error> {
        let mut operation = self
            .client
            .operation(&routes::UPDATE_GOOGLE_DOCUMENT, &[&google_document_id]);
        operation.json(body)?;
        self.client.send(operation).await
    }
}