import { LarkServer } from "../../types/larkServer"; import larkNetTool from "./larkNetTool"; /** * 发送卡片 * @param {LarkServer.ReceiveIDType} receive_id_type 消息接收者id类型 open_id/user_id/union_id/email/chat_id * @param {string} receive_id 消息接收者的ID,ID类型应与查询参数receive_id_type 对应 * @param {MsgType} msg_type 消息类型 包括:text、post、image、file、audio、media、sticker、interactive、share_chat、share_user * @param {string} content 消息内容,JSON结构序列化后的字符串。不同msg_type对应不同内容 */ const send = async ( receive_id_type: LarkServer.ReceiveIDType, receive_id: string, msg_type: LarkServer.MsgType, content: string ) => { const URL = `https://open.f.mioffice.cn/open-apis/im/v1/messages?receive_id_type=${receive_id_type}`; return larkNetTool.post(URL, { receive_id, msg_type, content, }); }; /** * 更新卡片 * @param {string} message_id 消息id * @param {string} content 消息内容,JSON结构序列化后的字符串。不同msg_type对应不同内容 */ const update = async (message_id: string, content: string) => { const URL = `https://open.f.mioffice.cn/open-apis/im/v1/messages/${message_id}`; return larkNetTool.patch(URL, { content }); }; const message = { send, update, }; export default message;