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(self.config.clone(), comment_guid.into())
47 }
48
49 pub fn update(&self, comment_guid: impl Into<String>) -> update::UpdateCommentRequest {
51 update::UpdateCommentRequest::new(self.config.clone(), comment_guid.into())
52 }
53
54 pub fn delete(&self, comment_guid: impl Into<String>) -> delete::DeleteCommentRequest {
56 delete::DeleteCommentRequest::new(self.config.clone(), comment_guid.into())
57 }
58
59 pub fn list(&self) -> list::ListCommentsRequest {
61 list::ListCommentsRequest::new(self.config.clone(), self.task_guid.clone())
62 }
63}
64
65pub use create::CreateCommentRequest;
67pub use delete::DeleteCommentRequest;
68pub use get::GetCommentRequest;
69pub use list::ListCommentsRequest;
70pub use update::UpdateCommentRequest;
71
72pub use models::{
74 CommentCreator, CommentItem, CreateCommentBody, CreateCommentResponse, DeleteCommentResponse,
75 GetCommentResponse, InputComment, ListCommentsResponse, UpdateCommentBody,
76 UpdateCommentResponse,
77};
78
79#[cfg(test)]
80#[allow(unused_imports)]
81mod tests {
82 use super::*;
83 use std::sync::Arc;
84
85 fn create_test_config() -> Arc<Config> {
86 Arc::new(
87 Config::builder()
88 .app_id("test_app")
89 .app_secret("test_secret")
90 .build(),
91 )
92 }
93
94 #[test]
95 fn test_comment_new() {
96 let config = create_test_config();
97 let comment = Comment::new(config);
98 assert!(comment.task_guid.is_empty());
99 }
100
101 #[test]
102 fn test_comment_with_task() {
103 let config = create_test_config();
104 let comment = Comment::new(config).with_task("task_123");
105 assert_eq!(comment.task_guid, "task_123");
106 }
107
108 #[test]
109 fn test_comment_create() {
110 let config = create_test_config();
111 let comment = Comment::new(config).with_task("task_123");
112 let _request = comment.create();
113 }
114
115 #[test]
116 fn test_comment_get() {
117 let config = create_test_config();
118 let comment = Comment::new(config).with_task("task_123");
119 let _request = comment.get("comment_456");
120 }
121
122 #[test]
123 fn test_comment_update() {
124 let config = create_test_config();
125 let comment = Comment::new(config).with_task("task_123");
126 let _request = comment.update("comment_456");
127 }
128
129 #[test]
130 fn test_comment_delete() {
131 let config = create_test_config();
132 let comment = Comment::new(config).with_task("task_123");
133 let _request = comment.delete("comment_456");
134 }
135
136 #[test]
137 fn test_comment_list() {
138 let config = create_test_config();
139 let comment = Comment::new(config).with_task("task_123");
140 let _request = comment.list();
141 }
142}