From 940daca7294f7bc9c5f3b5d0ac492005b6ff88e0 Mon Sep 17 00:00:00 2001 From: Jeremiah Russell Date: Mon, 13 Oct 2025 14:58:30 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(gmail):=20create=20gmail=20cli?= =?UTF-8?q?ent=20struct?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - create gmail client struct - add label map - add max results - add label ids - add query - add messages --- src/gmail_client.rs | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/gmail_client.rs b/src/gmail_client.rs index 82a4d13..21cc57e 100644 --- a/src/gmail_client.rs +++ b/src/gmail_client.rs @@ -10,7 +10,11 @@ use google_gmail1::{ yup_oauth2::{ApplicationSecret, InstalledFlowAuthenticator, InstalledFlowReturnMethod}, }; -use crate::{Credential, Error, MessageList, Result}; +mod message_summary; + +pub(crate) use message_summary::MessageSummary; + +use crate::{Credential, Error, Result}; /// Default for the maximum number of results to return on a page pub const DEFAULT_MAX_RESULTS: &str = "200"; @@ -20,6 +24,10 @@ pub const DEFAULT_MAX_RESULTS: &str = "200"; pub struct GmailClient { hub: Gmail>, label_map: BTreeMap, + pub(crate) max_results: u32, + pub(crate) label_ids: Vec, + pub(crate) query: String, + pub(crate) messages: Vec, } impl std::fmt::Debug for GmailClient { @@ -63,7 +71,14 @@ impl GmailClient { let hub = Gmail::new(client, auth); let label_map = GmailClient::get_label_map(&hub).await?; - Ok(GmailClient { hub, label_map }) + Ok(GmailClient { + hub, + label_map, + max_results: DEFAULT_MAX_RESULTS.parse::().unwrap(), + label_ids: Vec::new(), + query: String::new(), + messages: Vec::new(), + }) } /// Create a new List struct and add the Gmail api connection. @@ -111,8 +126,8 @@ impl GmailClient { self.hub.clone() } - /// Get the message list - pub async fn get_message_list(&self) -> Result { - MessageList::new(self).await - } + // /// Get the message list + // pub async fn get_message_list(&self) -> Result { + // MessageList::new(self).await + // } }