SubMerchantClient::update()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 14
c 0
b 0
f 0
nc 1
nop 2
dl 0
loc 20
ccs 6
cts 6
cp 1
crap 1
rs 9.7998
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\Card;
13
14
use EasyWeChat\Kernel\BaseClient;
15
use EasyWeChat\Kernel\Support\Arr;
16
17
/**
18
 * Class SubMerchantClient.
19
 *
20
 * @author overtrue <[email protected]>
21
 */
22
class SubMerchantClient extends BaseClient
23
{
24
    /**
25
     * 添加子商户.
26
     *
27
     * @param array $info
28
     *
29
     * @return mixed
30
     *
31
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
32
     * @throws \GuzzleHttp\Exception\GuzzleException
33
     */
34 1
    public function create(array $info = [])
35
    {
36
        $params = [
37 1
            'info' => Arr::only($info, [
38 1
                'brand_name',
39
                'logo_url',
40
                'protocol',
41
                'end_time',
42
                'primary_category_id',
43
                'secondary_category_id',
44
                'agreement_media_id',
45
                'operator_media_id',
46
                'app_id',
47
            ]),
48
        ];
49
50 1
        return $this->httpPostJson('card/submerchant/submit', $params);
51
    }
52
53
    /**
54
     * 更新子商户.
55
     *
56
     * @param int   $merchantId
57
     * @param array $info
58
     *
59
     * @return mixed
60
     *
61
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
62
     * @throws \GuzzleHttp\Exception\GuzzleException
63
     */
64 1
    public function update(int $merchantId, array $info = [])
65
    {
66
        $params = [
67 1
            'info' => array_merge(
68 1
                ['merchant_id' => $merchantId],
69 1
                Arr::only($info, [
70 1
                    'brand_name',
71
                    'logo_url',
72
                    'protocol',
73
                    'end_time',
74
                    'primary_category_id',
75
                    'secondary_category_id',
76
                    'agreement_media_id',
77
                    'operator_media_id',
78
                    'app_id',
79
                ])
80
            ),
81
        ];
82
83 1
        return $this->httpPostJson('card/submerchant/update', $params);
84
    }
85
86
    /**
87
     * 获取子商户信息.
88
     *
89
     * @param int $merchantId
90
     *
91
     * @return mixed
92
     *
93
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
94
     * @throws \GuzzleHttp\Exception\GuzzleException
95
     */
96 1
    public function get(int $merchantId)
97
    {
98 1
        return $this->httpPostJson('card/submerchant/get', ['merchant_id' => $merchantId]);
99
    }
100
101
    /**
102
     * 批量获取子商户信息.
103
     *
104
     * @param int    $beginId
105
     * @param int    $limit
106
     * @param string $status
107
     *
108
     * @return mixed
109
     *
110
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
111
     * @throws \GuzzleHttp\Exception\GuzzleException
112
     */
113 1
    public function list(int $beginId = 0, int $limit = 50, string $status = 'CHECKING')
114
    {
115
        $params = [
116 1
            'begin_id' => $beginId,
117 1
            'limit' => $limit,
118 1
            'status' => $status,
119
        ];
120
121 1
        return $this->httpPostJson('card/submerchant/batchget', $params);
122
    }
123
}
124