OapiMessageMassSendRequest.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <?php
  2. /**
  3. * dingtalk API: dingtalk.oapi.message.mass.send request
  4. *
  5. * @author auto create
  6. * @since 1.0, 2022.04.14
  7. */
  8. class OapiMessageMassSendRequest
  9. {
  10. /**
  11. * 接收者的部门id列表,接收者是部门id下(包括子部门下)的所有用户
  12. **/
  13. private $depIdList;
  14. /**
  15. * 是否预览推送
  16. **/
  17. private $isPreview;
  18. /**
  19. * 是否群发给所有订阅者,true-是,false-否
  20. **/
  21. private $isToAll;
  22. /**
  23. * 消息卡片素材id
  24. **/
  25. private $mediaId;
  26. /**
  27. * 消息体
  28. **/
  29. private $msgBody;
  30. /**
  31. * msg_type, 消息类型:text,文本类型,此时文本内容填在text_content字段中;news_card,消息卡片,此时的media_id通过消息卡片上传接口得到; image,图片,此时的media_id通过图片上传接口得到
  32. **/
  33. private $msgType;
  34. /**
  35. * 文本内容,当msg_type为text时有效
  36. **/
  37. private $textContent;
  38. /**
  39. * 服务号的unionid
  40. **/
  41. private $unionid;
  42. /**
  43. * 接收者的用户userid列表
  44. **/
  45. private $useridList;
  46. /**
  47. * 调用时填写随机生成的UUID, 防止消息重复发送
  48. **/
  49. private $uuid;
  50. private $apiParas = array();
  51. public function setDepIdList($depIdList)
  52. {
  53. $this->depIdList = $depIdList;
  54. $this->apiParas["dep_id_list"] = $depIdList;
  55. }
  56. public function getDepIdList()
  57. {
  58. return $this->depIdList;
  59. }
  60. public function setIsPreview($isPreview)
  61. {
  62. $this->isPreview = $isPreview;
  63. $this->apiParas["is_preview"] = $isPreview;
  64. }
  65. public function getIsPreview()
  66. {
  67. return $this->isPreview;
  68. }
  69. public function setIsToAll($isToAll)
  70. {
  71. $this->isToAll = $isToAll;
  72. $this->apiParas["is_to_all"] = $isToAll;
  73. }
  74. public function getIsToAll()
  75. {
  76. return $this->isToAll;
  77. }
  78. public function setMediaId($mediaId)
  79. {
  80. $this->mediaId = $mediaId;
  81. $this->apiParas["media_id"] = $mediaId;
  82. }
  83. public function getMediaId()
  84. {
  85. return $this->mediaId;
  86. }
  87. public function setMsgBody($msgBody)
  88. {
  89. $this->msgBody = $msgBody;
  90. $this->apiParas["msg_body"] = $msgBody;
  91. }
  92. public function getMsgBody()
  93. {
  94. return $this->msgBody;
  95. }
  96. public function setMsgType($msgType)
  97. {
  98. $this->msgType = $msgType;
  99. $this->apiParas["msg_type"] = $msgType;
  100. }
  101. public function getMsgType()
  102. {
  103. return $this->msgType;
  104. }
  105. public function setTextContent($textContent)
  106. {
  107. $this->textContent = $textContent;
  108. $this->apiParas["text_content"] = $textContent;
  109. }
  110. public function getTextContent()
  111. {
  112. return $this->textContent;
  113. }
  114. public function setUnionid($unionid)
  115. {
  116. $this->unionid = $unionid;
  117. $this->apiParas["unionid"] = $unionid;
  118. }
  119. public function getUnionid()
  120. {
  121. return $this->unionid;
  122. }
  123. public function setUseridList($useridList)
  124. {
  125. $this->useridList = $useridList;
  126. $this->apiParas["userid_list"] = $useridList;
  127. }
  128. public function getUseridList()
  129. {
  130. return $this->useridList;
  131. }
  132. public function setUuid($uuid)
  133. {
  134. $this->uuid = $uuid;
  135. $this->apiParas["uuid"] = $uuid;
  136. }
  137. public function getUuid()
  138. {
  139. return $this->uuid;
  140. }
  141. public function getApiMethodName()
  142. {
  143. return "dingtalk.oapi.message.mass.send";
  144. }
  145. public function getApiParas()
  146. {
  147. return $this->apiParas;
  148. }
  149. public function check()
  150. {
  151. RequestCheckUtil::checkMaxListSize($this->depIdList,2000,"depIdList");
  152. RequestCheckUtil::checkNotNull($this->isToAll,"isToAll");
  153. RequestCheckUtil::checkMaxLength($this->mediaId,256,"mediaId");
  154. RequestCheckUtil::checkNotNull($this->msgType,"msgType");
  155. RequestCheckUtil::checkMaxLength($this->msgType,32,"msgType");
  156. RequestCheckUtil::checkMaxLength($this->textContent,65535,"textContent");
  157. RequestCheckUtil::checkNotNull($this->unionid,"unionid");
  158. RequestCheckUtil::checkMaxLength($this->unionid,128,"unionid");
  159. RequestCheckUtil::checkMaxListSize($this->useridList,10000,"useridList");
  160. RequestCheckUtil::checkNotNull($this->uuid,"uuid");
  161. RequestCheckUtil::checkMaxLength($this->uuid,128,"uuid");
  162. }
  163. public function putOtherTextParam($key, $value) {
  164. $this->apiParas[$key] = $value;
  165. $this->$key = $value;
  166. }
  167. }