from ...tl.mtproto_request import MTProtoRequest


class PageBlockAuthorDate(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    pageBlockAuthorDate#baafe5e0 author:RichText published_date:date = PageBlock"""

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

    def __init__(self, author, published_date):
        """
        :param author: Telegram type: «RichText».
        :param published_date: Telegram type: «date».

        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.
        """
        super().__init__()

        self.author = author
        self.published_date = published_date

    def on_send(self, writer):
        writer.write_int(PageBlockAuthorDate.constructor_id, signed=False)
        self.author.on_send(writer)
        writer.tgwrite_date(self.published_date)

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

    def on_response(self, reader):
        self.author = reader.tgread_object()
        self.published_date = reader.tgread_date()

    def __repr__(self):
        return 'pageBlockAuthorDate#baafe5e0 author:RichText published_date:date = PageBlock'

    def __str__(self):
        return '(pageBlockAuthorDate (ID: 0xbaafe5e0) = (author={}, published_date={}))'.format(str(self.author), str(self.published_date))
