from logging import Logger

from interactor.route.menu.get_images.dto import (
    GetImagesRequest,
    GetImagesResponse
)
from model.config import Config
from model.services import ImagesServiceModel
from validation_util import validate_api_key


class GetImagesInteractor(object):

    def __init__(self, logger, config, images_service):
        # type: (Logger, Config, ImagesServiceModel) -> None

        self.logger = logger
        self.config = config
        self.images_service = images_service

    def execute(self, request):
        # type: (GetImagesRequest) -> GetImagesResponse

        validate_api_key(request, self.config.api_key_mapping)

        return self.images_service.get_images(
            images_path=self.config.images_path,
            totem_config_path=self.config.totem_config_path
        )
