2016-11-30 17:01:44 +00:00
|
|
|
from app.notify_client import NotifyAdminAPIClient
|
2016-08-08 10:28:40 +01:00
|
|
|
|
|
|
|
|
|
2016-11-30 17:01:44 +00:00
|
|
|
class OrganisationsClient(NotifyAdminAPIClient):
|
2016-08-08 10:28:40 +01:00
|
|
|
|
2016-09-12 12:14:57 +01:00
|
|
|
def __init__(self):
|
2017-07-26 10:23:39 +01:00
|
|
|
super().__init__("a" * 73, "b")
|
2016-08-08 10:28:40 +01:00
|
|
|
|
|
|
|
|
def init_app(self, app):
|
|
|
|
|
self.base_url = app.config['API_HOST_NAME']
|
2017-07-26 12:03:14 +01:00
|
|
|
self.service_id = app.config['ADMIN_CLIENT_USER_NAME']
|
|
|
|
|
self.api_key = app.config['ADMIN_CLIENT_SECRET']
|
2016-08-08 10:28:40 +01:00
|
|
|
|
2016-08-24 09:34:14 +01:00
|
|
|
def get_organisation(self, id):
|
|
|
|
|
return self.get(url='/organisation/{}'.format(id))
|
|
|
|
|
|
2016-08-08 10:28:40 +01:00
|
|
|
def get_organisations(self):
|
|
|
|
|
return self.get(url='/organisation')['organisations']
|
2017-04-20 14:11:51 +01:00
|
|
|
|
|
|
|
|
def get_letter_organisations(self):
|
|
|
|
|
return self.get(url='/dvla_organisations')
|
2017-07-28 15:17:50 +01:00
|
|
|
|
|
|
|
|
def create_organisation(self, logo, name, colour):
|
|
|
|
|
data = {
|
|
|
|
|
"logo": logo,
|
|
|
|
|
"name": name,
|
|
|
|
|
"colour": colour
|
|
|
|
|
}
|
2017-08-01 11:40:26 +01:00
|
|
|
return self.post(url="/organisation", data=data)
|
2017-07-28 15:17:50 +01:00
|
|
|
|
|
|
|
|
def update_organisation(self, org_id, logo, name, colour):
|
|
|
|
|
data = {
|
|
|
|
|
"logo": logo,
|
|
|
|
|
"name": name,
|
|
|
|
|
"colour": colour
|
|
|
|
|
}
|
2017-08-01 11:40:26 +01:00
|
|
|
return self.post(url="/organisation/{}".format(org_id), data=data)
|