from telethon.tl.mtproto_request import MTProtoRequest


class GetDocumentByHashRequest(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    messages.getDocumentByHash#338e2464 sha256:bytes size:int mime_type:string = Document"""

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

    def __init__(self, sha256, size, mime_type):
        """
        :param sha256: Telegram type: «bytes».
        :param size: Telegram type: «int».
        :param mime_type: Telegram type: «string».
        """
        super().__init__()
        self.result = None
        self.confirmed = True  # Confirmed by default

        self.sha256 = sha256
        self.size = size
        self.mime_type = mime_type

    def on_send(self, writer):
        writer.write_int(GetDocumentByHashRequest.constructor_id, signed=False)
        writer.tgwrite_bytes(self.sha256)
        writer.write_int(self.size)
        writer.tgwrite_string(self.mime_type)

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

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

    def __repr__(self):
        return 'messages.getDocumentByHash#338e2464 sha256:bytes size:int mime_type:string = Document'

    def __str__(self):
        return '(messages.getDocumentByHash (ID: 0x338e2464) = (sha256={}, size={}, mime_type={}))'.format(str(self.sha256), str(self.size), str(self.mime_type))
