openlark_workflow/v1/task/comment/
delete.rs1use openlark_core::{
6 api::{ApiRequest, ApiResponseTrait, ResponseFormat},
7 config::Config,
8 SDKResult,
9};
10use serde::Deserialize;
11use std::sync::Arc;
12
13#[derive(Debug, Clone, Deserialize)]
15pub struct DeleteTaskCommentResponseV1 {
16 pub success: bool,
18}
19
20#[derive(Debug, Clone)]
22pub struct DeleteTaskCommentRequestV1 {
23 config: Arc<Config>,
24 task_id: String,
25 comment_id: String,
26}
27
28impl DeleteTaskCommentRequestV1 {
29 pub fn new(
30 config: Arc<Config>,
31 task_id: impl Into<String>,
32 comment_id: impl Into<String>,
33 ) -> Self {
34 Self {
35 config,
36 task_id: task_id.into(),
37 comment_id: comment_id.into(),
38 }
39 }
40
41 pub async fn execute(self) -> SDKResult<DeleteTaskCommentResponseV1> {
43 self.execute_with_options(openlark_core::req_option::RequestOption::default())
44 .await
45 }
46
47 pub async fn execute_with_options(
49 self,
50 option: openlark_core::req_option::RequestOption,
51 ) -> SDKResult<DeleteTaskCommentResponseV1> {
52 let api_endpoint = crate::common::api_endpoints::TaskApiV1::TaskCommentDelete(
53 self.task_id.clone(),
54 self.comment_id.clone(),
55 );
56 let request = ApiRequest::<DeleteTaskCommentResponseV1>::delete(api_endpoint.to_url());
57
58 let response =
59 openlark_core::http::Transport::request(request, &self.config, Some(option)).await?;
60 response.data.ok_or_else(|| {
61 openlark_core::error::validation_error("响应数据为空", "服务器没有返回有效的数据")
62 })
63 }
64}
65
66impl ApiResponseTrait for DeleteTaskCommentResponseV1 {
67 fn data_format() -> ResponseFormat {
68 ResponseFormat::Data
69 }
70}
71
72#[cfg(test)]
73#[allow(unused_imports)]
74mod tests {
75
76 #[test]
77 fn test_delete_task_comment_v1_url() {
78 let endpoint = crate::common::api_endpoints::TaskApiV1::TaskCommentDelete(
79 "task_123".to_string(),
80 "comment_456".to_string(),
81 );
82 assert_eq!(
83 endpoint.to_url(),
84 "/open-apis/task/v1/tasks/task_123/comments/comment_456"
85 );
86 }
87}