// Code generated by gotdgen, DO NOT EDIT.

package tdapi

import (
	"context"
	"errors"
	"fmt"
	"sort"
	"strings"

	"go.uber.org/multierr"

	"go.mau.fi/mautrix-telegram/pkg/gotd/bin"
	"go.mau.fi/mautrix-telegram/pkg/gotd/tdjson"
	"go.mau.fi/mautrix-telegram/pkg/gotd/tdp"
	"go.mau.fi/mautrix-telegram/pkg/gotd/tgerr"
)

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

// InlineKeyboardButtonTypeURL represents TL type `inlineKeyboardButtonTypeUrl#4365beac`.
type InlineKeyboardButtonTypeURL struct {
	// HTTP or tg:// URL to open. If the link is of the type internalLinkTypeWebApp, then the
	// button must be marked as a Web App button
	URL string
}

// InlineKeyboardButtonTypeURLTypeID is TL type id of InlineKeyboardButtonTypeURL.
const InlineKeyboardButtonTypeURLTypeID = 0x4365beac

// construct implements constructor of InlineKeyboardButtonTypeClass.
func (i InlineKeyboardButtonTypeURL) construct() InlineKeyboardButtonTypeClass { return &i }

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

	_ InlineKeyboardButtonTypeClass = &InlineKeyboardButtonTypeURL{}
)

func (i *InlineKeyboardButtonTypeURL) Zero() bool {
	if i == nil {
		return true
	}
	if !(i.URL == "") {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (i *InlineKeyboardButtonTypeURL) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "inlineKeyboardButtonTypeUrl",
		ID:   InlineKeyboardButtonTypeURLTypeID,
	}
	if i == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "URL",
			SchemaName: "url",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (i *InlineKeyboardButtonTypeURL) Encode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode inlineKeyboardButtonTypeUrl#4365beac as nil")
	}
	b.PutID(InlineKeyboardButtonTypeURLTypeID)
	return i.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (i *InlineKeyboardButtonTypeURL) EncodeBare(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode inlineKeyboardButtonTypeUrl#4365beac as nil")
	}
	b.PutString(i.URL)
	return nil
}

// Decode implements bin.Decoder.
func (i *InlineKeyboardButtonTypeURL) Decode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't decode inlineKeyboardButtonTypeUrl#4365beac to nil")
	}
	if err := b.ConsumeID(InlineKeyboardButtonTypeURLTypeID); err != nil {
		return fmt.Errorf("unable to decode inlineKeyboardButtonTypeUrl#4365beac: %w", err)
	}
	return i.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (i *InlineKeyboardButtonTypeURL) DecodeBare(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't decode inlineKeyboardButtonTypeUrl#4365beac to nil")
	}
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode inlineKeyboardButtonTypeUrl#4365beac: field url: %w", err)
		}
		i.URL = value
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (i *InlineKeyboardButtonTypeURL) EncodeTDLibJSON(b tdjson.Encoder) error {
	if i == nil {
		return fmt.Errorf("can't encode inlineKeyboardButtonTypeUrl#4365beac as nil")
	}
	b.ObjStart()
	b.PutID("inlineKeyboardButtonTypeUrl")
	b.Comma()
	b.FieldStart("url")
	b.PutString(i.URL)
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (i *InlineKeyboardButtonTypeURL) DecodeTDLibJSON(b tdjson.Decoder) error {
	if i == nil {
		return fmt.Errorf("can't decode inlineKeyboardButtonTypeUrl#4365beac to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("inlineKeyboardButtonTypeUrl"); err != nil {
				return fmt.Errorf("unable to decode inlineKeyboardButtonTypeUrl#4365beac: %w", err)
			}
		case "url":
			value, err := b.String()
			if err != nil {
				return fmt.Errorf("unable to decode inlineKeyboardButtonTypeUrl#4365beac: field url: %w", err)
			}
			i.URL = value
		default:
			return b.Skip()
		}
		return nil
	})
}

// GetURL returns value of URL field.
func (i *InlineKeyboardButtonTypeURL) GetURL() (value string) {
	if i == nil {
		return
	}
	return i.URL
}

// InlineKeyboardButtonTypeLoginURL represents TL type `inlineKeyboardButtonTypeLoginUrl#b8455fa7`.
type InlineKeyboardButtonTypeLoginURL struct {
	// An HTTP URL to pass to getLoginUrlInfo
	URL string
	// Unique button identifier
	ID int64
	// If non-empty, new text of the button in forwarded messages
	ForwardText string
}

// InlineKeyboardButtonTypeLoginURLTypeID is TL type id of InlineKeyboardButtonTypeLoginURL.
const InlineKeyboardButtonTypeLoginURLTypeID = 0xb8455fa7

// construct implements constructor of InlineKeyboardButtonTypeClass.
func (i InlineKeyboardButtonTypeLoginURL) construct() InlineKeyboardButtonTypeClass { return &i }

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

	_ InlineKeyboardButtonTypeClass = &InlineKeyboardButtonTypeLoginURL{}
)

func (i *InlineKeyboardButtonTypeLoginURL) Zero() bool {
	if i == nil {
		return true
	}
	if !(i.URL == "") {
		return false
	}
	if !(i.ID == 0) {
		return false
	}
	if !(i.ForwardText == "") {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (i *InlineKeyboardButtonTypeLoginURL) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "inlineKeyboardButtonTypeLoginUrl",
		ID:   InlineKeyboardButtonTypeLoginURLTypeID,
	}
	if i == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "URL",
			SchemaName: "url",
		},
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "ForwardText",
			SchemaName: "forward_text",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (i *InlineKeyboardButtonTypeLoginURL) Encode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode inlineKeyboardButtonTypeLoginUrl#b8455fa7 as nil")
	}
	b.PutID(InlineKeyboardButtonTypeLoginURLTypeID)
	return i.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (i *InlineKeyboardButtonTypeLoginURL) EncodeBare(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode inlineKeyboardButtonTypeLoginUrl#b8455fa7 as nil")
	}
	b.PutString(i.URL)
	b.PutInt53(i.ID)
	b.PutString(i.ForwardText)
	return nil
}

