from ...tl.mtproto_request import MTProtoRequest


class KeyboardButtonCallback(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. TL definition below.
    keyboardButtonCallback#683a5e46 text:string data:bytes = KeyboardButton"""

    # Telegram's constructor (U)ID for this class
    constructor_id = 0x683a5e46
    # Also the ID of its resulting type for fast checks
    subclass_of_id = 0xbad74a3

    def __init__(self, text, data):
        """
        :param text: Telegram type: "string".
        :param data: Telegram type: "bytes".

        Constructor for KeyboardButton: Instance of either KeyboardButton, KeyboardButtonUrl, KeyboardButtonCallback, KeyboardButtonRequestPhone, KeyboardButtonRequestGeoLocation, KeyboardButtonSwitchInline, KeyboardButtonGame, KeyboardButtonBuy.
        """
        super().__init__()

        self.text = text
        self.data = data

    def to_dict(self):
        return {
            'text': self.text,
            'data': self.data,
        }

    def on_send(self, writer):
        writer.write_int(KeyboardButtonCallback.constructor_id, signed=False)
        writer.tgwrite_string(self.text)
        writer.tgwrite_bytes(self.data)

    @staticmethod
    def empty():
        """Returns an "empty" instance (attributes=None)"""
        return KeyboardButtonCallback(None, None)

    def on_response(self, reader):
        self.text = reader.tgread_string()
        self.data = reader.tgread_bytes()

    def __repr__(self):
        return 'keyboardButtonCallback#683a5e46 text:string data:bytes = KeyboardButton'

    def __str__(self):
        return '(keyboardButtonCallback (ID: 0x683a5e46) = (text={}, data={}))'.format(str(self.text), str(self.data))
