from typing import List
from messageprocessorutil import UuidMessageProcessor
from messagebus import NakMessage, AckMessage

from production.interactor import GetPrintersInfoInteractor
from production.box import ViewBox


class GetPrintersInfoProcessor(UuidMessageProcessor):
    def __init__(self, view_boxes):
        # type: (List[ViewBox]) -> None
        super(GetPrintersInfoProcessor, self).__init__()
        self.interactor = GetPrintersInfoInteractor(view_boxes)

    def parse_data(self, _):
        return ''

    def call_business(self, obj):
        return self.interactor.execute()

    def format_response(self, message_bus, message, event, input_obj, result):
        message_bus.reply_message(message, AckMessage(result))

    def format_exception(self, message_bus, message, event, input_obj, exception):
        message_bus.reply_message(message, NakMessage())

    def format_parse_exception(self, message_bus, message, event, data, exception):
        message_bus.reply_message(message, NakMessage())
