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    pub fn v1(&self) -> crate::spark::v1::SparkV1 {
27        crate::spark::v1::SparkV1::new(self.config.clone())
28    }
29}
30
31pub mod v1;
32
33#[cfg(test)]
34mod tests {
35    use crate::{PlatformConfig, spark::SparkService};
36
37    #[test]
38    fn test_service_creation() {
39        let config = PlatformConfig::builder()
40            .app_id("test_app_id")
41            .app_secret("test_app_secret")
42            .build();
43
44        let service = SparkService::new(std::sync::Arc::new(config));
45        assert_eq!(service.config().app_id(), "test_app_id");
46    }
47}