Client devices history (#266)

* Add list active devices endpoint

* Add list clients history endpoint
This commit is contained in:
Jacob Timmerman
2025-03-03 14:14:34 +01:00
committed by GitHub
parent 1d363deb18
commit 13cb313cd9

View File

@@ -1091,6 +1091,45 @@ class Client
return $this->fetch_results('/api/s/' . $this->site . '/stat/sta/' . $mac);
}
/**
* Fetch active client devices
*
* @param bool $includeTrafficUsage include the traffic usage of the client devices in the response
* @param bool $includeUnifiDevices include UniFi devices in the response
* @return array|bool returns an array of active client device objects, false upon error
* @throws Exception
*/
public function list_active_clients(bool $includeTrafficUsage = true, bool $includeUnifiDevices = true)
{
$query = http_build_query([
'includeTrafficUsage' => $includeTrafficUsage,
'includeUnifiDevices' => $includeUnifiDevices,
]);
return $this->fetch_results('/v2/api/site/' . $this->site . '/clients/active?' . $query);
}
/**
* Fetch client devices history (offline client devices)
*
* @param bool $onlyNonBlocked include non-blocked client devices in the response
* @param bool $includeUnifiDevices include UniFi devices in the response
* @param int $withinHours the number of hours a device has been offline to be included in the response
* (0 = no limit)
* @return array|bool returns an array of (offline) client device objects, false upon error
* @throws Exception
*/
public function list_clients_history(bool $onlyNonBlocked = true, bool $includeUnifiDevices = true, int $withinHours = 0)
{
$query = http_build_query([
'onlyNonBlocked' => $onlyNonBlocked,
'includeUnifiDevices' => $includeUnifiDevices,
'withinHours' => $withinHours,
]);
return $this->fetch_results('/v2/api/site/' . $this->site . '/clients/history?' . $query);
}
/**
* Fetch details for a single client device
*