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

// InputGameID represents TL type `inputGameID#32c3e77`.
// Indicates an already sent game
//
// See https://core.telegram.org/constructor/inputGameID for reference.
type InputGameID struct {
	// game ID from Game¹ constructor
	//
	// Links:
	//  1) https://core.telegram.org/type/Game
	ID int64
	// access hash from Game¹ constructor
	//
	// Links:
	//  1) https://core.telegram.org/type/Game
	AccessHash int64
}

// InputGameIDTypeID is TL type id of InputGameID.
const InputGameIDTypeID = 0x32c3e77

// construct implements constructor of InputGameClass.
func ( InputGameID) () InputGameClass { return & }

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

	_ InputGameClass = &InputGameID{}
)

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

	return true
}

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

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

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

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

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

// Encode implements bin.Encoder.
func ( *InputGameID) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputGameID#32c3e77 as nil")
	}
	.PutID(InputGameIDTypeID)
	return .EncodeBare()
}

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

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

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

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

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

// InputGameShortName represents TL type `inputGameShortName#c331e80a`.
// Game by short name
//
// See https://core.telegram.org/constructor/inputGameShortName for reference.
type InputGameShortName struct {
	// The bot that provides the game
	BotID InputUserClass
	// The game's short name, usually obtained from a game link »¹
	//
	// Links:
	//  1) https://core.telegram.org/api/links#game-links
	ShortName string
}

// InputGameShortNameTypeID is TL type id of InputGameShortName.
const InputGameShortNameTypeID = 0xc331e80a

// construct implements constructor of InputGameClass.
func ( InputGameShortName) () InputGameClass { return & }

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

	_ InputGameClass = &InputGameShortName{}
)

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

	return true
}

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

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

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

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

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

// Encode implements bin.Encoder.
func ( *InputGameShortName) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputGameShortName#c331e80a as nil")
	}
	.PutID(InputGameShortNameTypeID)
	return .EncodeBare()
}

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

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

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

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

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

// InputGameClassName is schema name of InputGameClass.
const InputGameClassName = "InputGame"

// InputGameClass represents InputGame generic type.
//
// See https://core.telegram.org/type/InputGame for reference.
//
// Example:
//
//	g, err := tg.DecodeInputGame(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.InputGameID: // inputGameID#32c3e77
//	case *tg.InputGameShortName: // inputGameShortName#c331e80a
//	default: panic(v)
//	}
type InputGameClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() InputGameClass

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

// DecodeInputGame implements binary de-serialization for InputGameClass.
func ( *bin.Buffer) (InputGameClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case InputGameIDTypeID:
		// Decoding inputGameID#32c3e77.
		 := InputGameID{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputGameClass: %w", )
		}
		return &, nil
	case InputGameShortNameTypeID:
		// Decoding inputGameShortName#c331e80a.
		 := InputGameShortName{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputGameClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode InputGameClass: %w", bin.NewUnexpectedID())
	}
}

// InputGame boxes the InputGameClass providing a helper.
type InputGameBox struct {
	InputGame InputGameClass
}

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

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