from ....tl.mtproto_request import MTProtoRequest


class WebFile(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    upload.webFile#21e753bc size:int mime_type:string file_type:storage.FileType mtime:int bytes:bytes = upload.WebFile"""

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

    def __init__(self, size, mime_type, file_type, mtime, bytes):
        """
        :param size: Telegram type: «int».
        :param mime_type: Telegram type: «string».
        :param file_type: Telegram type: «storage.FileType».
        :param mtime: Telegram type: «int».
        :param bytes: Telegram type: «bytes».

        Constructor for upload.WebFile: Instance of WebFile.
        """
        super().__init__()

        self.size = size
        self.mime_type = mime_type
        self.file_type = file_type
        self.mtime = mtime
        self.bytes = bytes

    def on_send(self, writer):
        writer.write_int(WebFile.constructor_id, signed=False)
        writer.write_int(self.size)
        writer.tgwrite_string(self.mime_type)
        self.file_type.on_send(writer)
        writer.write_int(self.mtime)
        writer.tgwrite_bytes(self.bytes)

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

    def on_response(self, reader):
        self.size = reader.read_int()
        self.mime_type = reader.tgread_string()
        self.file_type = reader.tgread_object()
        self.mtime = reader.read_int()
        self.bytes = reader.tgread_bytes()

    def __repr__(self):
        return 'upload.webFile#21e753bc size:int mime_type:string file_type:storage.FileType mtime:int bytes:bytes = upload.WebFile'

    def __str__(self):
        return '(upload.webFile (ID: 0x21e753bc) = (size={}, mime_type={}, file_type={}, mtime={}, bytes={}))'.format(str(self.size), str(self.mime_type), str(self.file_type), str(self.mtime), str(self.bytes))
