mirror of
https://github.com/Fare-spec/get_ovh_bills.git
synced 2025-12-07 10:20:36 +00:00
add a couple of things
This commit is contained in:
17
fetcher.py
17
fetcher.py
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user