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