from ....tl.mtproto_request import MTProtoRequest


class GetHistoryRequest(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    messages.getHistory#afa92846 peer:InputPeer offset_id:int offset_date:date add_offset:int limit:int max_id:int min_id:int = messages.Messages"""

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

    def __init__(self, peer, offset_id, offset_date, add_offset, limit, max_id, min_id):
        """
        :param peer: Telegram type: «InputPeer».
        :param offset_id: Telegram type: «int».
        :param offset_date: Telegram type: «date».
        :param add_offset: Telegram type: «int».
        :param limit: Telegram type: «int».
        :param max_id: Telegram type: «int».
        :param min_id: Telegram type: «int».

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

        self.peer = peer
        self.offset_id = offset_id
        self.offset_date = offset_date
        self.add_offset = add_offset
        self.limit = limit
        self.max_id = max_id
        self.min_id = min_id

    def on_send(self, writer):
        writer.write_int(GetHistoryRequest.constructor_id, signed=False)
        self.peer.on_send(writer)
        writer.write_int(self.offset_id)
        writer.tgwrite_date(self.offset_date)
        writer.write_int(self.add_offset)
        writer.write_int(self.limit)
        writer.write_int(self.max_id)
        writer.write_int(self.min_id)

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

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

    def __repr__(self):
        return 'messages.getHistory#afa92846 peer:InputPeer offset_id:int offset_date:date add_offset:int limit:int max_id:int min_id:int = messages.Messages'

    def __str__(self):
        return '(messages.getHistory (ID: 0xafa92846) = (peer={}, offset_id={}, offset_date={}, add_offset={}, limit={}, max_id={}, min_id={}))'.format(str(self.peer), str(self.offset_id), str(self.offset_date), str(self.add_offset), str(self.limit), str(self.max_id), str(self.min_id))
