from ....tl.mtproto_request import MTProtoRequest


class AcceptCallRequest(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    phone.acceptCall#3bd2b4a0 peer:InputPhoneCall g_b:bytes protocol:PhoneCallProtocol = phone.PhoneCall"""

    # Telegram's constructor ID (and unique identifier) for this class
    constructor_id = 0x3bd2b4a0

    def __init__(self, peer, g_b, protocol):
        """
        :param peer: Telegram type: «InputPhoneCall».
        :param g_b: Telegram type: «bytes».
        :param protocol: Telegram type: «PhoneCallProtocol».

        :returns phone.PhoneCall: Instance of PhoneCall.
        """
        super().__init__()
        self.result = None
        self.confirmed = True  # Confirmed by default

        self.peer = peer
        self.g_b = g_b
        self.protocol = protocol

    def on_send(self, writer):
        writer.write_int(AcceptCallRequest.constructor_id, signed=False)
        self.peer.on_send(writer)
        writer.tgwrite_bytes(self.g_b)
        self.protocol.on_send(writer)

    @staticmethod
    def empty():
        """Returns an "empty" instance (all attributes are None)"""
        return AcceptCallRequest(None, None, None)

    def on_response(self, reader):
        self.result = reader.tgread_object()

    def __repr__(self):
        return 'phone.acceptCall#3bd2b4a0 peer:InputPhoneCall g_b:bytes protocol:PhoneCallProtocol = phone.PhoneCall'

    def __str__(self):
        return '(phone.acceptCall (ID: 0x3bd2b4a0) = (peer={}, g_b={}, protocol={}))'.format(str(self.peer), str(self.g_b), str(self.protocol))
