Passed
Pull Request — master (#1179)
by Keal
03:20
created

Client::link()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 5
nc 4
nop 3
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: keal
5
 * Date: 2018/4/3
6
 * Time: 上午10:51
7
 */
8
9
namespace EasyWeChat\OpenPlatform\Authorizer\OfficialAccount\Management;
10
11
12
use EasyWeChat\Kernel\BaseClient;
13
14
class Client extends BaseClient
15
{
16
    /**
17
     * 获取公众号关联的小程序.
18
     *
19
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
20
     *
21
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
22
     */
23
    public function list()
24
    {
25
        return $this->httpPostJson('cgi-bin/wxopen/wxamplinkget');
26
    }
27
28
    /**
29
     * 关联小程序.
30
     *
31
     * @param string $miniProgramAppId
32
     * @param bool $notifyUsers
33
     * @param bool $showProfile
34
     *
35
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
36
     *
37
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
38
     */
39
    public function link(string $miniProgramAppId, bool $notifyUsers = true, bool $showProfile = false)
40
    {
41
        $params = [
42
            'appid' => $miniProgramAppId,
43
            'notify_users' => $notifyUsers ? '1' : '0',
44
            'show_profile' => $showProfile ? '1' : '0'
45
        ];
46
47
        return $this->httpPostJson('cgi-bin/wxopen/wxamplink', $params);
48
    }
49
50
    /**
51
     * 解除已关联的小程序.
52
     *
53
     * @param $miniProgramAppId
54
     *
55
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
56
     *
57
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
58
     */
59
    public function unlink($miniProgramAppId)
60
    {
61
        $params = [
62
            'appid' => $miniProgramAppId
63
        ];
64
65
        return $this->httpPostJson('cgi-bin/wxopen/wxampunlink', $params);
66
    }
67
68
    /**
69
     * 小程序快速注册.
70
     *
71
     * @param string $ticket
72
     *
73
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
74
     *
75
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
76
     */
77
    public function register(string $ticket)
78
    {
79
        $params = [
80
            'ticket' => $ticket
81
        ];
82
83
        return $this->httpPostJson('cgi-bin/account/fastregister', $params);
84
    }
85
}