OapiSmartbotMsgPushRequest.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. /**
  3. * dingtalk API: dingtalk.oapi.smartbot.msg.push request
  4. *
  5. * @author auto create
  6. * @since 1.0, 2021.03.19
  7. */
  8. class OapiSmartbotMsgPushRequest
  9. {
  10. /**
  11. * 接收者的会话chatid列表
  12. **/
  13. private $chatIdList;
  14. /**
  15. * 消息体,具体见文档
  16. **/
  17. private $msg;
  18. /**
  19. * 是否发送给企业全部用户,”true“则忽略用户列表和会话列表
  20. **/
  21. private $toAllUser;
  22. /**
  23. * 接收者的用户userid列表
  24. **/
  25. private $userIdList;
  26. private $apiParas = array();
  27. public function setChatIdList($chatIdList)
  28. {
  29. $this->chatIdList = $chatIdList;
  30. $this->apiParas["chat_id_list"] = $chatIdList;
  31. }
  32. public function getChatIdList()
  33. {
  34. return $this->chatIdList;
  35. }
  36. public function setMsg($msg)
  37. {
  38. $this->msg = $msg;
  39. $this->apiParas["msg"] = $msg;
  40. }
  41. public function getMsg()
  42. {
  43. return $this->msg;
  44. }
  45. public function setToAllUser($toAllUser)
  46. {
  47. $this->toAllUser = $toAllUser;
  48. $this->apiParas["to_all_user"] = $toAllUser;
  49. }
  50. public function getToAllUser()
  51. {
  52. return $this->toAllUser;
  53. }
  54. public function setUserIdList($userIdList)
  55. {
  56. $this->userIdList = $userIdList;
  57. $this->apiParas["user_id_list"] = $userIdList;
  58. }
  59. public function getUserIdList()
  60. {
  61. return $this->userIdList;
  62. }
  63. public function getApiMethodName()
  64. {
  65. return "dingtalk.oapi.smartbot.msg.push";
  66. }
  67. public function getApiParas()
  68. {
  69. return $this->apiParas;
  70. }
  71. public function check()
  72. {
  73. RequestCheckUtil::checkMaxListSize($this->chatIdList,500,"chatIdList");
  74. RequestCheckUtil::checkMaxListSize($this->userIdList,5000,"userIdList");
  75. }
  76. public function putOtherTextParam($key, $value) {
  77. $this->apiParas[$key] = $value;
  78. $this->$key = $value;
  79. }
  80. }