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

// MessagesSetChatAvailableReactionsRequest represents TL type `messages.setChatAvailableReactions#864b2581`.
// Change the set of message reactions »¹ that can be used in a certain group,
// supergroup or channel
//
// Links:
//  1. https://core.telegram.org/api/reactions
//
// See https://core.telegram.org/method/messages.setChatAvailableReactions for reference.
type MessagesSetChatAvailableReactionsRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Group where to apply changes
	Peer InputPeerClass
	// Allowed reaction emojis
	AvailableReactions ChatReactionsClass
	// This flag may be used to impose a custom limit of unique reactions (i.e. a
	// customizable version of appConfig.reactions_uniq_max¹); this field and the other info
	// set by the method will then be available to users in channelFull² and chatFull³. If
	// this flag is not set, the previously configured reactions_limit will not be altered.
	//
	// Links:
	//  1) https://core.telegram.org/api/config#reactions-uniq-max
	//  2) https://core.telegram.org/constructor/channelFull
	//  3) https://core.telegram.org/constructor/chatFull
	//
	// Use SetReactionsLimit and GetReactionsLimit helpers.
	ReactionsLimit int
	// If this flag is set and a Bool¹ is passed, the method will enable or disable paid
	// message reactions »². If this flag is not set, the previously stored setting will
	// not be changed.
	//
	// Links:
	//  1) https://core.telegram.org/type/Bool
	//  2) https://core.telegram.org/api/reactions#paid-reactions
	//
	// Use SetPaidEnabled and GetPaidEnabled helpers.
	PaidEnabled bool
}

// MessagesSetChatAvailableReactionsRequestTypeID is TL type id of MessagesSetChatAvailableReactionsRequest.
const MessagesSetChatAvailableReactionsRequestTypeID = 0x864b2581

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

func ( *MessagesSetChatAvailableReactionsRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.AvailableReactions == nil) {
		return false
	}
	if !(.ReactionsLimit == 0) {
		return false
	}
	if !(.PaidEnabled == false) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesSetChatAvailableReactionsRequest from given interface.
func ( *MessagesSetChatAvailableReactionsRequest) ( interface {
	() ( InputPeerClass)
	() ( ChatReactionsClass)
	() ( int,  bool)
	() ( bool,  bool)
}) {
	.Peer = .()
	.AvailableReactions = .()
	if ,  := .();  {
		.ReactionsLimit = 
	}

	if ,  := .();  {
		.PaidEnabled = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesSetChatAvailableReactionsRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.setChatAvailableReactions",
		ID:   MessagesSetChatAvailableReactionsRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "AvailableReactions",
			SchemaName: "available_reactions",
		},
		{
			Name:       "ReactionsLimit",
			SchemaName: "reactions_limit",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "PaidEnabled",
			SchemaName: "paid_enabled",
			Null:       !.Flags.Has(1),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *MessagesSetChatAvailableReactionsRequest) () {
	if !(.ReactionsLimit == 0) {
		.Flags.Set(0)
	}
	if !(.PaidEnabled == false) {
		.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func ( *MessagesSetChatAvailableReactionsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.setChatAvailableReactions#864b2581 as nil")
	}
	.PutID(MessagesSetChatAvailableReactionsRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesSetChatAvailableReactionsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.setChatAvailableReactions#864b2581 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.setChatAvailableReactions#864b2581: field flags: %w", )
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode messages.setChatAvailableReactions#864b2581: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.setChatAvailableReactions#864b2581: field peer: %w", )
	}
	if .AvailableReactions == nil {
		return fmt.Errorf("unable to encode messages.setChatAvailableReactions#864b2581: field available_reactions is nil")
	}
	if  := .AvailableReactions.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.setChatAvailableReactions#864b2581: field available_reactions: %w", )
	}
	if .Flags.Has(0) {
		.PutInt(.ReactionsLimit)
	}
	if .Flags.Has(1) {
		.PutBool(.PaidEnabled)
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *MessagesSetChatAvailableReactionsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.setChatAvailableReactions#864b2581 to nil")
	}
	if  := .ConsumeID(MessagesSetChatAvailableReactionsRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode messages.setChatAvailableReactions#864b2581: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *MessagesSetChatAvailableReactionsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.setChatAvailableReactions#864b2581 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.setChatAvailableReactions#864b2581: field flags: %w", )
		}
	}
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode messages.setChatAvailableReactions#864b2581: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := DecodeChatReactions()
		if  != nil {
			return fmt.Errorf("unable to decode messages.setChatAvailableReactions#864b2581: field available_reactions: %w", )
		}
		.AvailableReactions = 
	}
	if .Flags.Has(0) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.setChatAvailableReactions#864b2581: field reactions_limit: %w", )
		}
		.ReactionsLimit = 
	}
	if .Flags.Has(1) {
		,  := .Bool()
		if  != nil {
			return fmt.Errorf("unable to decode messages.setChatAvailableReactions#864b2581: field paid_enabled: %w", )
		}
		.PaidEnabled = 
	}
	return nil
}

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

// GetAvailableReactions returns value of AvailableReactions field.
func ( *MessagesSetChatAvailableReactionsRequest) () ( ChatReactionsClass) {
	if  == nil {
		return
	}
	return .AvailableReactions
}

// SetReactionsLimit sets value of ReactionsLimit conditional field.
func ( *MessagesSetChatAvailableReactionsRequest) ( int) {
	.Flags.Set(0)
	.ReactionsLimit = 
}

// GetReactionsLimit returns value of ReactionsLimit conditional field and
// boolean which is true if field was set.
func ( *MessagesSetChatAvailableReactionsRequest) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .ReactionsLimit, true
}

// SetPaidEnabled sets value of PaidEnabled conditional field.
func ( *MessagesSetChatAvailableReactionsRequest) ( bool) {
	.Flags.Set(1)
	.PaidEnabled = 
}

// GetPaidEnabled returns value of PaidEnabled conditional field and
// boolean which is true if field was set.
func ( *MessagesSetChatAvailableReactionsRequest) () ( bool,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .PaidEnabled, true
}

// MessagesSetChatAvailableReactions invokes method messages.setChatAvailableReactions#864b2581 returning error if any.
// Change the set of message reactions »¹ that can be used in a certain group,
// supergroup or channel
//
// Links:
//  1. https://core.telegram.org/api/reactions
//
// Possible errors:
//
//	400 CHAT_ADMIN_REQUIRED: You must be an admin in this chat to do this.
//	400 CHAT_NOT_MODIFIED: No changes were made to chat information because the new information you passed is identical to the current information.
//	400 DOCUMENT_INVALID: The specified document is invalid.
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//	400 REACTION_INVALID: The specified reaction is invalid.
//
// See https://core.telegram.org/method/messages.setChatAvailableReactions for reference.
func ( *Client) ( context.Context,  *MessagesSetChatAvailableReactionsRequest) (UpdatesClass, error) {
	var  UpdatesBox

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