diff --git a/app/__init__.py b/app/__init__.py index 0d01c194e..75af97bd2 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -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) diff --git a/app/notify_client/organisations_api_client.py b/app/notify_client/organisations_api_client.py new file mode 100644 index 000000000..ade5ad378 --- /dev/null +++ b/app/notify_client/organisations_api_client.py @@ -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)