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

// BotsReorderPreviewMediasRequest represents TL type `bots.reorderPreviewMedias#b627f3aa`.
// Reorder a main mini app previews, see here »¹ for more info.
// Only owners of bots with a configured Main Mini App can use this method, see see here
// »¹ for more info on how to check if you can invoke this method.
//
// Links:
//  1. https://core.telegram.org/api/bots/webapps#main-mini-app-previews
//  2. https://core.telegram.org/api/bots/webapps#main-mini-app-previews
//
// See https://core.telegram.org/method/bots.reorderPreviewMedias for reference.
type BotsReorderPreviewMediasRequest struct {
	// The bot that owns the Main Mini App.
	Bot InputUserClass
	// ISO 639-1 language code, indicating the localization of the previews to reorder.
	LangCode string
	// New order of the previews.
	Order []InputMediaClass
}

// BotsReorderPreviewMediasRequestTypeID is TL type id of BotsReorderPreviewMediasRequest.
const BotsReorderPreviewMediasRequestTypeID = 0xb627f3aa

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

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

	return true
}

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

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

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

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

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

// Encode implements bin.Encoder.
func ( *BotsReorderPreviewMediasRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode bots.reorderPreviewMedias#b627f3aa as nil")
	}
	.PutID(BotsReorderPreviewMediasRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *BotsReorderPreviewMediasRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode bots.reorderPreviewMedias#b627f3aa as nil")
	}
	if .Bot == nil {
		return fmt.Errorf("unable to encode bots.reorderPreviewMedias#b627f3aa: field bot is nil")
	}
	if  := .Bot.Encode();  != nil {
		return fmt.Errorf("unable to encode bots.reorderPreviewMedias#b627f3aa: field bot: %w", )
	}
	.PutString(.LangCode)
	.PutVectorHeader(len(.Order))
	for ,  := range .Order {
		if  == nil {
			return fmt.Errorf("unable to encode bots.reorderPreviewMedias#b627f3aa: field order element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode bots.reorderPreviewMedias#b627f3aa: field order element with index %d: %w", , )
		}
	}
	return nil
}

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

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

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

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

// GetLangCode returns value of LangCode field.
func ( *BotsReorderPreviewMediasRequest) () ( string) {
	if  == nil {
		return
	}
	return .LangCode
}

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

// MapOrder returns field Order wrapped in InputMediaClassArray helper.
func ( *BotsReorderPreviewMediasRequest) () ( InputMediaClassArray) {
	return InputMediaClassArray(.Order)
}

// BotsReorderPreviewMedias invokes method bots.reorderPreviewMedias#b627f3aa returning error if any.
// Reorder a main mini app previews, see here »¹ for more info.
// Only owners of bots with a configured Main Mini App can use this method, see see here
// »¹ for more info on how to check if you can invoke this method.
//
// Links:
//  1. https://core.telegram.org/api/bots/webapps#main-mini-app-previews
//  2. https://core.telegram.org/api/bots/webapps#main-mini-app-previews
//
// Possible errors:
//
//	400 BOT_INVALID: This is not a valid bot.
//
// See https://core.telegram.org/method/bots.reorderPreviewMedias for reference.
func ( *Client) ( context.Context,  *BotsReorderPreviewMediasRequest) (bool, error) {
	var  BoolBox

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