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