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

// BotAppNotModified represents TL type `botAppNotModified#5da674b7`.
// Bot app info hasn't changed.
//
// See https://core.telegram.org/constructor/botAppNotModified for reference.
type BotAppNotModified struct {
}

// BotAppNotModifiedTypeID is TL type id of BotAppNotModified.
const BotAppNotModifiedTypeID = 0x5da674b7

// construct implements constructor of BotAppClass.
func ( BotAppNotModified) () BotAppClass { return & }

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

	_ BotAppClass = &BotAppNotModified{}
)

func ( *BotAppNotModified) () bool {
	if  == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func ( *BotAppNotModified) () tdp.Type {
	 := tdp.Type{
		Name: "botAppNotModified",
		ID:   BotAppNotModifiedTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{}
	return 
}

// Encode implements bin.Encoder.
func ( *BotAppNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode botAppNotModified#5da674b7 as nil")
	}
	.PutID(BotAppNotModifiedTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *BotAppNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode botAppNotModified#5da674b7 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *BotAppNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode botAppNotModified#5da674b7 to nil")
	}
	if  := .ConsumeID(BotAppNotModifiedTypeID);  != nil {
		return fmt.Errorf("unable to decode botAppNotModified#5da674b7: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *BotAppNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode botAppNotModified#5da674b7 to nil")
	}
	return nil
}

// BotApp represents TL type `botApp#95fcd1d6`.
// Contains information about a named Mini App¹.
//
// Links:
//  1. https://core.telegram.org/api/bots/webapps#named-mini-apps
//
// See https://core.telegram.org/constructor/botApp for reference.
type BotApp struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// bot mini app ID
	ID int64
	// bot mini app access hash
	AccessHash int64
	// bot mini app short name, used to generate named Mini App deep links¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/links#named-mini-app-links
	ShortName string
	// bot mini app title.
	Title string
	// bot mini app description.
	Description string
	// bot mini app photo.
	Photo PhotoClass
	// bot mini app animation.
	//
	// Use SetDocument and GetDocument helpers.
	Document DocumentClass
	// Hash to pass to messages.getBotApp¹, to avoid refetching bot app info if it hasn't
	// changed.
	//
	// Links:
	//  1) https://core.telegram.org/method/messages.getBotApp
	Hash int64
}

// BotAppTypeID is TL type id of BotApp.
const BotAppTypeID = 0x95fcd1d6

// construct implements constructor of BotAppClass.
func ( BotApp) () BotAppClass { return & }

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

	_ BotAppClass = &BotApp{}
)

func ( *BotApp) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.ID == 0) {
		return false
	}
	if !(.AccessHash == 0) {
		return false
	}
	if !(.ShortName == "") {
		return false
	}
	if !(.Title == "") {
		return false
	}
	if !(.Description == "") {
		return false
	}
	if !(.Photo == nil) {
		return false
	}
	if !(.Document == nil) {
		return false
	}
	if !(.Hash == 0) {
		return false
	}

	return true
}

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

// FillFrom fills BotApp from given interface.
func ( *BotApp) ( interface {
	() ( int64)
	() ( int64)
	() ( string)
	() ( string)
	() ( string)
	() ( PhotoClass)
	() ( DocumentClass,  bool)
	() ( int64)
}) {
	.ID = .()
	.AccessHash = .()
	.ShortName = .()
	.Title = .()
	.Description = .()
	.Photo = .()
	if ,  := .();  {
		.Document = 
	}

	.Hash = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *BotApp) () tdp.Type {
	 := tdp.Type{
		Name: "botApp",
		ID:   BotAppTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "AccessHash",
			SchemaName: "access_hash",
		},
		{
			Name:       "ShortName",
			SchemaName: "short_name",
		},
		{
			Name:       "Title",
			SchemaName: "title",
		},
		{
			Name:       "Description",
			SchemaName: "description",
		},
		{
			Name:       "Photo",
			SchemaName: "photo",
		},
		{
			Name:       "Document",
			SchemaName: "document",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Hash",
			SchemaName: "hash",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *BotApp) () {
	if !(.Document == nil) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *BotApp) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode botApp#95fcd1d6 as nil")
	}
	.PutID(BotAppTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *BotApp) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode botApp#95fcd1d6 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode botApp#95fcd1d6: field flags: %w", )
	}
	.PutLong(.ID)
	.PutLong(.AccessHash)
	.PutString(.ShortName)
	.PutString(.Title)
	.PutString(.Description)
	if .Photo == nil {
		return fmt.Errorf("unable to encode botApp#95fcd1d6: field photo is nil")
	}
	if  := .Photo.Encode();  != nil {
		return fmt.Errorf("unable to encode botApp#95fcd1d6: field photo: %w", )
	}
	if .Flags.Has(0) {
		if .Document == nil {
			return fmt.Errorf("unable to encode botApp#95fcd1d6: field document is nil")
		}
		if  := .Document.Encode();  != nil {
			return fmt.Errorf("unable to encode botApp#95fcd1d6: field document: %w", )
		}
	}
	.PutLong(.Hash)
	return nil
}

