1use std::sync::Arc;
4
5use agent_service::GoogleCalendarAccessService;
6use agent_storage::ExternalConnectionId;
7
8use crate::{GoogleOAuthConfig, GoogleOAuthError, GoogleOAuthTokenManager};
9
10#[derive(Clone)]
15pub struct GoogleCalendarRuntimeConfig {
16 pub(crate) oauth: GoogleOAuthConfig,
17 pub(crate) access: Arc<GoogleCalendarAccessService>,
18 token_manager: Arc<GoogleOAuthTokenManager>,
19}
20
21impl GoogleCalendarRuntimeConfig {
22 pub fn new(
23 oauth: GoogleOAuthConfig,
24 access: Arc<GoogleCalendarAccessService>,
25 token_manager: Arc<GoogleOAuthTokenManager>,
26 ) -> Self {
27 Self {
28 oauth,
29 access,
30 token_manager,
31 }
32 }
33
34 pub(crate) async fn refresh_access_token(
36 &self,
37 connection_id: ExternalConnectionId,
38 refresh_token: &str,
39 ) -> Result<String, GoogleOAuthError> {
40 self.token_manager
41 .refresh_access_token(connection_id, &self.oauth, refresh_token)
42 .await
43 }
44}