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


class PhoneCall(TLObject):
    constructor_id = 0xec82e140
    subclass_of_id = 0xd48afe4f

    def __init__(self, phone_call, users):
        """
        :param phone_call: Telegram type: "PhoneCall".
        :param users: Telegram type: "User". Must be a list.

        Constructor for phone.PhoneCall: Instance of PhoneCall.
        """
        super().__init__()

        self.phone_call = phone_call
        self.users = users

    def to_dict(self):
        return {
            'phone_call': None if self.phone_call is None else self.phone_call.to_dict(),
            'users': [] if self.users is None else [None if x is None else x.to_dict() for x in self.users],
        }

    def on_send(self, writer):
        writer.write_int(PhoneCall.constructor_id, signed=False)
        self.phone_call.on_send(writer)
        writer.write_int(0x1cb5c415, signed=False)  # Vector's constructor ID
        writer.write_int(len(self.users))
        for _x in self.users:
            _x.on_send(writer)

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

    def on_response(self, reader):
        self.phone_call = reader.tgread_object()
        reader.read_int()
        self.users = []
        _len = reader.read_int()
        for _ in range(_len):
            _x = reader.tgread_object()
            self.users.append(_x)

    def __repr__(self):
        return 'phone.phoneCall#ec82e140 phone_call:PhoneCall users:Vector<User> = phone.PhoneCall'

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

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

