openlark_platform/
service.rs1use crate::PlatformConfig;
6use std::sync::Arc;
7
8#[derive(Debug, Clone)]
12pub struct PlatformService {
13 config: Arc<PlatformConfig>,
15}
16
17impl PlatformService {
18 pub fn new(config: PlatformConfig) -> Self {
24 Self {
25 config: Arc::new(config),
26 }
27 }
28
29 pub fn config(&self) -> Arc<PlatformConfig> {
31 self.config.clone()
32 }
33
34 #[cfg(feature = "app-engine")]
38 pub fn app_engine(&self) -> crate::app_engine::AppEngineService {
39 crate::app_engine::AppEngineService::new(self.config.clone())
40 }
41
42 #[cfg(feature = "directory")]
46 pub fn directory(&self) -> crate::directory::DirectoryService {
47 crate::directory::DirectoryService::new(self.config.clone())
48 }
49
50 #[cfg(feature = "admin")]
54 pub fn admin(&self) -> crate::admin::AdminService {
55 crate::admin::AdminService::new(self.config.clone())
56 }
57
58 #[cfg(feature = "spark")]
62 pub fn spark(&self) -> crate::spark::SparkService {
63 crate::spark::SparkService::new(self.config.clone())
64 }
65}
66
67#[cfg(test)]
68mod tests {
69 use crate::{PlatformConfig, PlatformService};
70
71 #[test]
72 fn test_service_creation() {
73 let config = PlatformConfig::builder()
74 .app_id("test_app_id")
75 .app_secret("test_app_secret")
76 .build();
77 let _service = PlatformService::new(config);
78 }
79}