From 91ee27e00517e3890b95e2e028e160eff04a776d Mon Sep 17 00:00:00 2001 From: Mehmetcan Yegen Date: Mon, 1 Feb 2021 19:22:57 +0300 Subject: [PATCH] added billing_history support --- digitalocean/Billing.py | 16 ++++++++++++++++ digitalocean/Manager.py | 13 +++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 digitalocean/Billing.py diff --git a/digitalocean/Billing.py b/digitalocean/Billing.py new file mode 100644 index 0000000..8e86691 --- /dev/null +++ b/digitalocean/Billing.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +from .baseapi import BaseAPI + + +class Billing(BaseAPI): + def __init__(self, *args, **kwargs): + self.description = None + self.amount = None + self.invoice_id = None + self.invoice_uuid = None + self.date = None + self.type = None + super(Billing, self).__init__(*args, **kwargs) + + def __str__(self): + return "" % (self.invoice_uuid) \ No newline at end of file diff --git a/digitalocean/Manager.py b/digitalocean/Manager.py index acd8f28..98eb63c 100644 --- a/digitalocean/Manager.py +++ b/digitalocean/Manager.py @@ -8,6 +8,7 @@ from .Account import Account from .Action import Action from .Balance import Balance +from .Billing import Billing from .Certificate import Certificate from .Domain import Domain from .Droplet import Droplet @@ -42,6 +43,18 @@ def get_balance(self): """ return Balance.get_object(api_token=self.token) + def get_billing_history(self): + """ + Billing history of the account + """ + data = self.get_data("customers/my/billing_history") + billing_history = list() + for jsoned in data['billing_history']: + billing = Billing(**jsoned) + billing.token = self.token + billing_history.append(billing) + return billing_history + def get_all_regions(self): """ This function returns a list of Region object.