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

// MessagesToggleBotInAttachMenuRequest represents TL type `messages.toggleBotInAttachMenu#69f59d69`.
// Enable or disable web bot attachment menu »¹
//
// Links:
//  1. https://core.telegram.org/api/bots/attach
//
// See https://core.telegram.org/method/messages.toggleBotInAttachMenu for reference.
type MessagesToggleBotInAttachMenuRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether the user authorizes the bot to write messages to them, if requested by
	// attachMenuBot¹.request_write_access
	//
	// Links:
	//  1) https://core.telegram.org/constructor/attachMenuBot
	WriteAllowed bool
	// Bot ID
	Bot InputUserClass
	// Toggle
	Enabled bool
}

// MessagesToggleBotInAttachMenuRequestTypeID is TL type id of MessagesToggleBotInAttachMenuRequest.
const MessagesToggleBotInAttachMenuRequestTypeID = 0x69f59d69

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

func ( *MessagesToggleBotInAttachMenuRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.WriteAllowed == false) {
		return false
	}
	if !(.Bot == nil) {
		return false
	}
	if !(.Enabled == false) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesToggleBotInAttachMenuRequest from given interface.
func ( *MessagesToggleBotInAttachMenuRequest) ( interface {
	() ( bool)
	() ( InputUserClass)
	() ( bool)
}) {
	.WriteAllowed = .()
	.Bot = .()
	.Enabled = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesToggleBotInAttachMenuRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.toggleBotInAttachMenu",
		ID:   MessagesToggleBotInAttachMenuRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "WriteAllowed",
			SchemaName: "write_allowed",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Bot",
			SchemaName: "bot",
		},
		{
			Name:       "Enabled",
			SchemaName: "enabled",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *MessagesToggleBotInAttachMenuRequest) () {
	if !(.WriteAllowed == false) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *MessagesToggleBotInAttachMenuRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.toggleBotInAttachMenu#69f59d69 as nil")
	}
	.PutID(MessagesToggleBotInAttachMenuRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesToggleBotInAttachMenuRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.toggleBotInAttachMenu#69f59d69 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.toggleBotInAttachMenu#69f59d69: field flags: %w", )
	}
	if .Bot == nil {
		return fmt.Errorf("unable to encode messages.toggleBotInAttachMenu#69f59d69: field bot is nil")
	}
	if  := .Bot.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.toggleBotInAttachMenu#69f59d69: field bot: %w", )
	}
	.PutBool(.Enabled)
	return nil
}

// Decode implements bin.Decoder.
func ( *MessagesToggleBotInAttachMenuRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.toggleBotInAttachMenu#69f59d69 to nil")
	}
	if  := .ConsumeID(MessagesToggleBotInAttachMenuRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode messages.toggleBotInAttachMenu#69f59d69: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *MessagesToggleBotInAttachMenuRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.toggleBotInAttachMenu#69f59d69 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.toggleBotInAttachMenu#69f59d69: field flags: %w", )
		}
	}
	.WriteAllowed = .Flags.Has(0)
	{
		,  := DecodeInputUser()
		if  != nil {
			return fmt.Errorf("unable to decode messages.toggleBotInAttachMenu#69f59d69: field bot: %w", )
		}
		.Bot = 
	}
	{
		,  := .Bool()
		if  != nil {
			return fmt.Errorf("unable to decode messages.toggleBotInAttachMenu#69f59d69: field enabled: %w", )
		}
		.Enabled = 
	}
	return nil
}

// SetWriteAllowed sets value of WriteAllowed conditional field.
func ( *MessagesToggleBotInAttachMenuRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.WriteAllowed = true
	} else {
		.Flags.Unset(0)
		.WriteAllowed = false
	}
}

// GetWriteAllowed returns value of WriteAllowed conditional field.
func ( *MessagesToggleBotInAttachMenuRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// GetBot returns value of Bot field.
func ( *MessagesToggleBotInAttachMenuRequest) () ( InputUserClass) {
	if  == nil {
		return
	}
	return .Bot
}

// GetEnabled returns value of Enabled field.
func ( *MessagesToggleBotInAttachMenuRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Enabled
}

// MessagesToggleBotInAttachMenu invokes method messages.toggleBotInAttachMenu#69f59d69 returning error if any.
// Enable or disable web bot attachment menu »¹
//
// Links:
//  1. https://core.telegram.org/api/bots/attach
//
// See https://core.telegram.org/method/messages.toggleBotInAttachMenu for reference.
func ( *Client) ( context.Context,  *MessagesToggleBotInAttachMenuRequest) (bool, error) {
	var  BoolBox

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