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

// BotsPreviewInfo represents TL type `bots.previewInfo#ca71d64`.
// Contains info about Main Mini App previews, see here »¹ for more info.
//
// Links:
//  1. https://core.telegram.org/api/bots/webapps#main-mini-app-previews
//
// See https://core.telegram.org/constructor/bots.previewInfo for reference.
type BotsPreviewInfo struct {
	// All preview medias for the language code passed to bots.getPreviewInfo¹.
	//
	// Links:
	//  1) https://core.telegram.org/method/bots.getPreviewInfo
	Media []BotPreviewMedia
	// All available language codes for which preview medias were uploaded (regardless of the
	// language code passed to bots.getPreviewInfo¹).
	//
	// Links:
	//  1) https://core.telegram.org/method/bots.getPreviewInfo
	LangCodes []string
}

// BotsPreviewInfoTypeID is TL type id of BotsPreviewInfo.
const BotsPreviewInfoTypeID = 0xca71d64

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

func ( *BotsPreviewInfo) () bool {
	if  == nil {
		return true
	}
	if !(.Media == nil) {
		return false
	}
	if !(.LangCodes == nil) {
		return false
	}

	return true
}

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

// FillFrom fills BotsPreviewInfo from given interface.
func ( *BotsPreviewInfo) ( interface {
	() ( []BotPreviewMedia)
	() ( []string)
}) {
	.Media = .()
	.LangCodes = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *BotsPreviewInfo) () tdp.Type {
	 := tdp.Type{
		Name: "bots.previewInfo",
		ID:   BotsPreviewInfoTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Media",
			SchemaName: "media",
		},
		{
			Name:       "LangCodes",
			SchemaName: "lang_codes",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *BotsPreviewInfo) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode bots.previewInfo#ca71d64 as nil")
	}
	.PutID(BotsPreviewInfoTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *BotsPreviewInfo) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode bots.previewInfo#ca71d64 as nil")
	}
	.PutVectorHeader(len(.Media))
	for ,  := range .Media {
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode bots.previewInfo#ca71d64: field media element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.LangCodes))
	for ,  := range .LangCodes {
		.PutString()
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *BotsPreviewInfo) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode bots.previewInfo#ca71d64 to nil")
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode bots.previewInfo#ca71d64: field media: %w", )
		}

		if  > 0 {
			.Media = make([]BotPreviewMedia, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  BotPreviewMedia
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode bots.previewInfo#ca71d64: field media: %w", )
			}
			.Media = append(.Media, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode bots.previewInfo#ca71d64: field lang_codes: %w", )
		}

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

// GetMedia returns value of Media field.
func ( *BotsPreviewInfo) () ( []BotPreviewMedia) {
	if  == nil {
		return
	}
	return .Media
}

// GetLangCodes returns value of LangCodes field.
func ( *BotsPreviewInfo) () ( []string) {
	if  == nil {
		return
	}
	return .LangCodes
}