feat(vikon): extract API URL from hardcoded to integration_credentials

- Rename ViconApiToken → ViconApiConfig with token() and apiUrl()
- Replace 9 hardcoded db-nica.ru URLs with dynamic apiUrl()
- Payload now stores both token and api_url with fallback
This commit is contained in:
F4ilji
2026-07-10 16:47:18 +05:00
parent 7748b05547
commit 73a0a6fe9c
4 changed files with 28 additions and 19 deletions
+32
View File
@@ -0,0 +1,32 @@
<?php
namespace App\Services\Vicon;
use App\Containers\Dashboard\Tasks\IntegrationCredentials\GetIntegrationCredentialTask;
class ViconApiConfig
{
private const FALLBACK_API_URL = 'https://db-nica.ru/api/v1';
public function __construct(
private readonly GetIntegrationCredentialTask $getCredential,
) {}
public function token(): string
{
$credential = $this->getCredential->run('vikon_api');
if (!$credential || empty($credential->payload['token'])) {
throw new \RuntimeException('VIKON API token not configured. Add it in /dashboard/integration-credentials.');
}
return $credential->payload['token'];
}
public function apiUrl(): string
{
$credential = $this->getCredential->run('vikon_api');
return $credential->payload['api_url'] ?? self::FALLBACK_API_URL;
}
}