openlark_workflow/v1/task/comment/
get.rs1use openlark_core::{
6 SDKResult,
7 api::{ApiRequest, ApiResponseTrait, ResponseFormat},
8 config::Config,
9};
10use serde::Deserialize;
11use std::sync::Arc;
12
13#[derive(Debug, Clone, Deserialize)]
15pub struct GetTaskCommentResponseV1 {
17 pub comment_id: String,
19 pub content: String,
21 pub creator_id: String,
23 pub created_at: Option<String>,
25 pub parent_id: Option<String>,
27}
28
29#[derive(Debug, Clone)]
31pub struct GetTaskCommentRequestV1 {
33 config: Arc<Config>,
34 task_id: String,
35 comment_id: String,
36}
37
38impl GetTaskCommentRequestV1 {
39 pub fn new(
41 config: Arc<Config>,
42 task_id: impl Into<String>,
43 comment_id: impl Into<String>,
44 ) -> Self {
45 Self {
46 config,
47 task_id: task_id.into(),
48 comment_id: comment_id.into(),
49 }
50 }
51
52 pub async fn execute(self) -> SDKResult<GetTaskCommentResponseV1> {
54 self.execute_with_options(openlark_core::req_option::RequestOption::default())
55 .await
56 }
57
58 pub async fn execute_with_options(
60 self,
61 option: openlark_core::req_option::RequestOption,
62 ) -> SDKResult<GetTaskCommentResponseV1> {
63 let api_endpoint = crate::common::api_endpoints::TaskApiV1::TaskCommentGet(
64 self.task_id.clone(),
65 self.comment_id.clone(),
66 );
67 let request = ApiRequest::<GetTaskCommentResponseV1>::get(api_endpoint.to_url());
68
69 openlark_core::http::Transport::request_typed(
70 request,
71 &self.config,
72 Some(option),
73 "响应数据为空",
74 )
75 .await
76 }
77}
78
79impl ApiResponseTrait for GetTaskCommentResponseV1 {
80 fn data_format() -> ResponseFormat {
81 ResponseFormat::Data
82 }
83}
84
85#[cfg(test)]
86#[allow(unused_imports)]
87mod tests {
88
89 #[test]
90 fn test_get_task_comment_v1_url() {
91 let endpoint = crate::common::api_endpoints::TaskApiV1::TaskCommentGet(
92 "task_123".to_string(),
93 "comment_456".to_string(),
94 );
95 assert_eq!(
96 endpoint.to_url(),
97 "/open-apis/task/v1/tasks/task_123/comments/comment_456"
98 );
99 }
100}