Skip to content

Commit

Permalink
- minor changes to apply consistent formatting/case
Browse files Browse the repository at this point in the history
  • Loading branch information
malle-pietje committed Mar 9, 2025
1 parent 3e99b7b commit 2cc60db
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 42 deletions.
14 changes: 7 additions & 7 deletions API_REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,26 +167,26 @@ Sets the name for a specific client.

### List Active Clients
```php
public function list_active_clients(bool $includeTrafficUsage = true, bool $includeUnifiDevices = true): array
public function list_active_clients(bool $include_traffic_usage = true, bool $include_unifi_devices = true): array
```
Lists all currently active clients.

**Parameters:**
- `$includeTrafficUsage` (bool): Whether to include traffic usage information (default: true)
- `$includeUnifiDevices` (bool): Whether to include UniFi devices (default: true)
- `$include_traffic_usage` (bool): Whether to include traffic usage information (default: true)
- `$include_unifi_devices` (bool): Whether to include UniFi devices (default: true)

**Returns:** array - Array of active client objects

### List Client History
```php
public function list_clients_history(bool $onlyNonBlocked = true, bool $includeUnifiDevices = true, int $withinHours = 0): array
public function list_clients_history(bool $only_non_blocked = true, bool $include_unifi_devices = true, int $within_hours = 0): array
```
Lists historical client information.

**Parameters:**
- `$onlyNonBlocked` (bool): Whether to only show non-blocked clients (default: true)
- `$includeUnifiDevices` (bool): Whether to include UniFi devices (default: true)
- `$withinHours` (int): Hours of history to retrieve (default: 0)
- `$only_non_blocked` (bool): Whether to only show non-blocked clients (default: true)
- `$include_unifi_devices` (bool): Whether to include UniFi devices (default: true)
- `$within_hours` (int): Hours of history to retrieve (default: 0)

**Returns:** array - Array of historical client objects

Expand Down
44 changes: 22 additions & 22 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use UniFi_API\Exceptions\LoginFailedException;
use UniFi_API\Exceptions\LoginRequiredException;
use UniFi_API\Exceptions\MethodDeprecatedException;
use UniFi_API\Exceptions\NotAnOsConsoleException;
use UniFi_API\Exceptions\NotAUnifiOsConsoleException;

/**
* The UniFi API client class.
Expand All @@ -34,7 +34,7 @@
class Client
{
/** Constants. */
const CLASS_VERSION = '2.0.3';
const CLASS_VERSION = '2.0.5';
const CURL_METHODS_ALLOWED = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'];
const DEFAULT_CURL_METHOD = 'GET';

Expand Down Expand Up @@ -85,7 +85,7 @@ class Client
*
* @param string $user username to use when connecting to the UniFi controller
* @param string $password password to use when connecting to the UniFi controller
* @param string $baseurl base URL of the UniFi controller which *must* include an 'https://' prefix,
* @param string $baseurl base URL of the UniFi controller which *must* include a 'https://' prefix,
* a port suffix (e.g. :8443) is required for non-UniFi OS controllers,
* do not add trailing slashes, defaults to 'https://127.0.0.1:8443'
* @param string|null $site short site name to access, defaults to 'default'
Expand Down Expand Up @@ -302,8 +302,8 @@ public function logout(): bool
* @param int|null $up optional, upload speed limit in kbps
* @param int|null $down optional, download speed limit in kbps
* @param int|null $megabytes optional, data transfer limit in MB
* @param string|null $ap_mac optional, AP MAC address to which client is connected, should result in faster
* authorization for the client device
* @param string|null $ap_mac optional, AP MAC address to which the client is connected
* (should result in faster authorization for the client device)
* @return bool true upon success
* @throws Exception
*/
Expand Down Expand Up @@ -725,8 +725,8 @@ public function stat_monthly_aps(?int $start = null, ?int $end = null, ?string $
* - only supported with UniFi controller versions 5.8.X and higher
* - make sure that the retention policy for 5-minute stats is set to the correct value in
* the controller settings
* - make sure that "Clients Historical Data" has been enabled in the UniFi controller settings in the Maintenance
* section
* - make sure that the "Clients Historical Data" option has been enabled in the UniFi controller settings in
* the Maintenance section
* @param string|null $mac optional, MAC address of the user/client device to return stats for
* @param int|null $start optional, Unix timestamp in milliseconds
* @param int|null $end optional, Unix timestamp in milliseconds
Expand Down Expand Up @@ -1095,16 +1095,16 @@ public function list_clients(?string $mac = null)
/**
* 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
* @param bool $include_traffic_usage include the traffic usage of the client devices in the response
* @param bool $include_unifi_devices 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)
public function list_active_clients(bool $include_traffic_usage = true, bool $include_unifi_devices = true)
{
$query = http_build_query([
'includeTrafficUsage' => $includeTrafficUsage,
'includeUnifiDevices' => $includeUnifiDevices,
'include_traffic_usage' => $include_traffic_usage,
'include_unifi_devices' => $include_unifi_devices,
]);

return $this->fetch_results('/v2/api/site/' . $this->site . '/clients/active?' . $query);
Expand All @@ -1113,19 +1113,19 @@ public function list_active_clients(bool $includeTrafficUsage = true, bool $incl
/**
* 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
* @param bool $only_non_blocked include non-blocked client devices in the response
* @param bool $include_unifi_devices include UniFi devices in the response
* @param int $within_hours 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)
public function list_clients_history(bool $only_non_blocked = true, bool $include_unifi_devices = true, int $within_hours = 0)
{
$query = http_build_query([
'onlyNonBlocked' => $onlyNonBlocked,
'includeUnifiDevices' => $includeUnifiDevices,
'withinHours' => $withinHours,
'only_non_blocked' => $only_non_blocked,
'include_unifi_devices' => $include_unifi_devices,
'within_hours' => $within_hours,
]);

return $this->fetch_results('/v2/api/site/' . $this->site . '/clients/history?' . $query);
Expand Down Expand Up @@ -3268,7 +3268,7 @@ public function check_controller_update()
public function get_update_os_console()
{
if (!$this->is_unifi_os) {
throw new NotAnOsConsoleException();
throw new NotAUnifiOsConsoleException();
}

return $this->fetch_results('/api/firmware/update', null, false, true, false);
Expand All @@ -3284,7 +3284,7 @@ public function get_update_os_console()
public function update_os_console(): bool
{
if (!$this->is_unifi_os) {
throw new NotAnOsConsoleException();
throw new NotAUnifiOsConsoleException();
}

$payload = ['persistFullData' => true];
Expand Down Expand Up @@ -4453,7 +4453,7 @@ protected function create_x_csrf_token_header()
/**
* Callback function for cURL to extract and store cookies as needed.
*
* @param object|resource $ch the cURL instance (type hinting is unavailable for cURL resources)
* @param object|resource|false $ch the cURL instance (type hinting is unavailable for cURL resources)
* @param string $header_line the response header line number
* @return int length of the header line
*/
Expand Down
13 changes: 13 additions & 0 deletions src/Exceptions/NotAUnifiOsConsoleException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace UniFi_API\Exceptions;

use Exception;

class NotAUnifiOsConsoleException extends Exception
{
public function __construct()
{
parent::__construct('This is not a UniFi OS console.');
}
}
13 changes: 0 additions & 13 deletions src/Exceptions/NotAnOsConsoleException.php

This file was deleted.

0 comments on commit 2cc60db

Please sign in to comment.