from telethon.tl.mtproto_request import MTProtoRequest


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

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

    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».
        """
        super().__init__()

        self.id = id
        self.critical = critical
        self.url = url
        self.text = 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 (all attributes are 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 '(help.appUpdate (ID: 0x8987f311) = (id={}, critical={}, url={}, text={}))'.format(str(self.id), str(self.critical), str(self.url), str(self.text))
