from ....tl.mtproto_request import MTProtoRequest


class FileCdnRedirect(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    upload.fileCdnRedirect#1508485a dc_id:int file_token:bytes encryption_key:bytes encryption_iv:bytes = upload.File"""

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

    def __init__(self, dc_id, file_token, encryption_key, encryption_iv):
        """
        :param dc_id: Telegram type: «int».
        :param file_token: Telegram type: «bytes».
        :param encryption_key: Telegram type: «bytes».
        :param encryption_iv: Telegram type: «bytes».

        Constructor for upload.File: Instance of either File, FileCdnRedirect.
        """
        super().__init__()

        self.dc_id = dc_id
        self.file_token = file_token
        self.encryption_key = encryption_key
        self.encryption_iv = encryption_iv

    def on_send(self, writer):
        writer.write_int(FileCdnRedirect.constructor_id, signed=False)
        writer.write_int(self.dc_id)
        writer.tgwrite_bytes(self.file_token)
        writer.tgwrite_bytes(self.encryption_key)
        writer.tgwrite_bytes(self.encryption_iv)

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

    def on_response(self, reader):
        self.dc_id = reader.read_int()
        self.file_token = reader.tgread_bytes()
        self.encryption_key = reader.tgread_bytes()
        self.encryption_iv = reader.tgread_bytes()

    def __repr__(self):
        return 'upload.fileCdnRedirect#1508485a dc_id:int file_token:bytes encryption_key:bytes encryption_iv:bytes = upload.File'

    def __str__(self):
        return '(upload.fileCdnRedirect (ID: 0x1508485a) = (dc_id={}, file_token={}, encryption_key={}, encryption_iv={}))'.format(str(self.dc_id), str(self.file_token), str(self.encryption_key), str(self.encryption_iv))
