fx-rates
This commit is contained in:
@@ -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([
|
||||
|
||||
Reference in New Issue
Block a user