// Decode implements bin.Decoder.
func (i *InlineKeyboardButtonTypeLoginURL) Decode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't decode inlineKeyboardButtonTypeLoginUrl#b8455fa7 to nil")
	}
	if err := b.ConsumeID(InlineKeyboardButtonTypeLoginURLTypeID); err != nil {
		return fmt.Errorf("unable to decode inlineKeyboardButtonTypeLoginUrl#b8455fa7: %w", err)
	}
	return i.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (i *InlineKeyboardButtonTypeLoginURL) DecodeBare(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't decode inlineKeyboardButtonTypeLoginUrl#b8455fa7 to nil")
	}
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode inlineKeyboardButtonTypeLoginUrl#b8455fa7: field url: %w", err)
		}
		i.URL = value
	}
	{
		value, err := b.Int53()
		if err != nil {
			return fmt.Errorf("unable to decode inlineKeyboardButtonTypeLoginUrl#b8455fa7: field id: %w", err)
		}
		i.ID = value
	}
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode inlineKeyboardButtonTypeLoginUrl#b8455fa7: field forward_text: %w", err)
		}
		i.ForwardText = value
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (i *InlineKeyboardButtonTypeLoginURL) EncodeTDLibJSON(b tdjson.Encoder) error {
	if i == nil {
		return fmt.Errorf("can't encode inlineKeyboardButtonTypeLoginUrl#b8455fa7 as nil")
	}
	b.ObjStart()
	b.PutID("inlineKeyboardButtonTypeLoginUrl")
	b.Comma()
	b.FieldStart("url")
	b.PutString(i.URL)
	b.Comma()
	b.FieldStart("id")
	b.PutInt53(i.ID)
	b.Comma()
	b.FieldStart("forward_text")
	b.PutString(i.ForwardText)
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (i *InlineKeyboardButtonTypeLoginURL) DecodeTDLibJSON(b tdjson.Decoder) error {
	if i == nil {
		return fmt.Errorf("can't decode inlineKeyboardButtonTypeLoginUrl#b8455fa7 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("inlineKeyboardButtonTypeLoginUrl"); err != nil {
				return fmt.Errorf("unable to decode inlineKeyboardButtonTypeLoginUrl#b8455fa7: %w", err)
			}
		case "url":
			value, err := b.String()
			if err != nil {
				return fmt.Errorf("unable to decode inlineKeyboardButtonTypeLoginUrl#b8455fa7: field url: %w", err)
			}
			i.URL = value
		case "id":
			value, err := b.Int53()
			if err != nil {
				return fmt.Errorf("unable to decode inlineKeyboardButtonTypeLoginUrl#b8455fa7: field id: %w", err)
			}
			i.ID = value
		case "forward_text":
			value, err := b.String()
			if err != nil {
				return fmt.Errorf("unable to decode inlineKeyboardButtonTypeLoginUrl#b8455fa7: field forward_text: %w", err)
			}
			i.ForwardText = value
		default:
			return b.Skip()
		}
		return nil
	})
}

// GetURL returns value of URL field.
func (i *InlineKeyboardButtonTypeLoginURL) GetURL() (value string) {
	if i == nil {
		return
	}
	return i.URL
}

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

// GetForwardText returns value of ForwardText field.
func (i *InlineKeyboardButtonTypeLoginURL) GetForwardText() (value string) {
	if i == nil {
		return
	}
	return i.ForwardText
}

// InlineKeyboardButtonTypeWebApp represents TL type `inlineKeyboardButtonTypeWebApp#96a685c8`.
type InlineKeyboardButtonTypeWebApp struct {
	// An HTTP URL to pass to openWebApp
	URL string
}

// InlineKeyboardButtonTypeWebAppTypeID is TL type id of InlineKeyboardButtonTypeWebApp.
const InlineKeyboardButtonTypeWebAppTypeID = 0x96a685c8

// construct implements constructor of InlineKeyboardButtonTypeClass.
func (i InlineKeyboardButtonTypeWebApp) construct() InlineKeyboardButtonTypeClass { return &i }

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

	_ InlineKeyboardButtonTypeClass = &InlineKeyboardButtonTypeWebApp{}
)

func (i *InlineKeyboardButtonTypeWebApp) Zero() bool {
	if i == nil {
		return true
	}
	if !(i.URL == "") {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (i *InlineKeyboardButtonTypeWebApp) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "inlineKeyboardButtonTypeWebApp",
		ID:   InlineKeyboardButtonTypeWebAppTypeID,
	}
	if i == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "URL",
			SchemaName: "url",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (i *InlineKeyboardButtonTypeWebApp) Encode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode inlineKeyboardButtonTypeWebApp#96a685c8 as nil")
	}
	b.PutID(InlineKeyboardButtonTypeWebAppTypeID)
	return i.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (i *InlineKeyboardButtonTypeWebApp) EncodeBare(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode inlineKeyboardButtonTypeWebApp#96a685c8 as nil")
	}
	b.PutString(i.URL)
	return nil
}

// Decode implements bin.Decoder.
func (i *InlineKeyboardButtonTypeWebApp) Decode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't decode inlineKeyboardButtonTypeWebApp#96a685c8 to nil")
	}
	if err := b.ConsumeID(InlineKeyboardButtonTypeWebAppTypeID); err != nil {
		return fmt.Errorf("unable to decode inlineKeyboardButtonTypeWebApp#96a685c8: %w", err)
	}
	return i.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (i *InlineKeyboardButtonTypeWebApp) DecodeBare(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't decode inlineKeyboardButtonTypeWebApp#96a685c8 to nil")
	}
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode inlineKeyboardButtonTypeWebApp#96a685c8: field url: %w", err)
		}
		i.URL = value
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (i *InlineKeyboardButtonTypeWebApp) EncodeTDLibJSON(b tdjson.Encoder) error {
	if i == nil {
		return fmt.Errorf("can't encode inlineKeyboardButtonTypeWebApp#96a685c8 as nil")
	}
	b.ObjStart()
	b.PutID("inlineKeyboardButtonTypeWebApp")
	b.Comma()
	b.FieldStart("url")
	b.PutString(i.URL)
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (i *InlineKeyboardButtonTypeWebApp) DecodeTDLibJSON(b tdjson.Decoder) error {
	if i == nil {
		return fmt.Errorf("can't decode inlineKeyboardButtonTypeWebApp#96a685c8 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("inlineKeyboardButtonTypeWebApp"); err != nil {
				return fmt.Errorf("unable to decode inlineKeyboardButtonTypeWebApp#96a685c8: %w", err)
			}
		case "url":
			value, err := b.String()
			if err != nil {
				return fmt.Errorf("unable to decode inlineKeyboardButtonTypeWebApp#96a685c8: field url: %w", err)
			}
			i.URL = value
		default:
			return b.Skip()
		}
		return nil
	})
}

