"""File auto-generated by tglib TL generator. Do not edit manually."""
from ..tlobject import TLObject
from typing import Optional, List, Union
import os
import struct
from datetime import datetime


class AuthorizationForm(TLObject):
    """TL type: account.authorizationForm"""
    CONSTRUCTOR_ID = 0xad2e1cd8
    SUBCLASS_OF_ID = 0x78049a94

    def __init__(self, required_types: List['TypeSecureRequiredType'], values: List['TypeSecureValue'], errors: List['TypeSecureValueError'], users: List['TypeUser'], privacy_policy_url: Optional[str] = None):
        self.required_types = required_types
        self.values = values
        self.errors = errors
        self.users = users
        self.privacy_policy_url = privacy_policy_url

    def to_dict(self):
        return {
            '_': 'AuthorizationForm',
            'required_types': self.required_types,
            'values': self.values,
            'errors': self.errors,
            'users': self.users,
            'privacy_policy_url': self.privacy_policy_url,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.privacy_policy_url is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.required_types)))
        for item in self.required_types:
            buf.write(bytes(self.item))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.values)))
        for item in self.values:
            buf.write(bytes(self.item))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.errors)))
        for item in self.errors:
            buf.write(bytes(self.item))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.users)))
        for item in self.users:
            buf.write(bytes(self.item))
        if self.privacy_policy_url is not None:
            buf.write(TLObject.serialize_bytes(self.privacy_policy_url))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        reader.read_int(signed=False)  # skip vector id
        _count_required_types = reader.read_int()
        _list_required_types = []
        for _ in range(_count_required_types):
            _item_required_types = reader.tgread_object()
            _list_required_types.append(_item_required_types)
        _args['required_types'] = _list_required_types
        reader.read_int(signed=False)  # skip vector id
        _count_values = reader.read_int()
        _list_values = []
        for _ in range(_count_values):
            _item_values = reader.tgread_object()
            _list_values.append(_item_values)
        _args['values'] = _list_values
        reader.read_int(signed=False)  # skip vector id
        _count_errors = reader.read_int()
        _list_errors = []
        for _ in range(_count_errors):
            _item_errors = reader.tgread_object()
            _list_errors.append(_item_errors)
        _args['errors'] = _list_errors
        reader.read_int(signed=False)  # skip vector id
        _count_users = reader.read_int()
        _list_users = []
        for _ in range(_count_users):
            _item_users = reader.tgread_object()
            _list_users.append(_item_users)
        _args['users'] = _list_users
        if flags & (1 << 0):
            _val_privacy_policy_url = reader.tgread_string()
            _args['privacy_policy_url'] = _val_privacy_policy_url
        else:
            _args['privacy_policy_url'] = None
        return cls(**_args)


class Authorizations(TLObject):
    """TL type: account.authorizations"""
    CONSTRUCTOR_ID = 0x4bff8ea0
    SUBCLASS_OF_ID = 0x0bf5e0ff

    def __init__(self, authorization_ttl_days: int, authorizations: List['TypeAuthorization']):
        self.authorization_ttl_days = authorization_ttl_days
        self.authorizations = authorizations

    def to_dict(self):
        return {
            '_': 'Authorizations',
            'authorization_ttl_days': self.authorization_ttl_days,
            'authorizations': self.authorizations,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.authorization_ttl_days))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.authorizations)))
        for item in self.authorizations:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_authorization_ttl_days = reader.read_int()
        _args['authorization_ttl_days'] = _val_authorization_ttl_days
        reader.read_int(signed=False)  # skip vector id
        _count_authorizations = reader.read_int()
        _list_authorizations = []
        for _ in range(_count_authorizations):
            _item_authorizations = reader.tgread_object()
            _list_authorizations.append(_item_authorizations)
        _args['authorizations'] = _list_authorizations
        return cls(**_args)


class AutoDownloadSettings(TLObject):
    """TL type: account.autoDownloadSettings"""
    CONSTRUCTOR_ID = 0x63cacf26
    SUBCLASS_OF_ID = 0x2fb85921

    def __init__(self, low: 'TypeAutoDownloadSettings', medium: 'TypeAutoDownloadSettings', high: 'TypeAutoDownloadSettings'):
        self.low = low
        self.medium = medium
        self.high = high

    def to_dict(self):
        return {
            '_': 'AutoDownloadSettings',
            'low': self.low,
            'medium': self.medium,
            'high': self.high,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.low))
        buf.write(bytes(self.medium))
        buf.write(bytes(self.high))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_low = reader.tgread_object()
        _args['low'] = _val_low
        _val_medium = reader.tgread_object()
        _args['medium'] = _val_medium
        _val_high = reader.tgread_object()
        _args['high'] = _val_high
        return cls(**_args)


