"""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 AcceptCallRequest(TLRequest):
    """TL type: phone.acceptCall"""
    CONSTRUCTOR_ID = 0x3bd2b4a0
    SUBCLASS_OF_ID = 0xd48afe4f

    def __init__(self, peer: 'TypeInputPhoneCall', g_b: bytes, protocol: 'TypePhoneCallProtocol'):
        self.peer = peer
        self.g_b = g_b
        self.protocol = protocol

    def to_dict(self):
        return {
            '_': 'AcceptCallRequest',
            'peer': self.peer,
            'g_b': self.g_b,
            'protocol': self.protocol,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_g_b = reader.tgread_bytes()
        _args['g_b'] = _val_g_b
        _val_protocol = reader.tgread_object()
        _args['protocol'] = _val_protocol
        return cls(**_args)


class CheckGroupCallRequest(TLRequest):
    """TL type: phone.checkGroupCall"""
    CONSTRUCTOR_ID = 0xb59cf977
    SUBCLASS_OF_ID = 0x5026710f

    def __init__(self, call: 'TypeInputGroupCall', sources: List[int]):
        self.call = call
        self.sources = sources

    def to_dict(self):
        return {
            '_': 'CheckGroupCallRequest',
            'call': self.call,
            'sources': self.sources,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_call = reader.tgread_object()
        _args['call'] = _val_call
        reader.read_int(signed=False)  # skip vector id
        _count_sources = reader.read_int()
        _list_sources = []
        for _ in range(_count_sources):
            _item_sources = reader.read_int()
            _list_sources.append(_item_sources)
        _args['sources'] = _list_sources
        return cls(**_args)


class ConfirmCallRequest(TLRequest):
    """TL type: phone.confirmCall"""
    CONSTRUCTOR_ID = 0x2efe1722
    SUBCLASS_OF_ID = 0xd48afe4f

    def __init__(self, peer: 'TypeInputPhoneCall', g_a: bytes, key_fingerprint: int, protocol: 'TypePhoneCallProtocol'):
        self.peer = peer
        self.g_a = g_a
        self.key_fingerprint = key_fingerprint
        self.protocol = protocol

    def to_dict(self):
        return {
            '_': 'ConfirmCallRequest',
            'peer': self.peer,
            'g_a': self.g_a,
            'key_fingerprint': self.key_fingerprint,
            'protocol': self.protocol,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_g_a = reader.tgread_bytes()
        _args['g_a'] = _val_g_a
        _val_key_fingerprint = reader.read_long()
        _args['key_fingerprint'] = _val_key_fingerprint
        _val_protocol = reader.tgread_object()
        _args['protocol'] = _val_protocol
        return cls(**_args)


class CreateConferenceCallRequest(TLRequest):
    """TL type: phone.createConferenceCall"""
    CONSTRUCTOR_ID = 0x7d0444bb
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, muted: Optional[bool] = None, video_stopped: Optional[bool] = None, join: Optional[bool] = None, random_id: int = None, public_key: Optional[int] = None, block: Optional[bytes] = None, params: Optional['TypeDataJSON'] = None):
        self.muted = muted
        self.video_stopped = video_stopped
        self.join = join
        self.random_id = random_id
        self.public_key = public_key
        self.block = block
        self.params = params

    def to_dict(self):
        return {
            '_': 'CreateConferenceCallRequest',
            'muted': self.muted,
            'video_stopped': self.video_stopped,
            'join': self.join,
            'random_id': self.random_id,
            'public_key': self.public_key,
            'block': self.block,
            'params': self.params,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.muted:
            flags |= (1 << 0)
        if self.video_stopped:
            flags |= (1 << 2)
        if self.params is not None:
            flags |= (1 << 3)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.random_id))
        if self.public_key is not None:
            buf.write(self.public_key.to_bytes(32, 'little'))
        if self.block is not None:
            buf.write(TLObject.serialize_bytes(self.block))
        if self.params is not None:
            buf.write(bytes(self.params))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['muted'] = bool(flags & (1 << 0))
        _args['video_stopped'] = bool(flags & (1 << 2))
        _args['join'] = bool(flags & (1 << 3))
        _val_random_id = reader.read_int()
        _args['random_id'] = _val_random_id
        if flags & (1 << 3):
            _val_public_key = reader.read_large_int(256)
            _args['public_key'] = _val_public_key
        else:
            _args['public_key'] = None
        if flags & (1 << 3):
            _val_block = reader.tgread_bytes()
            _args['block'] = _val_block
        else:
            _args['block'] = None
        if flags & (1 << 3):
            _val_params = reader.tgread_object()
            _args['params'] = _val_params
        else:
            _args['params'] = None
        return cls(**_args)


class CreateGroupCallRequest(TLRequest):
    """TL type: phone.createGroupCall"""
    CONSTRUCTOR_ID = 0x48cdc6d8
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, peer: 'TypeInputPeer', rtmp_stream: Optional[bool] = None, random_id: int = None, title: Optional[str] = None, schedule_date: Optional[datetime] = None):
        self.peer = peer
        self.rtmp_stream = rtmp_stream
        self.random_id = random_id
        self.title = title
        self.schedule_date = schedule_date

    def to_dict(self):
        return {
            '_': 'CreateGroupCallRequest',
            'peer': self.peer,
            'rtmp_stream': self.rtmp_stream,
            'random_id': self.random_id,
            'title': self.title,
            'schedule_date': self.schedule_date,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.rtmp_stream:
            flags |= (1 << 2)
        if self.title is not None:
            flags |= (1 << 0)
        if self.schedule_date is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.random_id))
        if self.title is not None:
            buf.write(TLObject.serialize_bytes(self.title))
        if self.schedule_date is not None:
            buf.write(struct.pack('<i', self.schedule_date))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['rtmp_stream'] = bool(flags & (1 << 2))
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_random_id = reader.read_int()
        _args['random_id'] = _val_random_id
        if flags & (1 << 0):
            _val_title = reader.tgread_string()
            _args['title'] = _val_title
        else:
            _args['title'] = None
        if flags & (1 << 1):
            _val_schedule_date = reader.read_int()
            _args['schedule_date'] = _val_schedule_date
        else:
            _args['schedule_date'] = None
        return cls(**_args)


class DeclineConferenceCallInviteRequest(TLRequest):
    """TL type: phone.declineConferenceCallInvite"""
    CONSTRUCTOR_ID = 0x3c479971
    SUBCLASS_OF_ID = 0x8af52aac

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

    def to_dict(self):
        return {
            '_': 'DeclineConferenceCallInviteRequest',
            'msg_id': self.msg_id,
        }

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

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


class DeleteConferenceCallParticipantsRequest(TLRequest):
    """TL type: phone.deleteConferenceCallParticipants"""
    CONSTRUCTOR_ID = 0x8ca60525
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, call: 'TypeInputGroupCall', ids: List[int], block: bytes, only_left: Optional[bool] = None, kick: Optional[bool] = None):
        self.call = call
        self.ids = ids
        self.block = block
        self.only_left = only_left
        self.kick = kick

    def to_dict(self):
        return {
            '_': 'DeleteConferenceCallParticipantsRequest',
            'call': self.call,
            'ids': self.ids,
            'block': self.block,
            'only_left': self.only_left,
            'kick': self.kick,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.only_left:
            flags |= (1 << 0)
        if self.kick:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.call))
        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))
        buf.write(TLObject.serialize_bytes(self.block))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['only_left'] = bool(flags & (1 << 0))
        _args['kick'] = bool(flags & (1 << 1))
        _val_call = reader.tgread_object()
        _args['call'] = _val_call
        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
        _val_block = reader.tgread_bytes()
        _args['block'] = _val_block
        return cls(**_args)


class DeleteGroupCallMessagesRequest(TLRequest):
    """TL type: phone.deleteGroupCallMessages"""
    CONSTRUCTOR_ID = 0xf64f54f7
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, call: 'TypeInputGroupCall', messages: List[int], report_spam: Optional[bool] = None):
        self.call = call
        self.messages = messages
        self.report_spam = report_spam

    def to_dict(self):
        return {
            '_': 'DeleteGroupCallMessagesRequest',
            'call': self.call,
            'messages': self.messages,
            'report_spam': self.report_spam,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['report_spam'] = bool(flags & (1 << 0))
        _val_call = reader.tgread_object()
        _args['call'] = _val_call
        reader.read_int(signed=False)  # skip vector id
        _count_messages = reader.read_int()
        _list_messages = []
        for _ in range(_count_messages):
            _item_messages = reader.read_int()
            _list_messages.append(_item_messages)
        _args['messages'] = _list_messages
        return cls(**_args)


class DeleteGroupCallParticipantMessagesRequest(TLRequest):
    """TL type: phone.deleteGroupCallParticipantMessages"""
    CONSTRUCTOR_ID = 0x1dbfeca0
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, call: 'TypeInputGroupCall', participant: 'TypeInputPeer', report_spam: Optional[bool] = None):
        self.call = call
        self.participant = participant
        self.report_spam = report_spam

    def to_dict(self):
        return {
            '_': 'DeleteGroupCallParticipantMessagesRequest',
            'call': self.call,
            'participant': self.participant,
            'report_spam': self.report_spam,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['report_spam'] = bool(flags & (1 << 0))
        _val_call = reader.tgread_object()
        _args['call'] = _val_call
        _val_participant = reader.tgread_object()
        _args['participant'] = _val_participant
        return cls(**_args)


class DiscardCallRequest(TLRequest):
    """TL type: phone.discardCall"""
    CONSTRUCTOR_ID = 0xb2cbc1c0
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, peer: 'TypeInputPhoneCall', duration: int, reason: 'TypePhoneCallDiscardReason', connection_id: int, video: Optional[bool] = None):
        self.peer = peer
        self.duration = duration
        self.reason = reason
        self.connection_id = connection_id
        self.video = video

    def to_dict(self):
        return {
            '_': 'DiscardCallRequest',
            'peer': self.peer,
            'duration': self.duration,
            'reason': self.reason,
            'connection_id': self.connection_id,
            'video': self.video,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.video:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.duration))
        buf.write(bytes(self.reason))
        buf.write(struct.pack('<q', self.connection_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['video'] = bool(flags & (1 << 0))
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_duration = reader.read_int()
        _args['duration'] = _val_duration
        _val_reason = reader.tgread_object()
        _args['reason'] = _val_reason
        _val_connection_id = reader.read_long()
        _args['connection_id'] = _val_connection_id
        return cls(**_args)


class DiscardGroupCallRequest(TLRequest):
    """TL type: phone.discardGroupCall"""
    CONSTRUCTOR_ID = 0x7a777135
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, call: 'TypeInputGroupCall'):
        self.call = call

    def to_dict(self):
        return {
            '_': 'DiscardGroupCallRequest',
            'call': self.call,
        }

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

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


class EditGroupCallParticipantRequest(TLRequest):
    """TL type: phone.editGroupCallParticipant"""
    CONSTRUCTOR_ID = 0xa5273abf
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, call: 'TypeInputGroupCall', participant: 'TypeInputPeer', muted: Optional[bool] = None, volume: Optional[int] = None, raise_hand: Optional[bool] = None, video_stopped: Optional[bool] = None, video_paused: Optional[bool] = None, presentation_paused: Optional[bool] = None):
        self.call = call
        self.participant = participant
        self.muted = muted
        self.volume = volume
        self.raise_hand = raise_hand
        self.video_stopped = video_stopped
        self.video_paused = video_paused
        self.presentation_paused = presentation_paused

    def to_dict(self):
        return {
            '_': 'EditGroupCallParticipantRequest',
            'call': self.call,
            'participant': self.participant,
            'muted': self.muted,
            'volume': self.volume,
            'raise_hand': self.raise_hand,
            'video_stopped': self.video_stopped,
            'video_paused': self.video_paused,
            'presentation_paused': self.presentation_paused,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.muted is not None:
            flags |= (1 << 0)
        if self.volume is not None:
            flags |= (1 << 1)
        if self.raise_hand is not None:
            flags |= (1 << 2)
        if self.video_stopped is not None:
            flags |= (1 << 3)
        if self.video_paused is not None:
            flags |= (1 << 4)
        if self.presentation_paused is not None:
            flags |= (1 << 5)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.call))
        buf.write(bytes(self.participant))
        if self.muted is not None:
            buf.write(struct.pack('<I', 0x997275b5 if self.muted else 0xbc799737))
        if self.volume is not None:
            buf.write(struct.pack('<i', self.volume))
        if self.raise_hand is not None:
            buf.write(struct.pack('<I', 0x997275b5 if self.raise_hand else 0xbc799737))
        if self.video_stopped is not None:
            buf.write(struct.pack('<I', 0x997275b5 if self.video_stopped else 0xbc799737))
        if self.video_paused is not None:
            buf.write(struct.pack('<I', 0x997275b5 if self.video_paused else 0xbc799737))
        if self.presentation_paused is not None:
            buf.write(struct.pack('<I', 0x997275b5 if self.presentation_paused else 0xbc799737))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_call = reader.tgread_object()
        _args['call'] = _val_call
        _val_participant = reader.tgread_object()
        _args['participant'] = _val_participant
        if flags & (1 << 0):
            _val_muted = reader.tgread_bool()
            _args['muted'] = _val_muted
        else:
            _args['muted'] = None
        if flags & (1 << 1):
            _val_volume = reader.read_int()
            _args['volume'] = _val_volume
        else:
            _args['volume'] = None
        if flags & (1 << 2):
            _val_raise_hand = reader.tgread_bool()
            _args['raise_hand'] = _val_raise_hand
        else:
            _args['raise_hand'] = None
        if flags & (1 << 3):
            _val_video_stopped = reader.tgread_bool()
            _args['video_stopped'] = _val_video_stopped
        else:
            _args['video_stopped'] = None
        if flags & (1 << 4):
            _val_video_paused = reader.tgread_bool()
            _args['video_paused'] = _val_video_paused
        else:
            _args['video_paused'] = None
        if flags & (1 << 5):
            _val_presentation_paused = reader.tgread_bool()
            _args['presentation_paused'] = _val_presentation_paused
        else:
            _args['presentation_paused'] = None
        return cls(**_args)


class EditGroupCallTitleRequest(TLRequest):
    """TL type: phone.editGroupCallTitle"""
    CONSTRUCTOR_ID = 0x1ca6ac0a
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, call: 'TypeInputGroupCall', title: str):
        self.call = call
        self.title = title

    def to_dict(self):
        return {
            '_': 'EditGroupCallTitleRequest',
            'call': self.call,
            'title': self.title,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_call = reader.tgread_object()
        _args['call'] = _val_call
        _val_title = reader.tgread_string()
        _args['title'] = _val_title
        return cls(**_args)


class ExportGroupCallInviteRequest(TLRequest):
    """TL type: phone.exportGroupCallInvite"""
    CONSTRUCTOR_ID = 0xe6aa647f
    SUBCLASS_OF_ID = 0x3b3bfe8f

    def __init__(self, call: 'TypeInputGroupCall', can_self_unmute: Optional[bool] = None):
        self.call = call
        self.can_self_unmute = can_self_unmute

    def to_dict(self):
        return {
            '_': 'ExportGroupCallInviteRequest',
            'call': self.call,
            'can_self_unmute': self.can_self_unmute,
        }

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

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


class GetCallConfigRequest(TLRequest):
    """TL type: phone.getCallConfig"""
    CONSTRUCTOR_ID = 0x55451fa9
    SUBCLASS_OF_ID = 0xad0352e8

    def __init__(self):
        pass

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

    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 GetGroupCallRequest(TLRequest):
    """TL type: phone.getGroupCall"""
    CONSTRUCTOR_ID = 0x041845db
    SUBCLASS_OF_ID = 0x304116be

    def __init__(self, call: 'TypeInputGroupCall', limit: int):
        self.call = call
        self.limit = limit

    def to_dict(self):
        return {
            '_': 'GetGroupCallRequest',
            'call': self.call,
            'limit': self.limit,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_call = reader.tgread_object()
        _args['call'] = _val_call
        _val_limit = reader.read_int()
        _args['limit'] = _val_limit
        return cls(**_args)


class GetGroupCallChainBlocksRequest(TLRequest):
    """TL type: phone.getGroupCallChainBlocks"""
    CONSTRUCTOR_ID = 0xee9f88a6
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, call: 'TypeInputGroupCall', sub_chain_id: int, offset: int, limit: int):
        self.call = call
        self.sub_chain_id = sub_chain_id
        self.offset = offset
        self.limit = limit

    def to_dict(self):
        return {
            '_': 'GetGroupCallChainBlocksRequest',
            'call': self.call,
            'sub_chain_id': self.sub_chain_id,
            'offset': self.offset,
            'limit': self.limit,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_call = reader.tgread_object()
        _args['call'] = _val_call
        _val_sub_chain_id = reader.read_int()
        _args['sub_chain_id'] = _val_sub_chain_id
        _val_offset = reader.read_int()
        _args['offset'] = _val_offset
        _val_limit = reader.read_int()
        _args['limit'] = _val_limit
        return cls(**_args)


class GetGroupCallJoinAsRequest(TLRequest):
    """TL type: phone.getGroupCallJoinAs"""
    CONSTRUCTOR_ID = 0xef7c213a
    SUBCLASS_OF_ID = 0xb4b770fb

    def __init__(self, peer: 'TypeInputPeer'):
        self.peer = peer

    def to_dict(self):
        return {
            '_': 'GetGroupCallJoinAsRequest',
            'peer': self.peer,
        }

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

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


class GetGroupCallStarsRequest(TLRequest):
    """TL type: phone.getGroupCallStars"""
    CONSTRUCTOR_ID = 0x6f636302
    SUBCLASS_OF_ID = 0xb447801a

    def __init__(self, call: 'TypeInputGroupCall'):
        self.call = call

    def to_dict(self):
        return {
            '_': 'GetGroupCallStarsRequest',
            'call': self.call,
        }

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

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


class GetGroupCallStreamChannelsRequest(TLRequest):
    """TL type: phone.getGroupCallStreamChannels"""
    CONSTRUCTOR_ID = 0x1ab21940
    SUBCLASS_OF_ID = 0x9157c5e4

    def __init__(self, call: 'TypeInputGroupCall'):
        self.call = call

    def to_dict(self):
        return {
            '_': 'GetGroupCallStreamChannelsRequest',
            'call': self.call,
        }

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

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


class GetGroupCallStreamRtmpUrlRequest(TLRequest):
    """TL type: phone.getGroupCallStreamRtmpUrl"""
    CONSTRUCTOR_ID = 0x5af4c73a
    SUBCLASS_OF_ID = 0xd1f515cb

    def __init__(self, peer: 'TypeInputPeer', revoke: bool, live_story: Optional[bool] = None):
        self.peer = peer
        self.revoke = revoke
        self.live_story = live_story

    def to_dict(self):
        return {
            '_': 'GetGroupCallStreamRtmpUrlRequest',
            'peer': self.peer,
            'revoke': self.revoke,
            'live_story': self.live_story,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.live_story:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<I', 0x997275b5 if self.revoke else 0xbc799737))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['live_story'] = bool(flags & (1 << 0))
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_revoke = reader.tgread_bool()
        _args['revoke'] = _val_revoke
        return cls(**_args)


class GetGroupParticipantsRequest(TLRequest):
    """TL type: phone.getGroupParticipants"""
    CONSTRUCTOR_ID = 0xc558d8ab
    SUBCLASS_OF_ID = 0x72d304f4

    def __init__(self, call: 'TypeInputGroupCall', ids: List['TypeInputPeer'], sources: List[int], offset: str, limit: int):
        self.call = call
        self.ids = ids
        self.sources = sources
        self.offset = offset
        self.limit = limit

    def to_dict(self):
        return {
            '_': 'GetGroupParticipantsRequest',
            'call': self.call,
            'ids': self.ids,
            'sources': self.sources,
            'offset': self.offset,
            'limit': self.limit,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_call = reader.tgread_object()
        _args['call'] = _val_call
        reader.read_int(signed=False)  # skip vector id
        _count_ids = reader.read_int()
        _list_ids = []
        for _ in range(_count_ids):
            _item_ids = reader.tgread_object()
            _list_ids.append(_item_ids)
        _args['ids'] = _list_ids
        reader.read_int(signed=False)  # skip vector id
        _count_sources = reader.read_int()
        _list_sources = []
        for _ in range(_count_sources):
            _item_sources = reader.read_int()
            _list_sources.append(_item_sources)
        _args['sources'] = _list_sources
        _val_offset = reader.tgread_string()
        _args['offset'] = _val_offset
        _val_limit = reader.read_int()
        _args['limit'] = _val_limit
        return cls(**_args)


class InviteConferenceCallParticipantRequest(TLRequest):
    """TL type: phone.inviteConferenceCallParticipant"""
    CONSTRUCTOR_ID = 0xbcf22685
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, call: 'TypeInputGroupCall', user_id: 'TypeInputUser', video: Optional[bool] = None):
        self.call = call
        self.user_id = user_id
        self.video = video

    def to_dict(self):
        return {
            '_': 'InviteConferenceCallParticipantRequest',
            'call': self.call,
            'user_id': self.user_id,
            'video': self.video,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['video'] = bool(flags & (1 << 0))
        _val_call = reader.tgread_object()
        _args['call'] = _val_call
        _val_user_id = reader.tgread_object()
        _args['user_id'] = _val_user_id
        return cls(**_args)


class InviteToGroupCallRequest(TLRequest):
    """TL type: phone.inviteToGroupCall"""
    CONSTRUCTOR_ID = 0x7b393160
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, call: 'TypeInputGroupCall', users: List['TypeInputUser']):
        self.call = call
        self.users = users

    def to_dict(self):
        return {
            '_': 'InviteToGroupCallRequest',
            'call': self.call,
            'users': self.users,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.call))
        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_call = reader.tgread_object()
        _args['call'] = _val_call
        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 JoinGroupCallRequest(TLRequest):
    """TL type: phone.joinGroupCall"""
    CONSTRUCTOR_ID = 0x8fb53057
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, call: 'TypeInputGroupCall', join_as: 'TypeInputPeer', params: 'TypeDataJSON', muted: Optional[bool] = None, video_stopped: Optional[bool] = None, invite_hash: Optional[str] = None, public_key: Optional[int] = None, block: Optional[bytes] = None):
        self.call = call
        self.join_as = join_as
        self.params = params
        self.muted = muted
        self.video_stopped = video_stopped
        self.invite_hash = invite_hash
        self.public_key = public_key
        self.block = block

    def to_dict(self):
        return {
            '_': 'JoinGroupCallRequest',
            'call': self.call,
            'join_as': self.join_as,
            'params': self.params,
            'muted': self.muted,
            'video_stopped': self.video_stopped,
            'invite_hash': self.invite_hash,
            'public_key': self.public_key,
            'block': self.block,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.muted:
            flags |= (1 << 0)
        if self.video_stopped:
            flags |= (1 << 2)
        if self.invite_hash is not None:
            flags |= (1 << 1)
        if self.block is not None:
            flags |= (1 << 3)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.call))
        buf.write(bytes(self.join_as))
        buf.write(bytes(self.params))
        if self.invite_hash is not None:
            buf.write(TLObject.serialize_bytes(self.invite_hash))
        if self.public_key is not None:
            buf.write(self.public_key.to_bytes(32, 'little'))
        if self.block is not None:
            buf.write(TLObject.serialize_bytes(self.block))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['muted'] = bool(flags & (1 << 0))
        _args['video_stopped'] = bool(flags & (1 << 2))
        _val_call = reader.tgread_object()
        _args['call'] = _val_call
        _val_join_as = reader.tgread_object()
        _args['join_as'] = _val_join_as
        if flags & (1 << 1):
            _val_invite_hash = reader.tgread_string()
            _args['invite_hash'] = _val_invite_hash
        else:
            _args['invite_hash'] = None
        if flags & (1 << 3):
            _val_public_key = reader.read_large_int(256)
            _args['public_key'] = _val_public_key
        else:
            _args['public_key'] = None
        if flags & (1 << 3):
            _val_block = reader.tgread_bytes()
            _args['block'] = _val_block
        else:
            _args['block'] = None
        _val_params = reader.tgread_object()
        _args['params'] = _val_params
        return cls(**_args)


class JoinGroupCallPresentationRequest(TLRequest):
    """TL type: phone.joinGroupCallPresentation"""
    CONSTRUCTOR_ID = 0xcbea6bc4
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, call: 'TypeInputGroupCall', params: 'TypeDataJSON'):
        self.call = call
        self.params = params

    def to_dict(self):
        return {
            '_': 'JoinGroupCallPresentationRequest',
            'call': self.call,
            'params': self.params,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_call = reader.tgread_object()
        _args['call'] = _val_call
        _val_params = reader.tgread_object()
        _args['params'] = _val_params
        return cls(**_args)


class LeaveGroupCallRequest(TLRequest):
    """TL type: phone.leaveGroupCall"""
    CONSTRUCTOR_ID = 0x500377f9
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, call: 'TypeInputGroupCall', source: int):
        self.call = call
        self.source = source

    def to_dict(self):
        return {
            '_': 'LeaveGroupCallRequest',
            'call': self.call,
            'source': self.source,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_call = reader.tgread_object()
        _args['call'] = _val_call
        _val_source = reader.read_int()
        _args['source'] = _val_source
        return cls(**_args)


class LeaveGroupCallPresentationRequest(TLRequest):
    """TL type: phone.leaveGroupCallPresentation"""
    CONSTRUCTOR_ID = 0x1c50d144
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, call: 'TypeInputGroupCall'):
        self.call = call

    def to_dict(self):
        return {
            '_': 'LeaveGroupCallPresentationRequest',
            'call': self.call,
        }

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

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


class ReceivedCallRequest(TLRequest):
    """TL type: phone.receivedCall"""
    CONSTRUCTOR_ID = 0x17d54f61
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, peer: 'TypeInputPhoneCall'):
        self.peer = peer

    def to_dict(self):
        return {
            '_': 'ReceivedCallRequest',
            'peer': self.peer,
        }

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

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


class RequestCallRequest(TLRequest):
    """TL type: phone.requestCall"""
    CONSTRUCTOR_ID = 0x42ff96ed
    SUBCLASS_OF_ID = 0xd48afe4f

    def __init__(self, user_id: 'TypeInputUser', g_a_hash: bytes, protocol: 'TypePhoneCallProtocol', video: Optional[bool] = None, random_id: int = None):
        self.user_id = user_id
        self.g_a_hash = g_a_hash
        self.protocol = protocol
        self.video = video
        self.random_id = random_id

    def to_dict(self):
        return {
            '_': 'RequestCallRequest',
            'user_id': self.user_id,
            'g_a_hash': self.g_a_hash,
            'protocol': self.protocol,
            'video': self.video,
            'random_id': self.random_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.video:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.user_id))
        buf.write(TLObject.serialize_bytes(self.g_a_hash))
        buf.write(bytes(self.protocol))
        buf.write(struct.pack('<i', self.random_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['video'] = bool(flags & (1 << 0))
        _val_user_id = reader.tgread_object()
        _args['user_id'] = _val_user_id
        _val_random_id = reader.read_int()
        _args['random_id'] = _val_random_id
        _val_g_a_hash = reader.tgread_bytes()
        _args['g_a_hash'] = _val_g_a_hash
        _val_protocol = reader.tgread_object()
        _args['protocol'] = _val_protocol
        return cls(**_args)


class SaveCallDebugRequest(TLRequest):
    """TL type: phone.saveCallDebug"""
    CONSTRUCTOR_ID = 0x277add7e
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, peer: 'TypeInputPhoneCall', debug: 'TypeDataJSON'):
        self.peer = peer
        self.debug = debug

    def to_dict(self):
        return {
            '_': 'SaveCallDebugRequest',
            'peer': self.peer,
            'debug': self.debug,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_debug = reader.tgread_object()
        _args['debug'] = _val_debug
        return cls(**_args)


class SaveCallLogRequest(TLRequest):
    """TL type: phone.saveCallLog"""
    CONSTRUCTOR_ID = 0x41248786
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, peer: 'TypeInputPhoneCall', file: 'TypeInputFile'):
        self.peer = peer
        self.file = file

    def to_dict(self):
        return {
            '_': 'SaveCallLogRequest',
            'peer': self.peer,
            'file': self.file,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_file = reader.tgread_object()
        _args['file'] = _val_file
        return cls(**_args)


class SaveDefaultGroupCallJoinAsRequest(TLRequest):
    """TL type: phone.saveDefaultGroupCallJoinAs"""
    CONSTRUCTOR_ID = 0x575e1f8c
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, peer: 'TypeInputPeer', join_as: 'TypeInputPeer'):
        self.peer = peer
        self.join_as = join_as

    def to_dict(self):
        return {
            '_': 'SaveDefaultGroupCallJoinAsRequest',
            'peer': self.peer,
            'join_as': self.join_as,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_join_as = reader.tgread_object()
        _args['join_as'] = _val_join_as
        return cls(**_args)


class SaveDefaultSendAsRequest(TLRequest):
    """TL type: phone.saveDefaultSendAs"""
    CONSTRUCTOR_ID = 0x4167add1
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, call: 'TypeInputGroupCall', send_as: 'TypeInputPeer'):
        self.call = call
        self.send_as = send_as

    def to_dict(self):
        return {
            '_': 'SaveDefaultSendAsRequest',
            'call': self.call,
            'send_as': self.send_as,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_call = reader.tgread_object()
        _args['call'] = _val_call
        _val_send_as = reader.tgread_object()
        _args['send_as'] = _val_send_as
        return cls(**_args)


class SendConferenceCallBroadcastRequest(TLRequest):
    """TL type: phone.sendConferenceCallBroadcast"""
    CONSTRUCTOR_ID = 0xc6701900
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, call: 'TypeInputGroupCall', block: bytes):
        self.call = call
        self.block = block

    def to_dict(self):
        return {
            '_': 'SendConferenceCallBroadcastRequest',
            'call': self.call,
            'block': self.block,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_call = reader.tgread_object()
        _args['call'] = _val_call
        _val_block = reader.tgread_bytes()
        _args['block'] = _val_block
        return cls(**_args)


class SendGroupCallEncryptedMessageRequest(TLRequest):
    """TL type: phone.sendGroupCallEncryptedMessage"""
    CONSTRUCTOR_ID = 0xe5afa56d
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, call: 'TypeInputGroupCall', encrypted_message: bytes):
        self.call = call
        self.encrypted_message = encrypted_message

    def to_dict(self):
        return {
            '_': 'SendGroupCallEncryptedMessageRequest',
            'call': self.call,
            'encrypted_message': self.encrypted_message,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_call = reader.tgread_object()
        _args['call'] = _val_call
        _val_encrypted_message = reader.tgread_bytes()
        _args['encrypted_message'] = _val_encrypted_message
        return cls(**_args)


class SendGroupCallMessageRequest(TLRequest):
    """TL type: phone.sendGroupCallMessage"""
    CONSTRUCTOR_ID = 0xb1d11410
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, call: 'TypeInputGroupCall', message: 'TypeTextWithEntities', random_id: int = None, allow_paid_stars: Optional[int] = None, send_as: Optional['TypeInputPeer'] = None):
        self.call = call
        self.message = message
        self.random_id = random_id
        self.allow_paid_stars = allow_paid_stars
        self.send_as = send_as

    def to_dict(self):
        return {
            '_': 'SendGroupCallMessageRequest',
            'call': self.call,
            'message': self.message,
            'random_id': self.random_id,
            'allow_paid_stars': self.allow_paid_stars,
            'send_as': self.send_as,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.allow_paid_stars is not None:
            flags |= (1 << 0)
        if self.send_as is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.call))
        buf.write(bytes(self.message))
        buf.write(struct.pack('<q', self.random_id))
        if self.allow_paid_stars is not None:
            buf.write(struct.pack('<q', self.allow_paid_stars))
        if self.send_as is not None:
            buf.write(bytes(self.send_as))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_call = reader.tgread_object()
        _args['call'] = _val_call
        _val_random_id = reader.read_long()
        _args['random_id'] = _val_random_id
        _val_message = reader.tgread_object()
        _args['message'] = _val_message
        if flags & (1 << 0):
            _val_allow_paid_stars = reader.read_long()
            _args['allow_paid_stars'] = _val_allow_paid_stars
        else:
            _args['allow_paid_stars'] = None
        if flags & (1 << 1):
            _val_send_as = reader.tgread_object()
            _args['send_as'] = _val_send_as
        else:
            _args['send_as'] = None
        return cls(**_args)


class SendSignalingDataRequest(TLRequest):
    """TL type: phone.sendSignalingData"""
    CONSTRUCTOR_ID = 0xff7a9383
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, peer: 'TypeInputPhoneCall', data: bytes):
        self.peer = peer
        self.data = data

    def to_dict(self):
        return {
            '_': 'SendSignalingDataRequest',
            'peer': self.peer,
            'data': self.data,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_data = reader.tgread_bytes()
        _args['data'] = _val_data
        return cls(**_args)


class SetCallRatingRequest(TLRequest):
    """TL type: phone.setCallRating"""
    CONSTRUCTOR_ID = 0x59ead627
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, peer: 'TypeInputPhoneCall', rating: int, comment: str, user_initiative: Optional[bool] = None):
        self.peer = peer
        self.rating = rating
        self.comment = comment
        self.user_initiative = user_initiative

    def to_dict(self):
        return {
            '_': 'SetCallRatingRequest',
            'peer': self.peer,
            'rating': self.rating,
            'comment': self.comment,
            'user_initiative': self.user_initiative,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.user_initiative:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.rating))
        buf.write(TLObject.serialize_bytes(self.comment))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['user_initiative'] = bool(flags & (1 << 0))
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_rating = reader.read_int()
        _args['rating'] = _val_rating
        _val_comment = reader.tgread_string()
        _args['comment'] = _val_comment
        return cls(**_args)


class StartScheduledGroupCallRequest(TLRequest):
    """TL type: phone.startScheduledGroupCall"""
    CONSTRUCTOR_ID = 0x5680e342
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, call: 'TypeInputGroupCall'):
        self.call = call

    def to_dict(self):
        return {
            '_': 'StartScheduledGroupCallRequest',
            'call': self.call,
        }

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

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


class ToggleGroupCallRecordRequest(TLRequest):
    """TL type: phone.toggleGroupCallRecord"""
    CONSTRUCTOR_ID = 0xf128c708
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, call: 'TypeInputGroupCall', start: Optional[bool] = None, video: Optional[bool] = None, title: Optional[str] = None, video_portrait: Optional[bool] = None):
        self.call = call
        self.start = start
        self.video = video
        self.title = title
        self.video_portrait = video_portrait

    def to_dict(self):
        return {
            '_': 'ToggleGroupCallRecordRequest',
            'call': self.call,
            'start': self.start,
            'video': self.video,
            'title': self.title,
            'video_portrait': self.video_portrait,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.start:
            flags |= (1 << 0)
        if self.video_portrait is not None:
            flags |= (1 << 2)
        if self.title is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.call))
        if self.title is not None:
            buf.write(TLObject.serialize_bytes(self.title))
        if self.video_portrait is not None:
            buf.write(struct.pack('<I', 0x997275b5 if self.video_portrait else 0xbc799737))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['start'] = bool(flags & (1 << 0))
        _args['video'] = bool(flags & (1 << 2))
        _val_call = reader.tgread_object()
        _args['call'] = _val_call
        if flags & (1 << 1):
            _val_title = reader.tgread_string()
            _args['title'] = _val_title
        else:
            _args['title'] = None
        if flags & (1 << 2):
            _val_video_portrait = reader.tgread_bool()
            _args['video_portrait'] = _val_video_portrait
        else:
            _args['video_portrait'] = None
        return cls(**_args)


class ToggleGroupCallSettingsRequest(TLRequest):
    """TL type: phone.toggleGroupCallSettings"""
    CONSTRUCTOR_ID = 0x974392f2
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, call: 'TypeInputGroupCall', reset_invite_hash: Optional[bool] = None, join_muted: Optional[bool] = None, messages_enabled: Optional[bool] = None, send_paid_messages_stars: Optional[int] = None):
        self.call = call
        self.reset_invite_hash = reset_invite_hash
        self.join_muted = join_muted
        self.messages_enabled = messages_enabled
        self.send_paid_messages_stars = send_paid_messages_stars

    def to_dict(self):
        return {
            '_': 'ToggleGroupCallSettingsRequest',
            'call': self.call,
            'reset_invite_hash': self.reset_invite_hash,
            'join_muted': self.join_muted,
            'messages_enabled': self.messages_enabled,
            'send_paid_messages_stars': self.send_paid_messages_stars,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.reset_invite_hash:
            flags |= (1 << 1)
        if self.join_muted is not None:
            flags |= (1 << 0)
        if self.messages_enabled is not None:
            flags |= (1 << 2)
        if self.send_paid_messages_stars is not None:
            flags |= (1 << 3)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.call))
        if self.join_muted is not None:
            buf.write(struct.pack('<I', 0x997275b5 if self.join_muted else 0xbc799737))
        if self.messages_enabled is not None:
            buf.write(struct.pack('<I', 0x997275b5 if self.messages_enabled else 0xbc799737))
        if self.send_paid_messages_stars is not None:
            buf.write(struct.pack('<q', self.send_paid_messages_stars))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['reset_invite_hash'] = bool(flags & (1 << 1))
        _val_call = reader.tgread_object()
        _args['call'] = _val_call
        if flags & (1 << 0):
            _val_join_muted = reader.tgread_bool()
            _args['join_muted'] = _val_join_muted
        else:
            _args['join_muted'] = None
        if flags & (1 << 2):
            _val_messages_enabled = reader.tgread_bool()
            _args['messages_enabled'] = _val_messages_enabled
        else:
            _args['messages_enabled'] = None
        if flags & (1 << 3):
            _val_send_paid_messages_stars = reader.read_long()
            _args['send_paid_messages_stars'] = _val_send_paid_messages_stars
        else:
            _args['send_paid_messages_stars'] = None
        return cls(**_args)


class ToggleGroupCallStartSubscriptionRequest(TLRequest):
    """TL type: phone.toggleGroupCallStartSubscription"""
    CONSTRUCTOR_ID = 0x219c34e6
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, call: 'TypeInputGroupCall', subscribed: bool):
        self.call = call
        self.subscribed = subscribed

    def to_dict(self):
        return {
            '_': 'ToggleGroupCallStartSubscriptionRequest',
            'call': self.call,
            'subscribed': self.subscribed,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.call))
        buf.write(struct.pack('<I', 0x997275b5 if self.subscribed else 0xbc799737))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_call = reader.tgread_object()
        _args['call'] = _val_call
        _val_subscribed = reader.tgread_bool()
        _args['subscribed'] = _val_subscribed
        return cls(**_args)

