from abc import (
    ABC,
    abstractmethod,
)
from typing import (
    Any,
    Dict,
    Tuple,
)

from messagebus import MessageBus
from nreports.repository import (
    I18N,
    OrderAPIRepository,
    ProductRepository,
    StoreConfigRepository,
    UserRepository,
)
from nreports_api.shared import JSON


class DataBuilder(ABC):

    def __init__(
        self,
        message_bus: MessageBus,
        order_api_repository: OrderAPIRepository,
        store_config_repository: StoreConfigRepository,
        i18n_repository: I18N,
        images_path: Dict[str, str],
        constants: Dict[str, str],
        user_repository: UserRepository,
        product_repository: ProductRepository,
    ) -> None:

        self._message_bus = message_bus
        self.order_api_repository = order_api_repository
        self.store_config_repository = store_config_repository
        self.user_repository = user_repository
        self.i18n_repository = i18n_repository
        self.product_repository = product_repository
        self.images_path = images_path
        self.constants = constants

    @abstractmethod
    def build_data(
        self,
        data_to_build: Dict[str, JSON],
        **kwargs: Any,
    ) -> Dict[str, JSON]:

        raise NotImplementedError()

    def get_builder_init(
        self,
    ) -> Tuple[
        MessageBus,
        OrderAPIRepository,
        StoreConfigRepository,
        I18N,
        Dict[str, str],
        Dict[str, str],
        UserRepository,
        ProductRepository,
    ]:

        return (
            self._message_bus,
            self.order_api_repository,
            self.store_config_repository,
            self.i18n_repository,
            self.images_path,
            self.constants,
            self.user_repository,
            self.product_repository,
        )
