from abc import ABCMeta

from messagebus import AckMessage, NakMessage
from messageprocessorutil import UuidMessageProcessor
from paymentrouter import PaymentRouter


class _CommonProcessor(UuidMessageProcessor):
    __metaclass__ = ABCMeta

    def __init__(self, payment_router):
        # type: (PaymentRouter) -> None
        super(_CommonProcessor, self).__init__()
        self.payment_router = payment_router

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

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

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