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

// BotsGetPreviewInfoRequest represents TL type `bots.getPreviewInfo#423ab3ad`.
// Bot owners only, fetch main mini app preview information, see here »¹ for more info.
// Note: technically non-owners may also invoke this method, but it will always behave
// exactly as bots.getPreviewMedias¹, returning only previews for the current language
// and an empty lang_codes array, regardless of the passed lang_code, so please only use
// bots.getPreviewMedias² if you're not the owner of the bot.
//
// Links:
//  1. https://core.telegram.org/api/bots/webapps#main-mini-app-previews
//  2. https://core.telegram.org/method/bots.getPreviewMedias
//  3. https://core.telegram.org/method/bots.getPreviewMedias
//
// See https://core.telegram.org/method/bots.getPreviewInfo for reference.
type BotsGetPreviewInfoRequest struct {
	// The bot that owns the Main Mini App.
	Bot InputUserClass
	// Fetch previews for the specified ISO 639-1 language code.
	LangCode string
}

// BotsGetPreviewInfoRequestTypeID is TL type id of BotsGetPreviewInfoRequest.
const BotsGetPreviewInfoRequestTypeID = 0x423ab3ad

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

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

	return true
}

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

// FillFrom fills BotsGetPreviewInfoRequest from given interface.
func ( *BotsGetPreviewInfoRequest) ( interface {
	() ( InputUserClass)
	() ( string)
}) {
	.Bot = .()
	.LangCode = .()
}

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

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

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

// Encode implements bin.Encoder.
func ( *BotsGetPreviewInfoRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode bots.getPreviewInfo#423ab3ad as nil")
	}
	.PutID(BotsGetPreviewInfoRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *BotsGetPreviewInfoRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode bots.getPreviewInfo#423ab3ad as nil")
	}
	if .Bot == nil {
		return fmt.Errorf("unable to encode bots.getPreviewInfo#423ab3ad: field bot is nil")
	}
	if  := .Bot.Encode();  != nil {
		return fmt.Errorf("unable to encode bots.getPreviewInfo#423ab3ad: field bot: %w", )
	}
	.PutString(.LangCode)
	return nil
}

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

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

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

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

// BotsGetPreviewInfo invokes method bots.getPreviewInfo#423ab3ad returning error if any.
// Bot owners only, fetch main mini app preview information, see here »¹ for more info.
// Note: technically non-owners may also invoke this method, but it will always behave
// exactly as bots.getPreviewMedias¹, returning only previews for the current language
// and an empty lang_codes array, regardless of the passed lang_code, so please only use
// bots.getPreviewMedias² if you're not the owner of the bot.
//
// Links:
//  1. https://core.telegram.org/api/bots/webapps#main-mini-app-previews
//  2. https://core.telegram.org/method/bots.getPreviewMedias
//  3. https://core.telegram.org/method/bots.getPreviewMedias
//
// Possible errors:
//
//	400 BOT_INVALID: This is not a valid bot.
//
// See https://core.telegram.org/method/bots.getPreviewInfo for reference.
func ( *Client) ( context.Context,  *BotsGetPreviewInfoRequest) (*BotsPreviewInfo, error) {
	var  BotsPreviewInfo

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