// GetURL returns value of URL field.
func (i *InlineKeyboardButtonTypeWebApp) GetURL() (value string) {
	if i == nil {
		return
	}
	return i.URL
}

// InlineKeyboardButtonTypeCallback represents TL type `inlineKeyboardButtonTypeCallback#bccb7bfd`.
type InlineKeyboardButtonTypeCallback struct {
	// Data to be sent to the bot via a callback query
	Data []byte
}

// InlineKeyboardButtonTypeCallbackTypeID is TL type id of InlineKeyboardButtonTypeCallback.
const InlineKeyboardButtonTypeCallbackTypeID = 0xbccb7bfd

// construct implements constructor of InlineKeyboardButtonTypeClass.
func (i InlineKeyboardButtonTypeCallback) construct() InlineKeyboardButtonTypeClass { return &i }

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

	_ InlineKeyboardButtonTypeClass = &InlineKeyboardButtonTypeCallback{}
)

func (i *InlineKeyboardButtonTypeCallback) Zero() bool {
	if i == nil {
		return true
	}
	if !(i.Data == nil) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (i *InlineKeyboardButtonTypeCallback) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "inlineKeyboardButtonTypeCallback",
		ID:   InlineKeyboardButtonTypeCallbackTypeID,
	}
	if i == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Data",
			SchemaName: "data",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (i *InlineKeyboardButtonTypeCallback) Encode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode inlineKeyboardButtonTypeCallback#bccb7bfd as nil")
	}
	b.PutID(InlineKeyboardButtonTypeCallbackTypeID)
	return i.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (i *InlineKeyboardButtonTypeCallback) EncodeBare(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode inlineKeyboardButtonTypeCallback#bccb7bfd as nil")
	}
	b.PutBytes(i.Data)
	return nil
}

// Decode implements bin.Decoder.
func (i *InlineKeyboardButtonTypeCallback) Decode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't decode inlineKeyboardButtonTypeCallback#bccb7bfd to nil")
	}
	if err := b.ConsumeID(InlineKeyboardButtonTypeCallbackTypeID); err != nil {
		return fmt.Errorf("unable to decode inlineKeyboardButtonTypeCallback#bccb7bfd: %w", err)
	}
	return i.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (i *InlineKeyboardButtonTypeCallback) DecodeBare(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't decode inlineKeyboardButtonTypeCallback#bccb7bfd to nil")
	}
	{
		value, err := b.Bytes()
		if err != nil {
			return fmt.Errorf("unable to decode inlineKeyboardButtonTypeCallback#bccb7bfd: field data: %w", err)
		}
		i.Data = value
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (i *InlineKeyboardButtonTypeCallback) EncodeTDLibJSON(b tdjson.Encoder) error {
	if i == nil {
		return fmt.Errorf("can't encode inlineKeyboardButtonTypeCallback#bccb7bfd as nil")
	}
	b.ObjStart()
	b.PutID("inlineKeyboardButtonTypeCallback")
	b.Comma()
	b.FieldStart("data")
	b.PutBytes(i.Data)
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (i *InlineKeyboardButtonTypeCallback) DecodeTDLibJSON(b tdjson.Decoder) error {
	if i == nil {
		return fmt.Errorf("can't decode inlineKeyboardButtonTypeCallback#bccb7bfd to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("inlineKeyboardButtonTypeCallback"); err != nil {
				return fmt.Errorf("unable to decode inlineKeyboardButtonTypeCallback#bccb7bfd: %w", err)
			}
		case "data":
			value, err := b.Bytes()
			if err != nil {
				return fmt.Errorf("unable to decode inlineKeyboardButtonTypeCallback#bccb7bfd: field data: %w", err)
			}
			i.Data = value
		default:
			return b.Skip()
		}
		return nil
	})
}

// GetData returns value of Data field.
func (i *InlineKeyboardButtonTypeCallback) GetData() (value []byte) {
	if i == nil {
		return
	}
	return i.Data
}

// InlineKeyboardButtonTypeCallbackWithPassword represents TL type `inlineKeyboardButtonTypeCallbackWithPassword#361f4248`.
type InlineKeyboardButtonTypeCallbackWithPassword struct {
	// Data to be sent to the bot via a callback query
	Data []byte
}

// InlineKeyboardButtonTypeCallbackWithPasswordTypeID is TL type id of InlineKeyboardButtonTypeCallbackWithPassword.
const InlineKeyboardButtonTypeCallbackWithPasswordTypeID = 0x361f4248

// construct implements constructor of InlineKeyboardButtonTypeClass.
func (i InlineKeyboardButtonTypeCallbackWithPassword) construct() InlineKeyboardButtonTypeClass {
	return &i
}

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

	_ InlineKeyboardButtonTypeClass = &InlineKeyboardButtonTypeCallbackWithPassword{}
)

func (i *InlineKeyboardButtonTypeCallbackWithPassword) Zero() bool {
	if i == nil {
		return true
	}
	if !(i.Data == nil) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (i *InlineKeyboardButtonTypeCallbackWithPassword) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "inlineKeyboardButtonTypeCallbackWithPassword",
		ID:   InlineKeyboardButtonTypeCallbackWithPasswordTypeID,
	}
	if i == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Data",
			SchemaName: "data",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (i *InlineKeyboardButtonTypeCallbackWithPassword) Encode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode inlineKeyboardButtonTypeCallbackWithPassword#361f4248 as nil")
	}
	b.PutID(InlineKeyboardButtonTypeCallbackWithPasswordTypeID)
	return i.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (i *InlineKeyboardButtonTypeCallbackWithPassword) EncodeBare(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode inlineKeyboardButtonTypeCallbackWithPassword#361f4248 as nil")
	}
	b.PutBytes(i.Data)
	return nil
}

