openlark_workflow/v2/
mod.rs1pub mod attachment;
12pub mod comment;
14pub mod custom_field;
16pub mod section;
18pub mod task;
20pub mod tasklist;
22
23use openlark_core::config::Config;
24use std::sync::Arc;
25
26#[derive(Clone)]
28pub struct TaskV2 {
29 config: Arc<Config>,
30}
31
32impl TaskV2 {
33 pub fn new(config: Arc<Config>) -> Self {
35 Self { config }
36 }
37
38 pub fn task(&self) -> task::Task {
40 task::Task::new(self.config.clone())
41 }
42
43 pub fn tasklist(&self) -> tasklist::Tasklist {
45 tasklist::Tasklist::new(self.config.clone())
46 }
47
48 pub fn custom_field(&self) -> custom_field::CustomField {
50 custom_field::CustomField::new(self.config.clone())
51 }
52
53 pub fn comment(&self) -> comment::Comment {
55 comment::Comment::new(self.config.clone())
56 }
57
58 pub fn section(&self) -> section::Section {
60 section::Section::new(self.config.clone())
61 }
62
63 pub fn attachment(&self) -> attachment::Attachment {
65 attachment::Attachment::new(self.config.clone())
66 }
67}
68
69#[cfg(test)]
70#[allow(unused_imports)]
71mod tests {
72 use super::*;
73 use std::sync::Arc;
74
75 fn create_test_config() -> Arc<Config> {
76 Arc::new(
77 Config::builder()
78 .app_id("test_app")
79 .app_secret("test_secret")
80 .build(),
81 )
82 }
83
84 #[test]
85 fn test_task_v2_new() {
86 let config = create_test_config();
87 let _task_v2 = TaskV2::new(config);
88 }
89
90 #[test]
91 fn test_task_v2_task() {
92 let config = create_test_config();
93 let task_v2 = TaskV2::new(config);
94 let _task = task_v2.task();
95 }
96
97 #[test]
98 fn test_task_v2_tasklist() {
99 let config = create_test_config();
100 let task_v2 = TaskV2::new(config);
101 let _tasklist = task_v2.tasklist();
102 }
103
104 #[test]
105 fn test_task_v2_custom_field() {
106 let config = create_test_config();
107 let task_v2 = TaskV2::new(config);
108 let _custom_field = task_v2.custom_field();
109 }
110
111 #[test]
112 fn test_task_v2_comment() {
113 let config = create_test_config();
114 let task_v2 = TaskV2::new(config);
115 let _comment = task_v2.comment();
116 }
117
118 #[test]
119 fn test_task_v2_section() {
120 let config = create_test_config();
121 let task_v2 = TaskV2::new(config);
122 let _section = task_v2.section();
123 }
124
125 #[test]
126 fn test_task_v2_attachment() {
127 let config = create_test_config();
128 let task_v2 = TaskV2::new(config);
129 let _attachment = task_v2.attachment();
130 }
131}