class AutoSaveSettings(TLObject):
    """TL type: account.autoSaveSettings"""
    CONSTRUCTOR_ID = 0x4c3e069d
    SUBCLASS_OF_ID = 0x48cf2f02

    def __init__(self, users_settings: 'TypeAutoSaveSettings', chats_settings: 'TypeAutoSaveSettings', broadcasts_settings: 'TypeAutoSaveSettings', exceptions: List['TypeAutoSaveException'], chats: List['TypeChat'], users: List['TypeUser']):
        self.users_settings = users_settings
        self.chats_settings = chats_settings
        self.broadcasts_settings = broadcasts_settings
        self.exceptions = exceptions
        self.chats = chats
        self.users = users

    def to_dict(self):
        return {
            '_': 'AutoSaveSettings',
            'users_settings': self.users_settings,
            'chats_settings': self.chats_settings,
            'broadcasts_settings': self.broadcasts_settings,
            'exceptions': self.exceptions,
            'chats': self.chats,
            'users': self.users,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.users_settings))
        buf.write(bytes(self.chats_settings))
        buf.write(bytes(self.broadcasts_settings))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.exceptions)))
        for item in self.exceptions:
            buf.write(bytes(self.item))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.chats)))
        for item in self.chats:
            buf.write(bytes(self.item))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.users)))
        for item in self.users:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_users_settings = reader.tgread_object()
        _args['users_settings'] = _val_users_settings
        _val_chats_settings = reader.tgread_object()
        _args['chats_settings'] = _val_chats_settings
        _val_broadcasts_settings = reader.tgread_object()
        _args['broadcasts_settings'] = _val_broadcasts_settings
        reader.read_int(signed=False)  # skip vector id
        _count_exceptions = reader.read_int()
        _list_exceptions = []
        for _ in range(_count_exceptions):
            _item_exceptions = reader.tgread_object()
            _list_exceptions.append(_item_exceptions)
        _args['exceptions'] = _list_exceptions
        reader.read_int(signed=False)  # skip vector id
        _count_chats = reader.read_int()
        _list_chats = []
        for _ in range(_count_chats):
            _item_chats = reader.tgread_object()
            _list_chats.append(_item_chats)
        _args['chats'] = _list_chats
        reader.read_int(signed=False)  # skip vector id
        _count_users = reader.read_int()
        _list_users = []
        for _ in range(_count_users):
            _item_users = reader.tgread_object()
            _list_users.append(_item_users)
        _args['users'] = _list_users
        return cls(**_args)


class BusinessChatLinks(TLObject):
    """TL type: account.businessChatLinks"""
    CONSTRUCTOR_ID = 0xec43a2d1
    SUBCLASS_OF_ID = 0xc6ba4a31

    def __init__(self, links: List['TypeBusinessChatLink'], chats: List['TypeChat'], users: List['TypeUser']):
        self.links = links
        self.chats = chats
        self.users = users

    def to_dict(self):
        return {
            '_': 'BusinessChatLinks',
            'links': self.links,
            'chats': self.chats,
            'users': self.users,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.links)))
        for item in self.links:
            buf.write(bytes(self.item))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.chats)))
        for item in self.chats:
            buf.write(bytes(self.item))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.users)))
        for item in self.users:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        reader.read_int(signed=False)  # skip vector id
        _count_links = reader.read_int()
        _list_links = []
        for _ in range(_count_links):
            _item_links = reader.tgread_object()
            _list_links.append(_item_links)
        _args['links'] = _list_links
        reader.read_int(signed=False)  # skip vector id
        _count_chats = reader.read_int()
        _list_chats = []
        for _ in range(_count_chats):
            _item_chats = reader.tgread_object()
            _list_chats.append(_item_chats)
        _args['chats'] = _list_chats
        reader.read_int(signed=False)  # skip vector id
        _count_users = reader.read_int()
        _list_users = []
        for _ in range(_count_users):
            _item_users = reader.tgread_object()
            _list_users.append(_item_users)
        _args['users'] = _list_users
        return cls(**_args)


