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

// BotsEditPreviewMediaRequest represents TL type `bots.editPreviewMedia#8525606f`.
// Edit a main mini app preview, 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.editPreviewMedia for reference.
type BotsEditPreviewMediaRequest struct {
	// The bot that owns the Main Mini App.
	Bot InputUserClass
	// ISO 639-1 language code, indicating the localization of the preview to edit.
	LangCode string
	// The photo/video preview to replace, previously fetched as specified here »¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/bots/webapps#main-mini-app-previews
	Media InputMediaClass
	// The new photo/video preview, uploaded using messages.uploadMedia¹.
	//
	// Links:
	//  1) https://core.telegram.org/method/messages.uploadMedia
	NewMedia InputMediaClass
}

// BotsEditPreviewMediaRequestTypeID is TL type id of BotsEditPreviewMediaRequest.
const BotsEditPreviewMediaRequestTypeID = 0x8525606f

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

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

	return true
}

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

// FillFrom fills BotsEditPreviewMediaRequest from given interface.
func ( *BotsEditPreviewMediaRequest) ( interface {
	() ( InputUserClass)
	() ( string)
	() ( InputMediaClass)
	() ( InputMediaClass)
}) {
	.Bot = .()
	.LangCode = .()
	.Media = .()
	.NewMedia = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *BotsEditPreviewMediaRequest) () tdp.Type {
	 := tdp.Type{
		Name: "bots.editPreviewMedia",
		ID:   BotsEditPreviewMediaRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Bot",
			SchemaName: "bot",
		},
		{
			Name:       "LangCode",
			SchemaName: "lang_code",
		},
		{
			Name:       "Media",
			SchemaName: "media",
		},
		{
			Name:       "NewMedia",
			SchemaName: "new_media",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *BotsEditPreviewMediaRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode bots.editPreviewMedia#8525606f as nil")
	}
	.PutID(BotsEditPreviewMediaRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *BotsEditPreviewMediaRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode bots.editPreviewMedia#8525606f as nil")
	}
	if .Bot == nil {
		return fmt.Errorf("unable to encode bots.editPreviewMedia#8525606f: field bot is nil")
	}
	if  := .Bot.Encode();  != nil {
		return fmt.Errorf("unable to encode bots.editPreviewMedia#8525606f: field bot: %w", )
	}
	.PutString(.LangCode)
	if .Media == nil {
		return fmt.Errorf("unable to encode bots.editPreviewMedia#8525606f: field media is nil")
	}
	if  := .Media.Encode();  != nil {
		return fmt.Errorf("unable to encode bots.editPreviewMedia#8525606f: field media: %w", )
	}
	if .NewMedia == nil {
		return fmt.Errorf("unable to encode bots.editPreviewMedia#8525606f: field new_media is nil")
	}
	if  := .NewMedia.Encode();  != nil {
		return fmt.Errorf("unable to encode bots.editPreviewMedia#8525606f: field new_media: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *BotsEditPreviewMediaRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode bots.editPreviewMedia#8525606f to nil")
	}
	{
		,  := DecodeInputUser()
		if  != nil {
			return fmt.Errorf("unable to decode bots.editPreviewMedia#8525606f: field bot: %w", )
		}
		.Bot = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode bots.editPreviewMedia#8525606f: field lang_code: %w", )
		}
		.LangCode = 
	}
	{
		,  := DecodeInputMedia()
		if  != nil {
			return fmt.Errorf("unable to decode bots.editPreviewMedia#8525606f: field media: %w", )
		}
		.Media = 
	}
	{
		,  := DecodeInputMedia()
		if  != nil {
			return fmt.Errorf("unable to decode bots.editPreviewMedia#8525606f: field new_media: %w", )
		}
		.NewMedia = 
	}
	return nil
}

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

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

// GetMedia returns value of Media field.
func ( *BotsEditPreviewMediaRequest) () ( InputMediaClass) {
	if  == nil {
		return
	}
	return .Media
}

// GetNewMedia returns value of NewMedia field.
func ( *BotsEditPreviewMediaRequest) () ( InputMediaClass) {
	if  == nil {
		return
	}
	return .NewMedia
}

// BotsEditPreviewMedia invokes method bots.editPreviewMedia#8525606f returning error if any.
// Edit a main mini app preview, 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.editPreviewMedia for reference.
func ( *Client) ( context.Context,  *BotsEditPreviewMediaRequest) (*BotPreviewMedia, error) {
	var  BotPreviewMedia

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