SessionClient::list()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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\OfficialAccount\CustomerService;
13
14
use EasyWeChat\Kernel\BaseClient;
15
16
/**
17
 * Class SessionClient.
18
 *
19
 * @author overtrue <[email protected]>
20
 */
21
class SessionClient extends BaseClient
22
{
23
    /**
24
     * List all sessions of $account.
25
     *
26
     * @param string $account
27
     *
28
     * @return mixed
29
     *
30
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
31
     */
32 1
    public function list(string $account)
33
    {
34 1
        return $this->httpGet('customservice/kfsession/getsessionlist', ['kf_account' => $account]);
35
    }
36
37
    /**
38
     * List all the people waiting.
39
     *
40
     * @return mixed
41
     *
42
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
43
     */
44 1
    public function waiting()
45
    {
46 1
        return $this->httpGet('customservice/kfsession/getwaitcase');
47
    }
48
49
    /**
50
     * Create a session.
51
     *
52
     * @param string $account
53
     * @param string $openid
54
     *
55
     * @return mixed
56
     *
57
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
58
     * @throws \GuzzleHttp\Exception\GuzzleException
59
     */
60 1
    public function create(string $account, string $openid)
61
    {
62
        $params = [
63 1
            'kf_account' => $account,
64 1
            'openid' => $openid,
65
        ];
66
67 1
        return $this->httpPostJson('customservice/kfsession/create', $params);
68
    }
69
70
    /**
71
     * Close a session.
72
     *
73
     * @param string $account
74
     * @param string $openid
75
     *
76
     * @return mixed
77
     *
78
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
79
     * @throws \GuzzleHttp\Exception\GuzzleException
80
     */
81 1
    public function close(string $account, string $openid)
82
    {
83
        $params = [
84 1
            'kf_account' => $account,
85 1
            'openid' => $openid,
86
        ];
87
88 1
        return $this->httpPostJson('customservice/kfsession/close', $params);
89
    }
90
91
    /**
92
     * Get a session.
93
     *
94
     * @param string $openid
95
     *
96
     * @return mixed
97
     *
98
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
99
     */
100 1
    public function get(string $openid)
101
    {
102 1
        return $this->httpGet('customservice/kfsession/getsession', ['openid' => $openid]);
103
    }
104
}
105