class ChatThemes(TLObject):
    """TL type: account.chatThemes"""
    CONSTRUCTOR_ID = 0xbe098173
    SUBCLASS_OF_ID = 0x15c14aa8

    def __init__(self, hash: int, themes: List['TypeChatTheme'], chats: List['TypeChat'], users: List['TypeUser'], next_offset: Optional[str] = None):
        self.hash = hash
        self.themes = themes
        self.chats = chats
        self.users = users
        self.next_offset = next_offset

    def to_dict(self):
        return {
            '_': 'ChatThemes',
            'hash': self.hash,
            'themes': self.themes,
            'chats': self.chats,
            'users': self.users,
            'next_offset': self.next_offset,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.next_offset is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.hash))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.themes)))
        for item in self.themes:
            buf.write(bytes(self.item))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.chats)))
        for item in self.chats:
            buf.write(bytes(self.item))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.users)))
        for item in self.users:
            buf.write(bytes(self.item))
        if self.next_offset is not None:
            buf.write(TLObject.serialize_bytes(self.next_offset))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_hash = reader.read_long()
        _args['hash'] = _val_hash
        reader.read_int(signed=False)  # skip vector id
        _count_themes = reader.read_int()
        _list_themes = []
        for _ in range(_count_themes):
            _item_themes = reader.tgread_object()
            _list_themes.append(_item_themes)
        _args['themes'] = _list_themes
        reader.read_int(signed=False)  # skip vector id
        _count_chats = reader.read_int()
        _list_chats = []
        for _ in range(_count_chats):
            _item_chats = reader.tgread_object()
            _list_chats.append(_item_chats)
        _args['chats'] = _list_chats
        reader.read_int(signed=False)  # skip vector id
        _count_users = reader.read_int()
        _list_users = []
        for _ in range(_count_users):
            _item_users = reader.tgread_object()
            _list_users.append(_item_users)
        _args['users'] = _list_users
        if flags & (1 << 0):
            _val_next_offset = reader.tgread_string()
            _args['next_offset'] = _val_next_offset
        else:
            _args['next_offset'] = None
        return cls(**_args)


class ChatThemesNotModified(TLObject):
    """TL type: account.chatThemesNotModified"""
    CONSTRUCTOR_ID = 0xe011e1c4
    SUBCLASS_OF_ID = 0x15c14aa8

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'ChatThemesNotModified',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class ConnectedBots(TLObject):
    """TL type: account.connectedBots"""
    CONSTRUCTOR_ID = 0x17d7f87b
    SUBCLASS_OF_ID = 0xe4caf7d3

    def __init__(self, connected_bots: List['TypeConnectedBot'], users: List['TypeUser']):
        self.connected_bots = connected_bots
        self.users = users

    def to_dict(self):
        return {
            '_': 'ConnectedBots',
            'connected_bots': self.connected_bots,
            'users': self.users,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.connected_bots)))
        for item in self.connected_bots:
            buf.write(bytes(self.item))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.users)))
        for item in self.users:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        reader.read_int(signed=False)  # skip vector id
        _count_connected_bots = reader.read_int()
        _list_connected_bots = []
        for _ in range(_count_connected_bots):
            _item_connected_bots = reader.tgread_object()
            _list_connected_bots.append(_item_connected_bots)
        _args['connected_bots'] = _list_connected_bots
        reader.read_int(signed=False)  # skip vector id
        _count_users = reader.read_int()
        _list_users = []
        for _ in range(_count_users):
            _item_users = reader.tgread_object()
            _list_users.append(_item_users)
        _args['users'] = _list_users
        return cls(**_args)


class ContentSettings(TLObject):
    """TL type: account.contentSettings"""
    CONSTRUCTOR_ID = 0x57e28221
    SUBCLASS_OF_ID = 0xae3ff891

    def __init__(self, sensitive_enabled: Optional[bool] = None, sensitive_can_change: Optional[bool] = None):
        self.sensitive_enabled = sensitive_enabled
        self.sensitive_can_change = sensitive_can_change

    def to_dict(self):
        return {
            '_': 'ContentSettings',
            'sensitive_enabled': self.sensitive_enabled,
            'sensitive_can_change': self.sensitive_can_change,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.sensitive_enabled:
            flags |= (1 << 0)
        if self.sensitive_can_change:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['sensitive_enabled'] = bool(flags & (1 << 0))
        _args['sensitive_can_change'] = bool(flags & (1 << 1))
        return cls(**_args)


class EmailVerified(TLObject):
    """TL type: account.emailVerified"""
    CONSTRUCTOR_ID = 0x2b96cd1b
    SUBCLASS_OF_ID = 0x64833188

    def __init__(self, email: str):
        self.email = email

    def to_dict(self):
        return {
            '_': 'EmailVerified',
            'email': self.email,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.email))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_email = reader.tgread_string()
        _args['email'] = _val_email
        return cls(**_args)


class EmailVerifiedLogin(TLObject):
    """TL type: account.emailVerifiedLogin"""
    CONSTRUCTOR_ID = 0xe1bb0d61
    SUBCLASS_OF_ID = 0x64833188

    def __init__(self, email: str, sent_code: 'TypeSentCode'):
        self.email = email
        self.sent_code = sent_code

    def to_dict(self):
        return {
            '_': 'EmailVerifiedLogin',
            'email': self.email,
            'sent_code': self.sent_code,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.email))
        buf.write(bytes(self.sent_code))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_email = reader.tgread_string()
        _args['email'] = _val_email
        _val_sent_code = reader.tgread_object()
        _args['sent_code'] = _val_sent_code
        return cls(**_args)


