from ....tl.mtproto_request import MTProtoRequest


class GetFileRequest(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    upload.getFile#e3a6cfb5 location:InputFileLocation offset:int limit:int = upload.File"""

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

    def __init__(self, location, offset, limit):
        """
        :param location: Telegram type: «InputFileLocation».
        :param offset: Telegram type: «int».
        :param limit: Telegram type: «int».

        :returns upload.File: Instance of either File, FileCdnRedirect.
        """
        super().__init__()
        self.result = None
        self.confirmed = True  # Confirmed by default

        self.location = location
        self.offset = offset
        self.limit = limit

    def on_send(self, writer):
        writer.write_int(GetFileRequest.constructor_id, signed=False)
        self.location.on_send(writer)
        writer.write_int(self.offset)
        writer.write_int(self.limit)

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

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

    def __repr__(self):
        return 'upload.getFile#e3a6cfb5 location:InputFileLocation offset:int limit:int = upload.File'

    def __str__(self):
        return '(upload.getFile (ID: 0xe3a6cfb5) = (location={}, offset={}, limit={}))'.format(str(self.location), str(self.offset), str(self.limit))
