from ...tl.mtproto_request import MTProtoRequest


class SetClientDHParamsRequest(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    set_client_DH_params#f5045f1f nonce:int128 server_nonce:int128 encrypted_data:string = Set_client_DH_params_answer"""

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

    def __init__(self, nonce, server_nonce, encrypted_data):
        """
        :param nonce: Telegram type: «int128».
        :param server_nonce: Telegram type: «int128».
        :param encrypted_data: Telegram type: «string».

        :returns Set_client_DH_params_answer: Instance of either DhGenOk, DhGenRetry, DhGenFail.
        """
        super().__init__()
        self.result = None
        self.confirmed = True  # Confirmed by default

        self.nonce = nonce
        self.server_nonce = server_nonce
        self.encrypted_data = encrypted_data

    def on_send(self, writer):
        writer.write_int(SetClientDHParamsRequest.constructor_id, signed=False)
        writer.write_large_int(self.nonce, bits=128)
        writer.write_large_int(self.server_nonce, bits=128)
        writer.tgwrite_string(self.encrypted_data)

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

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

    def __repr__(self):
        return 'set_client_DH_params#f5045f1f nonce:int128 server_nonce:int128 encrypted_data:string = Set_client_DH_params_answer'

    def __str__(self):
        return '(set_client_DH_params (ID: 0xf5045f1f) = (nonce={}, server_nonce={}, encrypted_data={}))'.format(str(self.nonce), str(self.server_nonce), str(self.encrypted_data))
