1 | <?php |
||
31 | class Notice extends AbstractAPI |
||
32 | { |
||
33 | /** |
||
34 | * Default color. |
||
35 | * |
||
36 | * @var string |
||
37 | */ |
||
38 | protected $defaultColor = '#173177'; |
||
39 | |||
40 | /** |
||
41 | * Attributes. |
||
42 | * |
||
43 | * @var array |
||
44 | */ |
||
45 | protected $message = [ |
||
46 | 'touser' => '', |
||
47 | 'template_id' => '', |
||
48 | 'url' => '', |
||
49 | 'data' => [], |
||
50 | ]; |
||
51 | |||
52 | /** |
||
53 | * Required attributes. |
||
54 | * |
||
55 | * @var array |
||
56 | */ |
||
57 | protected $required = ['touser', 'template_id']; |
||
58 | |||
59 | /** |
||
60 | * Message backup. |
||
61 | * |
||
62 | * @var array |
||
63 | */ |
||
64 | protected $messageBackup; |
||
65 | |||
66 | const API_SEND_NOTICE = 'https://api.weixin.qq.com/cgi-bin/message/template/send'; |
||
67 | const API_SET_INDUSTRY = 'https://api.weixin.qq.com/cgi-bin/template/api_set_industry'; |
||
68 | const API_ADD_TEMPLATE = 'https://api.weixin.qq.com/cgi-bin/template/api_add_template'; |
||
69 | const API_GET_INDUSTRY = 'https://api.weixin.qq.com/cgi-bin/template/get_industry'; |
||
70 | const API_GET_ALL_PRIVATE_TEMPLATE = 'https://api.weixin.qq.com/cgi-bin/template/get_all_private_template'; |
||
71 | const API_DEL_PRIVATE_TEMPLATE = 'https://api.weixin.qq.com/cgi-bin/template/del_private_template'; |
||
72 | const API_SEND_SUBSCRIPTION = 'https://api.weixin.qq.com/cgi-bin/message/template/subscribe'; |
||
73 | |||
74 | /** |
||
75 | * Notice constructor. |
||
76 | * |
||
77 | * @param \EasyWeChat\Core\AccessToken $accessToken |
||
78 | */ |
||
79 | 8 | public function __construct(AccessToken $accessToken) |
|
85 | |||
86 | /** |
||
87 | * Set default color. |
||
88 | * |
||
89 | * @param string $color example: #0f0f0f |
||
90 | * |
||
91 | * @return $this |
||
92 | */ |
||
93 | public function defaultColor($color) |
||
99 | |||
100 | /** |
||
101 | * Set industry. |
||
102 | * |
||
103 | * @param int $industryOne |
||
104 | * @param int $industryTwo |
||
105 | * |
||
106 | * @return \EasyWeChat\Support\Collection |
||
107 | */ |
||
108 | 1 | public function setIndustry($industryOne, $industryTwo) |
|
117 | |||
118 | /** |
||
119 | * Get industry. |
||
120 | * |
||
121 | * @return \EasyWeChat\Support\Collection |
||
122 | */ |
||
123 | 1 | public function getIndustry() |
|
127 | |||
128 | /** |
||
129 | * Add a template and get template ID. |
||
130 | * |
||
131 | * @param string $shortId |
||
132 | * |
||
133 | * @return \EasyWeChat\Support\Collection |
||
134 | */ |
||
135 | 1 | public function addTemplate($shortId) |
|
141 | |||
142 | /** |
||
143 | * Get private templates. |
||
144 | * |
||
145 | * @return \EasyWeChat\Support\Collection |
||
146 | */ |
||
147 | 1 | public function getPrivateTemplates() |
|
151 | |||
152 | /** |
||
153 | * Delete private template. |
||
154 | * |
||
155 | * @param string $templateId |
||
156 | * |
||
157 | * @return \EasyWeChat\Support\Collection |
||
158 | */ |
||
159 | 1 | public function deletePrivateTemplate($templateId) |
|
165 | |||
166 | /** |
||
167 | * Send a notice message. |
||
168 | * |
||
169 | * @param $data |
||
170 | * |
||
171 | * @return \EasyWeChat\Support\Collection |
||
172 | * |
||
173 | * @throws \EasyWeChat\Core\Exceptions\InvalidArgumentException |
||
174 | */ |
||
175 | 2 | public function send($data = []) |
|
179 | |||
180 | /** |
||
181 | * Send template-message for subscription. |
||
182 | * |
||
183 | * @param array $data |
||
184 | * |
||
185 | * @return \EasyWeChat\Support\Collection |
||
186 | */ |
||
187 | 1 | public function sendSubscription(array $data = []) |
|
191 | |||
192 | /** |
||
193 | * @param array $data |
||
194 | * |
||
195 | * @return array |
||
196 | */ |
||
197 | 3 | protected function validParams(array $data = []) |
|
215 | |||
216 | /** |
||
217 | * Magic access.. |
||
218 | * |
||
219 | * @param string $method |
||
220 | * @param array $args |
||
221 | * |
||
222 | * @return Notice |
||
223 | */ |
||
224 | 3 | public function __call($method, $args) |
|
254 | |||
255 | /** |
||
256 | * Format template data. |
||
257 | * |
||
258 | * @param array $data |
||
259 | * |
||
260 | * @return array |
||
261 | */ |
||
262 | 3 | protected function formatData($data) |
|
293 | } |
||
294 |