Skip to main content

openlark_workflow/v1/task/follower/
delete.rs

1//! 删除任务关注者(v1)
2//!
3//! docPath: <https://open.feishu.cn/document/server-docs/docs/task-v1/taskfollower/delete>
4
5use openlark_core::{
6    SDKResult,
7    api::{ApiRequest, ApiResponseTrait, ResponseFormat},
8    config::Config,
9};
10use serde::Deserialize;
11use std::sync::Arc;
12
13/// 删除任务关注者响应(v1)
14#[derive(Debug, Clone, Deserialize)]
15/// 删除任务关注者响应。
16pub struct DeleteTaskFollowerResponseV1 {
17    /// 是否成功删除
18    pub success: bool,
19}
20
21/// 删除任务关注者请求(v1)
22#[derive(Debug, Clone)]
23/// 删除任务关注者请求构建器。
24pub struct DeleteTaskFollowerRequestV1 {
25    config: Arc<Config>,
26    task_id: String,
27    follower_id: String,
28}
29
30impl DeleteTaskFollowerRequestV1 {
31    /// 创建新的请求构建器。
32    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    /// 执行请求
45    pub async fn execute(self) -> SDKResult<DeleteTaskFollowerResponseV1> {
46        self.execute_with_options(openlark_core::req_option::RequestOption::default())
47            .await
48    }
49
50    /// 执行请求(带选项)
51    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        openlark_core::http::Transport::request_typed(
62            request,
63            &self.config,
64            Some(option),
65            "响应数据为空",
66        )
67        .await
68    }
69}
70
71impl ApiResponseTrait for DeleteTaskFollowerResponseV1 {
72    fn data_format() -> ResponseFormat {
73        ResponseFormat::Data
74    }
75}
76
77#[cfg(test)]
78#[allow(unused_imports)]
79mod tests {
80
81    #[test]
82    fn test_delete_task_follower_v1_url() {
83        let endpoint = crate::common::api_endpoints::TaskApiV1::TaskFollowerDelete(
84            "task_123".to_string(),
85            "user_456".to_string(),
86        );
87        assert_eq!(
88            endpoint.to_url(),
89            "/open-apis/task/v1/tasks/task_123/followers/user_456"
90        );
91    }
92}