openlark_workflow/v2/task/subtask/
mod.rs1pub mod create;
4pub mod list;
5
6use openlark_core::config::Config;
7use std::sync::Arc;
8
9#[derive(Clone)]
11pub struct Subtask {
12 config: Arc<Config>,
13 task_guid: String,
14}
15
16impl Subtask {
17 pub fn new(config: Arc<Config>, task_guid: impl Into<String>) -> Self {
18 Self {
19 config,
20 task_guid: task_guid.into(),
21 }
22 }
23
24 pub fn create(&self) -> create::CreateSubtaskRequest {
26 create::CreateSubtaskRequest::new(self.config.clone(), self.task_guid.clone())
27 }
28
29 pub fn list(&self) -> list::ListSubtasksRequest {
31 list::ListSubtasksRequest::new(self.config.clone(), self.task_guid.clone())
32 }
33}
34
35pub use create::CreateSubtaskRequest;
37pub use list::ListSubtasksRequest;
38
39pub use create::CreateSubtaskResponse;
41pub use list::ListSubtasksResponse;
42
43#[cfg(test)]
44#[allow(unused_imports)]
45mod tests {
46 use super::*;
47 use std::sync::Arc;
48
49 fn create_test_config() -> Arc<Config> {
50 Arc::new(
51 Config::builder()
52 .app_id("test_app")
53 .app_secret("test_secret")
54 .build(),
55 )
56 }
57
58 #[test]
59 fn test_subtask_new() {
60 let config = create_test_config();
61 let subtask = Subtask::new(config, "task_guid_123");
62 assert_eq!(subtask.task_guid, "task_guid_123");
63 }
64
65 #[test]
66 fn test_subtask_create() {
67 let config = create_test_config();
68 let subtask = Subtask::new(config, "task_guid_123");
69 let _request = subtask.create();
70 }
71
72 #[test]
73 fn test_subtask_list() {
74 let config = create_test_config();
75 let subtask = Subtask::new(config, "task_guid_123");
76 let _request = subtask.list();
77 }
78}