mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-20 15:31:15 -05:00
Restructured how clients are implemented.
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
from abc import abstractmethod
|
||||||
from typing import Protocol
|
from typing import Protocol
|
||||||
|
|
||||||
from botocore.config import Config
|
from botocore.config import Config
|
||||||
@@ -29,7 +30,9 @@ class Client(Protocol):
|
|||||||
Base client for sending notifications.
|
Base client for sending notifications.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
pass
|
@abstractmethod
|
||||||
|
def init_app(self, current_app, *args, **kwargs):
|
||||||
|
raise NotImplementedError("TODO: Need to implement.")
|
||||||
|
|
||||||
|
|
||||||
class NotificationProviderClients(object):
|
class NotificationProviderClients(object):
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class PerformancePlatformClient:
|
|||||||
def active(self):
|
def active(self):
|
||||||
return self._active
|
return self._active
|
||||||
|
|
||||||
def init_app(self, app):
|
def init_app(self, app, *args, **kwargs):
|
||||||
self._active = app.config.get("PERFORMANCE_PLATFORM_ENABLED")
|
self._active = app.config.get("PERFORMANCE_PLATFORM_ENABLED")
|
||||||
if self.active:
|
if self.active:
|
||||||
self.performance_platform_url = app.config.get("PERFORMANCE_PLATFORM_URL")
|
self.performance_platform_url = app.config.get("PERFORMANCE_PLATFORM_URL")
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from abc import abstractmethod
|
from abc import abstractmethod, abstractproperty
|
||||||
|
from typing import final
|
||||||
|
|
||||||
from app.clients import Client, ClientException
|
from app.clients import Client, ClientException
|
||||||
|
|
||||||
@@ -20,14 +21,14 @@ class SmsClient(Client):
|
|||||||
Base Sms client for sending smss.
|
Base Sms client for sending smss.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
def init_app(self, *args, **kwargs):
|
|
||||||
raise NotImplementedError("TODO Need to implement.")
|
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def send_sms(self, *args, **kwargs):
|
def send_sms(self, *args, **kwargs):
|
||||||
raise NotImplementedError("TODO Need to implement.")
|
raise NotImplementedError("TODO Need to implement.")
|
||||||
|
|
||||||
@abstractmethod
|
@abstractproperty
|
||||||
def get_name(self):
|
def name(self):
|
||||||
raise NotImplementedError("TODO Need to implement.")
|
raise NotImplementedError("TODO Need to implement.")
|
||||||
|
|
||||||
|
@final
|
||||||
|
def get_name(self):
|
||||||
|
return self.name
|
||||||
|
|||||||
@@ -43,9 +43,6 @@ class AwsSnsClient(SmsClient):
|
|||||||
def name(self):
|
def name(self):
|
||||||
return "sns"
|
return "sns"
|
||||||
|
|
||||||
def get_name(self):
|
|
||||||
return self.name
|
|
||||||
|
|
||||||
def _valid_sender_number(self, sender):
|
def _valid_sender_number(self, sender):
|
||||||
return sender and re.match(self._valid_sender_regex, sender)
|
return sender and re.match(self._valid_sender_regex, sender)
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,12 @@ def fake_client(notify_api):
|
|||||||
def name(self):
|
def name(self):
|
||||||
return "fake"
|
return "fake"
|
||||||
|
|
||||||
|
def init_app(self, current_app, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def send_sms(self, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
fake_client = FakeSmsClient()
|
fake_client = FakeSmsClient()
|
||||||
# fake_client.init_app(notify_api)
|
# fake_client.init_app(notify_api)
|
||||||
return fake_client
|
return fake_client
|
||||||
|
|||||||
Reference in New Issue
Block a user