fx-rates
All checks were successful
Deploy / deploy-staging (push) Successful in 6s
Deploy / deploy-production (push) Has been skipped

This commit is contained in:
2026-04-29 00:53:38 +02:00
parent 1dd74d4674
commit 74b1651eac
4 changed files with 301 additions and 7 deletions

View File

@@ -29,6 +29,10 @@ final class Router
if ($path === 'v1/latest' && $method === 'GET') {
$symbols = $this->parseCsv($_GET['symbols'] ?? null);
$base = $this->stringOrNull($_GET['base'] ?? null);
if ($symbols === null) {
$settings = module_fn('fx-rates', 'settings');
$symbols = is_array($settings['preferred_currencies'] ?? null) ? $settings['preferred_currencies'] : null;
}
$snapshot = $this->service->snapshot($base, null, $symbols, null);
$this->respond(['data' => $snapshot]);
}
@@ -65,6 +69,10 @@ final class Router
$input = $this->input();
$base = $this->stringOrNull($input['base'] ?? null);
$currencies = $this->parseCsv($input['currencies'] ?? null);
if ($currencies === null) {
$settings = module_fn('fx-rates', 'settings');
$currencies = is_array($settings['preferred_currencies'] ?? null) ? $settings['preferred_currencies'] : null;
}
$force = !empty($input['force']);
$maxAgeHours = is_numeric($input['max_age_hours'] ?? null) ? (float) $input['max_age_hours'] : 24.0;
@@ -84,6 +92,18 @@ final class Router
$this->respond(['data' => $this->service->probeCurrencyCatalog()]);
}
if ($path === 'v1/currencies-refresh' && $method === 'POST') {
$this->respond(['data' => $this->service->refreshCurrencyCatalog()], 201);
}
if ($path === 'v1/settings' && $method === 'GET') {
$this->respond(['data' => module_fn('fx-rates', 'settings')]);
}
if ($path === 'v1/settings' && $method === 'PUT') {
$this->respond(['data' => module_fn('fx-rates', 'save_runtime_settings', $this->input())]);
}
$this->respond(['error' => 'Unbekannter API-Pfad.'], 404);
} catch (\Throwable $exception) {
$this->respond([