Add method for getting the credit status

This commit is contained in:
Mikkel Munch Mortensen 2024-08-22 09:40:27 +02:00
parent 98748f2ff6
commit cf51cebe48
2 changed files with 10 additions and 1 deletions

View file

@ -2,7 +2,7 @@
## New features
TBD
- Add support for getting the credit status from the gateway.
## Changes

View file

@ -116,3 +116,12 @@ class Gateway:
data = json.dumps(options).encode()
return self.request("/v2/send", data=data)
def get_credit_status(self) -> float:
"""Get the credit status."""
# As the amount is returned as a string with a Danish decimal
# separator, we replace this before parsing the amount.
data = self.request("/v2/creditvalue")
amount = float(data["credit"].replace(",", "."))
return amount