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

// BotsToggleUserEmojiStatusPermissionRequest represents TL type `bots.toggleUserEmojiStatusPermission#6de6392`.
// Allow or prevent a bot from changing our emoji status »¹
//
// Links:
//  1. https://core.telegram.org/api/emoji-status#setting-an-emoji-status-from-a-bot
//
// See https://core.telegram.org/method/bots.toggleUserEmojiStatusPermission for reference.
type BotsToggleUserEmojiStatusPermissionRequest struct {
	// The bot
	Bot InputUserClass
	// Whether to allow or prevent the bot from changing our emoji status
	Enabled bool
}

// BotsToggleUserEmojiStatusPermissionRequestTypeID is TL type id of BotsToggleUserEmojiStatusPermissionRequest.
const BotsToggleUserEmojiStatusPermissionRequestTypeID = 0x6de6392

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

func ( *BotsToggleUserEmojiStatusPermissionRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Bot == nil) {
		return false
	}
	if !(.Enabled == false) {
		return false
	}

	return true
}

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

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

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

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

// TypeInfo returns info about TL type.
func ( *BotsToggleUserEmojiStatusPermissionRequest) () tdp.Type {
	 := tdp.Type{
		Name: "bots.toggleUserEmojiStatusPermission",
		ID:   BotsToggleUserEmojiStatusPermissionRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Bot",
			SchemaName: "bot",
		},
		{
			Name:       "Enabled",
			SchemaName: "enabled",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *BotsToggleUserEmojiStatusPermissionRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode bots.toggleUserEmojiStatusPermission#6de6392 as nil")
	}
	.PutID(BotsToggleUserEmojiStatusPermissionRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *BotsToggleUserEmojiStatusPermissionRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode bots.toggleUserEmojiStatusPermission#6de6392 as nil")
	}
	if .Bot == nil {
		return fmt.Errorf("unable to encode bots.toggleUserEmojiStatusPermission#6de6392: field bot is nil")
	}
	if  := .Bot.Encode();  != nil {
		return fmt.Errorf("unable to encode bots.toggleUserEmojiStatusPermission#6de6392: field bot: %w", )
	}
	.PutBool(.Enabled)
	return nil
}

// Decode implements bin.Decoder.
func ( *BotsToggleUserEmojiStatusPermissionRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode bots.toggleUserEmojiStatusPermission#6de6392 to nil")
	}
	if  := .ConsumeID(BotsToggleUserEmojiStatusPermissionRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode bots.toggleUserEmojiStatusPermission#6de6392: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *BotsToggleUserEmojiStatusPermissionRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode bots.toggleUserEmojiStatusPermission#6de6392 to nil")
	}
	{
		,  := DecodeInputUser()
		if  != nil {
			return fmt.Errorf("unable to decode bots.toggleUserEmojiStatusPermission#6de6392: field bot: %w", )
		}
		.Bot = 
	}
	{
		,  := .Bool()
		if  != nil {
			return fmt.Errorf("unable to decode bots.toggleUserEmojiStatusPermission#6de6392: field enabled: %w", )
		}
		.Enabled = 
	}
	return nil
}

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

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

// BotsToggleUserEmojiStatusPermission invokes method bots.toggleUserEmojiStatusPermission#6de6392 returning error if any.
// Allow or prevent a bot from changing our emoji status »¹
//
// Links:
//  1. https://core.telegram.org/api/emoji-status#setting-an-emoji-status-from-a-bot
//
// Possible errors:
//
//	400 BOT_INVALID: This is not a valid bot.
//
// See https://core.telegram.org/method/bots.toggleUserEmojiStatusPermission for reference.
func ( *Client) ( context.Context,  *BotsToggleUserEmojiStatusPermissionRequest) (bool, error) {
	var  BoolBox

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