first commit
This commit is contained in:
commit
dc1245f164
22 changed files with 1666 additions and 0 deletions
32
notifications/base.py
Normal file
32
notifications/base.py
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
"""Notification service abstraction."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class NotificationService(ABC):
|
||||
"""Abstract notification service."""
|
||||
|
||||
@abstractmethod
|
||||
def send_sms(self, message: str) -> bool:
|
||||
"""Send an SMS message."""
|
||||
|
||||
@abstractmethod
|
||||
def send_email(self, subject: str, body: str) -> bool:
|
||||
"""Send an email message."""
|
||||
|
||||
|
||||
class LoggingNotificationService(NotificationService):
|
||||
"""Default implementation that logs notifications instead of sending them."""
|
||||
|
||||
def send_sms(self, message: str) -> bool:
|
||||
logger.info("SMS WOULD BE SENT:\n%s", message)
|
||||
return True
|
||||
|
||||
def send_email(self, subject: str, body: str) -> bool:
|
||||
logger.info("EMAIL WOULD BE SENT:\nSubject: %s\n%s", subject, body)
|
||||
return True
|
||||
Loading…
Add table
Add a link
Reference in a new issue