// Decode implements bin.Decoder.
func (i *InlineKeyboardButtonTypeCallbackWithPassword) Decode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't decode inlineKeyboardButtonTypeCallbackWithPassword#361f4248 to nil")
	}
	if err := b.ConsumeID(InlineKeyboardButtonTypeCallbackWithPasswordTypeID); err != nil {
		return fmt.Errorf("unable to decode inlineKeyboardButtonTypeCallbackWithPassword#361f4248: %w", err)
	}
	return i.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (i *InlineKeyboardButtonTypeCallbackWithPassword) DecodeBare(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't decode inlineKeyboardButtonTypeCallbackWithPassword#361f4248 to nil")
	}
	{
		value, err := b.Bytes()
		if err != nil {
			return fmt.Errorf("unable to decode inlineKeyboardButtonTypeCallbackWithPassword#361f4248: field data: %w", err)
		}
		i.Data = value
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (i *InlineKeyboardButtonTypeCallbackWithPassword) EncodeTDLibJSON(b tdjson.Encoder) error {
	if i == nil {
		return fmt.Errorf("can't encode inlineKeyboardButtonTypeCallbackWithPassword#361f4248 as nil")
	}
	b.ObjStart()
	b.PutID("inlineKeyboardButtonTypeCallbackWithPassword")
	b.Comma()
	b.FieldStart("data")
	b.PutBytes(i.Data)
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (i *InlineKeyboardButtonTypeCallbackWithPassword) DecodeTDLibJSON(b tdjson.Decoder) error {
	if i == nil {
		return fmt.Errorf("can't decode inlineKeyboardButtonTypeCallbackWithPassword#361f4248 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("inlineKeyboardButtonTypeCallbackWithPassword"); err != nil {
				return fmt.Errorf("unable to decode inlineKeyboardButtonTypeCallbackWithPassword#361f4248: %w", err)
			}
		case "data":
			value, err := b.Bytes()
			if err != nil {
				return fmt.Errorf("unable to decode inlineKeyboardButtonTypeCallbackWithPassword#361f4248: field data: %w", err)
			}
			i.Data = value
		default:
			return b.Skip()
		}
		return nil
	})
}

// GetData returns value of Data field.
func (i *InlineKeyboardButtonTypeCallbackWithPassword) GetData() (value []byte) {
	if i == nil {
		return
	}
	return i.Data
}

// InlineKeyboardButtonTypeCallbackGame represents TL type `inlineKeyboardButtonTypeCallbackGame#e9255468`.
type InlineKeyboardButtonTypeCallbackGame struct {
}

// InlineKeyboardButtonTypeCallbackGameTypeID is TL type id of InlineKeyboardButtonTypeCallbackGame.
const InlineKeyboardButtonTypeCallbackGameTypeID = 0xe9255468

// construct implements constructor of InlineKeyboardButtonTypeClass.
func (i InlineKeyboardButtonTypeCallbackGame) construct() InlineKeyboardButtonTypeClass { return &i }

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

	_ InlineKeyboardButtonTypeClass = &InlineKeyboardButtonTypeCallbackGame{}
)

