Skip to main content

openlark_platform/spark/
mod.rs

1//! 妙搭平台模块
2//!
3//! 提供妙搭平台相关 API 的访问入口。
4
5use crate::PlatformConfig;
6use std::sync::Arc;
7
8/// 妙搭平台服务
9#[derive(Debug, Clone)]
10pub struct SparkService {
11    config: Arc<PlatformConfig>,
12}
13
14impl SparkService {
15    /// 创建新的妙搭平台服务实例
16    pub fn new(config: Arc<PlatformConfig>) -> Self {
17        Self { config }
18    }
19
20    /// 获取客户端配置
21    pub fn config(&self) -> Arc<PlatformConfig> {
22        self.config.clone()
23    }
24
25    /// V1 版本 API
26    #[cfg(feature = "v1")]
27    pub fn v1(&self) -> crate::spark::spark::v1::SparkV1 {
28        crate::spark::spark::v1::SparkV1::new(self.config.clone())
29    }
30}
31
32#[cfg(feature = "v1")]
33pub mod spark;
34
35#[cfg(test)]
36mod tests {
37    use crate::{PlatformConfig, spark::SparkService};
38
39    #[test]
40    fn test_service_creation() {
41        let config = PlatformConfig::builder()
42            .app_id("test_app_id")
43            .app_secret("test_app_secret")
44            .build();
45
46        let service = SparkService::new(std::sync::Arc::new(config));
47        assert_eq!(service.config().app_id(), "test_app_id");
48    }
49}