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

// PhoneReceivedCallRequest represents TL type `phone.receivedCall#17d54f61`.
// Optional: notify the server that the user is currently busy in a call: this will
// automatically refuse all incoming phone calls until the current phone call is ended.
//
// See https://core.telegram.org/method/phone.receivedCall for reference.
type PhoneReceivedCallRequest struct {
	// The phone call we're currently in
	Peer InputPhoneCall
}

// PhoneReceivedCallRequestTypeID is TL type id of PhoneReceivedCallRequest.
const PhoneReceivedCallRequestTypeID = 0x17d54f61

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

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

	return true
}

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

// FillFrom fills PhoneReceivedCallRequest from given interface.
func ( *PhoneReceivedCallRequest) ( interface {
	() ( InputPhoneCall)
}) {
	.Peer = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *PhoneReceivedCallRequest) () tdp.Type {
	 := tdp.Type{
		Name: "phone.receivedCall",
		ID:   PhoneReceivedCallRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *PhoneReceivedCallRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode phone.receivedCall#17d54f61 as nil")
	}
	.PutID(PhoneReceivedCallRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PhoneReceivedCallRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode phone.receivedCall#17d54f61 as nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode phone.receivedCall#17d54f61: field peer: %w", )
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *PhoneReceivedCallRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode phone.receivedCall#17d54f61 to nil")
	}
	if  := .ConsumeID(PhoneReceivedCallRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode phone.receivedCall#17d54f61: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *PhoneReceivedCallRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode phone.receivedCall#17d54f61 to nil")
	}
	{
		if  := .Peer.Decode();  != nil {
			return fmt.Errorf("unable to decode phone.receivedCall#17d54f61: field peer: %w", )
		}
	}
	return nil
}

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

// PhoneReceivedCall invokes method phone.receivedCall#17d54f61 returning error if any.
// Optional: notify the server that the user is currently busy in a call: this will
// automatically refuse all incoming phone calls until the current phone call is ended.
//
// 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.receivedCall for reference.
func ( *Client) ( context.Context,  InputPhoneCall) (bool, error) {
	var  BoolBox

	 := &PhoneReceivedCallRequest{
		Peer: ,
	}
	if  := .rpc.Invoke(, , &);  != nil {
		return false, 
	}
	,  := .Bool.(*BoolTrue)
	return , nil
}