class EmojiStatuses(TLObject):
    """TL type: account.emojiStatuses"""
    CONSTRUCTOR_ID = 0x90c467d1
    SUBCLASS_OF_ID = 0xd3e005ca

    def __init__(self, hash: int, statuses: List['TypeEmojiStatus']):
        self.hash = hash
        self.statuses = statuses

    def to_dict(self):
        return {
            '_': 'EmojiStatuses',
            'hash': self.hash,
            'statuses': self.statuses,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.hash))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.statuses)))
        for item in self.statuses:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_hash = reader.read_long()
        _args['hash'] = _val_hash
        reader.read_int(signed=False)  # skip vector id
        _count_statuses = reader.read_int()
        _list_statuses = []
        for _ in range(_count_statuses):
            _item_statuses = reader.tgread_object()
            _list_statuses.append(_item_statuses)
        _args['statuses'] = _list_statuses
        return cls(**_args)


class EmojiStatusesNotModified(TLObject):
    """TL type: account.emojiStatusesNotModified"""
    CONSTRUCTOR_ID = 0xd08ce645
    SUBCLASS_OF_ID = 0xd3e005ca

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'EmojiStatusesNotModified',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class PaidMessagesRevenue(TLObject):
    """TL type: account.paidMessagesRevenue"""
    CONSTRUCTOR_ID = 0x1e109708
    SUBCLASS_OF_ID = 0x152f0c57

    def __init__(self, stars_amount: int):
        self.stars_amount = stars_amount

    def to_dict(self):
        return {
            '_': 'PaidMessagesRevenue',
            'stars_amount': self.stars_amount,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.stars_amount))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_stars_amount = reader.read_long()
        _args['stars_amount'] = _val_stars_amount
        return cls(**_args)


class PasskeyRegistrationOptions(TLObject):
    """TL type: account.passkeyRegistrationOptions"""
    CONSTRUCTOR_ID = 0xe16b5ce1
    SUBCLASS_OF_ID = 0x341d83e4

    def __init__(self, options: 'TypeDataJSON'):
        self.options = options

    def to_dict(self):
        return {
            '_': 'PasskeyRegistrationOptions',
            'options': self.options,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.options))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_options = reader.tgread_object()
        _args['options'] = _val_options
        return cls(**_args)


class Passkeys(TLObject):
    """TL type: account.passkeys"""
    CONSTRUCTOR_ID = 0xf8e0aa1c
    SUBCLASS_OF_ID = 0x24dd205e

    def __init__(self, passkeys: List['TypePasskey']):
        self.passkeys = passkeys

    def to_dict(self):
        return {
            '_': 'Passkeys',
            'passkeys': self.passkeys,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.passkeys)))
        for item in self.passkeys:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        reader.read_int(signed=False)  # skip vector id
        _count_passkeys = reader.read_int()
        _list_passkeys = []
        for _ in range(_count_passkeys):
            _item_passkeys = reader.tgread_object()
            _list_passkeys.append(_item_passkeys)
        _args['passkeys'] = _list_passkeys
        return cls(**_args)


