from ...tl.mtproto_request import MTProtoRequest


class TextEmail(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    textEmail#de5a0dd6 text:RichText email:string = RichText"""

    # Telegram's constructor ID (and unique identifier) for this class
    constructor_id = 0xde5a0dd6

    def __init__(self, text, email):
        """
        :param text: Telegram type: «RichText».
        :param email: Telegram type: «string».

        Constructor for RichText: Instance of either TextEmpty, TextPlain, TextBold, TextItalic, TextUnderline, TextStrike, TextFixed, TextUrl, TextEmail, TextConcat.
        """
        super().__init__()

        self.text = text
        self.email = email

    def on_send(self, writer):
        writer.write_int(TextEmail.constructor_id, signed=False)
        self.text.on_send(writer)
        writer.tgwrite_string(self.email)

    @staticmethod
    def empty():
        """Returns an "empty" instance (all attributes are None)"""
        return TextEmail(None, None)

    def on_response(self, reader):
        self.text = reader.tgread_object()
        self.email = reader.tgread_string()

    def __repr__(self):
        return 'textEmail#de5a0dd6 text:RichText email:string = RichText'

    def __str__(self):
        return '(textEmail (ID: 0xde5a0dd6) = (text={}, email={}))'.format(str(self.text), str(self.email))
