import { APIResource } from '../../resource'; export type MaybePromise = T | Promise; /** * 互动卡片 */ export declare class Instances extends APIResource { /** * 创建卡片 * * @param params - * @returns */ create(params: CardInstancesCreateParams): Promise; /** * 投放卡片 * * @param params - */ deliver(params: CardInstancesDeliverParams): Promise; /** * 发送卡片 * * @param params - * @returns */ send(params: CardInstancesSendParams): Promise<{ processQueryKey: string; }>; protected afterResponse(resultInit: MaybePromise | CardInstanceError>): Promise; } /** * 创建互动卡片实例 * * @see https://open.dingtalk.com/document/orgapp/interface-for-creating-a-card-instance */ export interface CardInstancesCreateParams { /** * 卡片创建者的用户 ID */ userId?: string; /** * 用户 ID 类型 * * 1 userId * 2 unionId */ userIdType?: number; /** * 卡片内容模板ID * * @see https://open-dev.dingtalk.com/fe/card */ cardTemplateId: string; /** * 外部卡片实例Id */ outTrackId: string; /** * 卡片回调的类型 * * - STREAM * - HTTP * * 注意参数均为大写 */ callbackType?: 'STREAM' | 'HTTP'; /** * 卡片回调HTTP模式时的路由 Key,用于查询注册的 callbackUrl */ callbackRouteKey?: string; /** * 卡片数据 */ cardData: CardData; /** * 私有数据 * * key 是用户 ID */ privateData?: Record; /** * 动态数据源配置 */ openDynamicDataConfig?: { /** * 动态数据源配置列表 */ dynamicDataSourceConfigs?: OpenDynamicDataConfig.SourceConfig[]; }; /** * IM 群聊场域信息 */ imGroupOpenSpaceModel?: OpenSpaceModel; /** * IM 单聊场域信息 */ imRobotOpenSpaceModel?: OpenSpaceModel; /** * 协作场域信息 */ coFeedOpenSpaceModel?: { /** * 卡片标题 */ title?: string; /** * 吊顶场域属性,通过增加spaeType使卡片支持吊顶场域 */ topOpenSpaceModel?: { spaceType: string; }; }; } /** * 卡片模板内容替换参数 */ export type CardParamMap = Record; export type CardData = { cardParamMap?: CardParamMap & { sys_full_json_obj?: string; }; }; export declare namespace OpenDynamicDataConfig { enum PullStrategy { /** * 不拉取,无动态数据 */ None = "NONE", /** * 间隔拉取 */ Interval = "INTERVAL", /** * 拉取一次 */ Once = "ONCE" } enum TimeUnit { Seconds = "SECONDS", Minutes = "MINUTES", Hours = "HOURS", Days = "DAYS" } type SourceConfig = { /** * 数据源的唯一 ID, 调用方指定 */ dynamicDataSourceId?: string; /** * 回调数据源时回传的固定参数 */ constParams?: Record; /** * 数据源拉取配置 */ pullConfig?: { /** * 拉取策略 */ pullStrategy?: PullStrategy; /** * 拉取的间隔时间 * * - 只在将pullStrategy设置为INTERVAL的时候生效。 * - 最小拉取间隔时间3s。 */ interval?: number; /** * 拉取的间隔时间的单位 */ timeUnit?: TimeUnit; }; }; } export type OpenSpaceModel = { /** * 是否支持转发 */ supportForward: boolean; /** * 支持国际化的LastMessage,目前支持的语言枚举值: * * ZH_CN:简体中文 * ZH_TW:繁体中文: * EN_US:英文 * JA_JP:日语 * VI_VN:越南语 */ lastMessageI18n?: Map; /** * 支持卡片消息可被搜索字段 */ searchSupport?: { /** * 类型的icon,供搜索展示使用。 */ searchIcon?: string; /** * 卡片类型名 */ searchTypeName?: string; /** * 供消息展示与搜索的字段 */ searchDesc?: string; }; /** * 通知信息 */ notification?: { /** * 通知内容 * * @defaultValue 如你收到 1 条新消息 */ alertContent?: string; /** * 是否关闭推送通知 */ notificationOff?: boolean; }; }; export declare namespace I18n { enum Language { /** * 简体中文 */ ZH_CN = "ZH_CN", /** * 繁体中文 */ ZH_TW = "ZH_TW", /** * 英文 */ EN_US = "EN_US", /** * 日语 */ JA_JP = "JA_JP", /** * 越南语 */ VI_VN = "VI_VN" } } export type CardInstanceResponse = { success: boolean; result: T; }; export type CardInstanceError = { code: string; requestId: string; message: string; }; export type CardInstancesDeliverParams = { /** * 外部卡片实例 ID */ outTrackId: string; /** * 卡片投放的场域 */ openSpaceId: string; /** * IM机器人单聊投放参数 */ imRobotOpenDeliverModel?: { robotCode?: string; spaceType?: string; extension?: Record; }; /** * 群聊投放参数 */ imGroupOpenDeliverModel?: { robotCode?: string; atUserIds: Record; recipients?: string[]; extension?: Record; }; /** * 吊顶投放参数 */ topOpenDeliverModel?: { expiredTimeMillis?: string; userIds?: string[]; platforms: string[]; }; /** * 协作投放参数 */ coFeedOpenDeliverModel?: { /** * 业务标识 */ bizTag?: string; /** * 协作场域下的排序时间 */ gmtTimeLine: string; }; /** * 文档投放参数 */ docOpenDeliverModel?: { userId?: string; }; userIdType?: number; }; /** * 发送互动卡片 * * @see https://open.dingtalk.com/document/orgapp-server/send-dingtalk-interactive-cards */ export type CardInstancesSendParams = { /** * 互动卡片的消息模板ID */ cardTemplateId: string; /** * 唯一标示卡片的外部编码 */ outTrackId: string; /** * 机器人唯一编码 */ robotCode?: string; /** * 机器人ID */ chatBotId?: string; /** * 群ID */ openConversationId: string; /** * 会话类型 * * - 0 单聊 * - 1 群聊 * * @remarks 和消息的会话类型不同 */ conversationType: number; /** * 接收用户列表 */ receiverUserIdList: string[]; /** * 消息提及的人 */ atOpenIds?: Record; /** * 用户ID类型 */ userIdType?: number; /** * 卡片回调时的路由Key,用于查询注册的callbackUrl */ callbackRouteKey?: string; /** * 卡片数据 */ cardData: CardData; /** * 卡片选项 */ cardOptions?: { supportForward: boolean; }; /** * 私有数据 */ privateData?: Record; /** * 拉取策略 * * - true:开启卡片纯拉模式 * - false:不开启卡片纯拉模式 */ pullStrategy?: boolean; };