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

// AccountReorderUsernamesRequest represents TL type `account.reorderUsernames#ef500eab`.
// Reorder usernames associated with the currently logged-in user.
//
// See https://core.telegram.org/method/account.reorderUsernames for reference.
type AccountReorderUsernamesRequest struct {
	// The new order for active usernames. All active usernames must be specified.
	Order []string
}

// AccountReorderUsernamesRequestTypeID is TL type id of AccountReorderUsernamesRequest.
const AccountReorderUsernamesRequestTypeID = 0xef500eab

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

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

	return true
}

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

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

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

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

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

// Encode implements bin.Encoder.
func ( *AccountReorderUsernamesRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.reorderUsernames#ef500eab as nil")
	}
	.PutID(AccountReorderUsernamesRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountReorderUsernamesRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.reorderUsernames#ef500eab as nil")
	}
	.PutVectorHeader(len(.Order))
	for ,  := range .Order {
		.PutString()
	}
	return nil
}

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

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

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

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

// AccountReorderUsernames invokes method account.reorderUsernames#ef500eab returning error if any.
// Reorder usernames associated with the currently logged-in user.
//
// Possible errors:
//
//	400 ORDER_INVALID: The specified username order is invalid.
//
// See https://core.telegram.org/method/account.reorderUsernames for reference.
func ( *Client) ( context.Context,  []string) (bool, error) {
	var  BoolBox

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