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

// BotsReorderUsernamesRequest represents TL type `bots.reorderUsernames#9709b1c2`.
// Reorder usernames associated to a bot we own.
//
// See https://core.telegram.org/method/bots.reorderUsernames for reference.
type BotsReorderUsernamesRequest struct {
	// The bot
	Bot InputUserClass
	// The new order for active usernames. All active usernames must be specified.
	Order []string
}

// BotsReorderUsernamesRequestTypeID is TL type id of BotsReorderUsernamesRequest.
const BotsReorderUsernamesRequestTypeID = 0x9709b1c2

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

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

	return true
}

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

// FillFrom fills BotsReorderUsernamesRequest from given interface.
func ( *BotsReorderUsernamesRequest) ( interface {
	() ( InputUserClass)
	() ( []string)
}) {
	.Bot = .()
	.Order = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *BotsReorderUsernamesRequest) () tdp.Type {
	 := tdp.Type{
		Name: "bots.reorderUsernames",
		ID:   BotsReorderUsernamesRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Bot",
			SchemaName: "bot",
		},
		{
			Name:       "Order",
			SchemaName: "order",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *BotsReorderUsernamesRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode bots.reorderUsernames#9709b1c2 as nil")
	}
	.PutID(BotsReorderUsernamesRequestTypeID)
	return .EncodeBare()
}

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

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

// DecodeBare implements bin.BareDecoder.
func ( *BotsReorderUsernamesRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode bots.reorderUsernames#9709b1c2 to nil")
	}
	{
		,  := DecodeInputUser()
		if  != nil {
			return fmt.Errorf("unable to decode bots.reorderUsernames#9709b1c2: field bot: %w", )
		}
		.Bot = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode bots.reorderUsernames#9709b1c2: field order: %w", )
		}

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

// GetBot returns value of Bot field.
func ( *BotsReorderUsernamesRequest) () ( InputUserClass) {
	if  == nil {
		return
	}
	return .Bot
}

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

// BotsReorderUsernames invokes method bots.reorderUsernames#9709b1c2 returning error if any.
// Reorder usernames associated to a bot we own.
//
// Possible errors:
//
//	400 BOT_INVALID: This is not a valid bot.
//
// See https://core.telegram.org/method/bots.reorderUsernames for reference.
// Can be used by bots.
func ( *Client) ( context.Context,  *BotsReorderUsernamesRequest) (bool, error) {
	var  BoolBox

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