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


class AppUpdate(TLObject):
    CONSTRUCTOR_ID = 0x8987f311
    SUBCLASS_OF_ID = 0x5897069e

    def __init__(self, id, critical, url, text):
        """
        :param int id:
        :param TLObject critical:
        :param str url:
        :param str text:

        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, recursive=True):
        return {
            'id': self.id,
            'critical': self.critical,
            'url': self.url,
            'text': self.text,
        }

    def to_bytes(self):
        return b''.join((
            b'\x11\xf3\x87\x89',
            struct.pack('<i', self.id),
            b'\xb5ur\x99' if self.critical else b'7\x97y\xbc',
            TLObject.serialize_bytes(self.url),
            TLObject.serialize_bytes(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 __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 datetime.datetime | None date:
        :param datetime.datetime | None expires:
        :param int dc_id:
        :param list[TLObject] ip_port_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, recursive=True):
        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]) if recursive else self.ip_port_list,
        }

    def to_bytes(self):
        return b''.join((
            b'\xc5\xc3\x97\xd9',
            b'\0\0\0\0' if self.date is None else struct.pack('<I', int(self.date.timestamp())),
            b'\0\0\0\0' if self.expires is None else struct.pack('<I', int(self.expires.timestamp())),
            struct.pack('<i', self.dc_id),
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.ip_port_list)),b''.join(x.to_bytes() for x in self.ip_port_list),
        ))

    @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 __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 str message:

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

        self.message = message

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

    def to_bytes(self):
        return b''.join((
            b'x\x9f\xcb\x18',
            TLObject.serialize_bytes(self.message),
        ))

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

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

    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__()

    def to_dict(self, recursive=True):
        return {}

    def to_bytes(self):
        return b''.join((
            b'6eZ\xc4',
        ))

    @staticmethod
    def empty():
        return NoAppUpdate()

    def on_response(self, reader):
        pass

    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 str phone_number:
        :param TLObject user:

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

        self.phone_number = phone_number
        self.user = user

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

    def to_bytes(self):
        return b''.join((
            b'\xf6\xb5\xc6\x17',
            TLObject.serialize_bytes(self.phone_number),
            self.user.to_bytes(),
        ))

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

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

    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 str text:

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

        self.text = text

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

    def to_bytes(self):
        return b''.join((
            b'\x90>\xee\xf1',
            TLObject.serialize_bytes(self.text),
        ))

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

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

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

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