32 lines
877 B
Python
32 lines
877 B
Python
"""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
|