from ...tl.mtproto_request import MTProtoRequest


class PageBlockPhoto(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    pageBlockPhoto#e9c69982 photo_id:long caption:RichText = PageBlock"""

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

    def __init__(self, photo_id, caption):
        """
        :param photo_id: Telegram type: «long».
        :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.
        """
        super().__init__()

        self.photo_id = photo_id
        self.caption = caption

    def on_send(self, writer):
        writer.write_int(PageBlockPhoto.constructor_id, signed=False)
        writer.write_long(self.photo_id)
        self.caption.on_send(writer)

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

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

    def __repr__(self):
        return 'pageBlockPhoto#e9c69982 photo_id:long caption:RichText = PageBlock'

    def __str__(self):
        return '(pageBlockPhoto (ID: 0xe9c69982) = (photo_id={}, caption={}))'.format(str(self.photo_id), str(self.caption))
