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

// MessagesToggleStickerSetsRequest represents TL type `messages.toggleStickerSets#b5052fea`.
// Apply changes to multiple stickersets
//
// See https://core.telegram.org/method/messages.toggleStickerSets for reference.
type MessagesToggleStickerSetsRequest struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Uninstall the specified stickersets
	Uninstall bool
	// Archive the specified stickersets
	Archive bool
	// Unarchive the specified stickersets
	Unarchive bool
	// Stickersets to act upon
	Stickersets []InputStickerSetClass
}

// MessagesToggleStickerSetsRequestTypeID is TL type id of MessagesToggleStickerSetsRequest.
const MessagesToggleStickerSetsRequestTypeID = 0xb5052fea

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

func ( *MessagesToggleStickerSetsRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Uninstall == false) {
		return false
	}
	if !(.Archive == false) {
		return false
	}
	if !(.Unarchive == false) {
		return false
	}
	if !(.Stickersets == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesToggleStickerSetsRequest from given interface.
func ( *MessagesToggleStickerSetsRequest) ( interface {
	() ( bool)
	() ( bool)
	() ( bool)
	() ( []InputStickerSetClass)
}) {
	.Uninstall = .()
	.Archive = .()
	.Unarchive = .()
	.Stickersets = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesToggleStickerSetsRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.toggleStickerSets",
		ID:   MessagesToggleStickerSetsRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Uninstall",
			SchemaName: "uninstall",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Archive",
			SchemaName: "archive",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "Unarchive",
			SchemaName: "unarchive",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "Stickersets",
			SchemaName: "stickersets",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *MessagesToggleStickerSetsRequest) () {
	if !(.Uninstall == false) {
		.Flags.Set(0)
	}
	if !(.Archive == false) {
		.Flags.Set(1)
	}
	if !(.Unarchive == false) {
		.Flags.Set(2)
	}
}

// Encode implements bin.Encoder.
func ( *MessagesToggleStickerSetsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.toggleStickerSets#b5052fea as nil")
	}
	.PutID(MessagesToggleStickerSetsRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesToggleStickerSetsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.toggleStickerSets#b5052fea as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.toggleStickerSets#b5052fea: field flags: %w", )
	}
	.PutVectorHeader(len(.Stickersets))
	for ,  := range .Stickersets {
		if  == nil {
			return fmt.Errorf("unable to encode messages.toggleStickerSets#b5052fea: field stickersets element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode messages.toggleStickerSets#b5052fea: field stickersets element with index %d: %w", , )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesToggleStickerSetsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.toggleStickerSets#b5052fea to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.toggleStickerSets#b5052fea: field flags: %w", )
		}
	}
	.Uninstall = .Flags.Has(0)
	.Archive = .Flags.Has(1)
	.Unarchive = .Flags.Has(2)
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode messages.toggleStickerSets#b5052fea: field stickersets: %w", )
		}

		if  > 0 {
			.Stickersets = make([]InputStickerSetClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeInputStickerSet()
			if  != nil {
				return fmt.Errorf("unable to decode messages.toggleStickerSets#b5052fea: field stickersets: %w", )
			}
			.Stickersets = append(.Stickersets, )
		}
	}
	return nil
}

// SetUninstall sets value of Uninstall conditional field.
func ( *MessagesToggleStickerSetsRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.Uninstall = true
	} else {
		.Flags.Unset(0)
		.Uninstall = false
	}
}

// GetUninstall returns value of Uninstall conditional field.
func ( *MessagesToggleStickerSetsRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetArchive sets value of Archive conditional field.
func ( *MessagesToggleStickerSetsRequest) ( bool) {
	if  {
		.Flags.Set(1)
		.Archive = true
	} else {
		.Flags.Unset(1)
		.Archive = false
	}
}

// GetArchive returns value of Archive conditional field.
func ( *MessagesToggleStickerSetsRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

// SetUnarchive sets value of Unarchive conditional field.
func ( *MessagesToggleStickerSetsRequest) ( bool) {
	if  {
		.Flags.Set(2)
		.Unarchive = true
	} else {
		.Flags.Unset(2)
		.Unarchive = false
	}
}

// GetUnarchive returns value of Unarchive conditional field.
func ( *MessagesToggleStickerSetsRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(2)
}

// GetStickersets returns value of Stickersets field.
func ( *MessagesToggleStickerSetsRequest) () ( []InputStickerSetClass) {
	if  == nil {
		return
	}
	return .Stickersets
}

// MapStickersets returns field Stickersets wrapped in InputStickerSetClassArray helper.
func ( *MessagesToggleStickerSetsRequest) () ( InputStickerSetClassArray) {
	return InputStickerSetClassArray(.Stickersets)
}

// MessagesToggleStickerSets invokes method messages.toggleStickerSets#b5052fea returning error if any.
// Apply changes to multiple stickersets
//
// See https://core.telegram.org/method/messages.toggleStickerSets for reference.
func ( *Client) ( context.Context,  *MessagesToggleStickerSetsRequest) (bool, error) {
	var  BoolBox

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