#[cfg(any(
feature = "attendance",
feature = "authentication",
feature = "im",
feature = "search",
feature = "cloud-docs"
))]
use std::sync::Arc;
use std::time::Duration;
use crate::core::{config::Config, constants::AppType};
#[cfg(feature = "acs")]
use crate::service::acs::AcsService;
#[cfg(feature = "admin")]
use crate::service::admin::AdminService;
#[cfg(feature = "ai")]
use crate::service::ai::AiService;
#[cfg(feature = "aily")]
use crate::service::aily::AilyService;
#[cfg(feature = "apass")]
use crate::service::apass::ApassService;
#[cfg(feature = "application")]
use crate::service::application::ApplicationService;
#[cfg(feature = "approval")]
use crate::service::approval::ApprovalService;
#[cfg(feature = "attendance")]
use crate::service::attendance::AttendanceService;
#[cfg(feature = "authentication")]
use crate::service::authentication::AuthenService;
#[cfg(feature = "bot")]
use crate::service::bot::BotService;
#[cfg(feature = "calendar")]
use crate::service::calendar::CalendarService;
#[cfg(feature = "cardkit")]
use crate::service::cardkit::CardkitService;
#[cfg(feature = "cloud-docs")]
use crate::service::cloud_docs::CloudDocsService;
#[cfg(feature = "contact")]
use crate::service::contact::ContactService;
#[cfg(feature = "corehr")]
use crate::service::corehr::CoreHRService;
#[cfg(feature = "directory")]
use crate::service::directory::DirectoryService;
#[cfg(feature = "ehr")]
use crate::service::ehr::EhrService;
#[cfg(feature = "elearning")]
use crate::service::elearning::ELearningService;
#[cfg(feature = "group")]
use crate::service::group::GroupService;
#[cfg(feature = "helpdesk")]
use crate::service::helpdesk::HelpdeskService;
#[cfg(feature = "hire")]
use crate::service::hire::HireService;
#[cfg(feature = "human-authentication")]
use crate::service::human_authentication::HumanAuthenticationService;
#[cfg(feature = "im")]
use crate::service::im::ImService;
#[cfg(feature = "lingo")]
use crate::service::lingo::LingoService;
#[cfg(feature = "mail")]
use crate::service::mail::MailService;
#[cfg(feature = "mdm")]
use crate::service::mdm::MdmService;
#[cfg(feature = "minutes")]
use crate::service::minutes::MinutesService;
#[cfg(feature = "moments")]
use crate::service::moments::MomentsService;
#[cfg(feature = "okr")]
use crate::service::okr::OkrService;
#[cfg(feature = "payroll")]
use crate::service::payroll::PayrollService;
#[cfg(feature = "performance")]
use crate::service::performance::PerformanceService;
#[cfg(feature = "personal-settings")]
use crate::service::personal_settings::PersonalSettingsService;
#[cfg(feature = "report")]
use crate::service::report::ReportService;
#[cfg(feature = "search")]
use crate::service::search::SearchService;
#[cfg(feature = "security-and-compliance")]
use crate::service::security_and_compliance::SecurityAndComplianceService;
#[cfg(feature = "task")]
use crate::service::task::TaskV2Service;
#[cfg(feature = "tenant")]
use crate::service::tenant::TenantService;
#[cfg(feature = "tenant-tag")]
use crate::service::tenant_tag::TenantTagService;
#[cfg(feature = "trust-party")]
use crate::service::trust_party::TrustPartyService;
#[cfg(feature = "vc")]
use crate::service::vc::VcService;
#[cfg(feature = "verification")]
use crate::service::verification::VerificationService;
#[cfg(feature = "workplace")]
use crate::service::workplace::WorkplaceService;
#[cfg(feature = "cloud-docs")]
use crate::service::{
AssistantService, BitableService, BoardService, CommentsService, DocsService, DriveService,
PermissionService, SheetsService, WikiService,
};
#[cfg(feature = "websocket")]
pub mod ws_client;
pub struct LarkClient {
pub config: Config,
#[cfg(feature = "acs")]
pub acs: AcsService,
#[cfg(feature = "admin")]
pub admin: AdminService,
#[cfg(feature = "ai")]
pub ai: AiService,
#[cfg(feature = "aily")]
pub aily: AilyService,
#[cfg(feature = "apass")]
pub apass: ApassService,
#[cfg(feature = "application")]
pub application: ApplicationService,
#[cfg(feature = "approval")]
pub approval: ApprovalService,
#[cfg(feature = "attendance")]
pub attendance: AttendanceService,
#[cfg(feature = "authentication")]
pub auth: AuthenService,
#[cfg(feature = "bot")]
pub bot: BotService,
#[cfg(feature = "calendar")]
pub calendar: CalendarService,
#[cfg(feature = "cardkit")]
pub cardkit: CardkitService,
#[cfg(feature = "contact")]
pub contact: ContactService,
#[cfg(feature = "corehr")]
pub corehr: CoreHRService,
#[cfg(feature = "directory")]
pub directory: DirectoryService,
#[cfg(feature = "ehr")]
pub ehr: EhrService,
#[cfg(feature = "elearning")]
pub elearning: ELearningService,
#[cfg(feature = "group")]
pub group: GroupService,
#[cfg(feature = "helpdesk")]
pub helpdesk: HelpdeskService,
#[cfg(feature = "hire")]
pub hire: HireService,
#[cfg(feature = "human-authentication")]
pub human_authentication: HumanAuthenticationService,
#[cfg(feature = "im")]
pub im: ImService,
#[cfg(feature = "lingo")]
pub lingo: LingoService,
#[cfg(feature = "mail")]
pub mail: MailService,
#[cfg(feature = "mdm")]
pub mdm: MdmService,
#[cfg(feature = "minutes")]
pub minutes: MinutesService,
#[cfg(feature = "moments")]
pub moments: MomentsService,
#[cfg(feature = "okr")]
pub okr: OkrService,
#[cfg(feature = "payroll")]
pub payroll: PayrollService,
#[cfg(feature = "performance")]
pub performance: PerformanceService,
#[cfg(feature = "personal-settings")]
pub personal_settings: PersonalSettingsService,
#[cfg(feature = "report")]
pub report: ReportService,
#[cfg(feature = "search")]
pub search: SearchService,
#[cfg(feature = "security-and-compliance")]
pub security_and_compliance: SecurityAndComplianceService,
#[cfg(feature = "task")]
pub task: TaskV2Service,
#[cfg(feature = "tenant")]
pub tenant: TenantService,
#[cfg(feature = "tenant-tag")]
pub tenant_tag: TenantTagService,
#[cfg(feature = "trust-party")]
pub trust_party: TrustPartyService,
#[cfg(feature = "vc")]
pub vc: VcService,
#[cfg(feature = "verification")]
pub verification: VerificationService,
#[cfg(feature = "workplace")]
pub workplace: WorkplaceService,
#[cfg(feature = "cloud-docs")]
pub cloud_docs: CloudDocsService,
#[cfg(feature = "cloud-docs")]
pub assistant: AssistantService,
#[cfg(feature = "cloud-docs")]
pub docs: DocsService,
#[cfg(feature = "cloud-docs")]
pub drive: DriveService,
#[cfg(feature = "cloud-docs")]
pub sheets: SheetsService,
#[cfg(feature = "cloud-docs")]
pub bitable: BitableService,
#[cfg(feature = "cloud-docs")]
pub wiki: WikiService,
#[cfg(feature = "cloud-docs")]
pub comments: CommentsService,
#[cfg(feature = "cloud-docs")]
pub permission: PermissionService,
#[cfg(feature = "cloud-docs")]
pub board: BoardService,
}
pub struct LarkClientBuilder {
config: Config,
}
impl LarkClientBuilder {
pub fn with_app_type(mut self, app_type: AppType) -> Self {
self.config.app_type = app_type;
self
}
pub fn with_marketplace_app(mut self) -> Self {
self.config.app_type = AppType::Marketplace;
self
}
pub fn with_open_base_url(mut self, base_url: String) -> Self {
self.config.base_url = base_url;
self
}
pub fn with_enable_token_cache(mut self, enable: bool) -> Self {
self.config.enable_token_cache = enable;
self
}
pub fn with_req_timeout(mut self, timeout: Option<f32>) -> Self {
self.config.req_timeout = timeout.map(Duration::from_secs_f32);
self
}
pub fn build(mut self) -> LarkClient {
if let Some(req_timeout) = self.config.req_timeout {
self.config.http_client = reqwest::Client::builder()
.timeout(req_timeout)
.build()
.expect("Failed to build HTTP client with timeout")
}
LarkClient {
config: self.config.clone(),
#[cfg(feature = "acs")]
acs: AcsService::new(self.config.clone()),
#[cfg(feature = "admin")]
admin: AdminService::new(self.config.clone()),
#[cfg(feature = "ai")]
ai: AiService::new(self.config.clone()),
#[cfg(feature = "aily")]
aily: AilyService::new(self.config.clone()),
#[cfg(feature = "apass")]
apass: ApassService::new(self.config.clone()),
#[cfg(feature = "application")]
application: ApplicationService::new(self.config.clone()),
#[cfg(feature = "approval")]
approval: ApprovalService::new(self.config.clone()),
#[cfg(feature = "attendance")]
attendance: AttendanceService::new(Arc::new(self.config.clone())),
#[cfg(feature = "authentication")]
auth: AuthenService::new(Arc::new(self.config.clone())),
#[cfg(feature = "bot")]
bot: BotService::new(self.config.clone()),
#[cfg(feature = "calendar")]
calendar: CalendarService::new(self.config.clone()),
#[cfg(feature = "cardkit")]
cardkit: CardkitService::new(self.config.clone()),
#[cfg(feature = "contact")]
contact: ContactService::new(self.config.clone()),
#[cfg(feature = "corehr")]
corehr: CoreHRService::new(self.config.clone()),
#[cfg(feature = "directory")]
directory: DirectoryService::new(self.config.clone()),
#[cfg(feature = "ehr")]
ehr: EhrService::new(self.config.clone()),
#[cfg(feature = "elearning")]
elearning: ELearningService::new(self.config.clone()),
#[cfg(feature = "group")]
group: GroupService::new(self.config.clone()),
#[cfg(feature = "helpdesk")]
helpdesk: HelpdeskService::new(self.config.clone()),
#[cfg(feature = "hire")]
hire: HireService::new(self.config.clone()),
#[cfg(feature = "human-authentication")]
human_authentication: HumanAuthenticationService::new(self.config.clone()),
#[cfg(feature = "im")]
im: ImService::new(Arc::new(self.config.clone())),
#[cfg(feature = "lingo")]
lingo: LingoService::new(self.config.clone()),
#[cfg(feature = "mail")]
mail: MailService::new(self.config.clone()),
#[cfg(feature = "mdm")]
mdm: MdmService::new(self.config.clone()),
#[cfg(feature = "minutes")]
minutes: MinutesService::new(self.config.clone()),
#[cfg(feature = "moments")]
moments: MomentsService::new(self.config.clone()),
#[cfg(feature = "okr")]
okr: OkrService::new(self.config.clone()),
#[cfg(feature = "payroll")]
payroll: PayrollService::new(self.config.clone()),
#[cfg(feature = "performance")]
performance: PerformanceService::new(self.config.clone()),
#[cfg(feature = "personal-settings")]
personal_settings: PersonalSettingsService::new(self.config.clone()),
#[cfg(feature = "report")]
report: ReportService::new(self.config.clone()),
#[cfg(feature = "search")]
search: SearchService::new(Arc::new(self.config.clone())),
#[cfg(feature = "security-and-compliance")]
security_and_compliance: SecurityAndComplianceService::new(self.config.clone()),
#[cfg(feature = "task")]
task: TaskV2Service::new(self.config.clone()),
#[cfg(feature = "tenant")]
tenant: TenantService::new(self.config.clone()),
#[cfg(feature = "tenant-tag")]
tenant_tag: TenantTagService::new(self.config.clone()),
#[cfg(feature = "trust-party")]
trust_party: TrustPartyService::new(self.config.clone()),
#[cfg(feature = "vc")]
vc: VcService::new(self.config.clone()),
#[cfg(feature = "verification")]
verification: VerificationService::new(self.config.clone()),
#[cfg(feature = "workplace")]
workplace: WorkplaceService::new(self.config.clone()),
#[cfg(feature = "cloud-docs")]
cloud_docs: CloudDocsService::new(Arc::new(self.config.clone())),
#[cfg(feature = "cloud-docs")]
assistant: AssistantService::new(Arc::new(self.config.clone())),
#[cfg(feature = "cloud-docs")]
docs: DocsService::new(Arc::new(self.config.clone())),
#[cfg(feature = "cloud-docs")]
drive: DriveService::new(Arc::new(self.config.clone())),
#[cfg(feature = "cloud-docs")]
sheets: SheetsService::new(Arc::new(self.config.clone())),
#[cfg(feature = "cloud-docs")]
bitable: BitableService::new(Arc::new(self.config.clone())),
#[cfg(feature = "cloud-docs")]
wiki: WikiService::new(Arc::new(self.config.clone())),
#[cfg(feature = "cloud-docs")]
comments: CommentsService::new(Arc::new(self.config.clone())),
#[cfg(feature = "cloud-docs")]
permission: PermissionService::new(Arc::new(self.config.clone())),
#[cfg(feature = "cloud-docs")]
board: BoardService::new(Arc::new(self.config.clone())),
}
}
}
impl LarkClient {
pub fn builder(app_id: &str, app_secret: &str) -> LarkClientBuilder {
LarkClientBuilder {
config: Config {
app_id: app_id.to_string(),
app_secret: app_secret.to_string(),
..Default::default()
},
}
}
}