openlark_workflow/v2/
mod.rs1pub mod attachment;
2pub mod comment;
3pub mod custom_field;
4pub mod section;
5pub mod task;
6pub mod tasklist;
7
8use openlark_core::config::Config;
9use std::sync::Arc;
10
11#[derive(Clone)]
13pub struct TaskV2 {
14 config: Arc<Config>,
15}
16
17impl TaskV2 {
18 pub fn new(config: Arc<Config>) -> Self {
19 Self { config }
20 }
21
22 pub fn task(&self) -> task::Task {
24 task::Task::new(self.config.clone())
25 }
26
27 pub fn tasklist(&self) -> tasklist::Tasklist {
29 tasklist::Tasklist::new(self.config.clone())
30 }
31
32 pub fn custom_field(&self) -> custom_field::CustomField {
34 custom_field::CustomField::new(self.config.clone())
35 }
36
37 pub fn comment(&self) -> comment::Comment {
39 comment::Comment::new(self.config.clone())
40 }
41
42 pub fn section(&self) -> section::Section {
44 section::Section::new(self.config.clone())
45 }
46
47 pub fn attachment(&self) -> attachment::Attachment {
49 attachment::Attachment::new(self.config.clone())
50 }
51}
52
53#[cfg(test)]
54#[allow(unused_imports)]
55mod tests {
56 use super::*;
57 use std::sync::Arc;
58
59 fn create_test_config() -> Arc<Config> {
60 Arc::new(
61 Config::builder()
62 .app_id("test_app")
63 .app_secret("test_secret")
64 .build(),
65 )
66 }
67
68 #[test]
69 fn test_task_v2_new() {
70 let config = create_test_config();
71 let _task_v2 = TaskV2::new(config);
72 }
73
74 #[test]
75 fn test_task_v2_task() {
76 let config = create_test_config();
77 let task_v2 = TaskV2::new(config);
78 let _task = task_v2.task();
79 }
80
81 #[test]
82 fn test_task_v2_tasklist() {
83 let config = create_test_config();
84 let task_v2 = TaskV2::new(config);
85 let _tasklist = task_v2.tasklist();
86 }
87
88 #[test]
89 fn test_task_v2_custom_field() {
90 let config = create_test_config();
91 let task_v2 = TaskV2::new(config);
92 let _custom_field = task_v2.custom_field();
93 }
94
95 #[test]
96 fn test_task_v2_comment() {
97 let config = create_test_config();
98 let task_v2 = TaskV2::new(config);
99 let _comment = task_v2.comment();
100 }
101
102 #[test]
103 fn test_task_v2_section() {
104 let config = create_test_config();
105 let task_v2 = TaskV2::new(config);
106 let _section = task_v2.section();
107 }
108
109 #[test]
110 fn test_task_v2_attachment() {
111 let config = create_test_config();
112 let task_v2 = TaskV2::new(config);
113 let _attachment = task_v2.attachment();
114 }
115}