org.notification_service ======================== .. py:module:: org.notification_service Attributes ---------- .. autoapisummary:: org.notification_service.logger org.notification_service._TEST_NOTIFICATION_SERVICE Classes ------- .. autoapisummary:: org.notification_service.NotificationService org.notification_service.FirebaseNotificationService org.notification_service.TestNotificationService Functions --------- .. autoapisummary:: org.notification_service.get_notification_service org.notification_service.set_test_notification_service Module Contents --------------- .. py:data:: logger .. py:class:: NotificationService Bases: :py:obj:`abc.ABC` It can't hurt to abstract this Firebase notification away. First and foremost, this should allow for testing without mocking the wohle house .. py:method:: send_notification(topic: str, title: str, body: str, data: dict[str, Any] | None = None) -> str :abstractmethod: Send a notification to a specific topic. Args: topic: The topic to send to title: Notification title body: Notification body data: Additional data to include Returns: str: Message ID or response .. py:class:: FirebaseNotificationService(credentials_json: str) Bases: :py:obj:`NotificationService` Firebase implementation of the notification service. .. py:attribute:: credentials_dict .. py:attribute:: _firebase_app :value: None .. py:method:: _get_firebase_app() -> Any Get or initialize the Firebase app instance. Returns: The Firebase app instance. .. py:method:: send_notification(topic: str, title: str, body: str, data: dict[str, Any] | None = None) -> str Send notification via Firebase. Args: topic: Topic to send the notification to. title: The notification title. body: The notification body text. data: Optional additional data to include. Returns: The message ID from Firebase. .. py:class:: TestNotificationService Bases: :py:obj:`NotificationService` Test implementation that records calls. .. py:attribute:: sent_messages :type: list[dict[str, str | dict[str, str]]] .. py:method:: send_notification(topic: str, title: str, body: str, data: dict[str, Any] | None = None) -> str Record the notification without sending it. .. py:data:: _TEST_NOTIFICATION_SERVICE :type: NotificationService | None :value: None .. py:function:: get_notification_service(credentials_json: str | None = None) -> NotificationService Get the appropriate notification service. In tests, returns the test service if one has been registered. In production, returns a Firebase notification service. Args: credentials_json: Firebase credentials JSON for production use Returns: NotificationService: The notification service implementation .. py:function:: set_test_notification_service(service: NotificationService | None = None) -> None Set a test notification service for testing purposes. Args: service: The test service to use, or None to clear