from ....tl.tlobject import TLObject


class DhConfig(TLObject):
    """Class generated by TLObjects' generator. All changes will be ERASED. TL definition below.
    messages.dhConfig#2c221edd g:int p:bytes version:int random:bytes = messages.DhConfig"""

    # Telegram's constructor (U)ID for this class
    constructor_id = 0x2c221edd
    # Also the ID of its resulting type for fast checks
    subclass_of_id = 0xe488ed8b

    def __init__(self, g, p, version, random):
        """
        :param g: Telegram type: "int".
        :param p: Telegram type: "bytes".
        :param version: Telegram type: "int".
        :param random: Telegram type: "bytes".

        Constructor for messages.DhConfig: Instance of either DhConfigNotModified, DhConfig.
        """
        super().__init__()

        self.g = g
        self.p = p
        self.version = version
        self.random = random

    def to_dict(self):
        return {
            'g': self.g,
            'p': self.p,
            'version': self.version,
            'random': self.random,
        }

    def on_send(self, writer):
        writer.write_int(DhConfig.constructor_id, signed=False)
        writer.write_int(self.g)
        writer.tgwrite_bytes(self.p)
        writer.write_int(self.version)
        writer.tgwrite_bytes(self.random)

    @staticmethod
    def empty():
        """Returns an "empty" instance (attributes=None)"""
        return DhConfig(None, None, None, None)

    def on_response(self, reader):
        self.g = reader.read_int()
        self.p = reader.tgread_bytes()
        self.version = reader.read_int()
        self.random = reader.tgread_bytes()

    def __repr__(self):
        return 'messages.dhConfig#2c221edd g:int p:bytes version:int random:bytes = messages.DhConfig'

    def __str__(self):
        return TLObject.pretty_format(self)

    def stringify(self):
        return TLObject.pretty_format(self, indent=0)
