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

// MessagesReorderStickerSetsRequest represents TL type `messages.reorderStickerSets#78337739`.
// Reorder installed stickersets
//
// See https://core.telegram.org/method/messages.reorderStickerSets for reference.
type MessagesReorderStickerSetsRequest struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Reorder mask stickersets
	Masks bool
	// Reorder custom emoji stickersetsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/api/custom-emoji
	Emojis bool
	// New stickerset order by stickerset IDs
	Order []int64
}

// MessagesReorderStickerSetsRequestTypeID is TL type id of MessagesReorderStickerSetsRequest.
const MessagesReorderStickerSetsRequestTypeID = 0x78337739

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

func ( *MessagesReorderStickerSetsRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Masks == false) {
		return false
	}
	if !(.Emojis == false) {
		return false
	}
	if !(.Order == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesReorderStickerSetsRequest from given interface.
func ( *MessagesReorderStickerSetsRequest) ( interface {
	() ( bool)
	() ( bool)
	() ( []int64)
}) {
	.Masks = .()
	.Emojis = .()
	.Order = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesReorderStickerSetsRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.reorderStickerSets",
		ID:   MessagesReorderStickerSetsRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Masks",
			SchemaName: "masks",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Emojis",
			SchemaName: "emojis",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "Order",
			SchemaName: "order",
		},
	}
	return 
}

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

// Encode implements bin.Encoder.
func ( *MessagesReorderStickerSetsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.reorderStickerSets#78337739 as nil")
	}
	.PutID(MessagesReorderStickerSetsRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesReorderStickerSetsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.reorderStickerSets#78337739 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.reorderStickerSets#78337739: field flags: %w", )
	}
	.PutVectorHeader(len(.Order))
	for ,  := range .Order {
		.PutLong()
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesReorderStickerSetsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.reorderStickerSets#78337739 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.reorderStickerSets#78337739: field flags: %w", )
		}
	}
	.Masks = .Flags.Has(0)
	.Emojis = .Flags.Has(1)
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode messages.reorderStickerSets#78337739: field order: %w", )
		}

		if  > 0 {
			.Order = make([]int64, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := .Long()
			if  != nil {
				return fmt.Errorf("unable to decode messages.reorderStickerSets#78337739: field order: %w", )
			}
			.Order = append(.Order, )
		}
	}
	return nil
}

// SetMasks sets value of Masks conditional field.
func ( *MessagesReorderStickerSetsRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.Masks = true
	} else {
		.Flags.Unset(0)
		.Masks = false
	}
}

// GetMasks returns value of Masks conditional field.
func ( *MessagesReorderStickerSetsRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetEmojis sets value of Emojis conditional field.
func ( *MessagesReorderStickerSetsRequest) ( bool) {
	if  {
		.Flags.Set(1)
		.Emojis = true
	} else {
		.Flags.Unset(1)
		.Emojis = false
	}
}

// GetEmojis returns value of Emojis conditional field.
func ( *MessagesReorderStickerSetsRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

// GetOrder returns value of Order field.
func ( *MessagesReorderStickerSetsRequest) () ( []int64) {
	if  == nil {
		return
	}
	return .Order
}

// MessagesReorderStickerSets invokes method messages.reorderStickerSets#78337739 returning error if any.
// Reorder installed stickersets
//
// See https://core.telegram.org/method/messages.reorderStickerSets for reference.
func ( *Client) ( context.Context,  *MessagesReorderStickerSetsRequest) (bool, error) {
	var  BoolBox

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