SendCorpConversationRequest.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  1. // Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
  2. //
  3. // 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。
  4. //
  5. // 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
  6. using Newtonsoft.Json.Converters;
  7. using System.Text.Json.Serialization;
  8. namespace Admin.Net.Plugin.DingTalk.RequestProxy.Message.DTO;
  9. public class SendCorpConversationRequest
  10. {
  11. /// <summary>
  12. /// 发送消息时使用的微应用的AgentID
  13. /// </summary>
  14. [JsonProperty("agent_id")]
  15. [JsonPropertyName("agent_id")]
  16. public long? AgentId { get; set; }
  17. /// <summary>
  18. /// 接收者的userid列表,最大用户列表长度100
  19. /// </summary>
  20. [JsonProperty("userid_list")]
  21. [JsonPropertyName("userid_list")]
  22. public string? UserIdList { get; set; }
  23. /// <summary>
  24. /// 接收者的部门id列表,最大列表长度20
  25. /// </summary>
  26. [JsonProperty("dept_id_list")]
  27. [JsonPropertyName("dept_id_list")]
  28. public string? DeptIdList { get; set; }
  29. /// <summary>
  30. /// 是否发送给企业全部用户
  31. /// </summary>
  32. [JsonProperty("to_all_user")]
  33. [JsonPropertyName("to_all_user")]
  34. public bool? ToAllUser { get; set; }
  35. /// <summary>
  36. /// 消息内容,最长不超过2048个字节
  37. /// </summary>
  38. [JsonProperty("msg")]
  39. [JsonPropertyName("msg")]
  40. public MsgDomain Msg { get; set; }
  41. }
  42. public class MsgDomain
  43. {
  44. /// <summary>
  45. /// 消息类型
  46. /// </summary>
  47. [JsonProperty("msgtype")]
  48. [JsonPropertyName("msgtype")]
  49. [Newtonsoft.Json.JsonConverter(typeof(StringEnumConverter))]
  50. public MsgTypeEnum MsgType { get; set; }
  51. /// <summary>
  52. /// 文本消息
  53. /// </summary>
  54. [JsonProperty("text")]
  55. [JsonPropertyName("text")]
  56. public MsgTextDomain? Text { get; set; }
  57. /// <summary>
  58. /// 图片消息
  59. /// </summary>
  60. [JsonProperty("image")]
  61. [JsonPropertyName("image")]
  62. public MsgImageDomain? Image { get; set; }
  63. /// <summary>
  64. /// 语音消息
  65. /// </summary>
  66. [JsonProperty("voice")]
  67. [JsonPropertyName("voice")]
  68. public MsgVoiceDomain? Voice { get; set; }
  69. /// <summary>
  70. /// 文件消息
  71. /// </summary>
  72. [JsonProperty("file")]
  73. [JsonPropertyName("file")]
  74. public MsgVoiceDomain? File { get; set; }
  75. /// <summary>
  76. /// 链接消息
  77. /// </summary>
  78. [JsonProperty("link")]
  79. [JsonPropertyName("link")]
  80. public MsgLinkDomain? Link { get; set; }
  81. /// <summary>
  82. /// OA消息
  83. /// </summary>
  84. [JsonProperty("oa")]
  85. [JsonPropertyName("oa")]
  86. public MsgOaDomain? Oa { get; set; }
  87. /// <summary>
  88. /// markdown消息
  89. /// </summary>
  90. [JsonProperty("markdown")]
  91. [JsonPropertyName("markdown")]
  92. public MsgMarkdownDomain? Markdown { get; set; }
  93. /// <summary>
  94. /// 卡片消息
  95. /// </summary>
  96. [JsonProperty("action_card")]
  97. [JsonPropertyName("action_card")]
  98. public MsgActionCardDomain? ActionCard { get; set; }
  99. }
  100. public enum MsgTypeEnum
  101. {
  102. text, image, voice, file, link, oa, markdown, action_card
  103. }
  104. /// <summary>
  105. /// 文本消息
  106. /// </summary>
  107. public class MsgTextDomain
  108. {
  109. /// <summary>
  110. /// 消息内容,建议500字符以内
  111. /// </summary>
  112. [JsonProperty("content")]
  113. [JsonPropertyName("content")]
  114. public string Content { get; set; }
  115. }
  116. /// <summary>
  117. /// 图片消息
  118. /// </summary>
  119. public class MsgImageDomain
  120. {
  121. /// <summary>
  122. /// 媒体文件mediaid,建议宽600像素 x 400像素,宽高比3 : 2
  123. /// </summary>
  124. [JsonProperty("media_id")]
  125. [JsonPropertyName("media_id")]
  126. public string MediaId { get; set; }
  127. }
  128. /// <summary>
  129. /// 语音消息
  130. /// </summary>
  131. public class MsgVoiceDomain
  132. {
  133. /// <summary>
  134. /// 媒体文件ID
  135. /// </summary>
  136. [JsonProperty("media_id")]
  137. [JsonPropertyName("media_id")]
  138. public string MediaId { get; set; }
  139. /// <summary>
  140. /// 正整数,小于60,表示音频时长
  141. /// </summary>
  142. [JsonProperty("duration")]
  143. [JsonPropertyName("duration")]
  144. public string Duration { get; set; }
  145. }
  146. /// <summary>
  147. /// 文件消息
  148. /// </summary>
  149. public class MsgFileDomain
  150. {
  151. /// <summary>
  152. /// 媒体文件ID,引用的媒体文件最大10MB
  153. /// </summary>
  154. [JsonProperty("media_id")]
  155. [JsonPropertyName("media_id")]
  156. public string MediaId { get; set; }
  157. }
  158. /// <summary>
  159. /// 链接消息
  160. /// </summary>
  161. public class MsgLinkDomain
  162. {
  163. /// <summary>
  164. /// 消息点击链接地址,当发送消息为小程序时支持小程序跳转链接
  165. /// </summary>
  166. [JsonProperty("messageUrl")]
  167. [JsonPropertyName("messageUrl")]
  168. public string MessageUrl { get; set; }
  169. [JsonProperty("picUrl")]
  170. [JsonPropertyName("picUrl")]
  171. public string PicUrl { get; set; }
  172. /// <summary>
  173. /// 消息标题,建议100字符以内
  174. /// </summary>
  175. [JsonProperty("title")]
  176. [JsonPropertyName("title")]
  177. public string Title { get; set; }
  178. /// <summary>
  179. /// 消息描述,建议500字符以内
  180. /// </summary>
  181. [JsonProperty("text")]
  182. [JsonPropertyName("text")]
  183. public string Text { get; set; }
  184. }
  185. /// <summary>
  186. /// OA消息
  187. /// </summary>
  188. public class MsgOaDomain
  189. {
  190. /// <summary>
  191. /// 消息点击链接地址,当发送消息为小程序时支持小程序跳转链接
  192. /// </summary>
  193. [JsonProperty("message_url")]
  194. [JsonPropertyName("message_url")]
  195. public string MessageUrl { get; set; }
  196. /// <summary>
  197. /// PC端点击消息时跳转到的地址
  198. /// </summary>
  199. [JsonProperty("pc_message_url")]
  200. [JsonPropertyName("pc_message_url")]
  201. public string? PcMessageUrl { get; set; }
  202. /// <summary>
  203. /// 消息头部内容
  204. /// </summary>
  205. [JsonProperty("head")]
  206. [JsonPropertyName("head")]
  207. public MsgOaHeadDomain Head { get; set; }
  208. /// <summary>
  209. /// 消息体
  210. /// </summary>
  211. [JsonProperty("body")]
  212. [JsonPropertyName("body")]
  213. public MsgOaBodyDomain Body { get; set; }
  214. /// <summary>
  215. /// 消息状态栏,只支持接收者的userid列表,userid最多不能超过5个人
  216. /// </summary>
  217. [JsonProperty("status_bar")]
  218. [JsonPropertyName("status_bar")]
  219. public MsgOaStatusBarDomain? StatusBar { get; set; }
  220. public class MsgOaHeadDomain
  221. {
  222. /// <summary>
  223. /// 消息头部的背景颜色。长度限制为8个英文字符,其中前2为表示透明度,后6位表示颜色值。不要添加0x。
  224. /// </summary>
  225. [JsonProperty("bgcolor")]
  226. [JsonPropertyName("bgcolor")]
  227. public string BgColor { get; set; }
  228. /// <summary>
  229. /// 消息的头部标题
  230. /// </summary>
  231. [JsonProperty("text")]
  232. [JsonPropertyName("text")]
  233. public string Text { get; set; }
  234. }
  235. public class MsgOaStatusBarDomain
  236. {
  237. /// <summary>
  238. /// 状态栏文案
  239. /// </summary>
  240. [JsonProperty("status_value")]
  241. [JsonPropertyName("status_value")]
  242. public string StatusValue { get; set; }
  243. /// <summary>
  244. /// 状态栏背景色,默认为黑色,推荐0xFF加六位颜色值
  245. /// </summary>
  246. [JsonProperty("status_bg")]
  247. [JsonPropertyName("status_bg")]
  248. public string StatusBg { get; set; }
  249. }
  250. public class MsgOaBodyDomain
  251. {
  252. /// <summary>
  253. /// 消息体的标题,建议50个字符以内
  254. /// </summary>
  255. [JsonProperty("title")]
  256. [JsonPropertyName("title")]
  257. public string? Title { get; set; }
  258. /// <summary>
  259. /// 消息体的表单,最多显示6个,超过会被隐藏
  260. /// </summary>
  261. [JsonProperty("form")]
  262. [JsonPropertyName("form")]
  263. public MsgOaBodyFormDomain[]? Form { get; set; }
  264. /// <summary>
  265. /// 单行富文本信息
  266. /// </summary>
  267. [JsonProperty("rich")]
  268. [JsonPropertyName("rich")]
  269. public MsgOaBodyRichDomain? Rich { get; set; }
  270. /// <summary>
  271. /// 消息体的内容,最多显示3行
  272. /// </summary>
  273. [JsonProperty("content")]
  274. [JsonPropertyName("content")]
  275. public string? Content { get; set; }
  276. /// <summary>
  277. /// 消息体中的图片,支持图片资源@mediaId。建议宽600像素 x 400像素,宽高比3 : 2
  278. /// </summary>
  279. [JsonProperty("image")]
  280. [JsonPropertyName("image")]
  281. public string? Image { get; set; }
  282. /// <summary>
  283. /// 自定义的附件数目。此数字仅供显示,钉钉不作验证
  284. /// </summary>
  285. [JsonProperty("file_count")]
  286. [JsonPropertyName("file_count")]
  287. public string? FileCount { get; set; }
  288. /// <summary>
  289. /// 自定义的作者名字
  290. /// </summary>
  291. [JsonProperty("author")]
  292. [JsonPropertyName("author")]
  293. public string? Author { get; set; }
  294. }
  295. public class MsgOaBodyRichDomain
  296. {
  297. /// <summary>
  298. /// 单行富文本信息的数目
  299. /// </summary>
  300. [JsonProperty("num")]
  301. [JsonPropertyName("num")]
  302. public string? Num { get; set; }
  303. /// <summary>
  304. /// 单行富文本信息的单位
  305. /// </summary>
  306. [JsonProperty("unit")]
  307. [JsonPropertyName("unit")]
  308. public string? Unit { get; set; }
  309. }
  310. public class MsgOaBodyFormDomain
  311. {
  312. /// <summary>
  313. /// 消息体的关键字
  314. /// </summary>
  315. [JsonProperty("key")]
  316. [JsonPropertyName("key")]
  317. public string? Key { get; set; }
  318. /// <summary>
  319. /// 消息体的关键字对应的值
  320. /// </summary>
  321. [JsonProperty("value")]
  322. [JsonPropertyName("value")]
  323. public string? Value { get; set; }
  324. }
  325. }
  326. /// <summary>
  327. /// markdown消息
  328. /// </summary>
  329. public class MsgMarkdownDomain
  330. {
  331. /// <summary>
  332. /// 首屏会话透出的展示内容
  333. /// </summary>
  334. [JsonProperty("title")]
  335. [JsonPropertyName("title")]
  336. public string Title { get; set; }
  337. /// <summary>
  338. /// markdown格式的消息,最大不超过5000字符
  339. /// </summary>
  340. [JsonProperty("text")]
  341. [JsonPropertyName("text")]
  342. public string Text { get; set; }
  343. }
  344. /// <summary>
  345. /// 卡片消息
  346. /// </summary>
  347. public class MsgActionCardDomain
  348. {
  349. /// <summary>
  350. /// 透出到会话列表和通知的文案
  351. /// </summary>
  352. [JsonProperty("title")]
  353. [JsonPropertyName("title")]
  354. public string? Title { get; set; }
  355. /// <summary>
  356. /// 消息内容,支持markdown,语法参考标准markdown语法。建议1000个字符以内
  357. /// </summary>
  358. [JsonProperty("markdown")]
  359. [JsonPropertyName("markdown")]
  360. public string Markdown { get; set; }
  361. /// <summary>
  362. /// 使用整体跳转ActionCard样式时的标题。必须与single_url同时设置,最长20个字符
  363. /// </summary>
  364. [JsonProperty("single_title")]
  365. [JsonPropertyName("single_title")]
  366. public string? SingleTitle { get; set; }
  367. /// <summary>
  368. /// 消息点击链接地址,当发送消息为小程序时支持小程序跳转链接,最长500个字符
  369. /// </summary>
  370. [JsonProperty("single_url")]
  371. [JsonPropertyName("single_url")]
  372. public string? SingleUrl { get; set; }
  373. /// <summary>
  374. /// 使用独立跳转ActionCard样式时的按钮排列方式:0:竖直排列,1:横向排列。必须与btn_json_list同时设置
  375. /// </summary>
  376. [JsonProperty("btn_orientation")]
  377. [JsonPropertyName("btn_orientation")]
  378. public BenOrientationEnum? BtnOrientation { get; set; }
  379. public enum BenOrientationEnum
  380. {
  381. 竖直排列,
  382. 横向排列
  383. }
  384. /// <summary>
  385. /// 使用独立跳转ActionCard样式时的按钮列表;必须与btn_orientation同时设置,且长度不超过1000字符
  386. /// </summary>
  387. [JsonProperty("btn_json_list")]
  388. [JsonPropertyName("btn_json_list")]
  389. public MsgActionCardBtnJsonListDomain[]? BtnJsonList { get; set; }
  390. public class MsgActionCardBtnJsonListDomain
  391. {
  392. /// <summary>
  393. /// 使用独立跳转ActionCard样式时的按钮的标题,最长20个字符
  394. /// </summary>
  395. [JsonProperty("title")]
  396. [JsonPropertyName("title")]
  397. public string Title { get; set; }
  398. /// <summary>
  399. /// 使用独立跳转ActionCard样式时的跳转链接,最长700个字符
  400. /// </summary>
  401. [JsonProperty("action_url")]
  402. [JsonPropertyName("action_url")]
  403. public string ActionUrl { get; set; }
  404. }
  405. }