|
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\ShakeAround; |
|
13
|
|
|
|
|
14
|
|
|
use EasyWeChat\Kernel\BaseClient; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Class DeviceClient. |
|
18
|
|
|
* |
|
19
|
|
|
* @author allen05ren <[email protected]> |
|
20
|
|
|
*/ |
|
21
|
|
|
class DeviceClient extends BaseClient |
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* @param array $data |
|
25
|
|
|
* |
|
26
|
|
|
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
|
27
|
|
|
* |
|
28
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
|
29
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
|
30
|
|
|
*/ |
|
31
|
1 |
|
public function apply(array $data) |
|
32
|
|
|
{ |
|
33
|
1 |
|
return $this->httpPostJson('shakearound/device/applyid', $data); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Get audit status. |
|
38
|
|
|
* |
|
39
|
|
|
* @param int $applyId |
|
40
|
|
|
* |
|
41
|
|
|
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string |
|
42
|
|
|
* |
|
43
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
|
44
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
|
45
|
|
|
*/ |
|
46
|
1 |
|
public function status(int $applyId) |
|
47
|
|
|
{ |
|
48
|
|
|
$params = [ |
|
49
|
1 |
|
'apply_id' => $applyId, |
|
50
|
|
|
]; |
|
51
|
|
|
|
|
52
|
1 |
|
return $this->httpPostJson('shakearound/device/applystatus', $params); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* Update a device comment. |
|
57
|
|
|
* |
|
58
|
|
|
* @param array $deviceIdentifier |
|
59
|
|
|
* @param string $comment |
|
60
|
|
|
* |
|
61
|
|
|
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string |
|
62
|
|
|
* |
|
63
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
|
64
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
|
65
|
|
|
*/ |
|
66
|
1 |
|
public function update(array $deviceIdentifier, string $comment) |
|
67
|
|
|
{ |
|
68
|
|
|
$params = [ |
|
69
|
1 |
|
'device_identifier' => $deviceIdentifier, |
|
70
|
1 |
|
'comment' => $comment, |
|
71
|
|
|
]; |
|
72
|
|
|
|
|
73
|
1 |
|
return $this->httpPostJson('shakearound/device/update', $params); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* Bind location for device. |
|
78
|
|
|
* |
|
79
|
|
|
* @param array $deviceIdentifier |
|
80
|
|
|
* @param int $poiId |
|
81
|
|
|
* |
|
82
|
|
|
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string |
|
83
|
|
|
* |
|
84
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
|
85
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
|
86
|
|
|
*/ |
|
87
|
1 |
|
public function bindPoi(array $deviceIdentifier, int $poiId) |
|
88
|
|
|
{ |
|
89
|
|
|
$params = [ |
|
90
|
1 |
|
'device_identifier' => $deviceIdentifier, |
|
91
|
1 |
|
'poi_id' => $poiId, |
|
92
|
|
|
]; |
|
93
|
|
|
|
|
94
|
1 |
|
return $this->httpPostJson('shakearound/device/bindlocation', $params); |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* @param array $deviceIdentifier |
|
99
|
|
|
* @param int $poiId |
|
100
|
|
|
* @param string $appId |
|
101
|
|
|
* |
|
102
|
|
|
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
|
103
|
|
|
* |
|
104
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
|
105
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
|
106
|
|
|
*/ |
|
107
|
1 |
|
public function bindThirdPoi(array $deviceIdentifier, int $poiId, string $appId) |
|
108
|
|
|
{ |
|
109
|
|
|
$params = [ |
|
110
|
1 |
|
'device_identifier' => $deviceIdentifier, |
|
111
|
1 |
|
'poi_id' => $poiId, |
|
112
|
1 |
|
'type' => 2, |
|
113
|
1 |
|
'poi_appid' => $appId, |
|
114
|
|
|
]; |
|
115
|
|
|
|
|
116
|
1 |
|
return $this->httpPostJson('shakearound/device/bindlocation', $params); |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
/** |
|
120
|
|
|
* Fetch batch of devices by deviceIds. |
|
121
|
|
|
* |
|
122
|
|
|
* @param array $deviceIdentifiers |
|
123
|
|
|
* |
|
124
|
|
|
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string |
|
125
|
|
|
*/ |
|
126
|
1 |
|
public function listByIds(array $deviceIdentifiers) |
|
127
|
|
|
{ |
|
128
|
|
|
$params = [ |
|
129
|
1 |
|
'type' => 1, |
|
130
|
1 |
|
'device_identifiers' => $deviceIdentifiers, |
|
131
|
|
|
]; |
|
132
|
|
|
|
|
133
|
1 |
|
return $this->search($params); |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
/** |
|
137
|
|
|
* Pagination to get batch of devices. |
|
138
|
|
|
* |
|
139
|
|
|
* @param int $lastId |
|
140
|
|
|
* @param int $count |
|
141
|
|
|
* |
|
142
|
|
|
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string |
|
143
|
|
|
*/ |
|
144
|
1 |
|
public function list(int $lastId, int $count) |
|
145
|
|
|
{ |
|
146
|
|
|
$params = [ |
|
147
|
1 |
|
'type' => 2, |
|
148
|
1 |
|
'last_seen' => $lastId, |
|
149
|
1 |
|
'count' => $count, |
|
150
|
|
|
]; |
|
151
|
|
|
|
|
152
|
1 |
|
return $this->search($params); |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
|
|
/** |
|
156
|
|
|
* Fetch batch of devices by applyId. |
|
157
|
|
|
* |
|
158
|
|
|
* @param int $applyId |
|
159
|
|
|
* @param int $lastId |
|
160
|
|
|
* @param int $count |
|
161
|
|
|
* |
|
162
|
|
|
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string |
|
163
|
|
|
*/ |
|
164
|
1 |
|
public function listByApplyId(int $applyId, int $lastId, int $count) |
|
165
|
|
|
{ |
|
166
|
|
|
$params = [ |
|
167
|
1 |
|
'type' => 3, |
|
168
|
1 |
|
'apply_id' => $applyId, |
|
169
|
1 |
|
'last_seen' => $lastId, |
|
170
|
1 |
|
'count' => $count, |
|
171
|
|
|
]; |
|
172
|
|
|
|
|
173
|
1 |
|
return $this->search($params); |
|
174
|
|
|
} |
|
175
|
|
|
|
|
176
|
|
|
/** |
|
177
|
|
|
* Fetch batch of devices. |
|
178
|
|
|
* |
|
179
|
|
|
* @param array $params |
|
180
|
|
|
* |
|
181
|
|
|
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string |
|
182
|
|
|
* |
|
183
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
|
184
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
|
185
|
|
|
*/ |
|
186
|
4 |
|
public function search(array $params) |
|
187
|
|
|
{ |
|
188
|
4 |
|
return $this->httpPostJson('shakearound/device/search', $params); |
|
189
|
|
|
} |
|
190
|
|
|
} |
|
191
|
|
|
|