meegle/chat/
api.rs

1use super::types::*;
2use crate::client::{AuthType, Client};
3use crate::error::ApiResult;
4
5pub trait ChatApi {
6    /// 拉机器人入群
7    /// 该接口用于将指定的飞书机器人拉入工作项关联群,且群里必须有飞书项目机器人
8    /// 对应的平台功能,如绑定飞书群可参考绑定飞书群。
9    /// 对应的权限申请在权限管理-群组分类下,相关功能介绍详见权限管理。
10    fn bot_join_chat(
11        &self,
12        request: BotJoinChatRequest,
13        auth: AuthType,
14    ) -> impl std::future::Future<Output = ApiResult<BotJoinChatResponse>> + Send;
15}
16
17impl ChatApi for Client {
18    async fn bot_join_chat(
19        &self,
20        request: BotJoinChatRequest,
21        auth: AuthType,
22    ) -> ApiResult<BotJoinChatResponse> {
23        let url = format!(
24            "{}/work_item/{}/bot_join_chat",
25            request.project_key, request.work_item_id
26        );
27        
28        let body = serde_json::json!({
29            "app_ids": request.app_ids,
30            "work_item_type_key": request.work_item_type_key,
31        });
32
33        Ok(self.post(&url, &body, auth).await?)
34    }
35}