from ....tl.mtproto_request import MTProtoRequest


class FeaturedStickers(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    messages.featuredStickers#f89d88e5 hash:int sets:Vector<StickerSetCovered> unread:Vector<long> = messages.FeaturedStickers"""

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

    def __init__(self, hash, sets, unread):
        """
        :param hash: Telegram type: «int».
        :param sets: Telegram type: «StickerSetCovered». Must be a list.
        :param unread: Telegram type: «long». Must be a list.

        Constructor for messages.FeaturedStickers: Instance of either FeaturedStickersNotModified, FeaturedStickers.
        """
        super().__init__()

        self.hash = hash
        self.sets = sets
        self.unread = unread

    def on_send(self, writer):
        writer.write_int(FeaturedStickers.constructor_id, signed=False)
        writer.write_int(self.hash)
        writer.write_int(0x1cb5c415, signed=False)  # Vector's constructor ID
        writer.write_int(len(self.sets))
        for sets_item in self.sets:
            sets_item.on_send(writer)

        writer.write_int(0x1cb5c415, signed=False)  # Vector's constructor ID
        writer.write_int(len(self.unread))
        for unread_item in self.unread:
            writer.write_long(unread_item)

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

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

        reader.read_int()  # Vector's constructor ID
        self.unread = []  # Initialize an empty list
        unread_len = reader.read_int()
        for _ in range(unread_len):
            unread_item = reader.read_long()
            self.unread.append(unread_item)

    def __repr__(self):
        return 'messages.featuredStickers#f89d88e5 hash:int sets:Vector<StickerSetCovered> unread:Vector<long> = messages.FeaturedStickers'

    def __str__(self):
        return '(messages.featuredStickers (ID: 0xf89d88e5) = (hash={}, sets={}, unread={}))'.format(str(self.hash), None if not self.sets else [str(_) for _ in self.sets], None if not self.unread else [str(_) for _ in self.unread])
