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

// ChannelsReorderUsernamesRequest represents TL type `channels.reorderUsernames#b45ced1d`.
// Reorder active usernames
//
// See https://core.telegram.org/method/channels.reorderUsernames for reference.
type ChannelsReorderUsernamesRequest struct {
	// The supergroup or channel
	Channel InputChannelClass
	// The new order for active usernames. All active usernames must be specified.
	Order []string
}

// ChannelsReorderUsernamesRequestTypeID is TL type id of ChannelsReorderUsernamesRequest.
const ChannelsReorderUsernamesRequestTypeID = 0xb45ced1d

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

func ( *ChannelsReorderUsernamesRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Channel == nil) {
		return false
	}
	if !(.Order == nil) {
		return false
	}

	return true
}

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

// FillFrom fills ChannelsReorderUsernamesRequest from given interface.
func ( *ChannelsReorderUsernamesRequest) ( interface {
	() ( InputChannelClass)
	() ( []string)
}) {
	.Channel = .()
	.Order = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *ChannelsReorderUsernamesRequest) () tdp.Type {
	 := tdp.Type{
		Name: "channels.reorderUsernames",
		ID:   ChannelsReorderUsernamesRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Channel",
			SchemaName: "channel",
		},
		{
			Name:       "Order",
			SchemaName: "order",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *ChannelsReorderUsernamesRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.reorderUsernames#b45ced1d as nil")
	}
	.PutID(ChannelsReorderUsernamesRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ChannelsReorderUsernamesRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.reorderUsernames#b45ced1d as nil")
	}
	if .Channel == nil {
		return fmt.Errorf("unable to encode channels.reorderUsernames#b45ced1d: field channel is nil")
	}
	if  := .Channel.Encode();  != nil {
		return fmt.Errorf("unable to encode channels.reorderUsernames#b45ced1d: field channel: %w", )
	}
	.PutVectorHeader(len(.Order))
	for ,  := range .Order {
		.PutString()
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *ChannelsReorderUsernamesRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode channels.reorderUsernames#b45ced1d to nil")
	}
	{
		,  := DecodeInputChannel()
		if  != nil {
			return fmt.Errorf("unable to decode channels.reorderUsernames#b45ced1d: field channel: %w", )
		}
		.Channel = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode channels.reorderUsernames#b45ced1d: field order: %w", )
		}

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

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

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

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

// ChannelsReorderUsernames invokes method channels.reorderUsernames#b45ced1d returning error if any.
// Reorder active usernames
//
// Possible errors:
//
//	400 CHANNEL_INVALID: The provided channel is invalid.
//
// See https://core.telegram.org/method/channels.reorderUsernames for reference.
// Can be used by bots.
func ( *Client) ( context.Context,  *ChannelsReorderUsernamesRequest) (bool, error) {
	var  BoolBox

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