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

// MessagesReorderPinnedForumTopicsRequest represents TL type `messages.reorderPinnedForumTopics#e7841f0`.
// Reorder pinned forum topics
//
// See https://core.telegram.org/method/messages.reorderPinnedForumTopics for reference.
type MessagesReorderPinnedForumTopicsRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// If not set, the order of only the topics present both server-side and in order will be
	// changed (i.e. mentioning topics not pinned server-side in order will not pin them, and
	// not mentioning topics pinned server-side will not unpin them).  If set, the entire
	// server-side pinned topic list will be replaced with order (i.e. mentioning topics not
	// pinned server-side in order will pin them, and not mentioning topics pinned
	// server-side will unpin them)
	Force bool
	// The supergroup forum, private chat (for forum-enabled bots) or bot forum (for users)
	// where the topic is located.
	Peer InputPeerClass
	// Topic IDs »¹
	//
	// Links:
	//  1) https://core.telegram.org/api/forum
	Order []int
}

// MessagesReorderPinnedForumTopicsRequestTypeID is TL type id of MessagesReorderPinnedForumTopicsRequest.
const MessagesReorderPinnedForumTopicsRequestTypeID = 0xe7841f0

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

func ( *MessagesReorderPinnedForumTopicsRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Force == false) {
		return false
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.Order == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesReorderPinnedForumTopicsRequest from given interface.
func ( *MessagesReorderPinnedForumTopicsRequest) ( interface {
	() ( bool)
	() ( InputPeerClass)
	() ( []int)
}) {
	.Force = .()
	.Peer = .()
	.Order = .()
}

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

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

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

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

// Encode implements bin.Encoder.
func ( *MessagesReorderPinnedForumTopicsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.reorderPinnedForumTopics#e7841f0 as nil")
	}
	.PutID(MessagesReorderPinnedForumTopicsRequestTypeID)
	return .EncodeBare()
}

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

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesReorderPinnedForumTopicsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.reorderPinnedForumTopics#e7841f0 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.reorderPinnedForumTopics#e7841f0: field flags: %w", )
		}
	}
	.Force = .Flags.Has(0)
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode messages.reorderPinnedForumTopics#e7841f0: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode messages.reorderPinnedForumTopics#e7841f0: field order: %w", )
		}

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

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

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

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

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

// MessagesReorderPinnedForumTopics invokes method messages.reorderPinnedForumTopics#e7841f0 returning error if any.
// Reorder pinned forum topics
//
// Possible errors:
//
//	400 CHANNEL_INVALID: The provided channel is invalid.
//
// See https://core.telegram.org/method/messages.reorderPinnedForumTopics for reference.
func ( *Client) ( context.Context,  *MessagesReorderPinnedForumTopicsRequest) (UpdatesClass, error) {
	var  UpdatesBox

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