Client::getDisplayedOfficialAccount()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
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\MiniProgram\Setting;
13
14
use EasyWeChat\Kernel\BaseClient;
15
16
/**
17
 * Class Client.
18
 *
19
 * @author ClouderSky <[email protected]>
20
 */
21
class Client extends BaseClient
22
{
23
    /**
24
     * 获取账号可以设置的所有类目.
25
     */
26 1
    public function getAllCategories()
27
    {
28 1
        return $this->httpPostJson('cgi-bin/wxopen/getallcategories');
29
    }
30
31
    /**
32
     * 添加类目.
33
     *
34
     * @param array $categories 类目数组
35
     *
36
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
37
     *
38
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
39
     * @throws \GuzzleHttp\Exception\GuzzleException
40
     */
41 1
    public function addCategories(array $categories)
42
    {
43 1
        $params = ['categories' => $categories];
44
45 1
        return $this->httpPostJson('cgi-bin/wxopen/addcategory', $params);
46
    }
47
48
    /**
49
     * 删除类目.
50
     *
51
     * @param int $firstId  一级类目ID
52
     * @param int $secondId 二级类目ID
53
     *
54
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
55
     *
56
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
57
     * @throws \GuzzleHttp\Exception\GuzzleException
58
     */
59 1
    public function deleteCategories(int $firstId, int $secondId)
60
    {
61 1
        $params = ['first' => $firstId, 'second' => $secondId];
62
63 1
        return $this->httpPostJson('cgi-bin/wxopen/deletecategory', $params);
64
    }
65
66
    /**
67
     * 获取账号已经设置的所有类目.
68
     */
69 1
    public function getCategories()
70
    {
71 1
        return $this->httpPostJson('cgi-bin/wxopen/getcategory');
72
    }
73
74
    /**
75
     * 修改类目.
76
     *
77
     * @param array $category 单个类目
78
     *
79
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
80
     *
81
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
82
     * @throws \GuzzleHttp\Exception\GuzzleException
83
     */
84 1
    public function updateCategory(array $category)
85
    {
86 1
        return $this->httpPostJson('cgi-bin/wxopen/modifycategory', $category);
87
    }
88
89
    /**
90
     * 小程序名称设置及改名.
91
     *
92
     * @param string $nickname       昵称
93
     * @param string $idCardMediaId  身份证照片素材ID
94
     * @param string $licenseMediaId 组织机构代码证或营业执照素材ID
95
     * @param array  $otherStuffs    其他证明材料素材ID
96
     *
97
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
98
     *
99
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
100
     * @throws \GuzzleHttp\Exception\GuzzleException
101
     */
102 1
    public function setNickname(
103
        string $nickname,
104
        string $idCardMediaId = '',
105
        string $licenseMediaId = '',
106
        array $otherStuffs = []
107
    ) {
108
        $params = [
109 1
            'nick_name' => $nickname,
110 1
            'id_card' => $idCardMediaId,
111 1
            'license' => $licenseMediaId,
112
        ];
113
114 1
        for ($i = \count($otherStuffs) - 1; $i >= 0; --$i) {
115 1
            $params['naming_other_stuff_'.($i + 1)] = $otherStuffs[$i];
116
        }
117
118 1
        return $this->httpPostJson('wxa/setnickname', $params);
119
    }
120
121
    /**
122
     * 小程序改名审核状态查询.
123
     *
124
     * @param int $auditId 审核单id
125
     *
126
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
127
     *
128
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
129
     * @throws \GuzzleHttp\Exception\GuzzleException
130
     */
131 1
    public function getNicknameAuditStatus($auditId)
132
    {
133 1
        $params = ['audit_id' => $auditId];
134
135 1
        return $this->httpPostJson('wxa/api_wxa_querynickname', $params);
136
    }
137
138
    /**
139
     * 微信认证名称检测.
140
     *
141
     * @param string $nickname 名称(昵称)
142
     *
143
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
144
     *
145
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
146
     * @throws \GuzzleHttp\Exception\GuzzleException
147
     */
148 1
    public function isAvailableNickname($nickname)
149
    {
150 1
        $params = ['nick_name' => $nickname];
151
152 1
        return $this->httpPostJson(
153 1
            'cgi-bin/wxverify/checkwxverifynickname',
154
            $params
155
        );
156
    }
157
158
    /**
159
     * 查询小程序是否可被搜索.
160
     *
161
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
162
     *
163
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
164
     * @throws \GuzzleHttp\Exception\GuzzleException
165
     */
166 1
    public function getSearchStatus()
167
    {
168 1
        return $this->httpGet('wxa/getwxasearchstatus');
169
    }
170
171
    /**
172
     * 设置小程序可被搜素.
173
     *
174
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
175
     *
176
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
177
     * @throws \GuzzleHttp\Exception\GuzzleException
178
     */
179 1
    public function setSearchable()
180
    {
181 1
        return $this->httpPostJson('wxa/changewxasearchstatus', [
182 1
            'status' => 0,
183
        ]);
184
    }
185
186
    /**
187
     * 设置小程序不可被搜素.
188
     *
189
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
190
     *
191
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
192
     * @throws \GuzzleHttp\Exception\GuzzleException
193
     */
194 1
    public function setUnsearchable()
195
    {
196 1
        return $this->httpPostJson('wxa/changewxasearchstatus', [
197 1
            'status' => 1,
198
        ]);
199
    }
200
201
    /**
202
     * 获取展示的公众号信息.
203
     *
204
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
205
     *
206
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
207
     * @throws \GuzzleHttp\Exception\GuzzleException
208
     */
209 1
    public function getDisplayedOfficialAccount()
210
    {
211 1
        return $this->httpGet('wxa/getshowwxaitem');
212
    }
213
214
    /**
215
     * 设置展示的公众号.
216
     *
217
     * @param string|bool $appid
218
     *
219
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
220
     *
221
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
222
     * @throws \GuzzleHttp\Exception\GuzzleException
223
     */
224 2
    public function setDisplayedOfficialAccount($appid)
225
    {
226 2
        return $this->httpPostJson('wxa/updateshowwxaitem', [
227 2
            'appid' => $appid ?: null,
228 2
            'wxa_subscribe_biz_flag' => $appid ? 1 : 0,
229
        ]);
230
    }
231
232
    /**
233
     * 获取可以用来设置的公众号列表.
234
     *
235
     * @param int $page
236
     * @param int $num
237
     *
238
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
239
     *
240
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
241
     * @throws \GuzzleHttp\Exception\GuzzleException
242
     */
243 1
    public function getDisplayableOfficialAccounts(int $page, int $num)
244
    {
245 1
        return $this->httpGet('wxa/getwxamplinkforshow', [
246 1
            'page' => $page,
247 1
            'num' => $num,
248
        ]);
249
    }
250
}
251