Don’t set combined API on Notify python client

Because we’re setting the API key and service ID after calling the
`__init__` method of the client it wasn’t doing the thing where it
splits the combined key into the two individual UUIDs. So we still need
to set them directly, individually on the client.
This commit is contained in:
Chris Hill-Scott
2017-07-26 12:03:14 +01:00
parent ae1a0b4804
commit 415e1a401a
12 changed files with 24 additions and 48 deletions

View File

@@ -12,10 +12,8 @@ class ApiKeyApiClient(NotifyAdminAPIClient):
def init_app(self, app):
self.base_url = app.config['API_HOST_NAME']
self.api_key = '{}-{}'.format(
app.config['ADMIN_CLIENT_USER_NAME'],
app.config['ADMIN_CLIENT_SECRET'],
)
self.service_id = app.config['ADMIN_CLIENT_USER_NAME']
self.api_key = app.config['ADMIN_CLIENT_SECRET']
def get_api_keys(self, service_id, key_id=None):
if key_id:

View File

@@ -7,10 +7,8 @@ class EventsApiClient(NotifyAdminAPIClient):
def init_app(self, app):
self.base_url = app.config['API_HOST_NAME']
self.api_key = '{}-{}'.format(
app.config['ADMIN_CLIENT_USER_NAME'],
app.config['ADMIN_CLIENT_SECRET'],
)
self.service_id = app.config['ADMIN_CLIENT_USER_NAME']
self.api_key = app.config['ADMIN_CLIENT_SECRET']
def create_event(self, event_type, event_data):
data = {

View File

@@ -9,10 +9,8 @@ class InviteApiClient(NotifyAdminAPIClient):
def init_app(self, app):
self.base_url = app.config['API_HOST_NAME']
self.api_key = '{}-{}'.format(
app.config['ADMIN_CLIENT_USER_NAME'],
app.config['ADMIN_CLIENT_SECRET'],
)
self.service_id = app.config['ADMIN_CLIENT_USER_NAME']
self.api_key = app.config['ADMIN_CLIENT_SECRET']
def create_invite(self, invite_from_id, service_id, email_address, permissions):
data = {

View File

@@ -21,10 +21,8 @@ class JobApiClient(NotifyAdminAPIClient):
def init_app(self, app):
self.base_url = app.config['API_HOST_NAME']
self.api_key = '{}-{}'.format(
app.config['ADMIN_CLIENT_USER_NAME'],
app.config['ADMIN_CLIENT_SECRET'],
)
self.service_id = app.config['ADMIN_CLIENT_USER_NAME']
self.api_key = app.config['ADMIN_CLIENT_SECRET']
@staticmethod
def __convert_statistics(job):

View File

@@ -8,10 +8,8 @@ class LetterJobsClient(NotifyAdminAPIClient):
def init_app(self, app):
self.base_url = app.config['API_HOST_NAME']
self.api_key = '{}-{}'.format(
app.config['ADMIN_CLIENT_USER_NAME'],
app.config['ADMIN_CLIENT_SECRET'],
)
self.service_id = app.config['ADMIN_CLIENT_USER_NAME']
self.api_key = app.config['ADMIN_CLIENT_SECRET']
def get_letter_jobs(self):
return self.get(url='/letter-jobs')['data']

View File

@@ -7,10 +7,8 @@ class NotificationApiClient(NotifyAdminAPIClient):
def init_app(self, app):
self.base_url = app.config['API_HOST_NAME']
self.api_key = '{}-{}'.format(
app.config['ADMIN_CLIENT_USER_NAME'],
app.config['ADMIN_CLIENT_SECRET'],
)
self.service_id = app.config['ADMIN_CLIENT_USER_NAME']
self.api_key = app.config['ADMIN_CLIENT_SECRET']
def get_notifications_for_service(
self,

View File

@@ -8,10 +8,8 @@ class OrganisationsClient(NotifyAdminAPIClient):
def init_app(self, app):
self.base_url = app.config['API_HOST_NAME']
self.api_key = '{}-{}'.format(
app.config['ADMIN_CLIENT_USER_NAME'],
app.config['ADMIN_CLIENT_SECRET'],
)
self.service_id = app.config['ADMIN_CLIENT_USER_NAME']
self.api_key = app.config['ADMIN_CLIENT_SECRET']
def get_organisation(self, id):
return self.get(url='/organisation/{}'.format(id))

View File

@@ -8,10 +8,8 @@ class ProviderClient(NotifyAdminAPIClient):
def init_app(self, app):
self.base_url = app.config['API_HOST_NAME']
self.api_key = '{}-{}'.format(
app.config['ADMIN_CLIENT_USER_NAME'],
app.config['ADMIN_CLIENT_SECRET'],
)
self.service_id = app.config['ADMIN_CLIENT_USER_NAME']
self.api_key = app.config['ADMIN_CLIENT_SECRET']
def get_all_providers(self):
return self.get(

View File

@@ -14,10 +14,8 @@ class ServiceAPIClient(NotifyAdminAPIClient):
def init_app(self, application):
self.base_url = application.config['API_HOST_NAME']
self.api_key = '{}-{}'.format(
application.config['ADMIN_CLIENT_USER_NAME'],
application.config['ADMIN_CLIENT_SECRET'],
)
self.service_id = application.config['ADMIN_CLIENT_USER_NAME']
self.api_key = application.config['ADMIN_CLIENT_SECRET']
def create_service(self, service_name, message_limit, restricted, user_id, email_from):
"""

View File

@@ -8,10 +8,8 @@ class StatusApiClient(NotifyAdminAPIClient):
def init_app(self, app):
self.base_url = app.config['API_HOST_NAME']
self.api_key = '{}-{}'.format(
app.config['ADMIN_CLIENT_USER_NAME'],
app.config['ADMIN_CLIENT_SECRET'],
)
self.service_id = app.config['ADMIN_CLIENT_USER_NAME']
self.api_key = app.config['ADMIN_CLIENT_SECRET']
def get_status(self, *params):
return self.get(url='/_status', *params)

View File

@@ -7,10 +7,8 @@ class TemplateStatisticsApiClient(NotifyAdminAPIClient):
def init_app(self, app):
self.base_url = app.config['API_HOST_NAME']
self.api_key = '{}-{}'.format(
app.config['ADMIN_CLIENT_USER_NAME'],
app.config['ADMIN_CLIENT_SECRET'],
)
self.service_id = app.config['ADMIN_CLIENT_USER_NAME']
self.api_key = app.config['ADMIN_CLIENT_SECRET']
def get_template_statistics_for_service(self, service_id, limit_days=None):
params = {}

View File

@@ -19,10 +19,8 @@ class UserApiClient(NotifyAdminAPIClient):
def init_app(self, app):
self.base_url = app.config['API_HOST_NAME']
self.api_key = '{}-{}'.format(
app.config['ADMIN_CLIENT_USER_NAME'],
app.config['ADMIN_CLIENT_SECRET'],
)
self.service_id = app.config['ADMIN_CLIENT_USER_NAME']
self.api_key = app.config['ADMIN_CLIENT_SECRET']
self.max_failed_login_count = app.config["MAX_FAILED_LOGIN_COUNT"]
def register_user(self, name, email_address, mobile_number, password):