1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// 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
}
}