Passed
Push — master ( 78b346...e9f486 )
by Carlos
02:47
created

Client::getGroupChat()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 7
ccs 0
cts 3
cp 0
crap 2
rs 10
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/91556
59
     *
60
     * @param string $externalUserId
61
     *
62
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
63
     *
64
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
65
     */
66 1
    public function get(string $externalUserId)
67
    {
68 1
        return $this->httpGet('cgi-bin/externalcontact/get', [
69 1
            'external_userid' => $externalUserId,
70
        ]);
71
    }
72
73
74
    /**
75
     * 修改客户备注信息.
76
     *
77
     * @see https://work.weixin.qq.com/api/doc/90000/90135/92115
78
     *
79
     * @param array $data
80
     *
81
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
82
     *
83
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
84
     */
85
    public function remark(array $data)
86
    {
87
        return $this->httpPostJson(
88
            'cgi-bin/externalcontact/remark',
89
            $data
90
        );
91
    }
92
93
94
    /**
95
     * 获取离职成员的客户列表.
96
     *
97
     * @see https://work.weixin.qq.com/api/doc#90000/90135/91563
98
     *
99
     * @param int $pageId
100
     * @param int $pageSize
101
     *
102
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
103
     *
104
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
105
     * @throws \GuzzleHttp\Exception\GuzzleException
106
     */
107 1
    public function getUnassigned(int $pageId = 0, int $pageSize = 1000)
108
    {
109 1
        return $this->httpPostJson('cgi-bin/externalcontact/get_unassigned_list', [
110 1
            'page_id' => $pageId,
111 1
            'page_size' => $pageSize,
112
        ]);
113
    }
114
115
    /**
116
     * 离职成员的外部联系人再分配.
117
     *
118
     * @see https://work.weixin.qq.com/api/doc#90000/90135/91564
119
     *
120
     * @param string $externalUserId
121
     * @param string $handoverUserId
122
     * @param string $takeoverUserId
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 transfer(string $externalUserId, string $handoverUserId, string $takeoverUserId)
130
    {
131
        $params = [
132 1
            'external_userid' => $externalUserId,
133 1
            'handover_userid' => $handoverUserId,
134 1
            'takeover_userid' => $takeoverUserId,
135
        ];
136
137 1
        return $this->httpPostJson('cgi-bin/externalcontact/transfer', $params);
138
    }
139
140
141
    /**
142
     * 获取客户群列表.
143
     *
144
     * @see https://work.weixin.qq.com/api/doc/90000/90135/92120
145
     *
146
     * @param array $params
147
     *
148
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
149
     *
150
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
151
     * @throws \GuzzleHttp\Exception\GuzzleException
152
     */
153
154
    public function getGroupChats(array $params)
155
    {
156
        return $this->httpPostJson('cgi-bin/externalcontact/groupchat/list', $params);
157
    }
158
159
    /**
160
     * 获取客户群详情.
161
     *
162
     * @see https://work.weixin.qq.com/api/doc/90000/90135/92122
163
     *
164
     * @param string $chatId
165
     *
166
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
167
     *
168
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
169
     * @throws \GuzzleHttp\Exception\GuzzleException
170
     */
171
172
    public function getGroupChat(string $chatId)
173
    {
174
        $params = [
175
            'chat_id' => $chatId
176
        ];
177
178
        return $this->httpPostJson('cgi-bin/externalcontact/groupchat/get', $params);
179
    }
180
181
    /**
182
     * 获取企业标签库.
183
     *
184
     * @see https://work.weixin.qq.com/api/doc/90000/90135/92117#获取企业标签库
185
     *
186
     * @param array $tagIds
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 getCorpTags(array $tagIds = [])
195
    {
196
        $params = [
197
            'tag_id' => $tagIds
198
        ];
199
200
        return $this->httpPostJson('cgi-bin/externalcontact/get_corp_tag_list', $params);
201
    }
202
203
204
205
    /**
206
     * 添加企业客户标签.
207
     *
208
     * @see https://work.weixin.qq.com/api/doc/90000/90135/92117#添加企业客户标签
209
     *
210
     * @param array $params
211
     *
212
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
213
     *
214
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
215
     * @throws \GuzzleHttp\Exception\GuzzleException
216
     */
217
218
    public function addCorpTag(array $params)
219
    {
220
        return $this->httpPostJson('cgi-bin/externalcontact/add_corp_tag', $params);
221
    }
222
223
224
    /**
225
     * 编辑企业客户标签.
226
     *
227
     * @see https://work.weixin.qq.com/api/doc/90000/90135/92117#编辑企业客户标签
228
     *
229
     * @param string $id
230
     * @param string $name
231
     * @param int $order
232
     *
233
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
234
     *
235
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
236
     * @throws \GuzzleHttp\Exception\GuzzleException
237
     */
238
239
    public function updateCorpTag(string $id, string $name, int $order = 1)
240
    {
241
        $params = [
242
            "id" => $id,
243
            "name" => $name,
244
            "order" => $order,
245
        ];
246
247
        return $this->httpPostJson('cgi-bin/externalcontact/edit_corp_tag', $params);
248
    }
249
250
251
    /**
252
     * 删除企业客户标签.
253
     *
254
     * @see https://work.weixin.qq.com/api/doc/90000/90135/92117#删除企业客户标签
255
     *
256
     * @param array $tagId
257
     * @param array $groupId
258
     *
259
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
260
     *
261
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
262
     * @throws \GuzzleHttp\Exception\GuzzleException
263
     */
264
265
    public function deleteCorpTag(array $tagId, array $groupId)
266
    {
267
        $params = [
268
            "tag_id" => $tagId,
269
            "group_id" => $groupId,
270
        ];
271
272
        return $this->httpPostJson('cgi-bin/externalcontact/del_corp_tag', $params);
273
    }
274
275
276
    /**
277
     * 编辑客户企业标签.
278
     *
279
     * @see https://work.weixin.qq.com/api/doc/90000/90135/92118
280
     *
281
     * @param array $params
282
     *
283
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
284
     *
285
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
286
     * @throws \GuzzleHttp\Exception\GuzzleException
287
     */
288
289
    public function markTags(array $params)
290
    {
291
        return $this->httpPostJson('cgi-bin/externalcontact/mark_tag', $params);
292
    }
293
}
294