from telethon.tl.mtproto_request import MTProtoRequest


class BindTempAuthKeyRequest(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    auth.bindTempAuthKey#cdd42a05 perm_auth_key_id:long nonce:long expires_at:int encrypted_message:bytes = Bool"""

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

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

        self.perm_auth_key_id = perm_auth_key_id
        self.nonce = nonce
        self.expires_at = expires_at
        self.encrypted_message = encrypted_message

    def on_send(self, writer):
        writer.write_int(BindTempAuthKeyRequest.constructor_id, signed=False)
        writer.write_long(self.perm_auth_key_id)
        writer.write_long(self.nonce)
        writer.write_int(self.expires_at)
        writer.tgwrite_bytes(self.encrypted_message)

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

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

    def __repr__(self):
        return 'auth.bindTempAuthKey#cdd42a05 perm_auth_key_id:long nonce:long expires_at:int encrypted_message:bytes = Bool'

    def __str__(self):
        return '(auth.bindTempAuthKey (ID: 0xcdd42a05) = (perm_auth_key_id={}, nonce={}, expires_at={}, encrypted_message={}))'.format(str(self.perm_auth_key_id), str(self.nonce), str(self.expires_at), str(self.encrypted_message))