class Password(TLObject):
    """TL type: account.password"""
    CONSTRUCTOR_ID = 0x957b50fb
    SUBCLASS_OF_ID = 0x53a211a3

    def __init__(self, new_algo: 'TypePasswordKdfAlgo', new_secure_algo: 'TypeSecurePasswordKdfAlgo', secure_random: bytes, has_recovery: Optional[bool] = None, has_secure_values: Optional[bool] = None, has_password: Optional[bool] = None, current_algo: Optional['TypePasswordKdfAlgo'] = None, srp_B: Optional[bytes] = None, srp_id: Optional[int] = None, hint: Optional[str] = None, email_unconfirmed_pattern: Optional[str] = None, pending_reset_date: Optional[datetime] = None, login_email_pattern: Optional[str] = None):
        self.new_algo = new_algo
        self.new_secure_algo = new_secure_algo
        self.secure_random = secure_random
        self.has_recovery = has_recovery
        self.has_secure_values = has_secure_values
        self.has_password = has_password
        self.current_algo = current_algo
        self.srp_B = srp_B
        self.srp_id = srp_id
        self.hint = hint
        self.email_unconfirmed_pattern = email_unconfirmed_pattern
        self.pending_reset_date = pending_reset_date
        self.login_email_pattern = login_email_pattern

    def to_dict(self):
        return {
            '_': 'Password',
            'new_algo': self.new_algo,
            'new_secure_algo': self.new_secure_algo,
            'secure_random': self.secure_random,
            'has_recovery': self.has_recovery,
            'has_secure_values': self.has_secure_values,
            'has_password': self.has_password,
            'current_algo': self.current_algo,
            'srp_B': self.srp_B,
            'srp_id': self.srp_id,
            'hint': self.hint,
            'email_unconfirmed_pattern': self.email_unconfirmed_pattern,
            'pending_reset_date': self.pending_reset_date,
            'login_email_pattern': self.login_email_pattern,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.has_recovery:
            flags |= (1 << 0)
        if self.has_secure_values:
            flags |= (1 << 1)
        if self.srp_id is not None:
            flags |= (1 << 2)
        if self.hint is not None:
            flags |= (1 << 3)
        if self.email_unconfirmed_pattern is not None:
            flags |= (1 << 4)
        if self.pending_reset_date is not None:
            flags |= (1 << 5)
        if self.login_email_pattern is not None:
            flags |= (1 << 6)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.new_algo))
        buf.write(bytes(self.new_secure_algo))
        buf.write(TLObject.serialize_bytes(self.secure_random))
        if self.current_algo is not None:
            buf.write(bytes(self.current_algo))
        if self.srp_B is not None:
            buf.write(TLObject.serialize_bytes(self.srp_B))
        if self.srp_id is not None:
            buf.write(struct.pack('<q', self.srp_id))
        if self.hint is not None:
            buf.write(TLObject.serialize_bytes(self.hint))
        if self.email_unconfirmed_pattern is not None:
            buf.write(TLObject.serialize_bytes(self.email_unconfirmed_pattern))
        if self.pending_reset_date is not None:
            buf.write(struct.pack('<i', self.pending_reset_date))
        if self.login_email_pattern is not None:
            buf.write(TLObject.serialize_bytes(self.login_email_pattern))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['has_recovery'] = bool(flags & (1 << 0))
        _args['has_secure_values'] = bool(flags & (1 << 1))
        _args['has_password'] = bool(flags & (1 << 2))
        if flags & (1 << 2):
            _val_current_algo = reader.tgread_object()
            _args['current_algo'] = _val_current_algo
        else:
            _args['current_algo'] = None
        if flags & (1 << 2):
            _val_srp_B = reader.tgread_bytes()
            _args['srp_B'] = _val_srp_B
        else:
            _args['srp_B'] = None
        if flags & (1 << 2):
            _val_srp_id = reader.read_long()
            _args['srp_id'] = _val_srp_id
        else:
            _args['srp_id'] = None
        if flags & (1 << 3):
            _val_hint = reader.tgread_string()
            _args['hint'] = _val_hint
        else:
            _args['hint'] = None
        if flags & (1 << 4):
            _val_email_unconfirmed_pattern = reader.tgread_string()
            _args['email_unconfirmed_pattern'] = _val_email_unconfirmed_pattern
        else:
            _args['email_unconfirmed_pattern'] = None
        _val_new_algo = reader.tgread_object()
        _args['new_algo'] = _val_new_algo
        _val_new_secure_algo = reader.tgread_object()
        _args['new_secure_algo'] = _val_new_secure_algo
        _val_secure_random = reader.tgread_bytes()
        _args['secure_random'] = _val_secure_random
        if flags & (1 << 5):
            _val_pending_reset_date = reader.read_int()
            _args['pending_reset_date'] = _val_pending_reset_date
        else:
            _args['pending_reset_date'] = None
        if flags & (1 << 6):
            _val_login_email_pattern = reader.tgread_string()
            _args['login_email_pattern'] = _val_login_email_pattern
        else:
            _args['login_email_pattern'] = None
        return cls(**_args)


class PasswordInputSettings(TLObject):
    """TL type: account.passwordInputSettings"""
    CONSTRUCTOR_ID = 0xc23727c9
    SUBCLASS_OF_ID = 0x0c426ca6

    def __init__(self, new_algo: Optional['TypePasswordKdfAlgo'] = None, new_password_hash: Optional[bytes] = None, hint: Optional[str] = None, email: Optional[str] = None, new_secure_settings: Optional['TypeSecureSecretSettings'] = None):
        self.new_algo = new_algo
        self.new_password_hash = new_password_hash
        self.hint = hint
        self.email = email
        self.new_secure_settings = new_secure_settings

    def to_dict(self):
        return {
            '_': 'PasswordInputSettings',
            'new_algo': self.new_algo,
            'new_password_hash': self.new_password_hash,
            'hint': self.hint,
            'email': self.email,
            'new_secure_settings': self.new_secure_settings,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.hint is not None:
            flags |= (1 << 0)
        if self.email is not None:
            flags |= (1 << 1)
        if self.new_secure_settings is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        if self.new_algo is not None:
            buf.write(bytes(self.new_algo))
        if self.new_password_hash is not None:
            buf.write(TLObject.serialize_bytes(self.new_password_hash))
        if self.hint is not None:
            buf.write(TLObject.serialize_bytes(self.hint))
        if self.email is not None:
            buf.write(TLObject.serialize_bytes(self.email))
        if self.new_secure_settings is not None:
            buf.write(bytes(self.new_secure_settings))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 0):
            _val_new_algo = reader.tgread_object()
            _args['new_algo'] = _val_new_algo
        else:
            _args['new_algo'] = None
        if flags & (1 << 0):
            _val_new_password_hash = reader.tgread_bytes()
            _args['new_password_hash'] = _val_new_password_hash
        else:
            _args['new_password_hash'] = None
        if flags & (1 << 0):
            _val_hint = reader.tgread_string()
            _args['hint'] = _val_hint
        else:
            _args['hint'] = None
        if flags & (1 << 1):
            _val_email = reader.tgread_string()
            _args['email'] = _val_email
        else:
            _args['email'] = None
        if flags & (1 << 2):
            _val_new_secure_settings = reader.tgread_object()
            _args['new_secure_settings'] = _val_new_secure_settings
        else:
            _args['new_secure_settings'] = None
        return cls(**_args)


