1use std::{collections::HashMap, sync::Arc, time::Duration};
2use tokio::sync::Mutex;
3
4use crate::core::{
5 app_ticket_manager::AppTicketManager,
6 constants::{AppType, FEISHU_BASE_URL},
7 token_manager::TokenManager,
8};
9
10#[derive(Debug, Clone)]
11pub struct Config {
12 pub app_id: String,
13 pub app_secret: String,
14 pub base_url: String,
16 pub enable_token_cache: bool,
17 pub app_type: AppType,
19 pub http_client: reqwest::Client,
20 pub req_timeout: Option<Duration>,
22 pub header: HashMap<String, String>,
23 pub token_manager: Arc<Mutex<TokenManager>>,
25 pub app_ticket_manager: Arc<Mutex<AppTicketManager>>,
27}
28
29impl Default for Config {
30 fn default() -> Self {
31 Self {
32 app_id: "".to_string(),
33 app_secret: "".to_string(),
34 base_url: FEISHU_BASE_URL.to_string(),
35 enable_token_cache: true,
36 app_type: AppType::SelfBuild,
37 http_client: reqwest::Client::new(),
38 req_timeout: None,
39 header: Default::default(),
40 token_manager: Arc::new(Mutex::new(TokenManager::new())),
41 app_ticket_manager: Arc::new(Mutex::new(AppTicketManager::new())),
42 }
43 }
44}