Files
JiriUhlir e39f52f027 Dalsi banky, prehled ve Swaggeru, /status a prazdne promenne
- zdroje rb, unicredit a air
- nahore ve Swaggeru prehled nabizenych a nenabizenych bank s duvody
- GET /status s prehledem vypadku stahovani u jednotlivych bank
- prazdna promenna prostredi znamena vychozi hodnotu
- popis stahovani v documentation/stahovani.md
2026-11-04 15:33:21 +01:00

32 lines
1.2 KiB
Python

"""Raiffeisenbank: the JSON endpoint used by the bank's own rate list page."""
import json
from datetime import datetime
from app.models import ParsedRates
from app.sources.base import PRAGUE_ZONE, make_rate
def parse(document: str) -> ParsedRates:
# The bank publishes several lists a day, only the last one is currently valid.
rate_lists = json.loads(document)["exchangeRateLists"]
current = next((item for item in rate_lists if item["lastRates"]), None)
if current is None:
raise ValueError("Raiffeisenbank current rate list not found")
# exchangeRateBuy and exchangeRateSell are non-cash, the cash rates have a Cash suffix.
rates = [
make_rate(
currency=item["currencyFrom"],
amount=item["unitsFrom"],
buy=item["exchangeRateBuy"],
sell=item["exchangeRateSell"],
middle=item["exchangeRateCenter"],
)
for item in current["exchangeRates"]
if item["exchangeRateBuy"] and item["exchangeRateSell"]
]
valid_from = datetime.fromisoformat(current["effectiveDateFrom"])
return ParsedRates(valid_date=valid_from.astimezone(PRAGUE_ZONE).date(), rates=rates)