from logging import Logger

from httpmessageprocessor import HttpMessageProcessorMessageHandler
from httpmessageprocessorutil.automapped import AutoMappedMessageProcessor
from interactor.event import ElectronicPaymentEventInteractor
from interactor.route.electronic_payment.cache import CacheInteractor
from interactor.route.electronic_payment.cache.dto import CacheRequest
from interactor.route.customization.get_styles import GetStylesInteractor
from interactor.route.customization.get_styles.dto import GetStylesRequest
from interactor.route.menu.get_images import GetImagesInteractor
from interactor.route.menu.get_images.dto import GetImagesRequest
from interactor.route.menu.get_navigation import GetNavigationInteractor
from interactor.route.menu.get_navigation.dto import GetNavigationRequest
from interactor.route.menu.get_product_info import GetProductInfoInteractor
from interactor.route.menu.get_product_info.dto import GetProductInfoRequest
from interactor.route.menu.get_products import GetProductsInteractor
from interactor.route.menu.get_products.dto import GetProductsRequest
from interactor.route.menu.get_ruptured_products import GetRupturedProducts
from interactor.route.menu.get_ruptured_products.dto import GetRupturedProductsRequest
from interactor.route.menu.get_banners import GetBannersInteractor
from interactor.route.menu.get_banners.dto import GetBannersRequest
from interactor.route.menu.get_up_sell_part_codes import GetUpSellPartCodesInteractor
from interactor.route.menu.get_up_sell_part_codes.dto import GetUpSellPartCodesRequest
from interactor.route.order.add_items import AddItemsInteractor
from interactor.route.order.add_items.dto import AddItemsRequest
from interactor.route.order.add_properties import AddPropertiesInteractor
from interactor.route.order.add_properties.dto import AddPropertiesRequest
from interactor.route.order.apply_coupon import ApplyCouponInteractor
from interactor.route.order.apply_coupon.dto import ApplyCouponRequest
from interactor.route.order.cancel import OrderCancelInteractor
from interactor.route.order.cancel.dto import OrderCancelRequest
from interactor.route.order.change_items_quantity import ChangeItemsQuantityInteractor
from interactor.route.order.change_items_quantity.dto import ChangeItemsQuantityRequest
from interactor.route.order.close_shopping_cart import CloseShoppingCartInteractor
from interactor.route.order.close_shopping_cart.dto import CloseShoppingCartRequest
from interactor.route.order.create import OrderCreateInteractor
from interactor.route.order.create.dto import OrderCreateRequest
from interactor.route.order.delete_line import OrderDeleteLineInteractor
from interactor.route.order.delete_line.dto import OrderDeleteLineRequest
from interactor.route.order.finalize import OrderFinalizeInteractor
from interactor.route.order.finalize.dto import OrderFinalizeRequest
from interactor.route.order.get_detail import OrderGetDetailInteractor
from interactor.route.order.get_detail.dto import OrderGetDetailRequest
from interactor.route.payment.insert import OrderInsertPaymentInteractor
from interactor.route.payment.insert.dto import OrderInsertPaymentRequest
from interactor.route.order.reopen_shopping_cart import ReopenShoppingCartInteractor
from interactor.route.order.reopen_shopping_cart.dto import ReopenShoppingCartRequest
from interactor.route.order.remove_coupon import RemoveCouponInteractor
from interactor.route.order.remove_coupon.dto import RemoveCouponRequest
from interactor.route.payment.get_payment_types import GetPaymentTypesInteractor
from interactor.route.payment.get_payment_types.dto import GetPaymentTypesRequest
from interactor.route.electronic_payment.read_messages import ReadMessagesInteractor
from interactor.route.electronic_payment.read_messages.dto import ReadMessagesRequest
from interactor.route.electronic_payment.clear_messages import ClearMessagesInteractor
from interactor.route.electronic_payment.clear_messages.dto import ClearMessagesRequest
from interactor.route.electronic_payment.send_responses import SendResponsesInteractor
from interactor.route.electronic_payment.send_responses.dto import SendResponsesRequest
from interactor.route.customization.get_text import GetTextInteractor
from interactor.route.customization.get_text.dto import GetTextRequest
from interactor.route.peripheral.print_text import PrintTextInteractor
from interactor.route.peripheral.print_text.dto import PrintTextRequest
from interactor.route.peripheral.read_scanner import ReadScannerInteractor
from interactor.route.peripheral.read_scanner.dto import ReadScannerRequest
from interactor.route.store.get_status import GetStoreInteractor
from interactor.route.store.get_status.dto import GetStoreRequest
from interactor.route.store.get_config import GetStoreConfigInteractor
from interactor.route.store.get_config.dto import GetStoreConfigRequest
from interactor.route.payment.cancel import CancelPaymentInteractor
from interactor.route.payment.cancel.dto import CancelPaymentRequest
from mbcontextmessagehandler import MbContextMessageBus
from messagebus import Message, Event
from messagehandler import MessageHandlerBuilder, MessageHandler
from messageprocessor import MessageProcessor, DefaultMessageProcessorExecutorFactory, MessageProcessorMessageHandler
from messageprocessorutil import LoggingProcessorCallback
from model.config import Config
from model.event import ListenedEvents
from model.exception import (
    ValidationError,
    AuthValidationErrors,
    ExternalServiceErrors,
    OperationErrors,
    BadRequestError,
)
from model.response import Responses
from processor.event.electronic_payment import (
    ElectronicPaymentCloseDialogProcessor,
    ElectronicPaymentShowQRCodeProcessor,
    ElectronicPaymentShowChoicesProcessor,
    ElectronicPaymentShowInputProcessor,
    ElectronicPaymentShowMessageProcessor,
    ElectronicPaymentShowQuestionProcessor
)
from pyscripts_cache import PyscriptsCache
from repository import PosRepository
from services import (
    FiscalService,
    OrderService,
    ApiService,
    CouponService,
    ImagesService,
    PaymentService,
    ProductInfoService
)
from simplehttprouter import Route
from typing import Dict, Optional


