from ....tl.mtproto_request import MTProtoRequest


class GetMessagesRequest(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    messages.getMessages#4222fa74 id:Vector<int> = messages.Messages"""

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

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

        :returns messages.Messages: Instance of either Messages, MessagesSlice, ChannelMessages.
        """
        super().__init__()
        self.result = None
        self.confirmed = True  # Confirmed by default

        self.id = id

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

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

    def on_response(self, reader):
        self.result = reader.tgread_object()

    def __repr__(self):
        return 'messages.getMessages#4222fa74 id:Vector<int> = messages.Messages'

    def __str__(self):
        return '(messages.getMessages (ID: 0x4222fa74) = (id={}))'.format(None if not self.id else [str(_) for _ in self.id])
