openlark_workflow/v2/section/
mod.rs1pub mod create;
3pub mod delete;
5pub mod get;
7pub mod list;
9pub mod models;
11pub mod patch;
13pub mod update;
15
16use openlark_core::config::Config;
17use std::sync::Arc;
18
19#[derive(Clone)]
21pub struct Section {
22 config: Arc<Config>,
23 tasklist_guid: String,
24}
25
26impl Section {
27 pub fn new(config: Arc<Config>) -> Self {
29 Self {
30 config,
31 tasklist_guid: String::new(),
32 }
33 }
34
35 pub fn with_tasklist(mut self, tasklist_guid: impl Into<String>) -> Self {
37 self.tasklist_guid = tasklist_guid.into();
38 self
39 }
40
41 pub fn create(&self) -> create::CreateSectionRequest {
43 create::CreateSectionRequest::new(self.config.clone(), self.tasklist_guid.clone())
44 }
45
46 pub fn get(&self, section_guid: impl Into<String>) -> get::GetSectionRequest {
48 get::GetSectionRequest::new(
49 self.config.clone(),
50 self.tasklist_guid.clone(),
51 section_guid.into(),
52 )
53 }
54
55 pub fn update(&self, section_guid: impl Into<String>) -> update::UpdateSectionRequest {
57 update::UpdateSectionRequest::new(
58 self.config.clone(),
59 self.tasklist_guid.clone(),
60 section_guid.into(),
61 )
62 }
63
64 pub fn delete(&self, section_guid: impl Into<String>) -> delete::DeleteSectionRequest {
66 delete::DeleteSectionRequest::new(
67 self.config.clone(),
68 self.tasklist_guid.clone(),
69 section_guid.into(),
70 )
71 }
72
73 pub fn list(&self) -> list::ListSectionsRequest {
75 list::ListSectionsRequest::new(self.config.clone(), self.tasklist_guid.clone())
76 }
77}
78
79pub use create::CreateSectionRequest;
81pub use delete::DeleteSectionRequest;
82pub use get::GetSectionRequest;
83pub use list::ListSectionsRequest;
84pub use patch::UpdateSectionRequest;
85
86pub use models::{
88 CreateSectionBody, CreateSectionResponse, DeleteSectionResponse, GetSectionResponse,
89 ListSectionsResponse, SectionItem, UpdateSectionBody, UpdateSectionResponse,
90};
91
92#[cfg(test)]
93#[allow(unused_imports)]
94mod tests {
95 use super::*;
96 use std::sync::Arc;
97
98 fn create_test_config() -> Arc<Config> {
99 Arc::new(
100 Config::builder()
101 .app_id("test_app")
102 .app_secret("test_secret")
103 .build(),
104 )
105 }
106
107 #[test]
108 fn test_section_new() {
109 let config = create_test_config();
110 let section = Section::new(config);
111 assert!(section.tasklist_guid.is_empty());
112 }
113
114 #[test]
115 fn test_section_with_tasklist() {
116 let config = create_test_config();
117 let section = Section::new(config).with_tasklist("tasklist_123");
118 assert_eq!(section.tasklist_guid, "tasklist_123");
119 }
120
121 #[test]
122 fn test_section_create() {
123 let config = create_test_config();
124 let section = Section::new(config).with_tasklist("tasklist_123");
125 let _request = section.create();
126 }
127
128 #[test]
129 fn test_section_get() {
130 let config = create_test_config();
131 let section = Section::new(config).with_tasklist("tasklist_123");
132 let _request = section.get("section_456");
133 }
134
135 #[test]
136 fn test_section_update() {
137 let config = create_test_config();
138 let section = Section::new(config).with_tasklist("tasklist_123");
139 let _request = section.update("section_456");
140 }
141
142 #[test]
143 fn test_section_delete() {
144 let config = create_test_config();
145 let section = Section::new(config).with_tasklist("tasklist_123");
146 let _request = section.delete("section_456");
147 }
148
149 #[test]
150 fn test_section_list() {
151 let config = create_test_config();
152 let section = Section::new(config).with_tasklist("tasklist_123");
153 let _request = section.list();
154 }
155}