from ...tl.mtproto_request import MTProtoRequest


class ServerDHInnerData(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    server_DH_inner_data#b5890dba nonce:int128 server_nonce:int128 g:int dh_prime:string g_a:string server_time:int = Server_DH_inner_data"""

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

    def __init__(self, nonce, server_nonce, g, dh_prime, g_a, server_time):
        """
        :param nonce: Telegram type: «int128».
        :param server_nonce: Telegram type: «int128».
        :param g: Telegram type: «int».
        :param dh_prime: Telegram type: «string».
        :param g_a: Telegram type: «string».
        :param server_time: Telegram type: «int».

        Constructor for Server_DH_inner_data: Instance of ServerDHInnerData.
        """
        super().__init__()

        self.nonce = nonce
        self.server_nonce = server_nonce
        self.g = g
        self.dh_prime = dh_prime
        self.g_a = g_a
        self.server_time = server_time

    def on_send(self, writer):
        writer.write_int(ServerDHInnerData.constructor_id, signed=False)
        writer.write_large_int(self.nonce, bits=128)
        writer.write_large_int(self.server_nonce, bits=128)
        writer.write_int(self.g)
        writer.tgwrite_string(self.dh_prime)
        writer.tgwrite_string(self.g_a)
        writer.write_int(self.server_time)

    @staticmethod
    def empty():
        """Returns an "empty" instance (all attributes are None)"""
        return ServerDHInnerData(None, None, None, 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.g = reader.read_int()
        self.dh_prime = reader.tgread_string()
        self.g_a = reader.tgread_string()
        self.server_time = reader.read_int()

    def __repr__(self):
        return 'server_DH_inner_data#b5890dba nonce:int128 server_nonce:int128 g:int dh_prime:string g_a:string server_time:int = Server_DH_inner_data'

    def __str__(self):
        return '(server_DH_inner_data (ID: 0xb5890dba) = (nonce={}, server_nonce={}, g={}, dh_prime={}, g_a={}, server_time={}))'.format(str(self.nonce), str(self.server_nonce), str(self.g), str(self.dh_prime), str(self.g_a), str(self.server_time))
