Merge pull request #1432 from alphagov/imdad-feat-make-usage-use-new-endpoints

Update the usage page to use new billing endpoints
This commit is contained in:
Imdad Ahad
2017-08-17 15:37:26 +01:00
committed by GitHub
5 changed files with 36 additions and 18 deletions

View File

@@ -0,0 +1,25 @@
from app.notify_client import NotifyAdminAPIClient
class BillingAPIClient(NotifyAdminAPIClient):
# Fudge assert in the super __init__ so
# we can set those variables later.
def __init__(self):
super().__init__("a" * 73, "b")
def init_app(self, application):
self.base_url = application.config['API_HOST_NAME']
self.service_id = application.config['ADMIN_CLIENT_USER_NAME']
self.api_key = application.config['ADMIN_CLIENT_SECRET']
def get_billable_units(self, service_id, year):
return self.get(
'/service/{0}/billing/monthly-usage'.format(service_id),
params=dict(year=year)
)
def get_service_usage(self, service_id, year=None):
return self.get(
'/service/{0}/billing/yearly-usage'.format(service_id),
params=dict(year=year)
)

View File

@@ -228,12 +228,6 @@ class ServiceAPIClient(NotifyAdminAPIClient):
def get_service_history(self, service_id):
return self.get('/service/{0}/history'.format(service_id))
def get_service_usage(self, service_id, year=None):
return self.get(
'/service/{0}/yearly-usage'.format(service_id),
params=dict(year=year)
)
def get_yearly_sms_unit_count_and_cost(self, service_id, year=None):
return self.get(
'/service/{0}/yearly-sms-billable-units'.format(service_id),
@@ -249,12 +243,6 @@ class ServiceAPIClient(NotifyAdminAPIClient):
def update_whitelist(self, service_id, data):
return self.put(url='/service/{}/whitelist'.format(service_id), data=data)
def get_billable_units(self, service_id, year):
return self.get(
'/service/{0}/monthly-usage'.format(service_id),
params=dict(year=year)
)
def get_inbound_sms(self, service_id, user_number=''):
return self.get(
'/service/{}/inbound-sms?user_number={}'.format(