Passed
Pull Request — master (#1604)
by
unknown
02:59
created

InvoiceClient   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 88
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 18
c 1
b 0
f 0
dl 0
loc 88
ccs 18
cts 18
cp 1
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A set() 0 9 1
A getAuthField() 0 3 1
A getAuthData() 0 7 1
A get() 0 3 1
A setAuthField() 0 9 1
A setBizattr() 0 3 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\OfficialAccount\Card;
13
14
use EasyWeChat\Kernel\BaseClient;
15
16
/**
17
 * Class InvoiceClient.
18
 *
19
 * @author overtrue <[email protected]>
20
 */
21
class InvoiceClient extends BaseClient
22
{
23
    /**
24
     * 设置支付后开票信息接口.
25
     *
26
     * @param string $mchid
27
     * @param string $sPappid
28
     *
29
     * @return mixed
30
     */
31 1
    public function set(string $mchid, string $sPappid)
32
    {
33
        $params = [
34
            'paymch_info' => [
35 1
                'mchid' => $mchid,
36 1
                's_pappid' => $sPappid,
37
            ],
38
        ];
39 1
        return $this->setBizattr('set_pay_mch', $params);
40
    }
41
42
    /**
43
     * 查询支付后开票信息接口.
44
     *
45
     * @return mixed
46
     */
47 1
    public function get()
48
    {
49 1
        return $this->setBizattr('get_pay_mch');
50
    }
51
52
    /**
53
     * 设置授权页字段信息接口.
54
     *
55
     * @param array $userData
56
     * @param array $bizData
57
     *
58
     * @return mixed
59
     */
60 1
    public function setAuthField(array $userData, array $bizData)
61
    {
62
        $params = [
63
            'auth_field' => [
64 1
                'user_field' => $userData,
65 1
                'biz_field' => $bizData,
66
            ],
67
        ];
68 1
        return $this->setBizattr('set_auth_field', $params);
69
    }
70
71
    /**
72
     * 查询授权页字段信息接口.
73
     *
74
     * @return mixed
75
     */
76 1
    public function getAuthField()
77
    {
78 1
        return $this->setBizattr('get_auth_field');
79
    }
80
81
    /**
82
     * 查询开票信息.
83
     *
84
     * @param string $orderId
85
     * @param string $appId
86
     *
87
     * @return mixed
88
     */
89 1
    public function getAuthData(string $appId, string $orderId)
90
    {
91
        $params = [
92 1
            'order_id' => $orderId,
93 1
            's_appid' => $appId
94
        ];
95 1
        return $this->httpPost('card/invoice/getauthdata', $params);
96
    }
97
98
    /**
99
     * @param string $action
100
     * @param array  $params
101
     *
102
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
103
     *
104
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
105
     */
106 4
    private function setBizattr(string $action, array $params = [])
107
    {
108 4
        return $this->httpPostJson('card/invoice/setbizattr', $params, ['action' => $action]);
109
    }
110
}