func (i *InlineKeyboardButtonTypeCallbackGame) Zero() bool {
	if i == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (i *InlineKeyboardButtonTypeCallbackGame) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "inlineKeyboardButtonTypeCallbackGame",
		ID:   InlineKeyboardButtonTypeCallbackGameTypeID,
	}
	if i == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (i *InlineKeyboardButtonTypeCallbackGame) Encode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode inlineKeyboardButtonTypeCallbackGame#e9255468 as nil")
	}
	b.PutID(InlineKeyboardButtonTypeCallbackGameTypeID)
	return i.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (i *InlineKeyboardButtonTypeCallbackGame) EncodeBare(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode inlineKeyboardButtonTypeCallbackGame#e9255468 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (i *InlineKeyboardButtonTypeCallbackGame) Decode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't decode inlineKeyboardButtonTypeCallbackGame#e9255468 to nil")
	}
	if err := b.ConsumeID(InlineKeyboardButtonTypeCallbackGameTypeID); err != nil {
		return fmt.Errorf("unable to decode inlineKeyboardButtonTypeCallbackGame#e9255468: %w", err)
	}
	return i.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (i *InlineKeyboardButtonTypeCallbackGame) DecodeBare(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't decode inlineKeyboardButtonTypeCallbackGame#e9255468 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (i *InlineKeyboardButtonTypeCallbackGame) EncodeTDLibJSON(b tdjson.Encoder) error {
	if i == nil {
		return fmt.Errorf("can't encode inlineKeyboardButtonTypeCallbackGame#e9255468 as nil")
	}
	b.ObjStart()
	b.PutID("inlineKeyboardButtonTypeCallbackGame")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (i *InlineKeyboardButtonTypeCallbackGame) DecodeTDLibJSON(b tdjson.Decoder) error {
	if i == nil {
		return fmt.Errorf("can't decode inlineKeyboardButtonTypeCallbackGame#e9255468 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("inlineKeyboardButtonTypeCallbackGame"); err != nil {
				return fmt.Errorf("unable to decode inlineKeyboardButtonTypeCallbackGame#e9255468: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// InlineKeyboardButtonTypeSwitchInline represents TL type `inlineKeyboardButtonTypeSwitchInline#207a9cf5`.
type InlineKeyboardButtonTypeSwitchInline struct {
	// Inline query to be sent to the bot
	Query string
	// Target chat from which to send the inline query
	TargetChat TargetChatClass
}

// InlineKeyboardButtonTypeSwitchInlineTypeID is TL type id of InlineKeyboardButtonTypeSwitchInline.
const InlineKeyboardButtonTypeSwitchInlineTypeID = 0x207a9cf5

// construct implements constructor of InlineKeyboardButtonTypeClass.
func (i InlineKeyboardButtonTypeSwitchInline) construct() InlineKeyboardButtonTypeClass { return &i }

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

	_ InlineKeyboardButtonTypeClass = &InlineKeyboardButtonTypeSwitchInline{}
)

func (i *InlineKeyboardButtonTypeSwitchInline) Zero() bool {
	if i == nil {
		return true
	}
	if !(i.Query == "") {
		return false
	}
	if !(i.TargetChat == nil) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (i *InlineKeyboardButtonTypeSwitchInline) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "inlineKeyboardButtonTypeSwitchInline",
		ID:   InlineKeyboardButtonTypeSwitchInlineTypeID,
	}
	if i == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Query",
			SchemaName: "query",
		},
		{
			Name:       "TargetChat",
			SchemaName: "target_chat",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (i *InlineKeyboardButtonTypeSwitchInline) Encode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode inlineKeyboardButtonTypeSwitchInline#207a9cf5 as nil")
	}
	b.PutID(InlineKeyboardButtonTypeSwitchInlineTypeID)
	return i.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (i *InlineKeyboardButtonTypeSwitchInline) EncodeBare(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode inlineKeyboardButtonTypeSwitchInline#207a9cf5 as nil")
	}
	b.PutString(i.Query)
	if i.TargetChat == nil {
		return fmt.Errorf("unable to encode inlineKeyboardButtonTypeSwitchInline#207a9cf5: field target_chat is nil")
	}
	if err := i.TargetChat.Encode(b); err != nil {
		return fmt.Errorf("unable to encode inlineKeyboardButtonTypeSwitchInline#207a9cf5: field target_chat: %w", err)
	}
	return nil
}

// Decode implements bin.Decoder.
func (i *InlineKeyboardButtonTypeSwitchInline) Decode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't decode inlineKeyboardButtonTypeSwitchInline#207a9cf5 to nil")
	}
	if err := b.ConsumeID(InlineKeyboardButtonTypeSwitchInlineTypeID); err != nil {
		return fmt.Errorf("unable to decode inlineKeyboardButtonTypeSwitchInline#207a9cf5: %w", err)
	}
	return i.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (i *InlineKeyboardButtonTypeSwitchInline) DecodeBare(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't decode inlineKeyboardButtonTypeSwitchInline#207a9cf5 to nil")
	}
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode inlineKeyboardButtonTypeSwitchInline#207a9cf5: field query: %w", err)
		}
		i.Query = value
	}
	{
		value, err := DecodeTargetChat(b)
		if err != nil {
			return fmt.Errorf("unable to decode inlineKeyboardButtonTypeSwitchInline#207a9cf5: field target_chat: %w", err)
		}
		i.TargetChat = value
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (i *InlineKeyboardButtonTypeSwitchInline) EncodeTDLibJSON(b tdjson.Encoder) error {
	if i == nil {
		return fmt.Errorf("can't encode inlineKeyboardButtonTypeSwitchInline#207a9cf5 as nil")
	}
	b.ObjStart()
	b.PutID("inlineKeyboardButtonTypeSwitchInline")
	b.Comma()
	b.FieldStart("query")
	b.PutString(i.Query)
	b.Comma()
	b.FieldStart("target_chat")
	if i.TargetChat == nil {
		return fmt.Errorf("unable to encode inlineKeyboardButtonTypeSwitchInline#207a9cf5: field target_chat is nil")
	}
	if err := i.TargetChat.EncodeTDLibJSON(b); err != nil {
		return fmt.Errorf("unable to encode inlineKeyboardButtonTypeSwitchInline#207a9cf5: field target_chat: %w", err)
	}
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (i *InlineKeyboardButtonTypeSwitchInline) DecodeTDLibJSON(b tdjson.Decoder) error {
	if i == nil {
		return fmt.Errorf("can't decode inlineKeyboardButtonTypeSwitchInline#207a9cf5 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("inlineKeyboardButtonTypeSwitchInline"); err != nil {
				return fmt.Errorf("unable to decode inlineKeyboardButtonTypeSwitchInline#207a9cf5: %w", err)
			}
		case "query":
			value, err := b.String()
			if err != nil {
				return fmt.Errorf("unable to decode inlineKeyboardButtonTypeSwitchInline#207a9cf5: field query: %w", err)
			}
			i.Query = value
		case "target_chat":
			value, err := DecodeTDLibJSONTargetChat(b)
			if err != nil {
				return fmt.Errorf("unable to decode inlineKeyboardButtonTypeSwitchInline#207a9cf5: field target_chat: %w", err)
			}
			i.TargetChat = value
		default:
			return b.Skip()
		}
		return nil
	})
}

// GetQuery returns value of Query field.
func (i *InlineKeyboardButtonTypeSwitchInline) GetQuery() (value string) {
	if i == nil {
		return
	}
	return i.Query
}

// GetTargetChat returns value of TargetChat field.
func (i *InlineKeyboardButtonTypeSwitchInline) GetTargetChat() (value TargetChatClass) {
	if i == nil {
		return
	}
	return i.TargetChat
}

// InlineKeyboardButtonTypeBuy represents TL type `inlineKeyboardButtonTypeBuy#511b3c70`.
type InlineKeyboardButtonTypeBuy struct {
}

// InlineKeyboardButtonTypeBuyTypeID is TL type id of InlineKeyboardButtonTypeBuy.
const InlineKeyboardButtonTypeBuyTypeID = 0x511b3c70

// construct implements constructor of InlineKeyboardButtonTypeClass.
func (i InlineKeyboardButtonTypeBuy) construct() InlineKeyboardButtonTypeClass { return &i }

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

	_ InlineKeyboardButtonTypeClass = &InlineKeyboardButtonTypeBuy{}
)

