// 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{}
)

// PhoneConfirmCallRequest represents TL type `phone.confirmCall#2efe1722`.
// Complete phone call E2E encryption key exchange »¹
//
// Links:
//  1. https://core.telegram.org/api/end-to-end/voice-calls
//
// See https://core.telegram.org/method/phone.confirmCall for reference.
type PhoneConfirmCallRequest struct {
	// The phone call
	Peer InputPhoneCall
	// Parameter for E2E encryption key exchange »¹
	//
	// Links:
	//  1) https://core.telegram.org/api/end-to-end/voice-calls
	GA []byte
	// Key fingerprint
	KeyFingerprint int64
	// Phone call settings
	Protocol PhoneCallProtocol
}

// PhoneConfirmCallRequestTypeID is TL type id of PhoneConfirmCallRequest.
const PhoneConfirmCallRequestTypeID = 0x2efe1722

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

func ( *PhoneConfirmCallRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Peer.Zero()) {
		return false
	}
	if !(.GA == nil) {
		return false
	}
	if !(.KeyFingerprint == 0) {
		return false
	}
	if !(.Protocol.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills PhoneConfirmCallRequest from given interface.
func ( *PhoneConfirmCallRequest) ( interface {
	() ( InputPhoneCall)
	() ( []byte)
	() ( int64)
	() ( PhoneCallProtocol)
}) {
	.Peer = .()
	.GA = .()
	.KeyFingerprint = .()
	.Protocol = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *PhoneConfirmCallRequest) () tdp.Type {
	 := tdp.Type{
		Name: "phone.confirmCall",
		ID:   PhoneConfirmCallRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "GA",
			SchemaName: "g_a",
		},
		{
			Name:       "KeyFingerprint",
			SchemaName: "key_fingerprint",
		},
		{
			Name:       "Protocol",
			SchemaName: "protocol",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *PhoneConfirmCallRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode phone.confirmCall#2efe1722 as nil")
	}
	.PutID(PhoneConfirmCallRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PhoneConfirmCallRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode phone.confirmCall#2efe1722 as nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode phone.confirmCall#2efe1722: field peer: %w", )
	}
	.PutBytes(.GA)
	.PutLong(.KeyFingerprint)
	if  := .Protocol.Encode();  != nil {
		return fmt.Errorf("unable to encode phone.confirmCall#2efe1722: field protocol: %w", )
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *PhoneConfirmCallRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode phone.confirmCall#2efe1722 to nil")
	}
	if  := .ConsumeID(PhoneConfirmCallRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode phone.confirmCall#2efe1722: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *PhoneConfirmCallRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode phone.confirmCall#2efe1722 to nil")
	}
	{
		if  := .Peer.Decode();  != nil {
			return fmt.Errorf("unable to decode phone.confirmCall#2efe1722: field peer: %w", )
		}
	}
	{
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode phone.confirmCall#2efe1722: field g_a: %w", )
		}
		.GA = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode phone.confirmCall#2efe1722: field key_fingerprint: %w", )
		}
		.KeyFingerprint = 
	}
	{
		if  := .Protocol.Decode();  != nil {
			return fmt.Errorf("unable to decode phone.confirmCall#2efe1722: field protocol: %w", )
		}
	}
	return nil
}

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

// GetGA returns value of GA field.
func ( *PhoneConfirmCallRequest) () ( []byte) {
	if  == nil {
		return
	}
	return .GA
}

// GetKeyFingerprint returns value of KeyFingerprint field.
func ( *PhoneConfirmCallRequest) () ( int64) {
	if  == nil {
		return
	}
	return .KeyFingerprint
}

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

// PhoneConfirmCall invokes method phone.confirmCall#2efe1722 returning error if any.
// Complete phone call E2E encryption key exchange »¹
//
// Links:
//  1. https://core.telegram.org/api/end-to-end/voice-calls
//
// Possible errors:
//
//	400 CALL_ALREADY_DECLINED: The call was already declined.
//	400 CALL_PEER_INVALID: The provided call peer object is invalid.
//
// See https://core.telegram.org/method/phone.confirmCall for reference.
func ( *Client) ( context.Context,  *PhoneConfirmCallRequest) (*PhonePhoneCall, error) {
	var  PhonePhoneCall

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