openlark_workflow/v1/task/
uncomplete.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 UncompleteTaskResponseV1 {
17 pub id: String,
19 pub summary: String,
21 pub is_completed: bool,
23}
24
25#[derive(Debug, Clone)]
27pub struct UncompleteTaskRequestV1 {
29 config: Arc<Config>,
30 task_id: String,
31}
32
33impl UncompleteTaskRequestV1 {
34 pub fn new(config: Arc<Config>, task_id: impl Into<String>) -> Self {
36 Self {
37 config,
38 task_id: task_id.into(),
39 }
40 }
41
42 pub async fn execute(self) -> SDKResult<UncompleteTaskResponseV1> {
44 self.execute_with_options(openlark_core::req_option::RequestOption::default())
45 .await
46 }
47
48 pub async fn execute_with_options(
50 self,
51 option: openlark_core::req_option::RequestOption,
52 ) -> SDKResult<UncompleteTaskResponseV1> {
53 let api_endpoint = crate::common::api_endpoints::TaskApiV1::TaskUncomplete(self.task_id);
54 let request = ApiRequest::<UncompleteTaskResponseV1>::post(api_endpoint.to_url());
55
56 openlark_core::http::Transport::request_typed(
57 request,
58 &self.config,
59 Some(option),
60 "响应数据为空",
61 )
62 .await
63 }
64}
65
66impl ApiResponseTrait for UncompleteTaskResponseV1 {
67 fn data_format() -> ResponseFormat {
68 ResponseFormat::Data
69 }
70}
71
72#[cfg(test)]
73#[allow(unused_imports)]
74mod tests {
75 use std::sync::Arc;
76
77 use super::*;
78
79 #[test]
80 fn test_uncomplete_task_v1_builder() {
81 let config = Arc::new(
82 openlark_core::config::Config::builder()
83 .app_id("test")
84 .app_secret("test")
85 .build(),
86 );
87
88 let request = UncompleteTaskRequestV1::new(config, "test_task_id");
89 assert_eq!(request.task_id, "test_task_id");
90 }
91
92 #[test]
93 fn test_task_api_v1_uncomplete_url() {
94 let endpoint =
95 crate::common::api_endpoints::TaskApiV1::TaskUncomplete("task_123".to_string());
96 assert_eq!(
97 endpoint.to_url(),
98 "/open-apis/task/v1/tasks/task_123/uncomplete"
99 );
100 }
101}