add a couple of things

This commit is contained in:
2025-09-04 21:44:29 +02:00
parent 363e5cd8c0
commit 89ff54acfe
2 changed files with 47 additions and 15 deletions

View File

@@ -1,5 +1,4 @@
import json
from re import error
from typing import Any, cast
import ovh
@@ -10,13 +9,21 @@ def fetch_api(app_key: str, app_secret: str, consumer_key: str) -> list[str]:
application_secret=app_secret,
consumer_key=consumer_key,
)
bills = client.get("/me/bill/")
data: Any = client.get("/me/bill/")
if data is None:
return []
if not isinstance(data, list) or not all(isinstance(x, str) for x in data):
raise TypeError("Réponse OVH inattendue pour /me/bill/: liste de str requise")
bills: list[str] = cast(list[str], data)
return bills
def fetch_invoice_content(
id: str, app_key: str, app_secret: str, consumer_key: str
) -> dict:
) -> dict[str, Any]:
client = ovh.Client(
endpoint="ovh-eu",
application_key=app_key,
@@ -24,4 +31,6 @@ def fetch_invoice_content(
consumer_key=consumer_key,
)
bill = client.get(f"/me/bill/{id}")
if bill is None:
raise RuntimeError(f"Facture {id} introuvable")
return bill