Test Failed
Pull Request — master (#1564)
by milkmeowo
04:45
created

ContactWayClient::add()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 3
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
3
4
namespace EasyWeChat\Work\Crm;
5
6
7
use EasyWeChat\Kernel\BaseClient;
8
9
10
/**
11
 * Class ContactWayClient.
12
 *
13
 * @author milkmeowo <[email protected]>
14
 */
15
class ContactWayClient extends BaseClient
16
{
17
    /**
18
     * 配置客户联系「联系我」方式
19
     *
20
     * @param int $type
21
     * @param int $scene
22
     * @param array $config
23
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
24
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
25
     */
26
    public function add(int $type, int $scene, array $config = [])
27
    {
28
        $params = array_merge([
29
            'type' => $type,
30
            'scene' => $scene
31
        ], $config);
32
33
        return $this->httpPostJson('cgi-bin/externalcontact/add_contact_way', $params);
34
    }
35
36
    /**
37
     * 获取企业已配置的「联系我」方式
38
     *
39
     * @param $configId
40
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
41
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
42
     */
43
    public function get(string $configId)
44
    {
45
        return $this->httpPostJson('cgi-bin/externalcontact/get_contact_way', [
46
            'config_id' => $configId
47
        ]);
48
    }
49
50
    /**
51
     * 更新企业已配置的「联系我」方式
52
     *
53
     * @param $configId
54
     * @param $config
55
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
56
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
57
     */
58
    public function update(string $configId, array $config = [])
59
    {
60
        $params = array_merge([
61
            'config_id' => $configId,
62
        ], $config);
63
64
        return $this->httpPostJson('cgi-bin/externalcontact/update_contact_way', $params);
65
    }
66
67
    /**
68
     * 删除企业已配置的「联系我」方式
69
     *
70
     * @param $configId
71
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
72
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
73
     */
74
    public function del($configId)
75
    {
76
        return $this->httpPostJson('cgi-bin/externalcontact/del_contact_way', [
77
            'config_id' => $configId
78
        ]);
79
    }
80
}