Add Organisations API Client

This commit is contained in:
Ken Tsang
2018-02-08 12:18:37 +00:00
parent 4eea97c83b
commit b11bfd49e3
2 changed files with 33 additions and 0 deletions

View File

@@ -51,6 +51,7 @@ from app.notify_client.events_api_client import EventsApiClient
from app.notify_client.provider_client import ProviderClient
from app.notify_client.email_branding_client import EmailBrandingClient
from app.notify_client.models import AnonymousUser
from app.notify_client.organisations_api_client import OrganisationsClient
from app.notify_client.letter_jobs_client import LetterJobsClient
from app.notify_client.inbound_number_client import InboundNumberClient
from app.notify_client.billing_api_client import BillingAPIClient
@@ -72,6 +73,7 @@ template_statistics_client = TemplateStatisticsApiClient()
events_api_client = EventsApiClient()
provider_client = ProviderClient()
email_branding_client = EmailBrandingClient()
organisations_client = OrganisationsClient()
asset_fingerprinter = AssetFingerprinter()
statsd_client = StatsdClient()
deskpro_client = DeskproClient()
@@ -108,6 +110,7 @@ def create_app(application):
events_api_client.init_app(application)
provider_client.init_app(application)
email_branding_client.init_app(application)
organisations_client.init_app(application)
letter_jobs_client.init_app(application)
inbound_number_client.init_app(application)
billing_api_client.init_app(application)

View File

@@ -0,0 +1,30 @@
from app.notify_client import NotifyAdminAPIClient
class OrganisationsClient(NotifyAdminAPIClient):
def __init__(self):
super().__init__("a" * 73, "b")
def init_app(self, app):
self.base_url = app.config['API_HOST_NAME']
self.service_id = app.config['ADMIN_CLIENT_USER_NAME']
self.api_key = app.config['ADMIN_CLIENT_SECRET']
def get_organisations(self):
return self.get(url='/organisations')
def get_organisation(self, org_id):
return self.get(url='/organisations/{}'.format(org_id))
def create_organisation(self, name):
data = {
"name": name
}
return self.post(url="/organisations", data=data)
def update_organisation(self, org_id, name):
data = {
"name": name
}
return self.post(url="/organisations/{}".format(org_id), data=data)