from logging import Logger
from typing import Dict

from interactor.route.store.get_config.dto import GetStoreConfigRequest
from model.config import Config
from model.repository import PosRepositoryModel
from validation_util import validate_api_key


class GetStoreConfigInteractor(object):

    def __init__(
            self,
            logger,         # type: Logger
            config,         # type: Config
            pos_repository  # type: PosRepositoryModel
    ):
        # type: (...) -> None

        self.logger = logger
        self.config = config
        self.pos_repository = pos_repository

    def execute(self, request):
        # type: (GetStoreConfigRequest) -> Dict

        pos_id = validate_api_key(
            request=request,
            secure_api_key_list=self.config.api_key_mapping
        )

        return self.pos_repository.get_static_config(pos_id)
