Completed
Pull Request — master (#1179)
by mingyoung
02:45
created

Client::list()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
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\OpenPlatform\Authorizer\OfficialAccount\MiniProgram;
13
14
use EasyWeChat\Kernel\BaseClient;
15
16
/**
17
 * Class Client.
18
 *
19
 * @author Keal <[email protected]>
20
 */
21
class Client extends BaseClient
22
{
23
    /**
24
     * 获取公众号关联的小程序.
25
     *
26
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
27
     *
28
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
29
     */
30
    public function list()
31
    {
32
        return $this->httpPostJson('cgi-bin/wxopen/wxamplinkget');
33
    }
34
35
    /**
36
     * 关联小程序.
37
     *
38
     * @param string $appId
39
     * @param bool   $notifyUsers
40
     * @param bool   $showProfile
41
     *
42
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
43
     *
44
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
45
     */
46
    public function link(string $appId, bool $notifyUsers = true, bool $showProfile = false)
47
    {
48
        $params = [
49
            'appid' => $appId,
50
            'notify_users' => (string) $notifyUsers,
51
            'show_profile' => (string) $showProfile,
52
        ];
53
54
        return $this->httpPostJson('cgi-bin/wxopen/wxamplink', $params);
55
    }
56
57
    /**
58
     * 解除已关联的小程序.
59
     *
60
     * @param string $appId
61
     *
62
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
63
     *
64
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
65
     */
66
    public function unlink(string $appId)
67
    {
68
        $params = [
69
            'appid' => $appId,
70
        ];
71
72
        return $this->httpPostJson('cgi-bin/wxopen/wxampunlink', $params);
73
    }
74
}
75