from ...tl.mtproto_request import MTProtoRequest


class PageBlockSlideshow(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    pageBlockSlideshow#130c8963 items:Vector<PageBlock> caption:RichText = PageBlock"""

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

    def __init__(self, items, caption):
        """
        :param items: Telegram type: «PageBlock». Must be a list.
        :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.items = items
        self.caption = caption

    def on_send(self, writer):
        writer.write_int(PageBlockSlideshow.constructor_id, signed=False)
        writer.write_int(0x1cb5c415, signed=False)  # Vector's constructor ID
        writer.write_int(len(self.items))
        for items_item in self.items:
            items_item.on_send(writer)

        self.caption.on_send(writer)

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

    def on_response(self, reader):
        reader.read_int()  # Vector's constructor ID
        self.items = []  # Initialize an empty list
        items_len = reader.read_int()
        for _ in range(items_len):
            items_item = reader.tgread_object()
            self.items.append(items_item)

        self.caption = reader.tgread_object()

    def __repr__(self):
        return 'pageBlockSlideshow#130c8963 items:Vector<PageBlock> caption:RichText = PageBlock'

    def __str__(self):
        return '(pageBlockSlideshow (ID: 0x130c8963) = (items={}, caption={}))'.format(None if not self.items else [str(_) for _ in self.items], str(self.caption))