func (i *InlineKeyboardButtonTypeBuy) Zero() bool {
	if i == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (i *InlineKeyboardButtonTypeBuy) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "inlineKeyboardButtonTypeBuy",
		ID:   InlineKeyboardButtonTypeBuyTypeID,
	}
	if i == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (i *InlineKeyboardButtonTypeBuy) Encode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode inlineKeyboardButtonTypeBuy#511b3c70 as nil")
	}
	b.PutID(InlineKeyboardButtonTypeBuyTypeID)
	return i.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (i *InlineKeyboardButtonTypeBuy) EncodeBare(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode inlineKeyboardButtonTypeBuy#511b3c70 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (i *InlineKeyboardButtonTypeBuy) Decode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't decode inlineKeyboardButtonTypeBuy#511b3c70 to nil")
	}
	if err := b.ConsumeID(InlineKeyboardButtonTypeBuyTypeID); err != nil {
		return fmt.Errorf("unable to decode inlineKeyboardButtonTypeBuy#511b3c70: %w", err)
	}
	return i.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (i *InlineKeyboardButtonTypeBuy) DecodeBare(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't decode inlineKeyboardButtonTypeBuy#511b3c70 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (i *InlineKeyboardButtonTypeBuy) EncodeTDLibJSON(b tdjson.Encoder) error {
	if i == nil {
		return fmt.Errorf("can't encode inlineKeyboardButtonTypeBuy#511b3c70 as nil")
	}
	b.ObjStart()
	b.PutID("inlineKeyboardButtonTypeBuy")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (i *InlineKeyboardButtonTypeBuy) DecodeTDLibJSON(b tdjson.Decoder) error {
	if i == nil {
		return fmt.Errorf("can't decode inlineKeyboardButtonTypeBuy#511b3c70 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("inlineKeyboardButtonTypeBuy"); err != nil {
				return fmt.Errorf("unable to decode inlineKeyboardButtonTypeBuy#511b3c70: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// InlineKeyboardButtonTypeUser represents TL type `inlineKeyboardButtonTypeUser#6d77e5a2`.
type InlineKeyboardButtonTypeUser struct {
	// User identifier
	UserID int64
}

// InlineKeyboardButtonTypeUserTypeID is TL type id of InlineKeyboardButtonTypeUser.
const InlineKeyboardButtonTypeUserTypeID = 0x6d77e5a2

// construct implements constructor of InlineKeyboardButtonTypeClass.
func (i InlineKeyboardButtonTypeUser) construct() InlineKeyboardButtonTypeClass { return &i }

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

	_ InlineKeyboardButtonTypeClass = &InlineKeyboardButtonTypeUser{}
)

func (i *InlineKeyboardButtonTypeUser) Zero() bool {
	if i == nil {
		return true
	}
	if !(i.UserID == 0) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (i *InlineKeyboardButtonTypeUser) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "inlineKeyboardButtonTypeUser",
		ID:   InlineKeyboardButtonTypeUserTypeID,
	}
	if i == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "UserID",
			SchemaName: "user_id",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (i *InlineKeyboardButtonTypeUser) Encode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode inlineKeyboardButtonTypeUser#6d77e5a2 as nil")
	}
	b.PutID(InlineKeyboardButtonTypeUserTypeID)
	return i.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (i *InlineKeyboardButtonTypeUser) EncodeBare(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode inlineKeyboardButtonTypeUser#6d77e5a2 as nil")
	}
	b.PutInt53(i.UserID)
	return nil
}

// Decode implements bin.Decoder.
func (i *InlineKeyboardButtonTypeUser) Decode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't decode inlineKeyboardButtonTypeUser#6d77e5a2 to nil")
	}
	if err := b.ConsumeID(InlineKeyboardButtonTypeUserTypeID); err != nil {
		return fmt.Errorf("unable to decode inlineKeyboardButtonTypeUser#6d77e5a2: %w", err)
	}
	return i.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (i *InlineKeyboardButtonTypeUser) DecodeBare(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't decode inlineKeyboardButtonTypeUser#6d77e5a2 to nil")
	}
	{
		value, err := b.Int53()
		if err != nil {
			return fmt.Errorf("unable to decode inlineKeyboardButtonTypeUser#6d77e5a2: field user_id: %w", err)
		}
		i.UserID = value
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (i *InlineKeyboardButtonTypeUser) EncodeTDLibJSON(b tdjson.Encoder) error {
	if i == nil {
		return fmt.Errorf("can't encode inlineKeyboardButtonTypeUser#6d77e5a2 as nil")
	}
	b.ObjStart()
	b.PutID("inlineKeyboardButtonTypeUser")
	b.Comma()
	b.FieldStart("user_id")
	b.PutInt53(i.UserID)
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (i *InlineKeyboardButtonTypeUser) DecodeTDLibJSON(b tdjson.Decoder) error {
	if i == nil {
		return fmt.Errorf("can't decode inlineKeyboardButtonTypeUser#6d77e5a2 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("inlineKeyboardButtonTypeUser"); err != nil {
				return fmt.Errorf("unable to decode inlineKeyboardButtonTypeUser#6d77e5a2: %w", err)
			}
		case "user_id":
			value, err := b.Int53()
			if err != nil {
				return fmt.Errorf("unable to decode inlineKeyboardButtonTypeUser#6d77e5a2: field user_id: %w", err)
			}
			i.UserID = value
		default:
			return b.Skip()
		}
		return nil
	})
}

// GetUserID returns value of UserID field.
func (i *InlineKeyboardButtonTypeUser) GetUserID() (value int64) {
	if i == nil {
		return
	}
	return i.UserID
}

// InlineKeyboardButtonTypeCopyText represents TL type `inlineKeyboardButtonTypeCopyText#41b1306`.
type InlineKeyboardButtonTypeCopyText struct {
	// The text to copy to clipboard
	Text string
}

// InlineKeyboardButtonTypeCopyTextTypeID is TL type id of InlineKeyboardButtonTypeCopyText.
const InlineKeyboardButtonTypeCopyTextTypeID = 0x41b1306

// construct implements constructor of InlineKeyboardButtonTypeClass.
func (i InlineKeyboardButtonTypeCopyText) construct() InlineKeyboardButtonTypeClass { return &i }

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

	_ InlineKeyboardButtonTypeClass = &InlineKeyboardButtonTypeCopyText{}
)

func (i *InlineKeyboardButtonTypeCopyText) Zero() bool {
	if i == nil {
		return true
	}
	if !(i.Text == "") {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (i *InlineKeyboardButtonTypeCopyText) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "inlineKeyboardButtonTypeCopyText",
		ID:   InlineKeyboardButtonTypeCopyTextTypeID,
	}
	if i == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Text",
			SchemaName: "text",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (i *InlineKeyboardButtonTypeCopyText) Encode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode inlineKeyboardButtonTypeCopyText#41b1306 as nil")
	}
	b.PutID(InlineKeyboardButtonTypeCopyTextTypeID)
	return i.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (i *InlineKeyboardButtonTypeCopyText) EncodeBare(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode inlineKeyboardButtonTypeCopyText#41b1306 as nil")
	}
	b.PutString(i.Text)
	return nil
}

