Skip to main content

openlark_workflow/v2/section/
mod.rs

1/// 创建接口。
2pub mod create;
3/// 删除接口。
4pub mod delete;
5/// 获取接口。
6pub mod get;
7/// 列表接口。
8pub mod list;
9/// 数据模型。
10pub mod models;
11/// 更新接口。
12pub mod patch;
13/// 分组任务列表接口。
14pub mod tasks;
15/// 更新接口。
16pub mod update;
17
18use openlark_core::config::Config;
19use std::sync::Arc;
20
21/// Section:分组资源
22#[derive(Clone)]
23pub struct Section {
24    config: Arc<Config>,
25}
26
27impl Section {
28    /// 创建新的实例。
29    pub fn new(config: Arc<Config>) -> Self {
30        Self { config }
31    }
32
33    /// 创建新建请求。
34    pub fn create(&self) -> create::CreateSectionRequest {
35        create::CreateSectionRequest::new(self.config.clone())
36    }
37
38    /// 创建获取详情请求。
39    pub fn get(&self, section_guid: impl Into<String>) -> get::GetSectionRequest {
40        get::GetSectionRequest::new(self.config.clone(), section_guid.into())
41    }
42
43    /// 创建更新请求。
44    pub fn update(&self, section_guid: impl Into<String>) -> update::UpdateSectionRequest {
45        update::UpdateSectionRequest::new(self.config.clone(), section_guid.into())
46    }
47
48    /// 创建删除请求。
49    pub fn delete(&self, section_guid: impl Into<String>) -> delete::DeleteSectionRequest {
50        delete::DeleteSectionRequest::new(self.config.clone(), section_guid.into())
51    }
52
53    /// 创建列表请求。
54    pub fn list(&self) -> list::ListSectionsRequest {
55        list::ListSectionsRequest::new(self.config.clone())
56    }
57
58    /// 创建分组任务列表请求。
59    pub fn tasks(&self, section_guid: impl Into<String>) -> tasks::GetSectionTasksRequest {
60        tasks::GetSectionTasksRequest::new(self.config.clone(), section_guid.into())
61    }
62}
63
64// 重新导出请求类型
65pub use create::CreateSectionRequest;
66pub use delete::DeleteSectionRequest;
67pub use get::GetSectionRequest;
68pub use list::ListSectionsRequest;
69pub use patch::UpdateSectionRequest;
70pub use tasks::GetSectionTasksRequest;
71
72// 重新导出响应类型
73pub use models::{
74    CreateSectionBody, CreateSectionResponse, DeleteSectionResponse, GetSectionResponse,
75    ListSectionsResponse, SectionItem, UpdateSectionBody, UpdateSectionResponse,
76};
77pub use tasks::ListSectionTasksResponse;
78
79#[cfg(test)]
80#[allow(unused_imports)]
81mod tests {
82    use super::*;
83    use std::sync::Arc;
84
85    fn create_test_config() -> Arc<Config> {
86        Arc::new(
87            Config::builder()
88                .app_id("test_app")
89                .app_secret("test_secret")
90                .build(),
91        )
92    }
93
94    #[test]
95    fn test_section_new() {
96        let config = create_test_config();
97        let _section = Section::new(config);
98    }
99
100    #[test]
101    fn test_section_create() {
102        let config = create_test_config();
103        let section = Section::new(config);
104        let _request = section.create();
105    }
106
107    #[test]
108    fn test_section_get() {
109        let config = create_test_config();
110        let section = Section::new(config);
111        let _request = section.get("section_456");
112    }
113
114    #[test]
115    fn test_section_update() {
116        let config = create_test_config();
117        let section = Section::new(config);
118        let _request = section.update("section_456");
119    }
120
121    #[test]
122    fn test_section_delete() {
123        let config = create_test_config();
124        let section = Section::new(config);
125        let _request = section.delete("section_456");
126    }
127
128    #[test]
129    fn test_section_list() {
130        let config = create_test_config();
131        let section = Section::new(config);
132        let _request = section.list();
133    }
134}