from ....tl.tlobject import TLObject


class AppUpdate(TLObject):
    """Class generated by TLObjects' generator. All changes will be ERASED. TL definition below.
    help.appUpdate#8987f311 id:int critical:Bool url:string text:string = help.AppUpdate"""

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

    def __init__(self, id, critical, url, text):
        """
        :param id: Telegram type: "int".
        :param critical: Telegram type: "Bool".
        :param url: Telegram type: "string".
        :param text: Telegram type: "string".

        Constructor for help.AppUpdate: Instance of either AppUpdate, NoAppUpdate.
        """
        super().__init__()

        self.id = id
        self.critical = critical
        self.url = url
        self.text = text

    def to_dict(self):
        return {
            'id': self.id,
            'critical': self.critical,
            'url': self.url,
            'text': self.text,
        }

    def on_send(self, writer):
        writer.write_int(AppUpdate.constructor_id, signed=False)
        writer.write_int(self.id)
        writer.tgwrite_bool(self.critical)
        writer.tgwrite_string(self.url)
        writer.tgwrite_string(self.text)

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

    def on_response(self, reader):
        self.id = reader.read_int()
        self.critical = reader.tgread_bool()
        self.url = reader.tgread_string()
        self.text = reader.tgread_string()

    def __repr__(self):
        return 'help.appUpdate#8987f311 id:int critical:Bool url:string text:string = help.AppUpdate'

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

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