from ....tl.mtproto_request import MTProtoRequest


class FoundGifs(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    messages.foundGifs#450a1c0a next_offset:int results:Vector<FoundGif> = messages.FoundGifs"""

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

    def __init__(self, next_offset, results):
        """
        :param next_offset: Telegram type: «int».
        :param results: Telegram type: «FoundGif». Must be a list.

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

        self.next_offset = next_offset
        self.results = results

    def on_send(self, writer):
        writer.write_int(FoundGifs.constructor_id, signed=False)
        writer.write_int(self.next_offset)
        writer.write_int(0x1cb5c415, signed=False)  # Vector's constructor ID
        writer.write_int(len(self.results))
        for results_item in self.results:
            results_item.on_send(writer)

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

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

    def __repr__(self):
        return 'messages.foundGifs#450a1c0a next_offset:int results:Vector<FoundGif> = messages.FoundGifs'

    def __str__(self):
        return '(messages.foundGifs (ID: 0x450a1c0a) = (next_offset={}, results={}))'.format(str(self.next_offset), None if not self.results else [str(_) for _ in self.results])
