from ....tl.mtproto_request import MTProtoRequest


class GetCdnFileRequest(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    upload.getCdnFile#2000bcc3 file_token:bytes offset:int limit:int = upload.CdnFile"""

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

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

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

        self.file_token = file_token
        self.offset = offset
        self.limit = limit

    def on_send(self, writer):
        writer.write_int(GetCdnFileRequest.constructor_id, signed=False)
        writer.tgwrite_bytes(self.file_token)
        writer.write_int(self.offset)
        writer.write_int(self.limit)

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

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

    def __repr__(self):
        return 'upload.getCdnFile#2000bcc3 file_token:bytes offset:int limit:int = upload.CdnFile'

    def __str__(self):
        return '(upload.getCdnFile (ID: 0x2000bcc3) = (file_token={}, offset={}, limit={}))'.format(str(self.file_token), str(self.offset), str(self.limit))
