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 31fa745..50617e4 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 @@ -41,6 +42,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.