MemberCardClient   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 103
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 6
eloc 13
dl 0
loc 103
ccs 16
cts 16
cp 1
rs 10
c 2
b 1
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A updateUser() 0 3 1
A getUser() 0 8 1
A getActivationForm() 0 7 1
A setActivationForm() 0 5 1
A activate() 0 3 1
A getActivateUrl() 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
/**
15
 * Class MemberCardClient.
16
 *
17
 * @author overtrue <[email protected]>
18
 */
19
class MemberCardClient extends Client
20
{
21
    /**
22
     * 会员卡接口激活.
23
     *
24
     * @param array $info
25
     *
26
     * @return mixed
27
     *
28
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
29
     * @throws \GuzzleHttp\Exception\GuzzleException
30
     */
31 1
    public function activate(array $info = [])
32
    {
33 1
        return $this->httpPostJson('card/membercard/activate', $info);
34
    }
35
36
    /**
37
     * 设置开卡字段接口.
38
     *
39
     * @param string $cardId
40
     * @param array  $settings
41
     *
42
     * @return mixed
43
     *
44
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
45
     * @throws \GuzzleHttp\Exception\GuzzleException
46
     */
47 1
    public function setActivationForm(string $cardId, array $settings)
48
    {
49 1
        $params = array_merge(['card_id' => $cardId], $settings);
50
51 1
        return $this->httpPostJson('card/membercard/activateuserform/set', $params);
52
    }
53
54
    /**
55
     * 拉取会员信息接口.
56
     *
57
     * @param string $cardId
58
     * @param string $code
59
     *
60
     * @return mixed
61
     *
62
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
63
     * @throws \GuzzleHttp\Exception\GuzzleException
64
     */
65 1
    public function getUser(string $cardId, string $code)
66
    {
67
        $params = [
68 1
            'card_id' => $cardId,
69 1
            'code' => $code,
70
        ];
71
72 1
        return $this->httpPostJson('card/membercard/userinfo/get', $params);
73
    }
74
75
    /**
76
     * 更新会员信息.
77
     *
78
     * @param array $params
79
     *
80
     * @return mixed
81
     *
82
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
83
     * @throws \GuzzleHttp\Exception\GuzzleException
84
     */
85 1
    public function updateUser(array $params = [])
86
    {
87 1
        return $this->httpPostJson('card/membercard/updateuser', $params);
88
    }
89
90
    /**
91
     * 获取用户提交资料.
92
     *
93
     * @param string $activateTicket
94
     *
95
     * @return mixed
96
     *
97
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
98
     * @throws \GuzzleHttp\Exception\GuzzleException
99
     */
100 1
    public function getActivationForm($activateTicket)
101
    {
102
        $params = [
103 1
            'activate_ticket' => $activateTicket,
104
        ];
105
106 1
        return $this->httpPostJson('card/membercard/activatetempinfo/get', $params);
107
    }
108
109
    /**
110
     * 获取开卡组件链接接口.
111
     *
112
     * @param array $params 包含会员卡ID和随机字符串
113
     *
114
     * @return string 开卡组件链接
115
     *
116
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
117
     * @throws \GuzzleHttp\Exception\GuzzleException
118
     */
119 1
    public function getActivateUrl(array $params = [])
120
    {
121 1
        return $this->httpPostJson('card/membercard/activate/geturl', $params);
122
    }
123
}
124