"""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 SavedMusic(TLObject):
    """TL type: users.savedMusic"""
    CONSTRUCTOR_ID = 0x34a2f297
    SUBCLASS_OF_ID = 0xf813ae37

    def __init__(self, count: int, documents: List['TypeDocument']):
        self.count = count
        self.documents = documents

    def to_dict(self):
        return {
            '_': 'SavedMusic',
            'count': self.count,
            'documents': self.documents,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_count = reader.read_int()
        _args['count'] = _val_count
        reader.read_int(signed=False)  # skip vector id
        _count_documents = reader.read_int()
        _list_documents = []
        for _ in range(_count_documents):
            _item_documents = reader.tgread_object()
            _list_documents.append(_item_documents)
        _args['documents'] = _list_documents
        return cls(**_args)


class SavedMusicNotModified(TLObject):
    """TL type: users.savedMusicNotModified"""
    CONSTRUCTOR_ID = 0xe3878aa4
    SUBCLASS_OF_ID = 0xf813ae37

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

    def to_dict(self):
        return {
            '_': 'SavedMusicNotModified',
            'count': self.count,
        }

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

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


class UserFull(TLObject):
    """TL type: users.userFull"""
    CONSTRUCTOR_ID = 0x3b6d152e
    SUBCLASS_OF_ID = 0x83df9df5

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

    def to_dict(self):
        return {
            '_': 'UserFull',
            'full_user': self.full_user,
            '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.full_user))
        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_full_user = reader.tgread_object()
        _args['full_user'] = _val_full_user
        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 Users(TLObject):
    """TL type: users.users"""
    CONSTRUCTOR_ID = 0x62d706b8
    SUBCLASS_OF_ID = 0xf24bf0c0

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

    def to_dict(self):
        return {
            '_': 'Users',
            '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.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_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 UsersSlice(TLObject):
    """TL type: users.usersSlice"""
    CONSTRUCTOR_ID = 0x315a4974
    SUBCLASS_OF_ID = 0xf24bf0c0

    def __init__(self, count: int, users: List['TypeUser']):
        self.count = count
        self.users = users

    def to_dict(self):
        return {
            '_': 'UsersSlice',
            'count': self.count,
            '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', self.count))
        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_count = reader.read_int()
        _args['count'] = _val_count
        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)

