from telethon.tl.mtproto_request import MTProtoRequest


class ServerDHParamsOk(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    server_DH_params_ok#d0e8075c nonce:int128 server_nonce:int128 encrypted_answer:string = Server_DH_Params"""

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

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

        self.nonce = nonce
        self.server_nonce = server_nonce
        self.encrypted_answer = encrypted_answer

    def on_send(self, writer):
        writer.write_int(ServerDHParamsOk.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_answer)

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

    def on_response(self, reader):
        self.nonce = reader.read_large_int(bits=128)
        self.server_nonce = reader.read_large_int(bits=128)
        self.encrypted_answer = reader.tgread_string()

    def __repr__(self):
        return 'server_DH_params_ok#d0e8075c nonce:int128 server_nonce:int128 encrypted_answer:string = Server_DH_Params'

    def __str__(self):
        return '(server_DH_params_ok (ID: 0xd0e8075c) = (nonce={}, server_nonce={}, encrypted_answer={}))'.format(str(self.nonce), str(self.server_nonce), str(self.encrypted_answer))
