from telethon.tl.mtproto_request import MTProtoRequest


class ReqDHParamsRequest(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    req_DH_params#d712e4be nonce:int128 server_nonce:int128 p:string q:string public_key_fingerprint:long encrypted_data:string = Server_DH_Params"""

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

    def __init__(self, nonce, server_nonce, p, q, public_key_fingerprint, encrypted_data):
        """
        :param nonce: Telegram type: «int128».
        :param server_nonce: Telegram type: «int128».
        :param p: Telegram type: «string».
        :param q: Telegram type: «string».
        :param public_key_fingerprint: Telegram type: «long».
        :param encrypted_data: Telegram type: «string».
        """
        super().__init__()
        self.result = None
        self.confirmed = True  # Confirmed by default

        self.nonce = nonce
        self.server_nonce = server_nonce
        self.p = p
        self.q = q
        self.public_key_fingerprint = public_key_fingerprint
        self.encrypted_data = encrypted_data

    def on_send(self, writer):
        writer.write_int(ReqDHParamsRequest.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.p)
        writer.tgwrite_string(self.q)
        writer.write_long(self.public_key_fingerprint)
        writer.tgwrite_string(self.encrypted_data)

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

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

    def __repr__(self):
        return 'req_DH_params#d712e4be nonce:int128 server_nonce:int128 p:string q:string public_key_fingerprint:long encrypted_data:string = Server_DH_Params'

    def __str__(self):
        return '(req_DH_params (ID: 0xd712e4be) = (nonce={}, server_nonce={}, p={}, q={}, public_key_fingerprint={}, encrypted_data={}))'.format(str(self.nonce), str(self.server_nonce), str(self.p), str(self.q), str(self.public_key_fingerprint), str(self.encrypted_data))
