Completed
Pull Request — master (#1565)
by milkmeowo
03:58
created

ContactWayClient   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 71
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A update() 0 7 1
A get() 0 4 1
A delete() 0 4 1
A add() 0 8 1
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 ContactWayClient.
18
 *
19
 * @author milkmeowo <[email protected]>
20
 */
21
class ContactWayClient extends BaseClient
22
{
23
    /**
24
     * 配置客户联系「联系我」方式.
25
     *
26
     * @param int   $type
27
     * @param int   $scene
28
     * @param array $config
29
     *
30
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
31
     *
32
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
33
     */
34 1
    public function add(int $type, int $scene, array $config = [])
35
    {
36 1
        $params = array_merge([
37 1
            'type' => $type,
38 1
            'scene' => $scene,
39
        ], $config);
40
41 1
        return $this->httpPostJson('cgi-bin/externalcontact/add_contact_way', $params);
42
    }
43
44
    /**
45
     * 获取企业已配置的「联系我」方式.
46
     *
47
     * @param $configId
48
     *
49
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
50
     *
51
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
52
     */
53 1
    public function get(string $configId)
54
    {
55 1
        return $this->httpPostJson('cgi-bin/externalcontact/get_contact_way', [
56 1
            'config_id' => $configId,
57
        ]);
58
    }
59
60
    /**
61
     * 更新企业已配置的「联系我」方式.
62
     *
63
     * @param $configId
64
     * @param $config
65
     *
66
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
67
     *
68
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
69
     */
70 1
    public function update(string $configId, array $config = [])
71
    {
72 1
        $params = array_merge([
73 1
            'config_id' => $configId,
74
        ], $config);
75
76 1
        return $this->httpPostJson('cgi-bin/externalcontact/update_contact_way', $params);
77
    }
78
79
    /**
80
     * 删除企业已配置的「联系我」方式.
81
     *
82
     * @param $configId
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 delete($configId)
89
    {
90 1
        return $this->httpPostJson('cgi-bin/externalcontact/del_contact_way', [
91 1
            'config_id' => $configId,
92
        ]);
93
    }
94
}
95