class PasswordSettings(TLObject):
    """TL type: account.passwordSettings"""
    CONSTRUCTOR_ID = 0x9a5c33e5
    SUBCLASS_OF_ID = 0xd23fb078

    def __init__(self, email: Optional[str] = None, secure_settings: Optional['TypeSecureSecretSettings'] = None):
        self.email = email
        self.secure_settings = secure_settings

    def to_dict(self):
        return {
            '_': 'PasswordSettings',
            'email': self.email,
            'secure_settings': self.secure_settings,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.email is not None:
            flags |= (1 << 0)
        if self.secure_settings is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        if self.email is not None:
            buf.write(TLObject.serialize_bytes(self.email))
        if self.secure_settings is not None:
            buf.write(bytes(self.secure_settings))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 0):
            _val_email = reader.tgread_string()
            _args['email'] = _val_email
        else:
            _args['email'] = None
        if flags & (1 << 1):
            _val_secure_settings = reader.tgread_object()
            _args['secure_settings'] = _val_secure_settings
        else:
            _args['secure_settings'] = None
        return cls(**_args)


class PrivacyRules(TLObject):
    """TL type: account.privacyRules"""
    CONSTRUCTOR_ID = 0x50a04e45
    SUBCLASS_OF_ID = 0xb55aba82

    def __init__(self, rules: List['TypePrivacyRule'], chats: List['TypeChat'], users: List['TypeUser']):
        self.rules = rules
        self.chats = chats
        self.users = users

    def to_dict(self):
        return {
            '_': 'PrivacyRules',
            'rules': self.rules,
            'chats': self.chats,
            'users': self.users,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.rules)))
        for item in self.rules:
            buf.write(bytes(self.item))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.chats)))
        for item in self.chats:
            buf.write(bytes(self.item))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.users)))
        for item in self.users:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        reader.read_int(signed=False)  # skip vector id
        _count_rules = reader.read_int()
        _list_rules = []
        for _ in range(_count_rules):
            _item_rules = reader.tgread_object()
            _list_rules.append(_item_rules)
        _args['rules'] = _list_rules
        reader.read_int(signed=False)  # skip vector id
        _count_chats = reader.read_int()
        _list_chats = []
        for _ in range(_count_chats):
            _item_chats = reader.tgread_object()
            _list_chats.append(_item_chats)
        _args['chats'] = _list_chats
        reader.read_int(signed=False)  # skip vector id
        _count_users = reader.read_int()
        _list_users = []
        for _ in range(_count_users):
            _item_users = reader.tgread_object()
            _list_users.append(_item_users)
        _args['users'] = _list_users
        return cls(**_args)


class ResetPasswordFailedWait(TLObject):
    """TL type: account.resetPasswordFailedWait"""
    CONSTRUCTOR_ID = 0xe3779861
    SUBCLASS_OF_ID = 0x49507416

    def __init__(self, retry_date: Optional[datetime]):
        self.retry_date = retry_date

    def to_dict(self):
        return {
            '_': 'ResetPasswordFailedWait',
            'retry_date': self.retry_date,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.retry_date))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_retry_date = reader.read_int()
        _args['retry_date'] = _val_retry_date
        return cls(**_args)


class ResetPasswordOk(TLObject):
    """TL type: account.resetPasswordOk"""
    CONSTRUCTOR_ID = 0xe926d63e
    SUBCLASS_OF_ID = 0x49507416

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'ResetPasswordOk',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class ResetPasswordRequestedWait(TLObject):
    """TL type: account.resetPasswordRequestedWait"""
    CONSTRUCTOR_ID = 0xe9effc7d
    SUBCLASS_OF_ID = 0x49507416

    def __init__(self, until_date: Optional[datetime]):
        self.until_date = until_date

    def to_dict(self):
        return {
            '_': 'ResetPasswordRequestedWait',
            'until_date': self.until_date,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.until_date))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_until_date = reader.read_int()
        _args['until_date'] = _val_until_date
        return cls(**_args)


