Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions digitalocean/Billing.py
Original file line number Diff line number Diff line change
@@ -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 "<Billing: %s>" % (self.invoice_uuid)
13 changes: 13 additions & 0 deletions digitalocean/Manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down