from ...tl.mtproto_request import MTProtoRequest


class StickerPack(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    stickerPack#12b299d4 emoticon:string documents:Vector<long> = StickerPack"""

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

    def __init__(self, emoticon, documents):
        """
        :param emoticon: Telegram type: «string».
        :param documents: Telegram type: «long». Must be a list.

        Constructor for StickerPack: Instance of StickerPack.
        """
        super().__init__()

        self.emoticon = emoticon
        self.documents = documents

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

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

    def on_response(self, reader):
        self.emoticon = reader.tgread_string()
        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.read_long()
            self.documents.append(documents_item)

    def __repr__(self):
        return 'stickerPack#12b299d4 emoticon:string documents:Vector<long> = StickerPack'

    def __str__(self):
        return '(stickerPack (ID: 0x12b299d4) = (emoticon={}, documents={}))'.format(str(self.emoticon), None if not self.documents else [str(_) for _ in self.documents])
