File tree Expand file tree Collapse file tree 2 files changed +9
-17
lines changed
Expand file tree Collapse file tree 2 files changed +9
-17
lines changed Original file line number Diff line number Diff line change @@ -227,6 +227,7 @@ private function buildQuery(array $params): string
227227 $ query [] = urlencode ($ key ) . '= ' . urlencode ($ value );
228228 }
229229 }
230+
230231 return implode ('& ' , $ query );
231232 }
232233
Original file line number Diff line number Diff line change @@ -48,24 +48,15 @@ public function __construct(UniFiClient $client)
4848 */
4949 public function list (array $ hostIds = [], string $ time = null ): array
5050 {
51- $ query = [];
52- if (!empty ($ hostIds )) {
53- $ query ['hostIds ' ] = $ hostIds ;
54- }
51+ /**
52+ * array_filter() removes any null values from the $query array
53+ */
54+ $ query = array_filter ([
55+ 'hostIds ' => !empty ($ hostIds ) ? $ hostIds : null ,
56+ 'time ' => $ time
57+ ]);
5558
56- if ($ time ) {
57- $ query ['time ' ] = $ time ;
58- }
59-
60- if (!empty ($ query ['hostIds ' ])) {
61- $ query = 'hostIds[]= ' . implode ('&hostIds[]= ' , $ query ['hostIds ' ]) . (isset ($ query ['time ' ]) ? '&time= ' . $ query ['time ' ] : '' );
62- }
63-
64- $ options = [
65- 'query ' => $ query
66- ];
67-
68- return $ this ->client ->request ('GET ' , '/ea/devices ' , $ options );
59+ return $ this ->client ->request ('GET ' , '/ea/devices ' , ['query ' => $ query ]);
6960 }
7061
7162 /**
You can’t perform that action at this time.
0 commit comments