// Decode implements bin.Decoder.
func ( *BotApp) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode botApp#95fcd1d6 to nil")
	}
	if  := .ConsumeID(BotAppTypeID);  != nil {
		return fmt.Errorf("unable to decode botApp#95fcd1d6: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *BotApp) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode botApp#95fcd1d6 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode botApp#95fcd1d6: field flags: %w", )
		}
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode botApp#95fcd1d6: field id: %w", )
		}
		.ID = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode botApp#95fcd1d6: field access_hash: %w", )
		}
		.AccessHash = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode botApp#95fcd1d6: field short_name: %w", )
		}
		.ShortName = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode botApp#95fcd1d6: field title: %w", )
		}
		.Title = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode botApp#95fcd1d6: field description: %w", )
		}
		.Description = 
	}
	{
		,  := DecodePhoto()
		if  != nil {
			return fmt.Errorf("unable to decode botApp#95fcd1d6: field photo: %w", )
		}
		.Photo = 
	}
	if .Flags.Has(0) {
		,  := DecodeDocument()
		if  != nil {
			return fmt.Errorf("unable to decode botApp#95fcd1d6: field document: %w", )
		}
		.Document = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode botApp#95fcd1d6: field hash: %w", )
		}
		.Hash = 
	}
	return nil
}

// GetID returns value of ID field.
func ( *BotApp) () ( int64) {
	if  == nil {
		return
	}
	return .ID
}

// GetAccessHash returns value of AccessHash field.
func ( *BotApp) () ( int64) {
	if  == nil {
		return
	}
	return .AccessHash
}

// GetShortName returns value of ShortName field.
func ( *BotApp) () ( string) {
	if  == nil {
		return
	}
	return .ShortName
}

// GetTitle returns value of Title field.
func ( *BotApp) () ( string) {
	if  == nil {
		return
	}
	return .Title
}

// GetDescription returns value of Description field.
func ( *BotApp) () ( string) {
	if  == nil {
		return
	}
	return .Description
}

// GetPhoto returns value of Photo field.
func ( *BotApp) () ( PhotoClass) {
	if  == nil {
		return
	}
	return .Photo
}

// SetDocument sets value of Document conditional field.
func ( *BotApp) ( DocumentClass) {
	.Flags.Set(0)
	.Document = 
}

// GetDocument returns value of Document conditional field and
// boolean which is true if field was set.
func ( *BotApp) () ( DocumentClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .Document, true
}

// GetHash returns value of Hash field.
func ( *BotApp) () ( int64) {
	if  == nil {
		return
	}
	return .Hash
}

// BotAppClassName is schema name of BotAppClass.
const BotAppClassName = "BotApp"

// BotAppClass represents BotApp generic type.
//
// See https://core.telegram.org/type/BotApp for reference.
//
// Example:
//
//	g, err := tg.DecodeBotApp(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.BotAppNotModified: // botAppNotModified#5da674b7
//	case *tg.BotApp: // botApp#95fcd1d6
//	default: panic(v)
//	}
type BotAppClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() BotAppClass

	// TypeID returns type id in TL schema.
	//
	// See https://core.telegram.org/mtproto/TL-tl#remarks.
	TypeID() uint32
	// TypeName returns name of type in TL schema.
	TypeName() string
	// String implements fmt.Stringer.
	String() string
	// Zero returns true if current object has a zero value.
	Zero() bool

	// AsModified tries to map BotAppClass to BotApp.
	AsModified() (*BotApp, bool)
}

// AsInputBotAppID tries to map BotApp to InputBotAppID.
func ( *BotApp) () *InputBotAppID {
	 := new(InputBotAppID)
	.ID = .GetID()
	.AccessHash = .GetAccessHash()
	.AccessHash = .GetHash()

	return 
}

// AsModified tries to map BotAppNotModified to BotApp.
func ( *BotAppNotModified) () (*BotApp, bool) {
	return nil, false
}

// AsModified tries to map BotApp to BotApp.
func ( *BotApp) () (*BotApp, bool) {
	return , true
}

// DecodeBotApp implements binary de-serialization for BotAppClass.
func ( *bin.Buffer) (BotAppClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case BotAppNotModifiedTypeID:
		// Decoding botAppNotModified#5da674b7.
		 := BotAppNotModified{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode BotAppClass: %w", )
		}
		return &, nil
	case BotAppTypeID:
		// Decoding botApp#95fcd1d6.
		 := BotApp{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode BotAppClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode BotAppClass: %w", bin.NewUnexpectedID())
	}
}

// BotApp boxes the BotAppClass providing a helper.
type BotAppBox struct {
	BotApp BotAppClass
}

// Decode implements bin.Decoder for BotAppBox.
func ( *BotAppBox) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("unable to decode BotAppBox to nil")
	}
	,  := DecodeBotApp()
	if  != nil {
		return fmt.Errorf("unable to decode boxed value: %w", )
	}
	.BotApp = 
	return nil
}

// Encode implements bin.Encode for BotAppBox.
func ( *BotAppBox) ( *bin.Buffer) error {
	if  == nil || .BotApp == nil {
		return fmt.Errorf("unable to encode BotAppClass as nil")
	}
	return .BotApp.Encode()
}