Agent::lists()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace EntWeChat\Agent;
4
5
use EntWeChat\Core\AbstractAPI;
6
7
/**
8
 * Class Agent.
9
 */
10
class Agent extends AbstractAPI
11
{
12
    const API_GET = 'https://qyapi.weixin.qq.com/cgi-bin/agent/get';
13
    const API_SET = 'https://qyapi.weixin.qq.com/cgi-bin/agent/set';
14
    const API_LIST = 'https://qyapi.weixin.qq.com/cgi-bin/agent/list';
15
16
    /**
17
     * Fetch an agent by agent id.
18
     *
19
     * @param int $agentId
20
     *
21
     * @return \EntWeChat\Support\Collection
22
     */
23
    public function get($agentId)
24
    {
25
        $params = [
26
            'agentid' => $agentId,
27
        ];
28
29
        return $this->parseJSON('get', [self::API_GET, $params]);
30
    }
31
32
    /**
33
     * Set an agent by agent id.
34
     *
35
     * @param int   $agentId
36
     * @param array $agentInfo
37
     *
38
     * @return \EntWeChat\Support\Collection
39
     */
40
    public function set($agentId, array $agentInfo = [])
41
    {
42
        $params = array_merge($agentInfo, [
43
            'agentid' => $agentId,
44
        ]);
45
46
        return $this->parseJSON('json', [self::API_SET, $params]);
47
    }
48
49
    /**
50
     * List agents.
51
     *
52
     * @return \EntWeChat\Support\Collection
53
     */
54
    public function lists()
55
    {
56
        return $this->parseJSON('get', [self::API_LIST]);
57
    }
58
}
59