// Code generated by gotdgen, DO NOT EDIT.

package tg

import (
	
	
	
	
	

	

	
	
	
	
)

// No-op definition for keeping imports.
var (
	_ = bin.Buffer{}
	_ = context.Background()
	_ = fmt.Stringer(nil)
	_ = strings.Builder{}
	_ = errors.Is
	_ = multierr.AppendInto
	_ = sort.Ints
	_ = tdp.Format
	_ = tgerr.Error{}
	_ = tdjson.Encoder{}
)

// PhoneAcceptCallRequest represents TL type `phone.acceptCall#3bd2b4a0`.
// Accept incoming call
//
// See https://core.telegram.org/method/phone.acceptCall for reference.
type PhoneAcceptCallRequest struct {
	// The call to accept
	Peer InputPhoneCall
	// Parameter for E2E encryption key exchange »¹
	//
	// Links:
	//  1) https://core.telegram.org/api/end-to-end/voice-calls
	GB []byte
	// Phone call settings
	Protocol PhoneCallProtocol
}

// PhoneAcceptCallRequestTypeID is TL type id of PhoneAcceptCallRequest.
const PhoneAcceptCallRequestTypeID = 0x3bd2b4a0

// Ensuring interfaces in compile-time for PhoneAcceptCallRequest.
var (
	_ bin.Encoder     = &PhoneAcceptCallRequest{}
	_ bin.Decoder     = &PhoneAcceptCallRequest{}
	_ bin.BareEncoder = &PhoneAcceptCallRequest{}
	_ bin.BareDecoder = &PhoneAcceptCallRequest{}
)

func ( *PhoneAcceptCallRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Peer.Zero()) {
		return false
	}
	if !(.GB == nil) {
		return false
	}
	if !(.Protocol.Zero()) {
		return false
	}

	return true
}

// String implements fmt.Stringer.
func ( *PhoneAcceptCallRequest) () string {
	if  == nil {
		return "PhoneAcceptCallRequest(nil)"
	}
	type  PhoneAcceptCallRequest
	return fmt.Sprintf("PhoneAcceptCallRequest%+v", (*))
}

// FillFrom fills PhoneAcceptCallRequest from given interface.
func ( *PhoneAcceptCallRequest) ( interface {
	() ( InputPhoneCall)
	() ( []byte)
	() ( PhoneCallProtocol)
}) {
	.Peer = .()
	.GB = .()
	.Protocol = .()
}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*PhoneAcceptCallRequest) () uint32 {
	return PhoneAcceptCallRequestTypeID
}

// TypeName returns name of type in TL schema.
func (*PhoneAcceptCallRequest) () string {
	return "phone.acceptCall"
}

// TypeInfo returns info about TL type.
func ( *PhoneAcceptCallRequest) () tdp.Type {
	 := tdp.Type{
		Name: "phone.acceptCall",
		ID:   PhoneAcceptCallRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "GB",
			SchemaName: "g_b",
		},
		{
			Name:       "Protocol",
			SchemaName: "protocol",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *PhoneAcceptCallRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode phone.acceptCall#3bd2b4a0 as nil")
	}
	.PutID(PhoneAcceptCallRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PhoneAcceptCallRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode phone.acceptCall#3bd2b4a0 as nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode phone.acceptCall#3bd2b4a0: field peer: %w", )
	}
	.PutBytes(.GB)
	if  := .Protocol.Encode();  != nil {
		return fmt.Errorf("unable to encode phone.acceptCall#3bd2b4a0: field protocol: %w", )
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *PhoneAcceptCallRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode phone.acceptCall#3bd2b4a0 to nil")
	}
	if  := .ConsumeID(PhoneAcceptCallRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode phone.acceptCall#3bd2b4a0: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *PhoneAcceptCallRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode phone.acceptCall#3bd2b4a0 to nil")
	}
	{
		if  := .Peer.Decode();  != nil {
			return fmt.Errorf("unable to decode phone.acceptCall#3bd2b4a0: field peer: %w", )
		}
	}
	{
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode phone.acceptCall#3bd2b4a0: field g_b: %w", )
		}
		.GB = 
	}
	{
		if  := .Protocol.Decode();  != nil {
			return fmt.Errorf("unable to decode phone.acceptCall#3bd2b4a0: field protocol: %w", )
		}
	}
	return nil
}

// GetPeer returns value of Peer field.
func ( *PhoneAcceptCallRequest) () ( InputPhoneCall) {
	if  == nil {
		return
	}
	return .Peer
}

// GetGB returns value of GB field.
func ( *PhoneAcceptCallRequest) () ( []byte) {
	if  == nil {
		return
	}
	return .GB
}

// GetProtocol returns value of Protocol field.
func ( *PhoneAcceptCallRequest) () ( PhoneCallProtocol) {
	if  == nil {
		return
	}
	return .Protocol
}

// PhoneAcceptCall invokes method phone.acceptCall#3bd2b4a0 returning error if any.
// Accept incoming call
//
// Possible errors:
//
//	400 CALL_ALREADY_ACCEPTED: The call was already accepted.
//	400 CALL_ALREADY_DECLINED: The call was already declined.
//	500 CALL_OCCUPY_FAILED: The call failed because the user is already making another call.
//	400 CALL_PEER_INVALID: The provided call peer object is invalid.
//	406 CALL_PROTOCOL_COMPAT_LAYER_INVALID: The other side of the call does not support any of the VoIP protocols supported by the local client, as specified by the protocol.layer and protocol.library_versions fields.
//	400 CALL_PROTOCOL_FLAGS_INVALID: Call protocol flags invalid.
//
// See https://core.telegram.org/method/phone.acceptCall for reference.
func ( *Client) ( context.Context,  *PhoneAcceptCallRequest) (*PhonePhoneCall, error) {
	var  PhonePhoneCall

	if  := .rpc.Invoke(, , &);  != nil {
		return nil, 
	}
	return &, nil
}