Test Failed
Pull Request — master (#1663)
by
unknown
04:51
created

ShopClient::list()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 8
rs 10
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\WiFi;
13
14
use EasyWeChat\Kernel\BaseClient;
15
16
/**
17
 * Class ShopClient.
18
 *
19
 * @author her-cat <[email protected]>
20
 */
21
class ShopClient extends BaseClient
22
{
23
    /**
24
     * Get shop Wi-Fi information.
25
     *
26
     * @param int $shopId
27
     *
28
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
29
     *
30
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
31
     * @throws \GuzzleHttp\Exception\GuzzleException
32
     */
33
    public function get(int $shopId)
34
    {
35
        return $this->httpPostJson('bizwifi/shop/get', ['shop_id' => $shopId]);
36
    }
37
38
    /**
39
     * Get a list of Wi-Fi shops.
40
     *
41
     * @param int $page
42
     * @param int $size
43
     *
44
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
45
     *
46
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
47
     * @throws \GuzzleHttp\Exception\GuzzleException
48
     */
49
    public function list(int $page = 1, int $size = 10)
50
    {
51
        $data = [
52
            'pageindex' => $page,
53
            'pagesize' => $size,
54
        ];
55
56
        return $this->httpPostJson('bizwifi/shop/list', $data);
57
    }
58
59
    /**
60
     * Update shop Wi-Fi information.
61
     *
62
     * @param int $shopId
63
     * @param array $data
64
     *
65
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
66
     *
67
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
68
     * @throws \GuzzleHttp\Exception\GuzzleException
69
     */
70
    public function update(int $shopId, array $data)
71
    {
72
        $data = array_merge(['shop_id' => $shopId], $data);
73
74
        return $this->httpPostJson('bizwifi/shop/update', $data);
75
    }
76
77
    /**
78
     * Clear shop network and equipment.
79
     *
80
     * @param int $shopId
81
     * @param string|null $ssid
82
     *
83
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
84
     *
85
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
86
     * @throws \GuzzleHttp\Exception\GuzzleException
87
     */
88
    public function clearDevice(int $shopId, string $ssid = null)
89
    {
90
        $data = [
91
            'shop_id' => $shopId,
92
        ];
93
94
        if (!is_null($ssid)) {
95
            $data['ssid'] = $ssid;
96
        }
97
98
        return $this->httpPostJson('bizwifi/shop/clean', $data);
99
    }
100
}
101