from ....tl.mtproto_request import MTProtoRequest


class StickerSet(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    messages.stickerSet#b60a24a6 set:StickerSet packs:Vector<StickerPack> documents:Vector<Document> = messages.StickerSet"""

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

    def __init__(self, set, packs, documents):
        """
        :param set: Telegram type: «StickerSet».
        :param packs: Telegram type: «StickerPack». Must be a list.
        :param documents: Telegram type: «Document». Must be a list.

        Constructor for messages.StickerSet: Instance of StickerSet.
        """
        super().__init__()

        self.set = set
        self.packs = packs
        self.documents = documents

    def on_send(self, writer):
        writer.write_int(StickerSet.constructor_id, signed=False)
        self.set.on_send(writer)
        writer.write_int(0x1cb5c415, signed=False)  # Vector's constructor ID
        writer.write_int(len(self.packs))
        for packs_item in self.packs:
            packs_item.on_send(writer)

        writer.write_int(0x1cb5c415, signed=False)  # Vector's constructor ID
        writer.write_int(len(self.documents))
        for documents_item in self.documents:
            documents_item.on_send(writer)

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

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

        reader.read_int()  # Vector's constructor ID
        self.documents = []  # Initialize an empty list
        documents_len = reader.read_int()
        for _ in range(documents_len):
            documents_item = reader.tgread_object()
            self.documents.append(documents_item)

    def __repr__(self):
        return 'messages.stickerSet#b60a24a6 set:StickerSet packs:Vector<StickerPack> documents:Vector<Document> = messages.StickerSet'

    def __str__(self):
        return '(messages.stickerSet (ID: 0xb60a24a6) = (set={}, packs={}, documents={}))'.format(str(self.set), None if not self.packs else [str(_) for _ in self.packs], None if not self.documents else [str(_) for _ in self.documents])
