from ...tl.mtproto_request import MTProtoRequest


class PageBlockPullquote(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. TL definition below.
    pageBlockPullquote#4f4456d3 text:RichText caption:RichText = PageBlock"""

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

    def __init__(self, text, caption):
        """
        :param text: Telegram type: "RichText".
        :param caption: Telegram type: "RichText".

        Constructor for PageBlock: Instance of either PageBlockUnsupported, PageBlockTitle, PageBlockSubtitle, PageBlockAuthorDate, PageBlockHeader, PageBlockSubheader, PageBlockParagraph, PageBlockPreformatted, PageBlockFooter, PageBlockDivider, PageBlockAnchor, PageBlockList, PageBlockBlockquote, PageBlockPullquote, PageBlockPhoto, PageBlockVideo, PageBlockCover, PageBlockEmbed, PageBlockEmbedPost, PageBlockCollage, PageBlockSlideshow, PageBlockChannel, PageBlockAudio.
        """
        super().__init__()

        self.text = text
        self.caption = caption

    def to_dict(self):
        return {
            'text': None if self.text is None else self.text.to_dict(),
            'caption': None if self.caption is None else self.caption.to_dict(),
        }

    def on_send(self, writer):
        writer.write_int(PageBlockPullquote.constructor_id, signed=False)
        self.text.on_send(writer)
        self.caption.on_send(writer)

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

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

    def __repr__(self):
        return 'pageBlockPullquote#4f4456d3 text:RichText caption:RichText = PageBlock'

    def __str__(self):
        return '(pageBlockPullquote (ID: 0x4f4456d3) = (text={}, caption={}))'.format(str(self.text), str(self.caption))
