diff --git a/CHANGELOG.md b/CHANGELOG.md index de3c5b8..9f0d003 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## New features -TBD +- Add support for getting the credit status from the gateway. ## Changes diff --git a/cpsms/cpsms.py b/cpsms/cpsms.py index bde7ed3..66762af 100644 --- a/cpsms/cpsms.py +++ b/cpsms/cpsms.py @@ -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