// Decode implements bin.Decoder.
func (i *InlineKeyboardButtonTypeCopyText) Decode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't decode inlineKeyboardButtonTypeCopyText#41b1306 to nil")
	}
	if err := b.ConsumeID(InlineKeyboardButtonTypeCopyTextTypeID); err != nil {
		return fmt.Errorf("unable to decode inlineKeyboardButtonTypeCopyText#41b1306: %w", err)
	}
	return i.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (i *InlineKeyboardButtonTypeCopyText) DecodeBare(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't decode inlineKeyboardButtonTypeCopyText#41b1306 to nil")
	}
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode inlineKeyboardButtonTypeCopyText#41b1306: field text: %w", err)
		}
		i.Text = value
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (i *InlineKeyboardButtonTypeCopyText) EncodeTDLibJSON(b tdjson.Encoder) error {
	if i == nil {
		return fmt.Errorf("can't encode inlineKeyboardButtonTypeCopyText#41b1306 as nil")
	}
	b.ObjStart()
	b.PutID("inlineKeyboardButtonTypeCopyText")
	b.Comma()
	b.FieldStart("text")
	b.PutString(i.Text)
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (i *InlineKeyboardButtonTypeCopyText) DecodeTDLibJSON(b tdjson.Decoder) error {
	if i == nil {
		return fmt.Errorf("can't decode inlineKeyboardButtonTypeCopyText#41b1306 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("inlineKeyboardButtonTypeCopyText"); err != nil {
				return fmt.Errorf("unable to decode inlineKeyboardButtonTypeCopyText#41b1306: %w", err)
			}
		case "text":
			value, err := b.String()
			if err != nil {
				return fmt.Errorf("unable to decode inlineKeyboardButtonTypeCopyText#41b1306: field text: %w", err)
			}
			i.Text = value
		default:
			return b.Skip()
		}
		return nil
	})
}

// GetText returns value of Text field.
func (i *InlineKeyboardButtonTypeCopyText) GetText() (value string) {
	if i == nil {
		return
	}
	return i.Text
}

// InlineKeyboardButtonTypeClassName is schema name of InlineKeyboardButtonTypeClass.
const InlineKeyboardButtonTypeClassName = "InlineKeyboardButtonType"

// InlineKeyboardButtonTypeClass represents InlineKeyboardButtonType generic type.
//
// Example:
//
//	g, err := tdapi.DecodeInlineKeyboardButtonType(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tdapi.InlineKeyboardButtonTypeURL: // inlineKeyboardButtonTypeUrl#4365beac
//	case *tdapi.InlineKeyboardButtonTypeLoginURL: // inlineKeyboardButtonTypeLoginUrl#b8455fa7
//	case *tdapi.InlineKeyboardButtonTypeWebApp: // inlineKeyboardButtonTypeWebApp#96a685c8
//	case *tdapi.InlineKeyboardButtonTypeCallback: // inlineKeyboardButtonTypeCallback#bccb7bfd
//	case *tdapi.InlineKeyboardButtonTypeCallbackWithPassword: // inlineKeyboardButtonTypeCallbackWithPassword#361f4248
//	case *tdapi.InlineKeyboardButtonTypeCallbackGame: // inlineKeyboardButtonTypeCallbackGame#e9255468
//	case *tdapi.InlineKeyboardButtonTypeSwitchInline: // inlineKeyboardButtonTypeSwitchInline#207a9cf5
//	case *tdapi.InlineKeyboardButtonTypeBuy: // inlineKeyboardButtonTypeBuy#511b3c70
//	case *tdapi.InlineKeyboardButtonTypeUser: // inlineKeyboardButtonTypeUser#6d77e5a2
//	case *tdapi.InlineKeyboardButtonTypeCopyText: // inlineKeyboardButtonTypeCopyText#41b1306
//	default: panic(v)
//	}
type InlineKeyboardButtonTypeClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() InlineKeyboardButtonTypeClass

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

	EncodeTDLibJSON(b tdjson.Encoder) error
	DecodeTDLibJSON(b tdjson.Decoder) error
}

// DecodeInlineKeyboardButtonType implements binary de-serialization for InlineKeyboardButtonTypeClass.
func DecodeInlineKeyboardButtonType(buf *bin.Buffer) (InlineKeyboardButtonTypeClass, error) {
	id, err := buf.PeekID()
	if err != nil {
		return nil, err
	}
	switch id {
	case InlineKeyboardButtonTypeURLTypeID:
		// Decoding inlineKeyboardButtonTypeUrl#4365beac.
		v := InlineKeyboardButtonTypeURL{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode InlineKeyboardButtonTypeClass: %w", err)
		}
		return &v, nil
	case InlineKeyboardButtonTypeLoginURLTypeID:
		// Decoding inlineKeyboardButtonTypeLoginUrl#b8455fa7.
		v := InlineKeyboardButtonTypeLoginURL{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode InlineKeyboardButtonTypeClass: %w", err)
		}
		return &v, nil
	case InlineKeyboardButtonTypeWebAppTypeID:
		// Decoding inlineKeyboardButtonTypeWebApp#96a685c8.
		v := InlineKeyboardButtonTypeWebApp{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode InlineKeyboardButtonTypeClass: %w", err)
		}
		return &v, nil
	case InlineKeyboardButtonTypeCallbackTypeID:
		// Decoding inlineKeyboardButtonTypeCallback#bccb7bfd.
		v := InlineKeyboardButtonTypeCallback{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode InlineKeyboardButtonTypeClass: %w", err)
		}
		return &v, nil
	case InlineKeyboardButtonTypeCallbackWithPasswordTypeID:
		// Decoding inlineKeyboardButtonTypeCallbackWithPassword#361f4248.
		v := InlineKeyboardButtonTypeCallbackWithPassword{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode InlineKeyboardButtonTypeClass: %w", err)
		}
		return &v, nil
	case InlineKeyboardButtonTypeCallbackGameTypeID:
		// Decoding inlineKeyboardButtonTypeCallbackGame#e9255468.
		v := InlineKeyboardButtonTypeCallbackGame{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode InlineKeyboardButtonTypeClass: %w", err)
		}
		return &v, nil
	case InlineKeyboardButtonTypeSwitchInlineTypeID:
		// Decoding inlineKeyboardButtonTypeSwitchInline#207a9cf5.
		v := InlineKeyboardButtonTypeSwitchInline{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode InlineKeyboardButtonTypeClass: %w", err)
		}
		return &v, nil
	case InlineKeyboardButtonTypeBuyTypeID:
		// Decoding inlineKeyboardButtonTypeBuy#511b3c70.
		v := InlineKeyboardButtonTypeBuy{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode InlineKeyboardButtonTypeClass: %w", err)
		}
		return &v, nil
	case InlineKeyboardButtonTypeUserTypeID:
		// Decoding inlineKeyboardButtonTypeUser#6d77e5a2.
		v := InlineKeyboardButtonTypeUser{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode InlineKeyboardButtonTypeClass: %w", err)
		}
		return &v, nil
	case InlineKeyboardButtonTypeCopyTextTypeID:
		// Decoding inlineKeyboardButtonTypeCopyText#41b1306.
		v := InlineKeyboardButtonTypeCopyText{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode InlineKeyboardButtonTypeClass: %w", err)
		}
		return &v, nil
	default:
		return nil, fmt.Errorf("unable to decode InlineKeyboardButtonTypeClass: %w", bin.NewUnexpectedID(id))
	}
}

