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


class GetFullUserRequest(TLRequest):
    """TL type: users.getFullUser"""
    CONSTRUCTOR_ID = 0xb60f5918
    SUBCLASS_OF_ID = 0x83df9df5

    def __init__(self, id: 'TypeInputUser'):
        self.id = id

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

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

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


class GetRequirementsToContactRequest(TLRequest):
    """TL type: users.getRequirementsToContact"""
    CONSTRUCTOR_ID = 0xd89a83a3
    SUBCLASS_OF_ID = 0x322623c3

    def __init__(self, id: List['TypeInputUser']):
        self.id = id

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

    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.id)))
        for item in self.id:
            buf.write(bytes(self.item))
        return buf.getvalue()

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


class GetSavedMusicRequest(TLRequest):
    """TL type: users.getSavedMusic"""
    CONSTRUCTOR_ID = 0x788d7fe3
    SUBCLASS_OF_ID = 0xf813ae37

    def __init__(self, id: 'TypeInputUser', offset: int, limit: int, hash: int):
        self.id = id
        self.offset = offset
        self.limit = limit
        self.hash = hash

    def to_dict(self):
        return {
            '_': 'GetSavedMusicRequest',
            'id': self.id,
            'offset': self.offset,
            'limit': self.limit,
            'hash': self.hash,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.tgread_object()
        _args['id'] = _val_id
        _val_offset = reader.read_int()
        _args['offset'] = _val_offset
        _val_limit = reader.read_int()
        _args['limit'] = _val_limit
        _val_hash = reader.read_long()
        _args['hash'] = _val_hash
        return cls(**_args)


class GetSavedMusicByIdRequest(TLRequest):
    """TL type: users.getSavedMusicByID"""
    CONSTRUCTOR_ID = 0x7573a4e9
    SUBCLASS_OF_ID = 0xf813ae37

    def __init__(self, id: 'TypeInputUser', documents: List['TypeInputDocument']):
        self.id = id
        self.documents = documents

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

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.id))
        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_id = reader.tgread_object()
        _args['id'] = _val_id
        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 GetUsersRequest(TLRequest):
    """TL type: users.getUsers"""
    CONSTRUCTOR_ID = 0x0d91a548
    SUBCLASS_OF_ID = 0x0406da4d

    def __init__(self, id: List['TypeInputUser']):
        self.id = id

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

    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.id)))
        for item in self.id:
            buf.write(bytes(self.item))
        return buf.getvalue()

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


class SetSecureValueErrorsRequest(TLRequest):
    """TL type: users.setSecureValueErrors"""
    CONSTRUCTOR_ID = 0x90c894b5
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, id: 'TypeInputUser', errors: List['TypeSecureValueError']):
        self.id = id
        self.errors = errors

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

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.tgread_object()
        _args['id'] = _val_id
        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
        return cls(**_args)


class SuggestBirthdayRequest(TLRequest):
    """TL type: users.suggestBirthday"""
    CONSTRUCTOR_ID = 0xfc533372
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, id: 'TypeInputUser', birthday: 'TypeBirthday'):
        self.id = id
        self.birthday = birthday

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

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

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

