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

// MessagesSendBotRequestedPeerRequest represents TL type `messages.sendBotRequestedPeer#91b2d060`.
// Send a chosen peer, as requested by a keyboardButtonRequestPeer¹ button.
//
// Links:
//  1. https://core.telegram.org/constructor/keyboardButtonRequestPeer
//
// See https://core.telegram.org/method/messages.sendBotRequestedPeer for reference.
type MessagesSendBotRequestedPeerRequest struct {
	// The bot that sent the keyboardButtonRequestPeer¹ button.
	//
	// Links:
	//  1) https://core.telegram.org/constructor/keyboardButtonRequestPeer
	Peer InputPeerClass
	// ID of the message that contained the reply keyboard with the
	// keyboardButtonRequestPeer¹ button.
	//
	// Links:
	//  1) https://core.telegram.org/constructor/keyboardButtonRequestPeer
	MsgID int
	// The button_id field from the keyboardButtonRequestPeer¹ constructor.
	//
	// Links:
	//  1) https://core.telegram.org/constructor/keyboardButtonRequestPeer
	ButtonID int
	// RequestedPeers field of MessagesSendBotRequestedPeerRequest.
	RequestedPeers []InputPeerClass
}

// MessagesSendBotRequestedPeerRequestTypeID is TL type id of MessagesSendBotRequestedPeerRequest.
const MessagesSendBotRequestedPeerRequestTypeID = 0x91b2d060

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

func ( *MessagesSendBotRequestedPeerRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.MsgID == 0) {
		return false
	}
	if !(.ButtonID == 0) {
		return false
	}
	if !(.RequestedPeers == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesSendBotRequestedPeerRequest from given interface.
func ( *MessagesSendBotRequestedPeerRequest) ( interface {
	() ( InputPeerClass)
	() ( int)
	() ( int)
	() ( []InputPeerClass)
}) {
	.Peer = .()
	.MsgID = .()
	.ButtonID = .()
	.RequestedPeers = .()
}

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

// TypeName returns name of type in TL schema.
func (*MessagesSendBotRequestedPeerRequest) () string {
	return "messages.sendBotRequestedPeer"
}

// TypeInfo returns info about TL type.
func ( *MessagesSendBotRequestedPeerRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.sendBotRequestedPeer",
		ID:   MessagesSendBotRequestedPeerRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "MsgID",
			SchemaName: "msg_id",
		},
		{
			Name:       "ButtonID",
			SchemaName: "button_id",
		},
		{
			Name:       "RequestedPeers",
			SchemaName: "requested_peers",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *MessagesSendBotRequestedPeerRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.sendBotRequestedPeer#91b2d060 as nil")
	}
	.PutID(MessagesSendBotRequestedPeerRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesSendBotRequestedPeerRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.sendBotRequestedPeer#91b2d060 as nil")
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode messages.sendBotRequestedPeer#91b2d060: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.sendBotRequestedPeer#91b2d060: field peer: %w", )
	}
	.PutInt(.MsgID)
	.PutInt(.ButtonID)
	.PutVectorHeader(len(.RequestedPeers))
	for ,  := range .RequestedPeers {
		if  == nil {
			return fmt.Errorf("unable to encode messages.sendBotRequestedPeer#91b2d060: field requested_peers element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode messages.sendBotRequestedPeer#91b2d060: field requested_peers element with index %d: %w", , )
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *MessagesSendBotRequestedPeerRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.sendBotRequestedPeer#91b2d060 to nil")
	}
	if  := .ConsumeID(MessagesSendBotRequestedPeerRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode messages.sendBotRequestedPeer#91b2d060: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *MessagesSendBotRequestedPeerRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.sendBotRequestedPeer#91b2d060 to nil")
	}
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode messages.sendBotRequestedPeer#91b2d060: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.sendBotRequestedPeer#91b2d060: field msg_id: %w", )
		}
		.MsgID = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.sendBotRequestedPeer#91b2d060: field button_id: %w", )
		}
		.ButtonID = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode messages.sendBotRequestedPeer#91b2d060: field requested_peers: %w", )
		}

		if  > 0 {
			.RequestedPeers = make([]InputPeerClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeInputPeer()
			if  != nil {
				return fmt.Errorf("unable to decode messages.sendBotRequestedPeer#91b2d060: field requested_peers: %w", )
			}
			.RequestedPeers = append(.RequestedPeers, )
		}
	}
	return nil
}

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

// GetMsgID returns value of MsgID field.
func ( *MessagesSendBotRequestedPeerRequest) () ( int) {
	if  == nil {
		return
	}
	return .MsgID
}

// GetButtonID returns value of ButtonID field.
func ( *MessagesSendBotRequestedPeerRequest) () ( int) {
	if  == nil {
		return
	}
	return .ButtonID
}

// GetRequestedPeers returns value of RequestedPeers field.
func ( *MessagesSendBotRequestedPeerRequest) () ( []InputPeerClass) {
	if  == nil {
		return
	}
	return .RequestedPeers
}

// MapRequestedPeers returns field RequestedPeers wrapped in InputPeerClassArray helper.
func ( *MessagesSendBotRequestedPeerRequest) () ( InputPeerClassArray) {
	return InputPeerClassArray(.RequestedPeers)
}

// MessagesSendBotRequestedPeer invokes method messages.sendBotRequestedPeer#91b2d060 returning error if any.
// Send a chosen peer, as requested by a keyboardButtonRequestPeer¹ button.
//
// Links:
//  1. https://core.telegram.org/constructor/keyboardButtonRequestPeer
//
// See https://core.telegram.org/method/messages.sendBotRequestedPeer for reference.
// Can be used by bots.
func ( *Client) ( context.Context,  *MessagesSendBotRequestedPeerRequest) (UpdatesClass, error) {
	var  UpdatesBox

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