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

// InputBotAppID represents TL type `inputBotAppID#a920bd7a`.
// Used to fetch information about a named Mini App¹ by its ID
//
// Links:
//  1. https://core.telegram.org/api/bots/webapps#named-mini-apps
//
// See https://core.telegram.org/constructor/inputBotAppID for reference.
type InputBotAppID struct {
	// named Mini App¹ ID.
	//
	// Links:
	//  1) https://core.telegram.org/api/bots/webapps#named-mini-apps
	ID int64
	// Access hash, obtained from the botApp¹ constructor.
	//
	// Links:
	//  1) https://core.telegram.org/constructor/botApp
	AccessHash int64
}

// InputBotAppIDTypeID is TL type id of InputBotAppID.
const InputBotAppIDTypeID = 0xa920bd7a

// construct implements constructor of InputBotAppClass.
func ( InputBotAppID) () InputBotAppClass { return & }

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

	_ InputBotAppClass = &InputBotAppID{}
)

func ( *InputBotAppID) () bool {
	if  == nil {
		return true
	}
	if !(.ID == 0) {
		return false
	}
	if !(.AccessHash == 0) {
		return false
	}

	return true
}

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

// FillFrom fills InputBotAppID from given interface.
func ( *InputBotAppID) ( interface {
	() ( int64)
	() ( int64)
}) {
	.ID = .()
	.AccessHash = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *InputBotAppID) () tdp.Type {
	 := tdp.Type{
		Name: "inputBotAppID",
		ID:   InputBotAppIDTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "AccessHash",
			SchemaName: "access_hash",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *InputBotAppID) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputBotAppID#a920bd7a as nil")
	}
	.PutID(InputBotAppIDTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputBotAppID) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputBotAppID#a920bd7a as nil")
	}
	.PutLong(.ID)
	.PutLong(.AccessHash)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *InputBotAppID) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputBotAppID#a920bd7a to nil")
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode inputBotAppID#a920bd7a: field id: %w", )
		}
		.ID = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode inputBotAppID#a920bd7a: field access_hash: %w", )
		}
		.AccessHash = 
	}
	return nil
}

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

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

// InputBotAppShortName represents TL type `inputBotAppShortName#908c0407`.
// Used to fetch information about a named Mini App¹ by its short name
//
// Links:
//  1. https://core.telegram.org/api/bots/webapps#named-mini-apps
//
// See https://core.telegram.org/constructor/inputBotAppShortName for reference.
type InputBotAppShortName struct {
	// ID of the bot that owns the bot mini app
	BotID InputUserClass
	// Short name, obtained from a named Mini App deep link¹
	//
	// Links:
	//  1) https://core.telegram.org/api/links#named-mini-app-links
	ShortName string
}

// InputBotAppShortNameTypeID is TL type id of InputBotAppShortName.
const InputBotAppShortNameTypeID = 0x908c0407

// construct implements constructor of InputBotAppClass.
func ( InputBotAppShortName) () InputBotAppClass { return & }

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

	_ InputBotAppClass = &InputBotAppShortName{}
)

func ( *InputBotAppShortName) () bool {
	if  == nil {
		return true
	}
	if !(.BotID == nil) {
		return false
	}
	if !(.ShortName == "") {
		return false
	}

	return true
}

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

// FillFrom fills InputBotAppShortName from given interface.
func ( *InputBotAppShortName) ( interface {
	() ( InputUserClass)
	() ( string)
}) {
	.BotID = .()
	.ShortName = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *InputBotAppShortName) () tdp.Type {
	 := tdp.Type{
		Name: "inputBotAppShortName",
		ID:   InputBotAppShortNameTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "BotID",
			SchemaName: "bot_id",
		},
		{
			Name:       "ShortName",
			SchemaName: "short_name",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *InputBotAppShortName) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputBotAppShortName#908c0407 as nil")
	}
	.PutID(InputBotAppShortNameTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputBotAppShortName) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputBotAppShortName#908c0407 as nil")
	}
	if .BotID == nil {
		return fmt.Errorf("unable to encode inputBotAppShortName#908c0407: field bot_id is nil")
	}
	if  := .BotID.Encode();  != nil {
		return fmt.Errorf("unable to encode inputBotAppShortName#908c0407: field bot_id: %w", )
	}
	.PutString(.ShortName)
	return nil
}

// Decode implements bin.Decoder.
func ( *InputBotAppShortName) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputBotAppShortName#908c0407 to nil")
	}
	if  := .ConsumeID(InputBotAppShortNameTypeID);  != nil {
		return fmt.Errorf("unable to decode inputBotAppShortName#908c0407: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *InputBotAppShortName) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputBotAppShortName#908c0407 to nil")
	}
	{
		,  := DecodeInputUser()
		if  != nil {
			return fmt.Errorf("unable to decode inputBotAppShortName#908c0407: field bot_id: %w", )
		}
		.BotID = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode inputBotAppShortName#908c0407: field short_name: %w", )
		}
		.ShortName = 
	}
	return nil
}

// GetBotID returns value of BotID field.
func ( *InputBotAppShortName) () ( InputUserClass) {
	if  == nil {
		return
	}
	return .BotID
}

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

// InputBotAppClassName is schema name of InputBotAppClass.
const InputBotAppClassName = "InputBotApp"

// InputBotAppClass represents InputBotApp generic type.
//
// See https://core.telegram.org/type/InputBotApp for reference.
//
// Example:
//
//	g, err := tg.DecodeInputBotApp(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.InputBotAppID: // inputBotAppID#a920bd7a
//	case *tg.InputBotAppShortName: // inputBotAppShortName#908c0407
//	default: panic(v)
//	}
type InputBotAppClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() InputBotAppClass

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

// DecodeInputBotApp implements binary de-serialization for InputBotAppClass.
func ( *bin.Buffer) (InputBotAppClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case InputBotAppIDTypeID:
		// Decoding inputBotAppID#a920bd7a.
		 := InputBotAppID{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputBotAppClass: %w", )
		}
		return &, nil
	case InputBotAppShortNameTypeID:
		// Decoding inputBotAppShortName#908c0407.
		 := InputBotAppShortName{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputBotAppClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode InputBotAppClass: %w", bin.NewUnexpectedID())
	}
}

// InputBotApp boxes the InputBotAppClass providing a helper.
type InputBotAppBox struct {
	InputBotApp InputBotAppClass
}

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

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