from typing import Dict

from externals.repository import AlertsRepository


class GetConfiguredAlertsInteractor(object):
    def __init__(
        self,
        alerts_repository,  # type: AlertsRepository
    ):
        # type: (...) -> None

        self.alerts_repository = alerts_repository

    def process_request(
        self,
    ):
        # type: (...) -> Dict

        from datetime import datetime
        response = {"last_updated": datetime.now().isoformat()}

        configured_alerts = self.alerts_repository.get_configured_alerts()
        for alert in configured_alerts:
            response[alert.id] = alert.alert_json

        return response
