openlark_workflow/v1/task/follower/
delete.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 DeleteTaskFollowerResponseV1 {
17 pub success: bool,
19}
20
21#[derive(Debug, Clone)]
23pub struct DeleteTaskFollowerRequestV1 {
25 config: Arc<Config>,
26 task_id: String,
27 follower_id: String,
28}
29
30impl DeleteTaskFollowerRequestV1 {
31 pub fn new(
33 config: Arc<Config>,
34 task_id: impl Into<String>,
35 follower_id: impl Into<String>,
36 ) -> Self {
37 Self {
38 config,
39 task_id: task_id.into(),
40 follower_id: follower_id.into(),
41 }
42 }
43
44 pub async fn execute(self) -> SDKResult<DeleteTaskFollowerResponseV1> {
46 self.execute_with_options(openlark_core::req_option::RequestOption::default())
47 .await
48 }
49
50 pub async fn execute_with_options(
52 self,
53 option: openlark_core::req_option::RequestOption,
54 ) -> SDKResult<DeleteTaskFollowerResponseV1> {
55 let api_endpoint = crate::common::api_endpoints::TaskApiV1::TaskFollowerDelete(
56 self.task_id.clone(),
57 self.follower_id.clone(),
58 );
59 let request = ApiRequest::<DeleteTaskFollowerResponseV1>::delete(api_endpoint.to_url());
60
61 let response =
62 openlark_core::http::Transport::request(request, &self.config, Some(option)).await?;
63 response.data.ok_or_else(|| {
64 openlark_core::error::validation_error("响应数据为空", "服务器没有返回有效的数据")
65 })
66 }
67}
68
69impl ApiResponseTrait for DeleteTaskFollowerResponseV1 {
70 fn data_format() -> ResponseFormat {
71 ResponseFormat::Data
72 }
73}
74
75#[cfg(test)]
76#[allow(unused_imports)]
77mod tests {
78
79 #[test]
80 fn test_delete_task_follower_v1_url() {
81 let endpoint = crate::common::api_endpoints::TaskApiV1::TaskFollowerDelete(
82 "task_123".to_string(),
83 "user_456".to_string(),
84 );
85 assert_eq!(
86 endpoint.to_url(),
87 "/open-apis/task/v1/tasks/task_123/followers/user_456"
88 );
89 }
90}