|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the overtrue/wechat. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) overtrue <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* This source file is subject to the MIT license that is bundled |
|
9
|
|
|
* with this source code in the file LICENSE. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace EasyWeChat\Work\ExternalContact; |
|
13
|
|
|
|
|
14
|
|
|
use EasyWeChat\Kernel\BaseClient; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Class Client. |
|
18
|
|
|
* |
|
19
|
|
|
* @author mingyoung <[email protected]> |
|
20
|
|
|
*/ |
|
21
|
|
|
class Client extends BaseClient |
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* 获取配置了客户联系功能的成员列表. |
|
25
|
|
|
* |
|
26
|
|
|
* @see https://work.weixin.qq.com/api/doc#90000/90135/91554 |
|
27
|
|
|
* |
|
28
|
|
|
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
|
29
|
|
|
* |
|
30
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
|
31
|
|
|
*/ |
|
32
|
1 |
|
public function getFollowUsers() |
|
33
|
|
|
{ |
|
34
|
1 |
|
return $this->httpGet('cgi-bin/externalcontact/get_follow_user_list'); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* 获取外部联系人列表. |
|
39
|
|
|
* |
|
40
|
|
|
* @see https://work.weixin.qq.com/api/doc#90000/90135/91555 |
|
41
|
|
|
* |
|
42
|
|
|
* @param string $userId |
|
43
|
|
|
* |
|
44
|
|
|
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
|
45
|
|
|
* |
|
46
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
|
47
|
|
|
*/ |
|
48
|
1 |
|
public function list(string $userId) |
|
49
|
|
|
{ |
|
50
|
1 |
|
return $this->httpGet('cgi-bin/externalcontact/list', [ |
|
51
|
1 |
|
'userid' => $userId, |
|
52
|
|
|
]); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* 批量获取客户详情. |
|
57
|
|
|
* |
|
58
|
|
|
* @see https://work.weixin.qq.com/api/doc/90000/90135/92994 |
|
59
|
|
|
* |
|
60
|
|
|
* @param string $userId |
|
61
|
|
|
* @param string $cursor |
|
62
|
|
|
* @param integer $limit |
|
63
|
|
|
* |
|
64
|
|
|
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
|
65
|
|
|
* |
|
66
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
|
67
|
|
|
*/ |
|
68
|
|
|
public function batchGet(string $userId, string $cursor = '', int $limit = 100) |
|
69
|
|
|
{ |
|
70
|
|
|
return $this->httpPostJson('cgi-bin/externalcontact/batch/get_by_user', [ |
|
71
|
|
|
'userid' => $userId, |
|
72
|
|
|
'cursor' => $cursor, |
|
73
|
|
|
'limit' => $limit, |
|
74
|
|
|
]); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* 获取外部联系人详情. |
|
79
|
|
|
* |
|
80
|
|
|
* @see https://work.weixin.qq.com/api/doc#90000/90135/91556 |
|
81
|
|
|
* |
|
82
|
|
|
* @param string $externalUserId |
|
83
|
|
|
* |
|
84
|
|
|
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
|
85
|
|
|
* |
|
86
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
|
87
|
|
|
*/ |
|
88
|
1 |
|
public function get(string $externalUserId) |
|
89
|
|
|
{ |
|
90
|
1 |
|
return $this->httpGet('cgi-bin/externalcontact/get', [ |
|
91
|
1 |
|
'external_userid' => $externalUserId, |
|
92
|
|
|
]); |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* 修改客户备注信息. |
|
98
|
|
|
* |
|
99
|
|
|
* @see https://work.weixin.qq.com/api/doc/90000/90135/92115 |
|
100
|
|
|
* |
|
101
|
|
|
* @param array $data |
|
102
|
|
|
* |
|
103
|
|
|
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
|
104
|
|
|
* |
|
105
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
|
106
|
|
|
*/ |
|
107
|
|
|
public function remark(array $data) |
|
108
|
|
|
{ |
|
109
|
|
|
return $this->httpPostJson( |
|
110
|
|
|
'cgi-bin/externalcontact/remark', |
|
111
|
|
|
$data |
|
112
|
|
|
); |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* 获取离职成员的客户列表. |
|
118
|
|
|
* |
|
119
|
|
|
* @see https://work.weixin.qq.com/api/doc#90000/90135/91563 |
|
120
|
|
|
* |
|
121
|
|
|
* @param int $pageId |
|
122
|
|
|
* @param int $pageSize |
|
123
|
|
|
* |
|
124
|
|
|
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
|
125
|
|
|
* |
|
126
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
|
127
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
|
128
|
|
|
*/ |
|
129
|
1 |
|
public function getUnassigned(int $pageId = 0, int $pageSize = 1000) |
|
130
|
|
|
{ |
|
131
|
1 |
|
return $this->httpPostJson('cgi-bin/externalcontact/get_unassigned_list', [ |
|
132
|
1 |
|
'page_id' => $pageId, |
|
133
|
1 |
|
'page_size' => $pageSize, |
|
134
|
|
|
]); |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
/** |
|
138
|
|
|
* 离职成员的外部联系人再分配. |
|
139
|
|
|
* |
|
140
|
|
|
* @see https://work.weixin.qq.com/api/doc#90000/90135/91564 |
|
141
|
|
|
* |
|
142
|
|
|
* @param string $externalUserId |
|
143
|
|
|
* @param string $handoverUserId |
|
144
|
|
|
* @param string $takeoverUserId |
|
145
|
|
|
* |
|
146
|
|
|
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
|
147
|
|
|
* |
|
148
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
|
149
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
|
150
|
|
|
*/ |
|
151
|
1 |
|
public function transfer(string $externalUserId, string $handoverUserId, string $takeoverUserId) |
|
152
|
|
|
{ |
|
153
|
|
|
$params = [ |
|
154
|
1 |
|
'external_userid' => $externalUserId, |
|
155
|
1 |
|
'handover_userid' => $handoverUserId, |
|
156
|
1 |
|
'takeover_userid' => $takeoverUserId, |
|
157
|
|
|
]; |
|
158
|
|
|
|
|
159
|
1 |
|
return $this->httpPostJson('cgi-bin/externalcontact/transfer', $params); |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
|
|
163
|
|
|
/** |
|
164
|
|
|
* 获取客户群列表. |
|
165
|
|
|
* |
|
166
|
|
|
* @see https://work.weixin.qq.com/api/doc/90000/90135/92120 |
|
167
|
|
|
* |
|
168
|
|
|
* @param array $params |
|
169
|
|
|
* |
|
170
|
|
|
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
|
171
|
|
|
* |
|
172
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
|
173
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
|
174
|
|
|
*/ |
|
175
|
|
|
|
|
176
|
|
|
public function getGroupChats(array $params) |
|
177
|
|
|
{ |
|
178
|
|
|
return $this->httpPostJson('cgi-bin/externalcontact/groupchat/list', $params); |
|
179
|
|
|
} |
|
180
|
|
|
|
|
181
|
|
|
/** |
|
182
|
|
|
* 获取客户群详情. |
|
183
|
|
|
* |
|
184
|
|
|
* @see https://work.weixin.qq.com/api/doc/90000/90135/92122 |
|
185
|
|
|
* |
|
186
|
|
|
* @param string $chatId |
|
187
|
|
|
* |
|
188
|
|
|
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
|
189
|
|
|
* |
|
190
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
|
191
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
|
192
|
|
|
*/ |
|
193
|
|
|
|
|
194
|
|
|
public function getGroupChat(string $chatId) |
|
195
|
|
|
{ |
|
196
|
|
|
$params = [ |
|
197
|
|
|
'chat_id' => $chatId |
|
198
|
|
|
]; |
|
199
|
|
|
|
|
200
|
|
|
return $this->httpPostJson('cgi-bin/externalcontact/groupchat/get', $params); |
|
201
|
|
|
} |
|
202
|
|
|
|
|
203
|
|
|
/** |
|
204
|
|
|
* 获取企业标签库. |
|
205
|
|
|
* |
|
206
|
|
|
* @see https://work.weixin.qq.com/api/doc/90000/90135/92117#获取企业标签库 |
|
207
|
|
|
* |
|
208
|
|
|
* @param array $tagIds |
|
209
|
|
|
* |
|
210
|
|
|
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
|
211
|
|
|
* |
|
212
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
|
213
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
|
214
|
|
|
*/ |
|
215
|
|
|
|
|
216
|
|
|
public function getCorpTags(array $tagIds = []) |
|
217
|
|
|
{ |
|
218
|
|
|
$params = [ |
|
219
|
|
|
'tag_id' => $tagIds |
|
220
|
|
|
]; |
|
221
|
|
|
|
|
222
|
|
|
return $this->httpPostJson('cgi-bin/externalcontact/get_corp_tag_list', $params); |
|
223
|
|
|
} |
|
224
|
|
|
|
|
225
|
|
|
|
|
226
|
|
|
|
|
227
|
|
|
/** |
|
228
|
|
|
* 添加企业客户标签. |
|
229
|
|
|
* |
|
230
|
|
|
* @see https://work.weixin.qq.com/api/doc/90000/90135/92117#添加企业客户标签 |
|
231
|
|
|
* |
|
232
|
|
|
* @param array $params |
|
233
|
|
|
* |
|
234
|
|
|
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
|
235
|
|
|
* |
|
236
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
|
237
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
|
238
|
|
|
*/ |
|
239
|
|
|
|
|
240
|
|
|
public function addCorpTag(array $params) |
|
241
|
|
|
{ |
|
242
|
|
|
return $this->httpPostJson('cgi-bin/externalcontact/add_corp_tag', $params); |
|
243
|
|
|
} |
|
244
|
|
|
|
|
245
|
|
|
|
|
246
|
|
|
/** |
|
247
|
|
|
* 编辑企业客户标签. |
|
248
|
|
|
* |
|
249
|
|
|
* @see https://work.weixin.qq.com/api/doc/90000/90135/92117#编辑企业客户标签 |
|
250
|
|
|
* |
|
251
|
|
|
* @param string $id |
|
252
|
|
|
* @param string $name |
|
253
|
|
|
* @param int $order |
|
254
|
|
|
* |
|
255
|
|
|
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
|
256
|
|
|
* |
|
257
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
|
258
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
|
259
|
|
|
*/ |
|
260
|
|
|
|
|
261
|
|
|
public function updateCorpTag(string $id, string $name, int $order = 1) |
|
262
|
|
|
{ |
|
263
|
|
|
$params = [ |
|
264
|
|
|
"id" => $id, |
|
265
|
|
|
"name" => $name, |
|
266
|
|
|
"order" => $order, |
|
267
|
|
|
]; |
|
268
|
|
|
|
|
269
|
|
|
return $this->httpPostJson('cgi-bin/externalcontact/edit_corp_tag', $params); |
|
270
|
|
|
} |
|
271
|
|
|
|
|
272
|
|
|
|
|
273
|
|
|
/** |
|
274
|
|
|
* 删除企业客户标签. |
|
275
|
|
|
* |
|
276
|
|
|
* @see https://work.weixin.qq.com/api/doc/90000/90135/92117#删除企业客户标签 |
|
277
|
|
|
* |
|
278
|
|
|
* @param array $tagId |
|
279
|
|
|
* @param array $groupId |
|
280
|
|
|
* |
|
281
|
|
|
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
|
282
|
|
|
* |
|
283
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
|
284
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
|
285
|
|
|
*/ |
|
286
|
|
|
|
|
287
|
|
|
public function deleteCorpTag(array $tagId, array $groupId) |
|
288
|
|
|
{ |
|
289
|
|
|
$params = [ |
|
290
|
|
|
"tag_id" => $tagId, |
|
291
|
|
|
"group_id" => $groupId, |
|
292
|
|
|
]; |
|
293
|
|
|
|
|
294
|
|
|
return $this->httpPostJson('cgi-bin/externalcontact/del_corp_tag', $params); |
|
295
|
|
|
} |
|
296
|
|
|
|
|
297
|
|
|
|
|
298
|
|
|
/** |
|
299
|
|
|
* 编辑客户企业标签. |
|
300
|
|
|
* |
|
301
|
|
|
* @see https://work.weixin.qq.com/api/doc/90000/90135/92118 |
|
302
|
|
|
* |
|
303
|
|
|
* @param array $params |
|
304
|
|
|
* |
|
305
|
|
|
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
|
306
|
|
|
* |
|
307
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
|
308
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
|
309
|
|
|
*/ |
|
310
|
|
|
|
|
311
|
|
|
public function markTags(array $params) |
|
312
|
|
|
{ |
|
313
|
|
|
return $this->httpPostJson('cgi-bin/externalcontact/mark_tag', $params); |
|
314
|
|
|
} |
|
315
|
|
|
} |
|
316
|
|
|
|