class ResolvedBusinessChatLinks(TLObject):
    """TL type: account.resolvedBusinessChatLinks"""
    CONSTRUCTOR_ID = 0x9a23af21
    SUBCLASS_OF_ID = 0x3a772c28

    def __init__(self, peer: 'TypePeer', message: str, chats: List['TypeChat'], users: List['TypeUser'], entities: Optional[List['TypeMessageEntity']] = None):
        self.peer = peer
        self.message = message
        self.chats = chats
        self.users = users
        self.entities = entities

    def to_dict(self):
        return {
            '_': 'ResolvedBusinessChatLinks',
            'peer': self.peer,
            'message': self.message,
            'chats': self.chats,
            'users': self.users,
            'entities': self.entities,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.entities is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(TLObject.serialize_bytes(self.message))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.chats)))
        for item in self.chats:
            buf.write(bytes(self.item))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.users)))
        for item in self.users:
            buf.write(bytes(self.item))
        if self.entities is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.entities)))
            for item in self.entities:
                buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_message = reader.tgread_string()
        _args['message'] = _val_message
        if flags & (1 << 0):
            reader.read_int(signed=False)  # skip vector id
            _count_entities = reader.read_int()
            _list_entities = []
            for _ in range(_count_entities):
                _item_entities = reader.tgread_object()
                _list_entities.append(_item_entities)
            _args['entities'] = _list_entities
        else:
            _args['entities'] = None
        reader.read_int(signed=False)  # skip vector id
        _count_chats = reader.read_int()
        _list_chats = []
        for _ in range(_count_chats):
            _item_chats = reader.tgread_object()
            _list_chats.append(_item_chats)
        _args['chats'] = _list_chats
        reader.read_int(signed=False)  # skip vector id
        _count_users = reader.read_int()
        _list_users = []
        for _ in range(_count_users):
            _item_users = reader.tgread_object()
            _list_users.append(_item_users)
        _args['users'] = _list_users
        return cls(**_args)


class SavedMusicIds(TLObject):
    """TL type: account.savedMusicIds"""
    CONSTRUCTOR_ID = 0x998d6636
    SUBCLASS_OF_ID = 0x4b4af692

    def __init__(self, ids: List[int]):
        self.ids = ids

    def to_dict(self):
        return {
            '_': 'SavedMusicIds',
            'ids': self.ids,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.ids)))
        for item in self.ids:
            buf.write(struct.pack('<q', self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        reader.read_int(signed=False)  # skip vector id
        _count_ids = reader.read_int()
        _list_ids = []
        for _ in range(_count_ids):
            _item_ids = reader.read_long()
            _list_ids.append(_item_ids)
        _args['ids'] = _list_ids
        return cls(**_args)


class SavedMusicIdsNotModified(TLObject):
    """TL type: account.savedMusicIdsNotModified"""
    CONSTRUCTOR_ID = 0x4fc81d6e
    SUBCLASS_OF_ID = 0x4b4af692

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'SavedMusicIdsNotModified',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class SavedRingtone(TLObject):
    """TL type: account.savedRingtone"""
    CONSTRUCTOR_ID = 0xb7263f6d
    SUBCLASS_OF_ID = 0xb1e28424

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'SavedRingtone',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class SavedRingtoneConverted(TLObject):
    """TL type: account.savedRingtoneConverted"""
    CONSTRUCTOR_ID = 0x1f307eb7
    SUBCLASS_OF_ID = 0xb1e28424

    def __init__(self, document: 'TypeDocument'):
        self.document = document

    def to_dict(self):
        return {
            '_': 'SavedRingtoneConverted',
            'document': self.document,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.document))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_document = reader.tgread_object()
        _args['document'] = _val_document
        return cls(**_args)


class SavedRingtones(TLObject):
    """TL type: account.savedRingtones"""
    CONSTRUCTOR_ID = 0xc1e92cc5
    SUBCLASS_OF_ID = 0x27bcc95e

    def __init__(self, hash: int, ringtones: List['TypeDocument']):
        self.hash = hash
        self.ringtones = ringtones

    def to_dict(self):
        return {
            '_': 'SavedRingtones',
            'hash': self.hash,
            'ringtones': self.ringtones,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.hash))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.ringtones)))
        for item in self.ringtones:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_hash = reader.read_long()
        _args['hash'] = _val_hash
        reader.read_int(signed=False)  # skip vector id
        _count_ringtones = reader.read_int()
        _list_ringtones = []
        for _ in range(_count_ringtones):
            _item_ringtones = reader.tgread_object()
            _list_ringtones.append(_item_ringtones)
        _args['ringtones'] = _list_ringtones
        return cls(**_args)


class SavedRingtonesNotModified(TLObject):
    """TL type: account.savedRingtonesNotModified"""
    CONSTRUCTOR_ID = 0xfbf6e8b1
    SUBCLASS_OF_ID = 0x27bcc95e

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'SavedRingtonesNotModified',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class SentEmailCode(TLObject):
    """TL type: account.sentEmailCode"""
    CONSTRUCTOR_ID = 0x811f854f
    SUBCLASS_OF_ID = 0x69f3c06e

    def __init__(self, email_pattern: str, length: int):
        self.email_pattern = email_pattern
        self.length = length

    def to_dict(self):
        return {
            '_': 'SentEmailCode',
            'email_pattern': self.email_pattern,
            'length': self.length,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.email_pattern))
        buf.write(struct.pack('<i', self.length))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_email_pattern = reader.tgread_string()
        _args['email_pattern'] = _val_email_pattern
        _val_length = reader.read_int()
        _args['length'] = _val_length
        return cls(**_args)


