from clochette.application.service.provider.dto.ProviderDTO import ProviderDTO
from clochette.application.service.provider.dto.ProviderType import ProviderType


class ProviderModel:
    """Non-reactive model for storing provider mappings"""

    _providers: dict[ProviderType, ProviderDTO]

    def __init__(self):
        self._providers = {}

    def set_providers(self, providers: list[ProviderDTO]) -> None:
        """Store providers indexed by type"""
        self._providers = {provider.provider_type: provider for provider in providers}

    def get_provider(self, provider_type: ProviderType) -> ProviderDTO:
        """Get a provider by type"""
        if provider_type not in self._providers:
            raise ValueError(f"Provider {provider_type} not found")
        return self._providers[provider_type]

    def get_all_providers(self) -> list[ProviderDTO]:
        """Get all providers"""
        return list(self._providers.values())
