from ...tl.tlobject import TLObject


class Error(TLObject):
    """Class generated by TLObjects' generator. All changes will be ERASED. TL definition below.
    error#c4b9f9bb code:int text:string = Error"""

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

    def __init__(self, code, text):
        """
        :param code: Telegram type: "int".
        :param text: Telegram type: "string".

        Constructor for Error: Instance of Error.
        """
        super().__init__()

        self.code = code
        self.text = text

    def to_dict(self):
        return {
            'code': self.code,
            'text': self.text,
        }

    def on_send(self, writer):
        writer.write_int(Error.constructor_id, signed=False)
        writer.write_int(self.code)
        writer.tgwrite_string(self.text)

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

    def on_response(self, reader):
        self.code = reader.read_int()
        self.text = reader.tgread_string()

    def __repr__(self):
        return 'error#c4b9f9bb code:int text:string = Error'

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

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