Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix DeviceFactory stats property #37

Merged
merged 2 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Factories/DeviceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function make(array $data): Device
profile: (new ProfileFactory())->make($data['profile']),
profile2: ! empty($data['profile2']) ? (new ProfileFactory())->make($data['profile2']) : null,
description: $data['description'] ?? '',
stats: DeviceAnalytics::tryFrom($data['stats'] ?? null),
stats: ! empty($data['stats']) ? DeviceAnalytics::tryFrom($data['stats']) : DeviceAnalytics::OFF,
icon: $data['icon'] ?? null,
dynamicDns: $dynamicDns ?? null,
dynamicDnsExternal: $externalDns ?? null,
Expand Down
46 changes: 23 additions & 23 deletions src/Resources/Devices.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ public function create(
string $name,
string $profilePk,
string $icon,
string $profilePk2 = null,
int $stats = null,
?string $profilePk2 = null,
?int $stats = null,
bool $legacyIpv4Status = false,
bool $learnIp = false,
bool $restricted = false,
bool $bumpTls = false,
string $description = null,
int $ddnsStatus = null,
string $ddnsSubdomain = null,
int $ddnsExternalStatus = null,
string $ddnsExternalHost = null,
?string $description = null,
?int $ddnsStatus = null,
?string $ddnsSubdomain = null,
?int $ddnsExternalStatus = null,
?string $ddnsExternalHost = null,
): Device {
$response = $this->client->post('devices', [
'name' => $name,
Expand Down Expand Up @@ -91,22 +91,22 @@ public function analyticsLevels(): array

public function modify(
string $devicePk,
string $name = null,
string $profilePk = null,
string $icon = null,
string $profilePk2 = null,
int $stats = null,
bool $legacyIpv4Status = null,
bool $learnIp = null,
bool $restricted = null,
bool $bumpTls = null,
string $description = null,
int $ddnsStatus = null,
string $ddnsSubdomain = null,
int $ddnsExternalStatus = null,
string $ddnsExternalHost = null,
DeviceStatus $status = null,
string $ctrldCustomConfig = null,
?string $name = null,
?string $profilePk = null,
?string $icon = null,
?string $profilePk2 = null,
?int $stats = null,
?bool $legacyIpv4Status = null,
?bool $learnIp = null,
?bool $restricted = null,
?bool $bumpTls = null,
?string $description = null,
?int $ddnsStatus = null,
?string $ddnsSubdomain = null,
?int $ddnsExternalStatus = null,
?string $ddnsExternalHost = null,
?DeviceStatus $status = null,
?string $ctrldCustomConfig = null,
): Device {
$response = $this->client->put("devices/{$devicePk}", [
'name' => $name,
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/MobileConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function generateProfile(
array $excludeDomain = [],
bool $dontSign = false,
bool $excludeCommon = false,
string $clientId = null,
?string $clientId = null,
): string {
return $this->client->get("mobileconfig/{$devicePk}", [
'exclude_wifi' => $excludeWifi,
Expand Down
32 changes: 16 additions & 16 deletions src/Resources/Organizations.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ public function createSubOrganization(
string $statsEndpoint,
int $maxUsers,
int $maxRouters,
string $address = null,
string $website = null,
string $contactName = null,
string $contactPhone = null,
string $parentProfile = null,
?string $address = null,
?string $website = null,
?string $contactName = null,
?string $contactPhone = null,
?string $parentProfile = null,
): Organization {
$response = $this->client->post('organizations/suborg', [
'name' => $name,
Expand All @@ -85,17 +85,17 @@ public function createSubOrganization(
}

public function modifyOrganization(
string $name = null,
string $contactEmail = null,
bool $twoFactorAuthenticationRequired = null,
string $statsEndpoint = null,
int $maxUsers = null,
int $maxRouters = null,
string $address = null,
string $website = null,
string $contactName = null,
string $contactPhone = null,
string $parentProfile = null,
?string $name = null,
?string $contactEmail = null,
?bool $twoFactorAuthenticationRequired = null,
?string $statsEndpoint = null,
?int $maxUsers = null,
?int $maxRouters = null,
?string $address = null,
?string $website = null,
?string $contactName = null,
?string $contactPhone = null,
?string $parentProfile = null,
): Organization {
$response = $this->client->put('organizations', [
'name' => $name,
Expand Down
4 changes: 2 additions & 2 deletions src/Resources/Profiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function list(): ProfileList
return $result;
}

public function create(string $name, string $cloneProfileId = null): Profile
public function create(string $name, ?string $cloneProfileId = null): Profile
{
$profile = $this->client->post('profiles', [
'name' => $name,
Expand All @@ -48,7 +48,7 @@ public function create(string $name, string $cloneProfileId = null): Profile
return $this->profile->make($profile);
}

public function modify(string $profilePk, string $name = null, int $disableTtl = null): Profile
public function modify(string $profilePk, ?string $name = null, ?int $disableTtl = null): Profile
{
$profile = $this->client->post("profiles/{$profilePk}", [
'name' => $name,
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/Profiles/CustomRules.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function __construct(private readonly PendingRequest $client, private rea
{
}

public function list(string $profilePk, int $folderPk = null): \Rapkis\Controld\Responses\CustomRules
public function list(string $profilePk, ?int $folderPk = null): \Rapkis\Controld\Responses\CustomRules
{
$folderPk = $folderPk ?? 'all'; // This is the default folder in ControlD that lists all rules
$response = $this->client->get("profiles/{$profilePk}/rules/{$folderPk}")->json('body.rules');
Expand Down