import json

from messagebus import AckMessage

from ._CommonProcessor import _CommonProcessor


class GetQRCodeConfigProcessor(_CommonProcessor):
    def parse_data(
        self,           # type: GetQRCodeConfigProcessor
        data,           # type: Any
        event_type,     # type: Any
    ):
        # type: (...) -> Any

        return data

    def call_business(
        self,   # type: GetQRCodeConfigProcessor
        _,      # type: Any
    ):
        # type: (...) -> Dict[str, str]

        return self.payment_router.get_qr_code_config()

    def format_response(
        self,           # type: GetQRCodeConfigProcessor
        message_bus,    # type: MessageBus
        message,        # type: Message
        event,          # type: Event
        input_obj,      # type: Any
        result,         # type: Dict[str, str]
    ):
        # type: (...) -> None

        message_bus.reply_message(
            message=message,
            reply_message=AckMessage(json.dumps(result).encode("utf-8"))
        )
