from telethon.tl.mtproto_request import MTProtoRequest


class SaveFilePartRequest(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    upload.saveFilePart#b304a621 file_id:long file_part:int bytes:bytes = Bool"""

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

    def __init__(self, file_id, file_part, bytes):
        """
        :param file_id: Telegram type: «long».
        :param file_part: Telegram type: «int».
        :param bytes: Telegram type: «bytes».
        """
        super().__init__()
        self.result = None
        self.confirmed = True  # Confirmed by default

        self.file_id = file_id
        self.file_part = file_part
        self.bytes = bytes

    def on_send(self, writer):
        writer.write_int(SaveFilePartRequest.constructor_id, signed=False)
        writer.write_long(self.file_id)
        writer.write_int(self.file_part)
        writer.tgwrite_bytes(self.bytes)

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

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

    def __repr__(self):
        return 'upload.saveFilePart#b304a621 file_id:long file_part:int bytes:bytes = Bool'

    def __str__(self):
        return '(upload.saveFilePart (ID: 0xb304a621) = (file_id={}, file_part={}, bytes={}))'.format(str(self.file_id), str(self.file_part), str(self.bytes))
