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

// MessagesReorderPinnedDialogsRequest represents TL type `messages.reorderPinnedDialogs#3b1adf37`.
// Reorder pinned dialogs
//
// See https://core.telegram.org/method/messages.reorderPinnedDialogs for reference.
type MessagesReorderPinnedDialogsRequest struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// If set, dialogs pinned server-side but not present in the order field will be unpinned.
	Force bool
	// Peer folder ID, for more info click hereĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/api/folders#peer-folders
	FolderID int
	// New dialog order
	Order []InputDialogPeerClass
}

// MessagesReorderPinnedDialogsRequestTypeID is TL type id of MessagesReorderPinnedDialogsRequest.
const MessagesReorderPinnedDialogsRequestTypeID = 0x3b1adf37

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

func ( *MessagesReorderPinnedDialogsRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Force == false) {
		return false
	}
	if !(.FolderID == 0) {
		return false
	}
	if !(.Order == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesReorderPinnedDialogsRequest from given interface.
func ( *MessagesReorderPinnedDialogsRequest) ( interface {
	() ( bool)
	() ( int)
	() ( []InputDialogPeerClass)
}) {
	.Force = .()
	.FolderID = .()
	.Order = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesReorderPinnedDialogsRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.reorderPinnedDialogs",
		ID:   MessagesReorderPinnedDialogsRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Force",
			SchemaName: "force",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "FolderID",
			SchemaName: "folder_id",
		},
		{
			Name:       "Order",
			SchemaName: "order",
		},
	}
	return 
}

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

// Encode implements bin.Encoder.
func ( *MessagesReorderPinnedDialogsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.reorderPinnedDialogs#3b1adf37 as nil")
	}
	.PutID(MessagesReorderPinnedDialogsRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesReorderPinnedDialogsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.reorderPinnedDialogs#3b1adf37 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.reorderPinnedDialogs#3b1adf37: field flags: %w", )
	}
	.PutInt(.FolderID)
	.PutVectorHeader(len(.Order))
	for ,  := range .Order {
		if  == nil {
			return fmt.Errorf("unable to encode messages.reorderPinnedDialogs#3b1adf37: field order element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode messages.reorderPinnedDialogs#3b1adf37: field order element with index %d: %w", , )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesReorderPinnedDialogsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.reorderPinnedDialogs#3b1adf37 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.reorderPinnedDialogs#3b1adf37: field flags: %w", )
		}
	}
	.Force = .Flags.Has(0)
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.reorderPinnedDialogs#3b1adf37: field folder_id: %w", )
		}
		.FolderID = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode messages.reorderPinnedDialogs#3b1adf37: field order: %w", )
		}

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

// SetForce sets value of Force conditional field.
func ( *MessagesReorderPinnedDialogsRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.Force = true
	} else {
		.Flags.Unset(0)
		.Force = false
	}
}

// GetForce returns value of Force conditional field.
func ( *MessagesReorderPinnedDialogsRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// GetFolderID returns value of FolderID field.
func ( *MessagesReorderPinnedDialogsRequest) () ( int) {
	if  == nil {
		return
	}
	return .FolderID
}

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

// MapOrder returns field Order wrapped in InputDialogPeerClassArray helper.
func ( *MessagesReorderPinnedDialogsRequest) () ( InputDialogPeerClassArray) {
	return InputDialogPeerClassArray(.Order)
}

// MessagesReorderPinnedDialogs invokes method messages.reorderPinnedDialogs#3b1adf37 returning error if any.
// Reorder pinned dialogs
//
// Possible errors:
//
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//
// See https://core.telegram.org/method/messages.reorderPinnedDialogs for reference.
func ( *Client) ( context.Context,  *MessagesReorderPinnedDialogsRequest) (bool, error) {
	var  BoolBox

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