openlark_workflow/v2/comment/
mod.rs1pub mod create;
3pub mod delete;
5pub mod get;
7pub mod list;
9pub mod models;
11pub mod update;
13
14use openlark_core::config::Config;
15use std::sync::Arc;
16
17#[derive(Clone)]
19pub struct Comment {
20 config: Arc<Config>,
21 task_guid: String,
22}
23
24impl Comment {
25 pub fn new(config: Arc<Config>) -> Self {
27 Self {
28 config,
29 task_guid: String::new(),
30 }
31 }
32
33 pub fn with_task(mut self, task_guid: impl Into<String>) -> Self {
35 self.task_guid = task_guid.into();
36 self
37 }
38
39 pub fn create(&self) -> create::CreateCommentRequest {
41 create::CreateCommentRequest::new(self.config.clone(), self.task_guid.clone())
42 }
43
44 pub fn get(&self, comment_guid: impl Into<String>) -> get::GetCommentRequest {
46 get::GetCommentRequest::new(
47 self.config.clone(),
48 self.task_guid.clone(),
49 comment_guid.into(),
50 )
51 }
52
53 pub fn update(&self, comment_guid: impl Into<String>) -> update::UpdateCommentRequest {
55 update::UpdateCommentRequest::new(
56 self.config.clone(),
57 self.task_guid.clone(),
58 comment_guid.into(),
59 )
60 }
61
62 pub fn delete(&self, comment_guid: impl Into<String>) -> delete::DeleteCommentRequest {
64 delete::DeleteCommentRequest::new(
65 self.config.clone(),
66 self.task_guid.clone(),
67 comment_guid.into(),
68 )
69 }
70
71 pub fn list(&self) -> list::ListCommentsRequest {
73 list::ListCommentsRequest::new(self.config.clone(), self.task_guid.clone())
74 }
75}
76
77pub use create::CreateCommentRequest;
79pub use delete::DeleteCommentRequest;
80pub use get::GetCommentRequest;
81pub use list::ListCommentsRequest;
82pub use update::UpdateCommentRequest;
83
84pub use models::{
86 CommentItem, CreateCommentBody, CreateCommentResponse, DeleteCommentResponse,
87 GetCommentResponse, ListCommentsResponse, UpdateCommentBody, UpdateCommentResponse,
88};
89
90#[cfg(test)]
91#[allow(unused_imports)]
92mod tests {
93 use super::*;
94 use std::sync::Arc;
95
96 fn create_test_config() -> Arc<Config> {
97 Arc::new(
98 Config::builder()
99 .app_id("test_app")
100 .app_secret("test_secret")
101 .build(),
102 )
103 }
104
105 #[test]
106 fn test_comment_new() {
107 let config = create_test_config();
108 let comment = Comment::new(config);
109 assert!(comment.task_guid.is_empty());
110 }
111
112 #[test]
113 fn test_comment_with_task() {
114 let config = create_test_config();
115 let comment = Comment::new(config).with_task("task_123");
116 assert_eq!(comment.task_guid, "task_123");
117 }
118
119 #[test]
120 fn test_comment_create() {
121 let config = create_test_config();
122 let comment = Comment::new(config).with_task("task_123");
123 let _request = comment.create();
124 }
125
126 #[test]
127 fn test_comment_get() {
128 let config = create_test_config();
129 let comment = Comment::new(config).with_task("task_123");
130 let _request = comment.get("comment_456");
131 }
132
133 #[test]
134 fn test_comment_update() {
135 let config = create_test_config();
136 let comment = Comment::new(config).with_task("task_123");
137 let _request = comment.update("comment_456");
138 }
139
140 #[test]
141 fn test_comment_delete() {
142 let config = create_test_config();
143 let comment = Comment::new(config).with_task("task_123");
144 let _request = comment.delete("comment_456");
145 }
146
147 #[test]
148 fn test_comment_list() {
149 let config = create_test_config();
150 let comment = Comment::new(config).with_task("task_123");
151 let _request = comment.list();
152 }
153}