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

// ChannelsReorderPinnedForumTopicsRequest represents TL type `channels.reorderPinnedForumTopics#2950a18f`.
// Reorder pinned forum topics
//
// See https://core.telegram.org/method/channels.reorderPinnedForumTopics for reference.
type ChannelsReorderPinnedForumTopicsRequest 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
	// Supergroup ID
	Channel InputChannelClass
	// Topic IDs »¹
	//
	// Links:
	//  1) https://core.telegram.org/api/forum
	Order []int
}

// ChannelsReorderPinnedForumTopicsRequestTypeID is TL type id of ChannelsReorderPinnedForumTopicsRequest.
const ChannelsReorderPinnedForumTopicsRequestTypeID = 0x2950a18f

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

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

	return true
}

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

// FillFrom fills ChannelsReorderPinnedForumTopicsRequest from given interface.
func ( *ChannelsReorderPinnedForumTopicsRequest) ( interface {
	() ( bool)
	() ( InputChannelClass)
	() ( []int)
}) {
	.Force = .()
	.Channel = .()
	.Order = .()
}

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

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

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

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

// Encode implements bin.Encoder.
func ( *ChannelsReorderPinnedForumTopicsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.reorderPinnedForumTopics#2950a18f as nil")
	}
	.PutID(ChannelsReorderPinnedForumTopicsRequestTypeID)
	return .EncodeBare()
}

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

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

// DecodeBare implements bin.BareDecoder.
func ( *ChannelsReorderPinnedForumTopicsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode channels.reorderPinnedForumTopics#2950a18f to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode channels.reorderPinnedForumTopics#2950a18f: field flags: %w", )
		}
	}
	.Force = .Flags.Has(0)
	{
		,  := DecodeInputChannel()
		if  != nil {
			return fmt.Errorf("unable to decode channels.reorderPinnedForumTopics#2950a18f: field channel: %w", )
		}
		.Channel = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode channels.reorderPinnedForumTopics#2950a18f: field order: %w", )
		}

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

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

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

// GetChannel returns value of Channel field.
func ( *ChannelsReorderPinnedForumTopicsRequest) () ( InputChannelClass) {
	if  == nil {
		return
	}
	return .Channel
}

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

// GetChannelAsNotEmpty returns mapped value of Channel field.
func ( *ChannelsReorderPinnedForumTopicsRequest) () (NotEmptyInputChannel, bool) {
	return .Channel.AsNotEmpty()
}

// ChannelsReorderPinnedForumTopics invokes method channels.reorderPinnedForumTopics#2950a18f returning error if any.
// Reorder pinned forum topics
//
// See https://core.telegram.org/method/channels.reorderPinnedForumTopics for reference.
// Can be used by bots.
func ( *Client) ( context.Context,  *ChannelsReorderPinnedForumTopicsRequest) (UpdatesClass, error) {
	var  UpdatesBox

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