// DecodeTDLibJSONInlineKeyboardButtonType implements binary de-serialization for InlineKeyboardButtonTypeClass.
func DecodeTDLibJSONInlineKeyboardButtonType(buf tdjson.Decoder) (InlineKeyboardButtonTypeClass, error) {
	id, err := buf.FindTypeID()
	if err != nil {
		return nil, err
	}
	switch id {
	case "inlineKeyboardButtonTypeUrl":
		// Decoding inlineKeyboardButtonTypeUrl#4365beac.
		v := InlineKeyboardButtonTypeURL{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode InlineKeyboardButtonTypeClass: %w", err)
		}
		return &v, nil
	case "inlineKeyboardButtonTypeLoginUrl":
		// Decoding inlineKeyboardButtonTypeLoginUrl#b8455fa7.
		v := InlineKeyboardButtonTypeLoginURL{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode InlineKeyboardButtonTypeClass: %w", err)
		}
		return &v, nil
	case "inlineKeyboardButtonTypeWebApp":
		// Decoding inlineKeyboardButtonTypeWebApp#96a685c8.
		v := InlineKeyboardButtonTypeWebApp{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode InlineKeyboardButtonTypeClass: %w", err)
		}
		return &v, nil
	case "inlineKeyboardButtonTypeCallback":
		// Decoding inlineKeyboardButtonTypeCallback#bccb7bfd.
		v := InlineKeyboardButtonTypeCallback{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode InlineKeyboardButtonTypeClass: %w", err)
		}
		return &v, nil
	case "inlineKeyboardButtonTypeCallbackWithPassword":
		// Decoding inlineKeyboardButtonTypeCallbackWithPassword#361f4248.
		v := InlineKeyboardButtonTypeCallbackWithPassword{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode InlineKeyboardButtonTypeClass: %w", err)
		}
		return &v, nil
	case "inlineKeyboardButtonTypeCallbackGame":
		// Decoding inlineKeyboardButtonTypeCallbackGame#e9255468.
		v := InlineKeyboardButtonTypeCallbackGame{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode InlineKeyboardButtonTypeClass: %w", err)
		}
		return &v, nil
	case "inlineKeyboardButtonTypeSwitchInline":
		// Decoding inlineKeyboardButtonTypeSwitchInline#207a9cf5.
		v := InlineKeyboardButtonTypeSwitchInline{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode InlineKeyboardButtonTypeClass: %w", err)
		}
		return &v, nil
	case "inlineKeyboardButtonTypeBuy":
		// Decoding inlineKeyboardButtonTypeBuy#511b3c70.
		v := InlineKeyboardButtonTypeBuy{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode InlineKeyboardButtonTypeClass: %w", err)
		}
		return &v, nil
	case "inlineKeyboardButtonTypeUser":
		// Decoding inlineKeyboardButtonTypeUser#6d77e5a2.
		v := InlineKeyboardButtonTypeUser{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode InlineKeyboardButtonTypeClass: %w", err)
		}
		return &v, nil
	case "inlineKeyboardButtonTypeCopyText":
		// Decoding inlineKeyboardButtonTypeCopyText#41b1306.
		v := InlineKeyboardButtonTypeCopyText{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode InlineKeyboardButtonTypeClass: %w", err)
		}
		return &v, nil
	default:
		return nil, fmt.Errorf("unable to decode InlineKeyboardButtonTypeClass: %w", tdjson.NewUnexpectedID(id))
	}
}

// InlineKeyboardButtonType boxes the InlineKeyboardButtonTypeClass providing a helper.
type InlineKeyboardButtonTypeBox struct {
	InlineKeyboardButtonType InlineKeyboardButtonTypeClass
}

// Decode implements bin.Decoder for InlineKeyboardButtonTypeBox.
func (b *InlineKeyboardButtonTypeBox) Decode(buf *bin.Buffer) error {
	if b == nil {
		return fmt.Errorf("unable to decode InlineKeyboardButtonTypeBox to nil")
	}
	v, err := DecodeInlineKeyboardButtonType(buf)
	if err != nil {
		return fmt.Errorf("unable to decode boxed value: %w", err)
	}
	b.InlineKeyboardButtonType = v
	return nil
}

// Encode implements bin.Encode for InlineKeyboardButtonTypeBox.
func (b *InlineKeyboardButtonTypeBox) Encode(buf *bin.Buffer) error {
	if b == nil || b.InlineKeyboardButtonType == nil {
		return fmt.Errorf("unable to encode InlineKeyboardButtonTypeClass as nil")
	}
	return b.InlineKeyboardButtonType.Encode(buf)
}

// DecodeTDLibJSON implements bin.Decoder for InlineKeyboardButtonTypeBox.
func (b *InlineKeyboardButtonTypeBox) DecodeTDLibJSON(buf tdjson.Decoder) error {
	if b == nil {
		return fmt.Errorf("unable to decode InlineKeyboardButtonTypeBox to nil")
	}
	v, err := DecodeTDLibJSONInlineKeyboardButtonType(buf)
	if err != nil {
		return fmt.Errorf("unable to decode boxed value: %w", err)
	}
	b.InlineKeyboardButtonType = v
	return nil
}

// EncodeTDLibJSON implements bin.Encode for InlineKeyboardButtonTypeBox.
func (b *InlineKeyboardButtonTypeBox) EncodeTDLibJSON(buf tdjson.Encoder) error {
	if b == nil || b.InlineKeyboardButtonType == nil {
		return fmt.Errorf("unable to encode InlineKeyboardButtonTypeClass as nil")
	}
	return b.InlineKeyboardButtonType.EncodeTDLibJSON(buf)
}
