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 DeviceClient. |
18
|
|
|
* |
19
|
|
|
* @author her-cat <[email protected]> |
20
|
|
|
*/ |
21
|
|
|
class DeviceClient extends BaseClient |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* Add a password device. |
25
|
|
|
* |
26
|
|
|
* @param int $shopId |
27
|
|
|
* @param string $ssid |
28
|
|
|
* @param string $password |
29
|
|
|
* |
30
|
|
|
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
31
|
|
|
* |
32
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
33
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
34
|
|
|
*/ |
35
|
|
|
public function addPasswordDevice(int $shopId, string $ssid, string $password) |
36
|
|
|
{ |
37
|
|
|
$data = [ |
38
|
|
|
'shop_id' => $shopId, |
39
|
|
|
'ssid' => $ssid, |
40
|
|
|
'password' => $password, |
41
|
|
|
]; |
42
|
|
|
|
43
|
|
|
return $this->httpPostJson('bizwifi/device/add', $data); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Add a portal device. |
48
|
|
|
* |
49
|
|
|
* @param int $shopId |
50
|
|
|
* @param string $ssid |
51
|
|
|
* @param bool $reset |
52
|
|
|
* |
53
|
|
|
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
54
|
|
|
* |
55
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
56
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
57
|
|
|
*/ |
58
|
|
|
public function addPortalDevice(int $shopId, string $ssid, bool $reset = false) |
59
|
|
|
{ |
60
|
|
|
$data = [ |
61
|
|
|
'shop_id' => $shopId, |
62
|
|
|
'ssid' => $ssid, |
63
|
|
|
'reset' => $reset, |
64
|
|
|
]; |
65
|
|
|
|
66
|
|
|
return $this->httpPostJson('bizwifi/apportal/register', $data); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Delete device by MAC address. |
71
|
|
|
* |
72
|
|
|
* @param string $macAddress |
73
|
|
|
* |
74
|
|
|
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
75
|
|
|
* |
76
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
77
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
78
|
|
|
*/ |
79
|
|
|
public function delete(string $macAddress) |
80
|
|
|
{ |
81
|
|
|
return $this->httpPostJson('bizwifi/device/delete', ['bssid' => $macAddress]); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Get a list of devices. |
86
|
|
|
* |
87
|
|
|
* @param int $page |
88
|
|
|
* @param int $size |
89
|
|
|
* |
90
|
|
|
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
91
|
|
|
* |
92
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
93
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
94
|
|
|
*/ |
95
|
|
|
public function list(int $page = 1, int $size = 10) |
96
|
|
|
{ |
97
|
|
|
$data = [ |
98
|
|
|
'pageindex' => $page, |
99
|
|
|
'pagesize' => $size, |
100
|
|
|
]; |
101
|
|
|
|
102
|
|
|
return $this->httpPostJson('bizwifi/device/list', $data); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* Get a list of devices by shop ID. |
107
|
|
|
* |
108
|
|
|
* @param int $shopId |
109
|
|
|
* @param int $page |
110
|
|
|
* @param int $size |
111
|
|
|
* |
112
|
|
|
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
113
|
|
|
* |
114
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
115
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
116
|
|
|
*/ |
117
|
|
|
public function listByShopId(int $shopId, int $page = 1, int $size = 10) |
118
|
|
|
{ |
119
|
|
|
$data = [ |
120
|
|
|
'shop_id' => $shopId, |
121
|
|
|
'pageindex' => $page, |
122
|
|
|
'pagesize' => $size, |
123
|
|
|
]; |
124
|
|
|
|
125
|
|
|
return $this->httpPostJson('bizwifi/device/list', $data); |
126
|
|
|
} |
127
|
|
|
} |
128
|
|
|
|