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

// BotsSetBotMenuButtonRequest represents TL type `bots.setBotMenuButton#4504d54f`.
// Sets the menu button action »¹ for a given user or for all users
//
// Links:
//  1. https://core.telegram.org/api/bots/menu
//
// See https://core.telegram.org/method/bots.setBotMenuButton for reference.
type BotsSetBotMenuButtonRequest struct {
	// User ID
	UserID InputUserClass
	// Bot menu button action
	Button BotMenuButtonClass
}

// BotsSetBotMenuButtonRequestTypeID is TL type id of BotsSetBotMenuButtonRequest.
const BotsSetBotMenuButtonRequestTypeID = 0x4504d54f

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

func ( *BotsSetBotMenuButtonRequest) () bool {
	if  == nil {
		return true
	}
	if !(.UserID == nil) {
		return false
	}
	if !(.Button == nil) {
		return false
	}

	return true
}

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

// FillFrom fills BotsSetBotMenuButtonRequest from given interface.
func ( *BotsSetBotMenuButtonRequest) ( interface {
	() ( InputUserClass)
	() ( BotMenuButtonClass)
}) {
	.UserID = .()
	.Button = .()
}

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

// TypeName returns name of type in TL schema.
func (*BotsSetBotMenuButtonRequest) () string {
	return "bots.setBotMenuButton"
}

// TypeInfo returns info about TL type.
func ( *BotsSetBotMenuButtonRequest) () tdp.Type {
	 := tdp.Type{
		Name: "bots.setBotMenuButton",
		ID:   BotsSetBotMenuButtonRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "UserID",
			SchemaName: "user_id",
		},
		{
			Name:       "Button",
			SchemaName: "button",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *BotsSetBotMenuButtonRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode bots.setBotMenuButton#4504d54f as nil")
	}
	.PutID(BotsSetBotMenuButtonRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *BotsSetBotMenuButtonRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode bots.setBotMenuButton#4504d54f as nil")
	}
	if .UserID == nil {
		return fmt.Errorf("unable to encode bots.setBotMenuButton#4504d54f: field user_id is nil")
	}
	if  := .UserID.Encode();  != nil {
		return fmt.Errorf("unable to encode bots.setBotMenuButton#4504d54f: field user_id: %w", )
	}
	if .Button == nil {
		return fmt.Errorf("unable to encode bots.setBotMenuButton#4504d54f: field button is nil")
	}
	if  := .Button.Encode();  != nil {
		return fmt.Errorf("unable to encode bots.setBotMenuButton#4504d54f: field button: %w", )
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *BotsSetBotMenuButtonRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode bots.setBotMenuButton#4504d54f to nil")
	}
	if  := .ConsumeID(BotsSetBotMenuButtonRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode bots.setBotMenuButton#4504d54f: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *BotsSetBotMenuButtonRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode bots.setBotMenuButton#4504d54f to nil")
	}
	{
		,  := DecodeInputUser()
		if  != nil {
			return fmt.Errorf("unable to decode bots.setBotMenuButton#4504d54f: field user_id: %w", )
		}
		.UserID = 
	}
	{
		,  := DecodeBotMenuButton()
		if  != nil {
			return fmt.Errorf("unable to decode bots.setBotMenuButton#4504d54f: field button: %w", )
		}
		.Button = 
	}
	return nil
}

// GetUserID returns value of UserID field.
func ( *BotsSetBotMenuButtonRequest) () ( InputUserClass) {
	if  == nil {
		return
	}
	return .UserID
}

// GetButton returns value of Button field.
func ( *BotsSetBotMenuButtonRequest) () ( BotMenuButtonClass) {
	if  == nil {
		return
	}
	return .Button
}

// BotsSetBotMenuButton invokes method bots.setBotMenuButton#4504d54f returning error if any.
// Sets the menu button action »¹ for a given user or for all users
//
// Links:
//  1. https://core.telegram.org/api/bots/menu
//
// Possible errors:
//
//	400 BUTTON_TEXT_INVALID: The specified button text is invalid.
//	400 BUTTON_URL_INVALID: Button URL invalid.
//
// See https://core.telegram.org/method/bots.setBotMenuButton for reference.
// Can be used by bots.
func ( *Client) ( context.Context,  *BotsSetBotMenuButtonRequest) (bool, error) {
	var  BoolBox

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