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

// BotPreviewMedia represents TL type `botPreviewMedia#23e91ba3`.
// Represents a Main Mini App preview media, see here »¹ for more info.
//
// Links:
//  1. https://core.telegram.org/api/bots/webapps#main-mini-app-previews
//
// See https://core.telegram.org/constructor/botPreviewMedia for reference.
type BotPreviewMedia struct {
	// When was this media last updated.
	Date int
	// The actual photo/video.
	Media MessageMediaClass
}

// BotPreviewMediaTypeID is TL type id of BotPreviewMedia.
const BotPreviewMediaTypeID = 0x23e91ba3

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

func ( *BotPreviewMedia) () bool {
	if  == nil {
		return true
	}
	if !(.Date == 0) {
		return false
	}
	if !(.Media == nil) {
		return false
	}

	return true
}

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

// FillFrom fills BotPreviewMedia from given interface.
func ( *BotPreviewMedia) ( interface {
	() ( int)
	() ( MessageMediaClass)
}) {
	.Date = .()
	.Media = .()
}

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

// TypeName returns name of type in TL schema.
func (*BotPreviewMedia) () string {
	return "botPreviewMedia"
}

// TypeInfo returns info about TL type.
func ( *BotPreviewMedia) () tdp.Type {
	 := tdp.Type{
		Name: "botPreviewMedia",
		ID:   BotPreviewMediaTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Date",
			SchemaName: "date",
		},
		{
			Name:       "Media",
			SchemaName: "media",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *BotPreviewMedia) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode botPreviewMedia#23e91ba3 as nil")
	}
	.PutID(BotPreviewMediaTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *BotPreviewMedia) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode botPreviewMedia#23e91ba3 as nil")
	}
	.PutInt(.Date)
	if .Media == nil {
		return fmt.Errorf("unable to encode botPreviewMedia#23e91ba3: field media is nil")
	}
	if  := .Media.Encode();  != nil {
		return fmt.Errorf("unable to encode botPreviewMedia#23e91ba3: field media: %w", )
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *BotPreviewMedia) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode botPreviewMedia#23e91ba3 to nil")
	}
	if  := .ConsumeID(BotPreviewMediaTypeID);  != nil {
		return fmt.Errorf("unable to decode botPreviewMedia#23e91ba3: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *BotPreviewMedia) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode botPreviewMedia#23e91ba3 to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode botPreviewMedia#23e91ba3: field date: %w", )
		}
		.Date = 
	}
	{
		,  := DecodeMessageMedia()
		if  != nil {
			return fmt.Errorf("unable to decode botPreviewMedia#23e91ba3: field media: %w", )
		}
		.Media = 
	}
	return nil
}

// GetDate returns value of Date field.
func ( *BotPreviewMedia) () ( int) {
	if  == nil {
		return
	}
	return .Date
}

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