mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-24 08:16:51 -04:00
Fix calls to API client which now takes fewer args
The Notify API client changed in version 4 to take two arguments, not three (service ID was removed in favour of the combined API key). This gets a bit gnarly because the API key has to be at least a certain length so it can be substringed internally.
This commit is contained in:
@@ -8,12 +8,14 @@ KEY_TYPE_TEST = 'test'
|
||||
|
||||
class ApiKeyApiClient(NotifyAdminAPIClient):
|
||||
def __init__(self):
|
||||
super().__init__("a", "b", "c")
|
||||
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']
|
||||
self.api_key = '{}-{}'.format(
|
||||
app.config['ADMIN_CLIENT_USER_NAME'],
|
||||
app.config['ADMIN_CLIENT_SECRET'],
|
||||
)
|
||||
|
||||
def get_api_keys(self, service_id, key_id=None):
|
||||
if key_id:
|
||||
|
||||
@@ -3,12 +3,14 @@ from app.notify_client import NotifyAdminAPIClient
|
||||
|
||||
class EventsApiClient(NotifyAdminAPIClient):
|
||||
def __init__(self):
|
||||
super().__init__("a", "b", "c")
|
||||
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']
|
||||
self.api_key = '{}-{}'.format(
|
||||
app.config['ADMIN_CLIENT_USER_NAME'],
|
||||
app.config['ADMIN_CLIENT_SECRET'],
|
||||
)
|
||||
|
||||
def create_event(self, event_type, event_data):
|
||||
data = {
|
||||
|
||||
@@ -5,12 +5,14 @@ from app.notify_client.models import InvitedUser
|
||||
|
||||
class InviteApiClient(NotifyAdminAPIClient):
|
||||
def __init__(self):
|
||||
super().__init__("a", "b", "c")
|
||||
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']
|
||||
self.api_key = '{}-{}'.format(
|
||||
app.config['ADMIN_CLIENT_USER_NAME'],
|
||||
app.config['ADMIN_CLIENT_SECRET'],
|
||||
)
|
||||
|
||||
def create_invite(self, invite_from_id, service_id, email_address, permissions):
|
||||
data = {
|
||||
|
||||
@@ -17,12 +17,14 @@ class JobApiClient(NotifyAdminAPIClient):
|
||||
}
|
||||
|
||||
def __init__(self):
|
||||
super().__init__("a", "b", "c")
|
||||
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']
|
||||
self.api_key = '{}-{}'.format(
|
||||
app.config['ADMIN_CLIENT_USER_NAME'],
|
||||
app.config['ADMIN_CLIENT_SECRET'],
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def __convert_statistics(job):
|
||||
|
||||
@@ -4,12 +4,14 @@ from app.notify_client import NotifyAdminAPIClient
|
||||
class LetterJobsClient(NotifyAdminAPIClient):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__("a", "b", "c")
|
||||
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']
|
||||
self.api_key = '{}-{}'.format(
|
||||
app.config['ADMIN_CLIENT_USER_NAME'],
|
||||
app.config['ADMIN_CLIENT_SECRET'],
|
||||
)
|
||||
|
||||
def get_letter_jobs(self):
|
||||
return self.get(url='/letter-jobs')['data']
|
||||
|
||||
@@ -3,12 +3,14 @@ from app.notify_client import _attach_current_user, NotifyAdminAPIClient
|
||||
|
||||
class NotificationApiClient(NotifyAdminAPIClient):
|
||||
def __init__(self):
|
||||
super().__init__("a", "b", "c")
|
||||
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']
|
||||
self.api_key = '{}-{}'.format(
|
||||
app.config['ADMIN_CLIENT_USER_NAME'],
|
||||
app.config['ADMIN_CLIENT_SECRET'],
|
||||
)
|
||||
|
||||
def get_notifications_for_service(
|
||||
self,
|
||||
|
||||
@@ -4,12 +4,14 @@ from app.notify_client import NotifyAdminAPIClient
|
||||
class OrganisationsClient(NotifyAdminAPIClient):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__("a", "b", "c")
|
||||
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']
|
||||
self.api_key = '{}-{}'.format(
|
||||
app.config['ADMIN_CLIENT_USER_NAME'],
|
||||
app.config['ADMIN_CLIENT_SECRET'],
|
||||
)
|
||||
|
||||
def get_organisation(self, id):
|
||||
return self.get(url='/organisation/{}'.format(id))
|
||||
|
||||
@@ -4,12 +4,14 @@ from app.notify_client import _attach_current_user, NotifyAdminAPIClient
|
||||
|
||||
class ProviderClient(NotifyAdminAPIClient):
|
||||
def __init__(self):
|
||||
super().__init__("a", "b", "c")
|
||||
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']
|
||||
self.api_key = '{}-{}'.format(
|
||||
app.config['ADMIN_CLIENT_USER_NAME'],
|
||||
app.config['ADMIN_CLIENT_SECRET'],
|
||||
)
|
||||
|
||||
def get_all_providers(self):
|
||||
return self.get(
|
||||
|
||||
@@ -10,12 +10,14 @@ class ServiceAPIClient(NotifyAdminAPIClient):
|
||||
# Fudge assert in the super __init__ so
|
||||
# we can set those variables later.
|
||||
def __init__(self):
|
||||
super().__init__("a", "b", "c")
|
||||
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']
|
||||
self.api_key = '{}-{}'.format(
|
||||
application.config['ADMIN_CLIENT_USER_NAME'],
|
||||
application.config['ADMIN_CLIENT_SECRET'],
|
||||
)
|
||||
|
||||
def create_service(self, service_name, message_limit, restricted, user_id, email_from):
|
||||
"""
|
||||
|
||||
@@ -4,12 +4,14 @@ from app.notify_client import NotifyAdminAPIClient
|
||||
|
||||
class StatusApiClient(NotifyAdminAPIClient):
|
||||
def __init__(self):
|
||||
super().__init__("a", "b", "c")
|
||||
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']
|
||||
self.api_key = '{}-{}'.format(
|
||||
app.config['ADMIN_CLIENT_USER_NAME'],
|
||||
app.config['ADMIN_CLIENT_SECRET'],
|
||||
)
|
||||
|
||||
def get_status(self, *params):
|
||||
return self.get(url='/_status', *params)
|
||||
|
||||
@@ -3,12 +3,14 @@ from app.notify_client import NotifyAdminAPIClient
|
||||
|
||||
class TemplateStatisticsApiClient(NotifyAdminAPIClient):
|
||||
def __init__(self):
|
||||
super().__init__("a", "b", "c")
|
||||
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']
|
||||
self.api_key = '{}-{}'.format(
|
||||
app.config['ADMIN_CLIENT_USER_NAME'],
|
||||
app.config['ADMIN_CLIENT_SECRET'],
|
||||
)
|
||||
|
||||
def get_template_statistics_for_service(self, service_id, limit_days=None):
|
||||
params = {}
|
||||
|
||||
@@ -15,12 +15,14 @@ ALLOWED_ATTRIBUTES = {
|
||||
|
||||
class UserApiClient(NotifyAdminAPIClient):
|
||||
def __init__(self):
|
||||
super().__init__("a", "b", "c")
|
||||
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']
|
||||
self.api_key = '{}-{}'.format(
|
||||
app.config['ADMIN_CLIENT_USER_NAME'],
|
||||
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):
|
||||
|
||||
Reference in New Issue
Block a user