class ServiceMessageHandlerBuilder(MessageHandlerBuilder):

    def __init__(self, logger, config, message_bus, flask_server=False):
        # type: (Logger, Config, MbContextMessageBus, bool) -> None

        self.logger = logger
        self.config = config
        self.message_bus = message_bus
        self.flask_server = flask_server

        self.pos_repository = None
        self.fiscal_service = None
        self.coupon_service = None
        self.order_service = None
        self.api_service = None
        self.modifier_service = None
        self.images_service = None
        self.payment_service = None
        self.product_info_service = None

        self.pyscripts_cache = None

        self.cache_menu_ruptured_items = {"last_request_date": None, "data": None}
        self.cache_menu_products = None
        self.cache_menu_navigation = []
        self.electronic_messages = []

        self.callbacks = None
        self.message_handler = None

    def build_singletons(self):
        # type: () -> None

        self.callbacks = [LoggingProcessorCallback(self.logger)]

        if self.flask_server:
            self.pos_repository = PosRepository(self.message_bus, self.logger, self.config)
            self.fiscal_service = FiscalService(self.message_bus, self.logger)
            self.coupon_service = CouponService(self.message_bus, self.logger)
            self.pyscripts_cache = PyscriptsCache(self.message_bus.mbcontext)
            self.order_service = OrderService()
            self.images_service = ImagesService()
            self.payment_service = PaymentService(
                self.message_bus,
                self.config
            )
            self.product_info_service = ProductInfoService(self.message_bus)

            self.fiscal_service.get_electronic_payments_id()
        else:
            self.api_service = ApiService(self.config, self.logger)

            events_processors = self._build_events_processors()
            default_message_processor_executor_factory = DefaultMessageProcessorExecutorFactory(self.callbacks)
            self.message_handler = MessageProcessorMessageHandler(events_processors,
                                                                  None,
                                                                  default_message_processor_executor_factory)

    def build_message_handler(self, message=None, event=None):
        # type: (Optional[Message], Optional[Event]) -> MessageHandler

        if self.flask_server:
            processors_routes = self._build_processors_routes()
            http_message_processor = HttpMessageProcessorMessageHandler(route_processor=processors_routes,
                                                                        callbacks=self.callbacks)
            return http_message_processor
        else:
            return self.message_handler

    def destroy_message_handler(self, message_handler):
        # type: (MessageHandler) -> None

        pass

    def destroy_singletons(self):
        # type: () -> None

        pass

    def _build_events_processors(self):
        # type: () -> Optional[Dict[str, MessageProcessor]]

        electronic_payment_event_interactor = ElectronicPaymentEventInteractor(self.api_service)

        electronic_payment_close_dialog_processor = \
            ElectronicPaymentCloseDialogProcessor(electronic_payment_event_interactor)
        electronic_payment_show_qrcode_processor = \
            ElectronicPaymentShowQRCodeProcessor(electronic_payment_event_interactor)
        electronic_payment_show_choices_processor = \
            ElectronicPaymentShowChoicesProcessor(electronic_payment_event_interactor)
        electronic_payment_show_input_processor = \
            ElectronicPaymentShowInputProcessor(electronic_payment_event_interactor)
        electronic_payment_show_message_processor = \
            ElectronicPaymentShowMessageProcessor(electronic_payment_event_interactor)
        electronic_payment_show_question_processor = \
            ElectronicPaymentShowQuestionProcessor(electronic_payment_event_interactor)

        events_processors = {
            ListenedEvents.ELECTRONIC_PAYMENT_CLOSE_DIALOGS: electronic_payment_close_dialog_processor,
            ListenedEvents.ELECTRONIC_PAYMENT_SHOW_QRCODE: electronic_payment_show_qrcode_processor,
            ListenedEvents.ELECTRONIC_PAYMENT_SHOW_CHOICES: electronic_payment_show_choices_processor,
            ListenedEvents.ELECTRONIC_PAYMENT_SHOW_INPUT: electronic_payment_show_input_processor,
            ListenedEvents.ELECTRONIC_PAYMENT_SHOW_MESSAGE: electronic_payment_show_message_processor,
            ListenedEvents.ELECTRONIC_PAYMENT_SHOW_QUESTION: electronic_payment_show_question_processor
        }

        return events_processors

    def _build_processors_routes(self):
        # type: () -> Dict[Route, MessageProcessor]

        customization_get_styles_interactor = GetStylesInteractor(
            logger=self.logger,
            config=self.config
        )
        order_add_items_interactor = \
            AddItemsInteractor(self.logger, self.config, self.pos_repository)
        order_cancel_interactor = \
            OrderCancelInteractor(self.logger, self.config, self.pos_repository)
        order_delete_line_interactor = \
            OrderDeleteLineInteractor(self.logger, self.config, self.pos_repository)
        order_close_shopping_cart_interactor = \
            CloseShoppingCartInteractor(self.logger, self.config, self.pos_repository, self.order_service)
        order_create_interactor = \
            OrderCreateInteractor(self.logger, self.config, self.pos_repository)
        order_add_properties_interactor = \
            AddPropertiesInteractor(self.logger, self.config, self.pos_repository)
        order_finalize_interactor = \
            OrderFinalizeInteractor(self.logger, self.config, self.pos_repository, self.fiscal_service)
        order_get_detail_interactor = \
            OrderGetDetailInteractor(self.logger, self.config, self.pos_repository, self.order_service)
        order_insert_payment_interactor = OrderInsertPaymentInteractor(
            self.logger,
            self.config,
            self.pos_repository,
            self.fiscal_service,
            self.payment_service
        )
        order_change_items_quantity_interactor = \
            ChangeItemsQuantityInteractor(self.logger, self.config, self.pos_repository)
        order_reopen_shopping_cart_interactor = ReopenShoppingCartInteractor(
            logger=self.logger,
            config=self.config,
            pos_repository=self.pos_repository,
            order_service=self.order_service
        )
        order_apply_coupon_interactor = ApplyCouponInteractor(
            logger=self.logger,
            config=self.config,
            pos_repository=self.pos_repository,
            coupon_service=self.coupon_service,
            order_service=self.order_service
        )
        order_remove_coupon_interactor = RemoveCouponInteractor(
            logger=self.logger,
            config=self.config,
            pos_repository=self.pos_repository,
            order_service=self.order_service
        )
        menu_get_products_interactor = \
            GetProductsInteractor(self.logger, self.config, self.pos_repository, self.cache_menu_products)
        menu_get_ruptured_products = \
            GetRupturedProducts(self.logger, self.config, self.pos_repository, self.cache_menu_ruptured_items)
        menu_get_navigation_interactor = GetNavigationInteractor(
            logger=self.logger,
            config=self.config,
            pos_repository=self.pos_repository,
            cache_navigation=self.cache_menu_navigation
        )
        menu_get_images_interactor = GetImagesInteractor(self.logger, self.config, self.images_service)
        menu_get_banners_interactor = GetBannersInteractor(
            logger=self.logger,
            config=self.config
        )
        menu_get_up_sell_part_codes_interactor = GetUpSellPartCodesInteractor(
            logger=self.logger,
            config=self.config
        )
        menu_get_product_info_interactor = GetProductInfoInteractor(
            logger=self.logger,
            config=self.config,
            pos_repository=self.pos_repository,
            product_info_service=self.product_info_service
        )
        payment_get_payment_types_interactor = GetPaymentTypesInteractor(
            self.logger,
            self.config,
            self.pos_repository,
            self.payment_service
        )
        peripheral_electronic_payment_read_messages_interactor = \
            ReadMessagesInteractor(
                self.logger,
                self.config,
                self.pos_repository,
                self.fiscal_service,
                self.electronic_messages
            )
        peripheral_electronic_payment_clear_messages_interactor = \
            ClearMessagesInteractor(
                self.logger,
                self.config,
                self.pos_repository,
                self.electronic_messages
            )
        peripheral_electronic_payment_send_responses_interactor = \
            SendResponsesInteractor(
                self.logger,
                self.config,
                self.pos_repository,
                self.fiscal_service,
                self.electronic_messages
            )
        peripheral_print_text_interactor = \
            PrintTextInteractor(self.logger, self.config, self.pos_repository)
        peripheral_read_scanner_interactor = \
            ReadScannerInteractor(self.logger, self.config, self.pos_repository)
        status_get_store_interactor = \
            GetStoreInteractor(self.logger, self.config, self.pos_repository)
        cache_peripheral_electronic_payment_interactor = \
            CacheInteractor(self.logger, self.config, self.electronic_messages)

        customization_get_store_config_interactor = GetStoreConfigInteractor(
            logger=self.logger,
            config=self.config,
            pos_repository=self.pos_repository
        )

        customization_get_text_interactor = GetTextInteractor(
            self.logger,
            self.config,
            self.pos_repository
        )

        order_cancel_payment_interactor = CancelPaymentInteractor(
            self.logger,
            self.config,
            self.pos_repository
        )

        processor_routes = {
            Route("GET", "/order/getDetail/{posId}"): AutoMappedMessageProcessor(
                OrderGetDetailRequest,
                order_get_detail_interactor,
                {
                    ValidationError: Responses.ValidationError,
                    AuthValidationErrors: Responses.AuthValidation,
                    ExternalServiceErrors: Responses.ExternalServicesError,
                    OperationErrors: Responses.OperationErrors
                }
            ),

            Route("POST", "/order/create/{posId}"): AutoMappedMessageProcessor(
                OrderCreateRequest,
                order_create_interactor,
                {
                    ValidationError: Responses.ValidationError,
                    AuthValidationErrors: Responses.AuthValidation,
                    ExternalServiceErrors: Responses.ExternalServicesError,
                    OperationErrors: Responses.OperationErrors
                },
                success_status=201
            ),

            Route("POST", "/order/addProperties/{posId}"): AutoMappedMessageProcessor(
                AddPropertiesRequest,
                order_add_properties_interactor,
                {
                    ValidationError: Responses.ValidationError,
                    AuthValidationErrors: Responses.AuthValidation,
                    ExternalServiceErrors: Responses.ExternalServicesError,
                    OperationErrors: Responses.OperationErrors
                },
                success_status=204
            ),

            Route("POST", "/order/addItems/{posId}"): AutoMappedMessageProcessor(
                AddItemsRequest,
                order_add_items_interactor,
                {
                    ValidationError: Responses.ValidationError,
                    AuthValidationErrors: Responses.AuthValidation,
                    ExternalServiceErrors: Responses.ExternalServicesError,
                    OperationErrors: Responses.OperationErrors
                },
                success_status=204
            ),

            Route("POST", "/order/changeItemsQuantity/{posId}"): AutoMappedMessageProcessor(
                ChangeItemsQuantityRequest,
                order_change_items_quantity_interactor,
                {
                    ValidationError: Responses.ValidationError,
                    AuthValidationErrors: Responses.AuthValidation,
                    ExternalServiceErrors: Responses.ExternalServicesError,
                    OperationErrors: Responses.OperationErrors
                },
                success_status=204
            ),

            Route("POST", "/order/insertPayment/{posId}"): AutoMappedMessageProcessor(
                OrderInsertPaymentRequest,
                order_insert_payment_interactor,
                {
                    ValidationError: Responses.ValidationError,
                    AuthValidationErrors: Responses.AuthValidation,
                    ExternalServiceErrors: Responses.ExternalServicesError,
                    OperationErrors: Responses.OperationErrors,
                    BadRequestError: Responses.BadRequestError,
                }
            ),

            Route("POST", "/order/registerPayment/{posId}"): AutoMappedMessageProcessor(
                OrderInsertPaymentRequest,
                order_insert_payment_interactor,
                {
                    ValidationError: Responses.ValidationError,
                    AuthValidationErrors: Responses.AuthValidation,
                    ExternalServiceErrors: Responses.ExternalServicesError,
                    OperationErrors: Responses.OperationErrors,
                    BadRequestError: Responses.BadRequestError,
                }),

            Route("DELETE", "/order/cancelPayment/{posId}/{tenderId}"): AutoMappedMessageProcessor(
                CancelPaymentRequest,
                order_cancel_payment_interactor,
                {
                    ValidationError: Responses.ValidationError,
                    AuthValidationErrors: Responses.AuthValidation,
                    ExternalServiceErrors: Responses.ExternalServicesError,
                    OperationErrors: Responses.OperationErrors
                }
            ),

            Route("POST", "/order/cancel/{posId}"): AutoMappedMessageProcessor(
                OrderCancelRequest,
                order_cancel_interactor,
                {
                    ValidationError: Responses.ValidationError,
                    AuthValidationErrors: Responses.AuthValidation,
                    ExternalServiceErrors: Responses.ExternalServicesError,
                    OperationErrors: Responses.OperationErrors
                },
                success_status=204
            ),

            Route("DELETE", "/order/deleteLine/{posId}"): AutoMappedMessageProcessor(
                OrderDeleteLineRequest,
                order_delete_line_interactor,
                {
                    ValidationError: Responses.ValidationError,
                    AuthValidationErrors: Responses.AuthValidation,
                    ExternalServiceErrors: Responses.ExternalServicesError,
                    OperationErrors: Responses.OperationErrors
                },
                success_status=204
            ),

            Route("POST", "/order/closeShoppingCart/{posId}"): AutoMappedMessageProcessor(
                CloseShoppingCartRequest,
                order_close_shopping_cart_interactor,
                {
                    ValidationError: Responses.ValidationError,
                    AuthValidationErrors: Responses.AuthValidation,
                    ExternalServiceErrors: Responses.ExternalServicesError,
                    OperationErrors: Responses.OperationErrors
                }
            ),

            Route("POST", "/order/reopenShoppingCart/{posId}"): AutoMappedMessageProcessor(
                request_type=ReopenShoppingCartRequest,
                interactor=order_reopen_shopping_cart_interactor,
                exception_map={
                    ValidationError: Responses.ValidationError,
                    AuthValidationErrors: Responses.AuthValidation,
                    ExternalServiceErrors: Responses.ExternalServicesError,
                    OperationErrors: Responses.OperationErrors
                }
            ),

            Route("POST", "/order/finalize/{posId}"): AutoMappedMessageProcessor(
                OrderFinalizeRequest,
                order_finalize_interactor,
                {
                    ValidationError: Responses.ValidationError,
                    AuthValidationErrors: Responses.AuthValidation,
                    ExternalServiceErrors: Responses.ExternalServicesError,
                    OperationErrors: Responses.OperationErrors
                },
                success_status=204
            ),

            Route("POST", "/order/applyCoupon/{posId}"): AutoMappedMessageProcessor(
                ApplyCouponRequest,
                order_apply_coupon_interactor,
                {
                    ValidationError: Responses.ValidationError,
                    AuthValidationErrors: Responses.AuthValidation,
                    ExternalServiceErrors: Responses.ExternalServicesError,
                    OperationErrors: Responses.OperationErrors
                },
                success_status=200
            ),

            Route("DELETE", "/order/removeCoupon/{posId}"): AutoMappedMessageProcessor(
                RemoveCouponRequest,
                order_remove_coupon_interactor,
                {
                    ValidationError: Responses.ValidationError,
                    AuthValidationErrors: Responses.AuthValidation,
                    ExternalServiceErrors: Responses.ExternalServicesError,
                    OperationErrors: Responses.OperationErrors
                }
            ),

            Route("GET", "/menu/products"): AutoMappedMessageProcessor(
                GetProductsRequest,
                menu_get_products_interactor,
                {
                    ValidationError: Responses.ValidationError,
                    AuthValidationErrors: Responses.AuthValidation,
                    ExternalServiceErrors: Responses.ExternalServicesError,
                    OperationErrors: Responses.OperationErrors
                },
                response_content_type="application/gzip"
            ),

            Route("GET", "/menu/rupturedProducts"): AutoMappedMessageProcessor(
                GetRupturedProductsRequest,
                menu_get_ruptured_products,
                {
                    ValidationError: Responses.ValidationError,
                    AuthValidationErrors: Responses.AuthValidation,
                    ExternalServiceErrors: Responses.ExternalServicesError,
                    OperationErrors: Responses.OperationErrors
                }
            ),

            Route("GET", "/menu/navigation/{posId}"): AutoMappedMessageProcessor(
                GetNavigationRequest,
                menu_get_navigation_interactor,
                {
                    ValidationError: Responses.ValidationError,
                    AuthValidationErrors: Responses.AuthValidation,
                    ExternalServiceErrors: Responses.ExternalServicesError,
                    OperationErrors: Responses.OperationErrors
                }
            ),

            Route("GET", "/menu/productInfo/{language}"): AutoMappedMessageProcessor(
                GetProductInfoRequest,
                menu_get_product_info_interactor,
                {
                    ValidationError: Responses.ValidationError,
                    AuthValidationErrors: Responses.AuthValidation,
                    ExternalServiceErrors: Responses.ExternalServicesError,
                    OperationErrors: Responses.OperationErrors
                }),

            Route("GET", "/menu/images"): AutoMappedMessageProcessor(
                GetImagesRequest,
                menu_get_images_interactor,
                {
                    ValidationError: Responses.ValidationError,
                    AuthValidationErrors: Responses.AuthValidation,
                    ExternalServiceErrors: Responses.ExternalServicesError,
                    OperationErrors: Responses.OperationErrors
                }
            ),

            Route("GET", "/menu/banners"): AutoMappedMessageProcessor(
                GetBannersRequest,
                menu_get_banners_interactor,
                {
                    AuthValidationErrors: Responses.AuthValidation
                }
            ),

            Route("GET", "/menu/upSellPartCodes"): AutoMappedMessageProcessor(
                GetUpSellPartCodesRequest,
                menu_get_up_sell_part_codes_interactor,
                {
                    AuthValidationErrors: Responses.AuthValidation
                }),

            Route("GET", "/payment/paymentTypes"): AutoMappedMessageProcessor(
                GetPaymentTypesRequest,
                payment_get_payment_types_interactor,
                {
                    ValidationError: Responses.ValidationError,
                    AuthValidationErrors: Responses.AuthValidation,
                    ExternalServiceErrors: Responses.ExternalServicesError,
                    OperationErrors: Responses.OperationErrors
                }
            ),

            Route("POST", "/peripheral/electronicPayment/readMessages/{posId}"): AutoMappedMessageProcessor(
                ReadMessagesRequest,
                peripheral_electronic_payment_read_messages_interactor,
                {
                    ValidationError: Responses.ValidationError,
                    AuthValidationErrors: Responses.AuthValidation,
                    ExternalServiceErrors: Responses.ExternalServicesError,
                    OperationErrors: Responses.OperationErrors
                }
            ),

            Route("POST", "/peripheral/electronicPayment/clearMessages/{posId}"): AutoMappedMessageProcessor(
                ClearMessagesRequest,
                peripheral_electronic_payment_clear_messages_interactor,
                {
                    ValidationError: Responses.ValidationError,
                    AuthValidationErrors: Responses.AuthValidation,
                    ExternalServiceErrors: Responses.ExternalServicesError,
                    OperationErrors: Responses.OperationErrors
                }
            ),

            Route("POST", "/peripheral/electronicPayment/sendResponse/{posId}"): AutoMappedMessageProcessor(
                SendResponsesRequest,
                peripheral_electronic_payment_send_responses_interactor,
                {
                    ValidationError: Responses.ValidationError,
                    AuthValidationErrors: Responses.AuthValidation,
                    ExternalServiceErrors: Responses.ExternalServicesError,
                    OperationErrors: Responses.OperationErrors
                },
                success_status=204
            ),

            Route("POST", "/peripheral/printText/{posId}"): AutoMappedMessageProcessor(
                PrintTextRequest,
                peripheral_print_text_interactor,
                {
                    ValidationError: Responses.ValidationError,
                    AuthValidationErrors: Responses.AuthValidation,
                    ExternalServiceErrors: Responses.ExternalServicesError
                },
                success_status=204
            ),

            Route("GET", "/peripheral/readScanner/{posId}"): AutoMappedMessageProcessor(
                ReadScannerRequest,
                peripheral_read_scanner_interactor,
                {
                    ValidationError: Responses.ValidationError,
                    AuthValidationErrors: Responses.AuthValidation,
                    ExternalServiceErrors: Responses.ExternalServicesError,
                    OperationErrors: Responses.OperationErrors
                },
                success_status=200
            ),

            Route("GET", "/status/store/{posId}"): AutoMappedMessageProcessor(
                GetStoreRequest,
                status_get_store_interactor,
                {
                    ValidationError: Responses.ValidationError,
                    AuthValidationErrors: Responses.AuthValidation,
                    ExternalServiceErrors: Responses.ExternalServicesError,
                    OperationErrors: Responses.OperationErrors
                }
            ),

            Route("POST", "/cache/peripheral/electronicPayment"): AutoMappedMessageProcessor(
                CacheRequest,
                cache_peripheral_electronic_payment_interactor,
                {},
                success_status=204
            ),

            Route("GET", "/customization/getStyles"): AutoMappedMessageProcessor(
                request_type=GetStylesRequest,
                interactor=customization_get_styles_interactor,
                exception_map={
                    ValidationError: Responses.ValidationError,
                    AuthValidationErrors: Responses.AuthValidation,
                    ExternalServiceErrors: Responses.ExternalServicesError,
                    OperationErrors: Responses.OperationErrors
                }
            ),

            Route("GET", "/customization/getText"): AutoMappedMessageProcessor(
                GetTextRequest,
                customization_get_text_interactor,
                {
                    ValidationError: Responses.ValidationError,
                    AuthValidationErrors: Responses.AuthValidation,
                    ExternalServiceErrors: Responses.ExternalServicesError
                }
            ),

            Route("GET", "/customization/storeConfig/{posId}"): AutoMappedMessageProcessor(
                GetStoreConfigRequest,
                customization_get_store_config_interactor,
                {
                    ValidationError: Responses.ValidationError,
                    AuthValidationErrors: Responses.AuthValidation,
                    ExternalServiceErrors: Responses.ExternalServicesError,
                    OperationErrors: Responses.OperationErrors
                }
            )
        }

        return processor_routes
