mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-25 18:38:57 -04:00
Inherit don’t duplicate API client constructor
This removes some code which is duplicative and obscure (ie it’s not very clear why we do `"a" * 73` even though there is a Very Good Reason for doing so).
This commit is contained in:
@@ -16,6 +16,9 @@ class NotifyAdminAPIClient(BaseAPIClient):
|
||||
|
||||
redis_client = RedisClient()
|
||||
|
||||
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']
|
||||
|
||||
@@ -7,8 +7,6 @@ KEY_TYPE_TEST = 'test'
|
||||
|
||||
|
||||
class ApiKeyApiClient(NotifyAdminAPIClient):
|
||||
def __init__(self):
|
||||
super().__init__("a" * 73, "b")
|
||||
|
||||
def get_api_keys(self, service_id):
|
||||
return self.get(url='/service/{}/api-keys'.format(service_id))
|
||||
|
||||
@@ -2,10 +2,6 @@ from app.notify_client import NotifyAdminAPIClient
|
||||
|
||||
|
||||
class BillingAPIClient(NotifyAdminAPIClient):
|
||||
# Fudge assert in the super __init__ so
|
||||
# we can set those variables later.
|
||||
def __init__(self):
|
||||
super().__init__("a" * 73, "b")
|
||||
|
||||
def get_billable_units_ft(self, service_id, year):
|
||||
return self.get(
|
||||
|
||||
@@ -2,10 +2,6 @@ from app.notify_client import NotifyAdminAPIClient
|
||||
|
||||
|
||||
class ComplaintApiClient(NotifyAdminAPIClient):
|
||||
# Fudge assert in the super __init__ so
|
||||
# we can set those variables later.
|
||||
def __init__(self):
|
||||
super().__init__("a" * 73, "b")
|
||||
|
||||
def get_all_complaints(self, page=1):
|
||||
params = {'page': page}
|
||||
|
||||
@@ -3,9 +3,6 @@ from app.notify_client import NotifyAdminAPIClient, cache
|
||||
|
||||
class EmailBrandingClient(NotifyAdminAPIClient):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__("a" * 73, "b")
|
||||
|
||||
@cache.set('email_branding-{branding_id}')
|
||||
def get_email_branding(self, branding_id):
|
||||
return self.get(url='/email-branding/{}'.format(branding_id))
|
||||
|
||||
@@ -2,8 +2,6 @@ from app.notify_client import NotifyAdminAPIClient
|
||||
|
||||
|
||||
class EventsApiClient(NotifyAdminAPIClient):
|
||||
def __init__(self):
|
||||
super().__init__("a" * 73, "b")
|
||||
|
||||
def create_event(self, event_type, event_data):
|
||||
data = {
|
||||
|
||||
@@ -3,9 +3,6 @@ from app.notify_client import NotifyAdminAPIClient
|
||||
|
||||
class InboundNumberClient(NotifyAdminAPIClient):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__("a" * 73, "b")
|
||||
|
||||
def get_available_inbound_sms_numbers(self):
|
||||
return self.get(url='/inbound-number/available')
|
||||
|
||||
|
||||
@@ -6,8 +6,6 @@ from app.notify_client import NotifyAdminAPIClient, _attach_current_user, cache
|
||||
|
||||
|
||||
class InviteApiClient(NotifyAdminAPIClient):
|
||||
def __init__(self):
|
||||
super().__init__("a" * 73, "b")
|
||||
|
||||
def init_app(self, app):
|
||||
super().init_app(app)
|
||||
|
||||
@@ -18,9 +18,6 @@ class JobApiClient(NotifyAdminAPIClient):
|
||||
|
||||
NON_SCHEDULED_JOB_STATUSES = JOB_STATUSES - {'scheduled', 'cancelled'}
|
||||
|
||||
def __init__(self):
|
||||
super().__init__("a" * 73, "b")
|
||||
|
||||
@staticmethod
|
||||
def __convert_statistics(job):
|
||||
results = defaultdict(int)
|
||||
|
||||
@@ -3,9 +3,6 @@ from app.notify_client import NotifyAdminAPIClient
|
||||
|
||||
class LetterBrandingClient(NotifyAdminAPIClient):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__("a" * 73, "b")
|
||||
|
||||
def get_letter_branding(self):
|
||||
return self.get(url='/dvla_organisations')
|
||||
|
||||
|
||||
@@ -3,9 +3,6 @@ from app.notify_client import NotifyAdminAPIClient
|
||||
|
||||
class LetterJobsClient(NotifyAdminAPIClient):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__("a" * 73, "b")
|
||||
|
||||
def submit_returned_letters(self, references):
|
||||
return self.post(
|
||||
url='/letters/returned',
|
||||
|
||||
@@ -2,8 +2,6 @@ from app.notify_client import NotifyAdminAPIClient, _attach_current_user
|
||||
|
||||
|
||||
class NotificationApiClient(NotifyAdminAPIClient):
|
||||
def __init__(self):
|
||||
super().__init__("a" * 73, "b")
|
||||
|
||||
def get_notifications_for_service(
|
||||
self,
|
||||
|
||||
@@ -3,8 +3,6 @@ from app.notify_client import NotifyAdminAPIClient, _attach_current_user
|
||||
|
||||
|
||||
class OrgInviteApiClient(NotifyAdminAPIClient):
|
||||
def __init__(self):
|
||||
super().__init__("a" * 73, "b")
|
||||
|
||||
def init_app(self, app):
|
||||
super().init_app(app)
|
||||
|
||||
@@ -3,9 +3,6 @@ from app.notify_client import NotifyAdminAPIClient, _attach_current_user, cache
|
||||
|
||||
class OrganisationsClient(NotifyAdminAPIClient):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__("a" * 73, "b")
|
||||
|
||||
def get_organisations(self):
|
||||
return self.get(url='/organisations')
|
||||
|
||||
|
||||
@@ -2,10 +2,6 @@ from app.notify_client import NotifyAdminAPIClient
|
||||
|
||||
|
||||
class PlatformStatsAPIClient(NotifyAdminAPIClient):
|
||||
# Fudge assert in the super __init__ so
|
||||
# we can set those variables later.
|
||||
def __init__(self):
|
||||
super().__init__("a" * 73, "b")
|
||||
|
||||
def get_aggregate_platform_stats(self, params_dict=None):
|
||||
return self.get("/platform-stats", params=params_dict)
|
||||
|
||||
@@ -3,8 +3,6 @@ from app.notify_client import NotifyAdminAPIClient, _attach_current_user
|
||||
|
||||
|
||||
class ProviderClient(NotifyAdminAPIClient):
|
||||
def __init__(self):
|
||||
super().__init__("a" * 73, "b")
|
||||
|
||||
def get_all_providers(self):
|
||||
return self.get(
|
||||
|
||||
@@ -3,10 +3,6 @@ from app.notify_client import NotifyAdminAPIClient, _attach_current_user, cache
|
||||
|
||||
|
||||
class ServiceAPIClient(NotifyAdminAPIClient):
|
||||
# Fudge assert in the super __init__ so
|
||||
# we can set those variables later.
|
||||
def __init__(self):
|
||||
super().__init__("a" * 73, "b")
|
||||
|
||||
@cache.delete('user-{user_id}')
|
||||
def create_service(
|
||||
|
||||
@@ -3,8 +3,6 @@ from app.notify_client import NotifyAdminAPIClient
|
||||
|
||||
|
||||
class StatusApiClient(NotifyAdminAPIClient):
|
||||
def __init__(self):
|
||||
super().__init__("a" * 73, "b")
|
||||
|
||||
def get_status(self, *params):
|
||||
return self.get(url='/_status', *params)
|
||||
|
||||
@@ -2,10 +2,6 @@ from app.notify_client import NotifyAdminAPIClient, cache
|
||||
|
||||
|
||||
class TemplateFolderAPIClient(NotifyAdminAPIClient):
|
||||
# Fudge assert in the super __init__ so
|
||||
# we can set those variables later.
|
||||
def __init__(self):
|
||||
super().__init__('a' * 73, 'b')
|
||||
|
||||
@cache.delete('service-{service_id}-template-folders')
|
||||
def create_template_folder(
|
||||
|
||||
@@ -2,8 +2,6 @@ from app.notify_client import NotifyAdminAPIClient
|
||||
|
||||
|
||||
class TemplateStatisticsApiClient(NotifyAdminAPIClient):
|
||||
def __init__(self):
|
||||
super().__init__("a" * 73, "b")
|
||||
|
||||
def get_template_statistics_for_service(self, service_id, limit_days=None):
|
||||
params = {}
|
||||
|
||||
@@ -18,8 +18,6 @@ ALLOWED_ATTRIBUTES = {
|
||||
|
||||
|
||||
class UserApiClient(NotifyAdminAPIClient):
|
||||
def __init__(self):
|
||||
super().__init__("a" * 73, "b")
|
||||
|
||||
def init_app(self, app):
|
||||
super().init_app(app)
|
||||
|
||||
Reference in New Issue
Block a user