class Takeout(TLObject):
    """TL type: account.takeout"""
    CONSTRUCTOR_ID = 0x4dba4501
    SUBCLASS_OF_ID = 0x843ebe85

    def __init__(self, id: int):
        self.id = id

    def to_dict(self):
        return {
            '_': 'Takeout',
            'id': self.id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_long()
        _args['id'] = _val_id
        return cls(**_args)


class Themes(TLObject):
    """TL type: account.themes"""
    CONSTRUCTOR_ID = 0x9a3d8c6d
    SUBCLASS_OF_ID = 0x7fc52204

    def __init__(self, hash: int, themes: List['TypeTheme']):
        self.hash = hash
        self.themes = themes

    def to_dict(self):
        return {
            '_': 'Themes',
            'hash': self.hash,
            'themes': self.themes,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.hash))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.themes)))
        for item in self.themes:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_hash = reader.read_long()
        _args['hash'] = _val_hash
        reader.read_int(signed=False)  # skip vector id
        _count_themes = reader.read_int()
        _list_themes = []
        for _ in range(_count_themes):
            _item_themes = reader.tgread_object()
            _list_themes.append(_item_themes)
        _args['themes'] = _list_themes
        return cls(**_args)


class ThemesNotModified(TLObject):
    """TL type: account.themesNotModified"""
    CONSTRUCTOR_ID = 0xf41eb622
    SUBCLASS_OF_ID = 0x7fc52204

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'ThemesNotModified',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class TmpPassword(TLObject):
    """TL type: account.tmpPassword"""
    CONSTRUCTOR_ID = 0xdb64fd34
    SUBCLASS_OF_ID = 0xb064992d

    def __init__(self, tmp_password: bytes, valid_until: Optional[datetime]):
        self.tmp_password = tmp_password
        self.valid_until = valid_until

    def to_dict(self):
        return {
            '_': 'TmpPassword',
            'tmp_password': self.tmp_password,
            'valid_until': self.valid_until,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.tmp_password))
        buf.write(struct.pack('<i', self.valid_until))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_tmp_password = reader.tgread_bytes()
        _args['tmp_password'] = _val_tmp_password
        _val_valid_until = reader.read_int()
        _args['valid_until'] = _val_valid_until
        return cls(**_args)


class WallPapers(TLObject):
    """TL type: account.wallPapers"""
    CONSTRUCTOR_ID = 0xcdc3858c
    SUBCLASS_OF_ID = 0xa2c548fd

    def __init__(self, hash: int, wallpapers: List['TypeWallPaper']):
        self.hash = hash
        self.wallpapers = wallpapers

    def to_dict(self):
        return {
            '_': 'WallPapers',
            'hash': self.hash,
            'wallpapers': self.wallpapers,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.hash))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.wallpapers)))
        for item in self.wallpapers:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_hash = reader.read_long()
        _args['hash'] = _val_hash
        reader.read_int(signed=False)  # skip vector id
        _count_wallpapers = reader.read_int()
        _list_wallpapers = []
        for _ in range(_count_wallpapers):
            _item_wallpapers = reader.tgread_object()
            _list_wallpapers.append(_item_wallpapers)
        _args['wallpapers'] = _list_wallpapers
        return cls(**_args)


class WallPapersNotModified(TLObject):
    """TL type: account.wallPapersNotModified"""
    CONSTRUCTOR_ID = 0x1c199183
    SUBCLASS_OF_ID = 0xa2c548fd

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'WallPapersNotModified',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class WebAuthorizations(TLObject):
    """TL type: account.webAuthorizations"""
    CONSTRUCTOR_ID = 0xed56c9fc
    SUBCLASS_OF_ID = 0x9a365b32

    def __init__(self, authorizations: List['TypeWebAuthorization'], users: List['TypeUser']):
        self.authorizations = authorizations
        self.users = users

    def to_dict(self):
        return {
            '_': 'WebAuthorizations',
            'authorizations': self.authorizations,
            'users': self.users,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.authorizations)))
        for item in self.authorizations:
            buf.write(bytes(self.item))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.users)))
        for item in self.users:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        reader.read_int(signed=False)  # skip vector id
        _count_authorizations = reader.read_int()
        _list_authorizations = []
        for _ in range(_count_authorizations):
            _item_authorizations = reader.tgread_object()
            _list_authorizations.append(_item_authorizations)
        _args['authorizations'] = _list_authorizations
        reader.read_int(signed=False)  # skip vector id
        _count_users = reader.read_int()
        _list_users = []
        for _ in range(_count_users):
            _item_users = reader.tgread_object()
            _list_users.append(_item_users)
        _args['users'] = _list_users
        return cls(**_args)

