"""File generated by TLObjects' generator. All changes will be ERASED"""
from ...tl.tlobject import TLObject


class AppUpdate(TLObject):
    constructor_id = 0x8987f311
    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():
        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)



class ConfigSimple(TLObject):
    constructor_id = 0xd997c3c5
    subclass_of_id = 0x29183ac4

    def __init__(self, date, expires, dc_id, ip_port_list):
        """
        :param date: Telegram type: "date".
        :param expires: Telegram type: "date".
        :param dc_id: Telegram type: "int".
        :param ip_port_list: Telegram type: "ipPort". Must be a list.

        Constructor for help.ConfigSimple: Instance of ConfigSimple.
        """
        super().__init__()

        self.date = date
        self.expires = expires
        self.dc_id = dc_id
        self.ip_port_list = ip_port_list

    def to_dict(self):
        return {
            'date': self.date,
            'expires': self.expires,
            'dc_id': self.dc_id,
            'ip_port_list': [] if self.ip_port_list is None else [None if x is None else x.to_dict() for x in self.ip_port_list],
        }

    def on_send(self, writer):
        writer.write_int(ConfigSimple.constructor_id, signed=False)
        writer.tgwrite_date(self.date)
        writer.tgwrite_date(self.expires)
        writer.write_int(self.dc_id)
        writer.write_int(0x1cb5c415, signed=False)  # Vector's constructor ID
        writer.write_int(len(self.ip_port_list))
        for _x in self.ip_port_list:
            _x.on_send(writer)

    @staticmethod
    def empty():
        return ConfigSimple(None, None, None, None)

    def on_response(self, reader):
        self.date = reader.tgread_date()
        self.expires = reader.tgread_date()
        self.dc_id = reader.read_int()
        reader.read_int()
        self.ip_port_list = []
        _len = reader.read_int()
        for _ in range(_len):
            _x = reader.tgread_object()
            self.ip_port_list.append(_x)

    def __repr__(self):
        return 'help.configSimple#d997c3c5 date:int expires:int dc_id:int ip_port_list:Vector<ipPort> = help.ConfigSimple'

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

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



class InviteText(TLObject):
    constructor_id = 0x18cb9f78
    subclass_of_id = 0xcf70aa35

    def __init__(self, message):
        """
        :param message: Telegram type: "string".

        Constructor for help.InviteText: Instance of InviteText.
        """
        super().__init__()

        self.message = message

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

    def on_send(self, writer):
        writer.write_int(InviteText.constructor_id, signed=False)
        writer.tgwrite_string(self.message)

    @staticmethod
    def empty():
        return InviteText(None)

    def on_response(self, reader):
        self.message = reader.tgread_string()

    def __repr__(self):
        return 'help.inviteText#18cb9f78 message:string = help.InviteText'

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

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



class NoAppUpdate(TLObject):
    constructor_id = 0xc45a6536
    subclass_of_id = 0x5897069e

    def __init__(self):
        super().__init__()

    @staticmethod
    def to_dict():
        return {}

    def on_send(self, writer):
        writer.write_int(NoAppUpdate.constructor_id, signed=False)

    @staticmethod
    def empty():
        return NoAppUpdate()

    def on_response(self, reader):
        pass

    def __repr__(self):
        return 'help.noAppUpdate#c45a6536 = help.AppUpdate'

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

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



class Support(TLObject):
    constructor_id = 0x17c6b5f6
    subclass_of_id = 0x7159bceb

    def __init__(self, phone_number, user):
        """
        :param phone_number: Telegram type: "string".
        :param user: Telegram type: "User".

        Constructor for help.Support: Instance of Support.
        """
        super().__init__()

        self.phone_number = phone_number
        self.user = user

    def to_dict(self):
        return {
            'phone_number': self.phone_number,
            'user': None if self.user is None else self.user.to_dict(),
        }

    def on_send(self, writer):
        writer.write_int(Support.constructor_id, signed=False)
        writer.tgwrite_string(self.phone_number)
        self.user.on_send(writer)

    @staticmethod
    def empty():
        return Support(None, None)

    def on_response(self, reader):
        self.phone_number = reader.tgread_string()
        self.user = reader.tgread_object()

    def __repr__(self):
        return 'help.support#17c6b5f6 phone_number:string user:User = help.Support'

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

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



class TermsOfService(TLObject):
    constructor_id = 0xf1ee3e90
    subclass_of_id = 0x20ee8312

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

        Constructor for help.TermsOfService: Instance of TermsOfService.
        """
        super().__init__()

        self.text = text

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

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

    @staticmethod
    def empty():
        return TermsOfService(None)

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

    def __repr__(self):
        return 'help.termsOfService#f1ee3e90 text:string = help.TermsOfService'

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

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

