fix: use consistent camelCase field names in BCV response
Browse files
main.py
CHANGED
|
@@ -93,18 +93,18 @@ async def fetch_bcv() -> dict:
|
|
| 93 |
soup = BeautifulSoup(response.text, "lxml")
|
| 94 |
|
| 95 |
currency_ids = {
|
| 96 |
-
"
|
| 97 |
-
"
|
| 98 |
-
"
|
| 99 |
-
"
|
| 100 |
-
"
|
| 101 |
}
|
| 102 |
|
| 103 |
rates = {}
|
| 104 |
-
for
|
| 105 |
div = soup.find(id=div_id)
|
| 106 |
tag = div.find("strong") if div else None
|
| 107 |
-
rates[f"bcv{
|
| 108 |
|
| 109 |
if all(v is None for v in rates.values()):
|
| 110 |
raise HTTPException(status_code=503, detail="No se pudo obtener las tasas BCV")
|
|
|
|
| 93 |
soup = BeautifulSoup(response.text, "lxml")
|
| 94 |
|
| 95 |
currency_ids = {
|
| 96 |
+
"Usd": "dolar",
|
| 97 |
+
"Eur": "euro",
|
| 98 |
+
"Cny": "yuan",
|
| 99 |
+
"Try": "lira",
|
| 100 |
+
"Rub": "rublo",
|
| 101 |
}
|
| 102 |
|
| 103 |
rates = {}
|
| 104 |
+
for suffix, div_id in currency_ids.items():
|
| 105 |
div = soup.find(id=div_id)
|
| 106 |
tag = div.find("strong") if div else None
|
| 107 |
+
rates[f"bcv{suffix}"] = _parse_bcv_rate(tag.text) if tag else None
|
| 108 |
|
| 109 |
if all(v is None for v in rates.values()):
|
| 110 |
raise HTTPException(status_code=503, detail="No se pudo obtener las tasas BCV")
|