pub struct GoogleClient {
pub docs: Docs<Connector>,
pub drive: DriveHub<Connector>,
}Expand description
Bundled Google Docs and Drive hubs backed by one authenticator.
Fields§
§docs: Docs<Connector>Google Docs API hub (documents.create / get / batchUpdate).
drive: DriveHub<Connector>Google Drive API hub (comments.list / update).
Implementations§
Source§impl GoogleClient
impl GoogleClient
Sourcepub fn new<A: GetToken + Clone + 'static>(auth: A) -> Result<Self>
pub fn new<A: GetToken + Clone + 'static>(auth: A) -> Result<Self>
Build both hubs from an authenticator, targeting the default Google roots.
Generic over the authenticator so production passes the
crate::auth::GoogleAuthenticator while tests can pass any
GetToken (e.g. a String static token).
§Errors
Returns crate::error::Error::Auth when the HTTPS connector cannot be
constructed.
Sourcepub fn set_base_url(&mut self, base_url: &str)
pub fn set_base_url(&mut self, base_url: &str)
Point both hubs at base_url instead of the live Google endpoints.
The generated call builders construct request URLs from each hub’s
_base_url, so the override must target that field (not root_url). A
trailing / is ensured because the builders append the path directly.
Used by mockito tests to assert request shapes without network access
(OVR-3 CI tier).
Source§impl GoogleClient
impl GoogleClient
Sourcepub async fn create_document(&self, title: &str) -> Result<DocumentRef>
pub async fn create_document(&self, title: &str) -> Result<DocumentRef>
Create a blank document titled title and return its DocumentRef.
§Errors
Returns Error::Google on API failure, or when the response omits a
document id.
Sourcepub async fn document_end_index(&self, document_id: &str) -> Result<u32>
pub async fn document_end_index(&self, document_id: &str) -> Result<u32>
Fetch the document’s end index (UTF-16 code units), operating on the first/legacy tab (DI-6).
§Errors
Returns Error::Google on API failure, or Error::MultipleTabs when
the document exposes more than one tab.
Sourcepub async fn batch_update(
&self,
document_id: &str,
requests: Vec<Request>,
) -> Result<()>
pub async fn batch_update( &self, document_id: &str, requests: Vec<Request>, ) -> Result<()>
Apply requests to the document in a single batchUpdate.
An empty request list is a no-op (the API rejects empty batches).
§Errors
Returns Error::Google on API failure.
Source§impl GoogleClient
impl GoogleClient
Sourcepub async fn list_comments(&self, file_id: &str) -> Result<Vec<Comment>>
pub async fn list_comments(&self, file_id: &str) -> Result<Vec<Comment>>
List every comment on the document, following pagination, mapped to the
domain Comment model. Comments lacking an id are dropped (they cannot
be merged or resolved).
§Errors
Returns crate::error::Error::Google on API failure.
Sourcepub async fn resolve_comment(
&self,
file_id: &str,
comment_id: &str,
) -> Result<()>
pub async fn resolve_comment( &self, file_id: &str, comment_id: &str, ) -> Result<()>
Resolve a single comment via comments.update {resolved:true} (DI-4).
§Errors
Returns crate::error::Error::Google on API failure.
Sourcepub async fn resolve_comments(
&self,
file_id: &str,
comment_ids: &[String],
) -> Vec<(String, Result<()>)>
pub async fn resolve_comments( &self, file_id: &str, comment_ids: &[String], ) -> Vec<(String, Result<()>)>
Resolve many comments, isolating failures so one failed call never aborts the rest (DI-4). Returns each comment id paired with its own outcome.
Sourcepub async fn create_reply(
&self,
file_id: &str,
comment_id: &str,
content: &str,
) -> Result<String>
pub async fn create_reply( &self, file_id: &str, comment_id: &str, content: &str, ) -> Result<String>
Post a reply to an existing comment via replies.create, returning the new
reply’s id.
Unlike anchored top-level comments (which the API cannot create with a usable anchor — D1, hence DI-4’s “never create comments”), a reply carries no anchor: it inherits its parent comment’s. Creating replies is therefore both supported by the API and outside DI-4’s prohibition.
§Errors
Returns crate::error::Error::Google on API failure, or when the response
omits a reply id.