Extrahiert die wichtigste DB-/netzwerkfreie Geschäftslogik (Monatsnavigation, Admin-/Aktien-Rollenprüfung, Aktien-GuV-Berechnung, OpenFIGI-/Alpha-Vantage- Antwortauswertung, Eingabevalidierung, CSV-Export, Migrations-Logik) nach html/lib/fscash.php und deckt sie mit 31 PHPUnit-Tests ab. update.sh installiert Composer-Abhängigkeiten bei Bedarf und führt die Tests jetzt vor jedem Deploy aus - bei Fehlschlag wird nichts kopiert oder migriert. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
45 lines
882 B
PHP
45 lines
882 B
PHP
<?php
|
|
|
|
require_once __DIR__ . '/lib/fscash.php';
|
|
|
|
function get2symbol(string $isin, string $openFigiApiKey): ?string
|
|
{
|
|
$url = "https://api.openfigi.com/v3/mapping";
|
|
|
|
$postData = json_encode([
|
|
[
|
|
"idType" => "ID_ISIN",
|
|
"idValue" => $isin
|
|
]
|
|
]);
|
|
|
|
$headers = [
|
|
"Content-Type: application/json",
|
|
"X-OPENFIGI-APIKEY: $openFigiApiKey"
|
|
];
|
|
|
|
$ch = curl_init();
|
|
curl_setopt($ch, CURLOPT_URL, $url);
|
|
curl_setopt($ch, CURLOPT_POST, true);
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
|
|
$response = curl_exec($ch);
|
|
|
|
if (curl_errno($ch)) {
|
|
curl_close($ch);
|
|
return null;
|
|
}
|
|
|
|
curl_close($ch);
|
|
|
|
$data = json_decode($response, true);
|
|
|
|
if (!isset($data[0]['data']) || empty($data[0]['data'])) {
|
|
return null;
|
|
}
|
|
|
|
return fscash_select_figi_symbol($data[0]['data']);
|
|
}
|
|
|