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

// StarTransactionTypePremiumBotDeposit represents TL type `starTransactionTypePremiumBotDeposit#d879090e`.
type StarTransactionTypePremiumBotDeposit struct {
}

// StarTransactionTypePremiumBotDepositTypeID is TL type id of StarTransactionTypePremiumBotDeposit.
const StarTransactionTypePremiumBotDepositTypeID = 0xd879090e

// construct implements constructor of StarTransactionTypeClass.
func (s StarTransactionTypePremiumBotDeposit) construct() StarTransactionTypeClass { return &s }

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

	_ StarTransactionTypeClass = &StarTransactionTypePremiumBotDeposit{}
)

func (s *StarTransactionTypePremiumBotDeposit) Zero() bool {
	if s == nil {
		return true
	}

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (s *StarTransactionTypePremiumBotDeposit) Encode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypePremiumBotDeposit#d879090e as nil")
	}
	b.PutID(StarTransactionTypePremiumBotDepositTypeID)
	return s.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (s *StarTransactionTypePremiumBotDeposit) EncodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypePremiumBotDeposit#d879090e as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (s *StarTransactionTypePremiumBotDeposit) Decode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypePremiumBotDeposit#d879090e to nil")
	}
	if err := b.ConsumeID(StarTransactionTypePremiumBotDepositTypeID); err != nil {
		return fmt.Errorf("unable to decode starTransactionTypePremiumBotDeposit#d879090e: %w", err)
	}
	return s.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (s *StarTransactionTypePremiumBotDeposit) DecodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypePremiumBotDeposit#d879090e to nil")
	}
	return nil
}

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

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *StarTransactionTypePremiumBotDeposit) DecodeTDLibJSON(b tdjson.Decoder) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypePremiumBotDeposit#d879090e to nil")
	}

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

// StarTransactionTypeAppStoreDeposit represents TL type `starTransactionTypeAppStoreDeposit#8283941`.
type StarTransactionTypeAppStoreDeposit struct {
}

// StarTransactionTypeAppStoreDepositTypeID is TL type id of StarTransactionTypeAppStoreDeposit.
const StarTransactionTypeAppStoreDepositTypeID = 0x8283941

// construct implements constructor of StarTransactionTypeClass.
func (s StarTransactionTypeAppStoreDeposit) construct() StarTransactionTypeClass { return &s }

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

	_ StarTransactionTypeClass = &StarTransactionTypeAppStoreDeposit{}
)

func (s *StarTransactionTypeAppStoreDeposit) Zero() bool {
	if s == nil {
		return true
	}

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (s *StarTransactionTypeAppStoreDeposit) Encode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeAppStoreDeposit#8283941 as nil")
	}
	b.PutID(StarTransactionTypeAppStoreDepositTypeID)
	return s.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (s *StarTransactionTypeAppStoreDeposit) EncodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeAppStoreDeposit#8283941 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (s *StarTransactionTypeAppStoreDeposit) Decode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeAppStoreDeposit#8283941 to nil")
	}
	if err := b.ConsumeID(StarTransactionTypeAppStoreDepositTypeID); err != nil {
		return fmt.Errorf("unable to decode starTransactionTypeAppStoreDeposit#8283941: %w", err)
	}
	return s.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (s *StarTransactionTypeAppStoreDeposit) DecodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeAppStoreDeposit#8283941 to nil")
	}
	return nil
}

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

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *StarTransactionTypeAppStoreDeposit) DecodeTDLibJSON(b tdjson.Decoder) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeAppStoreDeposit#8283941 to nil")
	}

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

// StarTransactionTypeGooglePlayDeposit represents TL type `starTransactionTypeGooglePlayDeposit#ecbdb656`.
type StarTransactionTypeGooglePlayDeposit struct {
}

// StarTransactionTypeGooglePlayDepositTypeID is TL type id of StarTransactionTypeGooglePlayDeposit.
const StarTransactionTypeGooglePlayDepositTypeID = 0xecbdb656

// construct implements constructor of StarTransactionTypeClass.
func (s StarTransactionTypeGooglePlayDeposit) construct() StarTransactionTypeClass { return &s }

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

	_ StarTransactionTypeClass = &StarTransactionTypeGooglePlayDeposit{}
)

func (s *StarTransactionTypeGooglePlayDeposit) Zero() bool {
	if s == nil {
		return true
	}

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (s *StarTransactionTypeGooglePlayDeposit) Encode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeGooglePlayDeposit#ecbdb656 as nil")
	}
	b.PutID(StarTransactionTypeGooglePlayDepositTypeID)
	return s.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (s *StarTransactionTypeGooglePlayDeposit) EncodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeGooglePlayDeposit#ecbdb656 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (s *StarTransactionTypeGooglePlayDeposit) Decode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeGooglePlayDeposit#ecbdb656 to nil")
	}
	if err := b.ConsumeID(StarTransactionTypeGooglePlayDepositTypeID); err != nil {
		return fmt.Errorf("unable to decode starTransactionTypeGooglePlayDeposit#ecbdb656: %w", err)
	}
	return s.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (s *StarTransactionTypeGooglePlayDeposit) DecodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeGooglePlayDeposit#ecbdb656 to nil")
	}
	return nil
}

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

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *StarTransactionTypeGooglePlayDeposit) DecodeTDLibJSON(b tdjson.Decoder) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeGooglePlayDeposit#ecbdb656 to nil")
	}

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

// StarTransactionTypeFragmentDeposit represents TL type `starTransactionTypeFragmentDeposit#7625e44`.
type StarTransactionTypeFragmentDeposit struct {
}

// StarTransactionTypeFragmentDepositTypeID is TL type id of StarTransactionTypeFragmentDeposit.
const StarTransactionTypeFragmentDepositTypeID = 0x7625e44

// construct implements constructor of StarTransactionTypeClass.
func (s StarTransactionTypeFragmentDeposit) construct() StarTransactionTypeClass { return &s }

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

	_ StarTransactionTypeClass = &StarTransactionTypeFragmentDeposit{}
)

func (s *StarTransactionTypeFragmentDeposit) Zero() bool {
	if s == nil {
		return true
	}

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (s *StarTransactionTypeFragmentDeposit) Encode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeFragmentDeposit#7625e44 as nil")
	}
	b.PutID(StarTransactionTypeFragmentDepositTypeID)
	return s.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (s *StarTransactionTypeFragmentDeposit) EncodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeFragmentDeposit#7625e44 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (s *StarTransactionTypeFragmentDeposit) Decode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeFragmentDeposit#7625e44 to nil")
	}
	if err := b.ConsumeID(StarTransactionTypeFragmentDepositTypeID); err != nil {
		return fmt.Errorf("unable to decode starTransactionTypeFragmentDeposit#7625e44: %w", err)
	}
	return s.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (s *StarTransactionTypeFragmentDeposit) DecodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeFragmentDeposit#7625e44 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (s *StarTransactionTypeFragmentDeposit) EncodeTDLibJSON(b tdjson.Encoder) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeFragmentDeposit#7625e44 as nil")
	}
	b.ObjStart()
	b.PutID("starTransactionTypeFragmentDeposit")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *StarTransactionTypeFragmentDeposit) DecodeTDLibJSON(b tdjson.Decoder) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeFragmentDeposit#7625e44 to nil")
	}

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

// StarTransactionTypeUserDeposit represents TL type `starTransactionTypeUserDeposit#c2a18e9`.
type StarTransactionTypeUserDeposit struct {
	// Identifier of the user that gifted Telegram Stars; 0 if the user was anonymous
	UserID int64
	// The sticker to be shown in the transaction information; may be null if unknown
	Sticker Sticker
}

// StarTransactionTypeUserDepositTypeID is TL type id of StarTransactionTypeUserDeposit.
const StarTransactionTypeUserDepositTypeID = 0xc2a18e9

// construct implements constructor of StarTransactionTypeClass.
func (s StarTransactionTypeUserDeposit) construct() StarTransactionTypeClass { return &s }

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

	_ StarTransactionTypeClass = &StarTransactionTypeUserDeposit{}
)

func (s *StarTransactionTypeUserDeposit) Zero() bool {
	if s == nil {
		return true
	}
	if !(s.UserID == 0) {
		return false
	}
	if !(s.Sticker.Zero()) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (s *StarTransactionTypeUserDeposit) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "starTransactionTypeUserDeposit",
		ID:   StarTransactionTypeUserDepositTypeID,
	}
	if s == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "UserID",
			SchemaName: "user_id",
		},
		{
			Name:       "Sticker",
			SchemaName: "sticker",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (s *StarTransactionTypeUserDeposit) Encode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeUserDeposit#c2a18e9 as nil")
	}
	b.PutID(StarTransactionTypeUserDepositTypeID)
	return s.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (s *StarTransactionTypeUserDeposit) EncodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeUserDeposit#c2a18e9 as nil")
	}
	b.PutInt53(s.UserID)
	if err := s.Sticker.Encode(b); err != nil {
		return fmt.Errorf("unable to encode starTransactionTypeUserDeposit#c2a18e9: field sticker: %w", err)
	}
	return nil
}

// Decode implements bin.Decoder.
func (s *StarTransactionTypeUserDeposit) Decode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeUserDeposit#c2a18e9 to nil")
	}
	if err := b.ConsumeID(StarTransactionTypeUserDepositTypeID); err != nil {
		return fmt.Errorf("unable to decode starTransactionTypeUserDeposit#c2a18e9: %w", err)
	}
	return s.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (s *StarTransactionTypeUserDeposit) DecodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeUserDeposit#c2a18e9 to nil")
	}
	{
		value, err := b.Int53()
		if err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeUserDeposit#c2a18e9: field user_id: %w", err)
		}
		s.UserID = value
	}
	{
		if err := s.Sticker.Decode(b); err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeUserDeposit#c2a18e9: field sticker: %w", err)
		}
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (s *StarTransactionTypeUserDeposit) EncodeTDLibJSON(b tdjson.Encoder) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeUserDeposit#c2a18e9 as nil")
	}
	b.ObjStart()
	b.PutID("starTransactionTypeUserDeposit")
	b.Comma()
	b.FieldStart("user_id")
	b.PutInt53(s.UserID)
	b.Comma()
	b.FieldStart("sticker")
	if err := s.Sticker.EncodeTDLibJSON(b); err != nil {
		return fmt.Errorf("unable to encode starTransactionTypeUserDeposit#c2a18e9: field sticker: %w", err)
	}
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *StarTransactionTypeUserDeposit) DecodeTDLibJSON(b tdjson.Decoder) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeUserDeposit#c2a18e9 to nil")
	}

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

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

// GetSticker returns value of Sticker field.
func (s *StarTransactionTypeUserDeposit) GetSticker() (value Sticker) {
	if s == nil {
		return
	}
	return s.Sticker
}

// StarTransactionTypeGiveawayDeposit represents TL type `starTransactionTypeGiveawayDeposit#b16200c6`.
type StarTransactionTypeGiveawayDeposit struct {
	// Identifier of a supergroup or a channel chat that created the giveaway
	ChatID int64
	// Identifier of the message with the giveaway; can be 0 or an identifier of a deleted
	// message
	GiveawayMessageID int64
}

// StarTransactionTypeGiveawayDepositTypeID is TL type id of StarTransactionTypeGiveawayDeposit.
const StarTransactionTypeGiveawayDepositTypeID = 0xb16200c6

// construct implements constructor of StarTransactionTypeClass.
func (s StarTransactionTypeGiveawayDeposit) construct() StarTransactionTypeClass { return &s }

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

	_ StarTransactionTypeClass = &StarTransactionTypeGiveawayDeposit{}
)

func (s *StarTransactionTypeGiveawayDeposit) Zero() bool {
	if s == nil {
		return true
	}
	if !(s.ChatID == 0) {
		return false
	}
	if !(s.GiveawayMessageID == 0) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (s *StarTransactionTypeGiveawayDeposit) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "starTransactionTypeGiveawayDeposit",
		ID:   StarTransactionTypeGiveawayDepositTypeID,
	}
	if s == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "ChatID",
			SchemaName: "chat_id",
		},
		{
			Name:       "GiveawayMessageID",
			SchemaName: "giveaway_message_id",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (s *StarTransactionTypeGiveawayDeposit) Encode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeGiveawayDeposit#b16200c6 as nil")
	}
	b.PutID(StarTransactionTypeGiveawayDepositTypeID)
	return s.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (s *StarTransactionTypeGiveawayDeposit) EncodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeGiveawayDeposit#b16200c6 as nil")
	}
	b.PutInt53(s.ChatID)
	b.PutInt53(s.GiveawayMessageID)
	return nil
}

// Decode implements bin.Decoder.
func (s *StarTransactionTypeGiveawayDeposit) Decode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeGiveawayDeposit#b16200c6 to nil")
	}
	if err := b.ConsumeID(StarTransactionTypeGiveawayDepositTypeID); err != nil {
		return fmt.Errorf("unable to decode starTransactionTypeGiveawayDeposit#b16200c6: %w", err)
	}
	return s.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (s *StarTransactionTypeGiveawayDeposit) DecodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeGiveawayDeposit#b16200c6 to nil")
	}
	{
		value, err := b.Int53()
		if err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeGiveawayDeposit#b16200c6: field chat_id: %w", err)
		}
		s.ChatID = value
	}
	{
		value, err := b.Int53()
		if err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeGiveawayDeposit#b16200c6: field giveaway_message_id: %w", err)
		}
		s.GiveawayMessageID = value
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (s *StarTransactionTypeGiveawayDeposit) EncodeTDLibJSON(b tdjson.Encoder) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeGiveawayDeposit#b16200c6 as nil")
	}
	b.ObjStart()
	b.PutID("starTransactionTypeGiveawayDeposit")
	b.Comma()
	b.FieldStart("chat_id")
	b.PutInt53(s.ChatID)
	b.Comma()
	b.FieldStart("giveaway_message_id")
	b.PutInt53(s.GiveawayMessageID)
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *StarTransactionTypeGiveawayDeposit) DecodeTDLibJSON(b tdjson.Decoder) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeGiveawayDeposit#b16200c6 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("starTransactionTypeGiveawayDeposit"); err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeGiveawayDeposit#b16200c6: %w", err)
			}
		case "chat_id":
			value, err := b.Int53()
			if err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeGiveawayDeposit#b16200c6: field chat_id: %w", err)
			}
			s.ChatID = value
		case "giveaway_message_id":
			value, err := b.Int53()
			if err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeGiveawayDeposit#b16200c6: field giveaway_message_id: %w", err)
			}
			s.GiveawayMessageID = value
		default:
			return b.Skip()
		}
		return nil
	})
}

// GetChatID returns value of ChatID field.
func (s *StarTransactionTypeGiveawayDeposit) GetChatID() (value int64) {
	if s == nil {
		return
	}
	return s.ChatID
}

// GetGiveawayMessageID returns value of GiveawayMessageID field.
func (s *StarTransactionTypeGiveawayDeposit) GetGiveawayMessageID() (value int64) {
	if s == nil {
		return
	}
	return s.GiveawayMessageID
}

// StarTransactionTypeFragmentWithdrawal represents TL type `starTransactionTypeFragmentWithdrawal#af3a2992`.
type StarTransactionTypeFragmentWithdrawal struct {
	// State of the withdrawal; may be null for refunds from Fragment
	WithdrawalState RevenueWithdrawalStateClass
}

// StarTransactionTypeFragmentWithdrawalTypeID is TL type id of StarTransactionTypeFragmentWithdrawal.
const StarTransactionTypeFragmentWithdrawalTypeID = 0xaf3a2992

// construct implements constructor of StarTransactionTypeClass.
func (s StarTransactionTypeFragmentWithdrawal) construct() StarTransactionTypeClass { return &s }

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

	_ StarTransactionTypeClass = &StarTransactionTypeFragmentWithdrawal{}
)

func (s *StarTransactionTypeFragmentWithdrawal) Zero() bool {
	if s == nil {
		return true
	}
	if !(s.WithdrawalState == nil) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (s *StarTransactionTypeFragmentWithdrawal) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "starTransactionTypeFragmentWithdrawal",
		ID:   StarTransactionTypeFragmentWithdrawalTypeID,
	}
	if s == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "WithdrawalState",
			SchemaName: "withdrawal_state",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (s *StarTransactionTypeFragmentWithdrawal) Encode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeFragmentWithdrawal#af3a2992 as nil")
	}
	b.PutID(StarTransactionTypeFragmentWithdrawalTypeID)
	return s.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (s *StarTransactionTypeFragmentWithdrawal) EncodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeFragmentWithdrawal#af3a2992 as nil")
	}
	if s.WithdrawalState == nil {
		return fmt.Errorf("unable to encode starTransactionTypeFragmentWithdrawal#af3a2992: field withdrawal_state is nil")
	}
	if err := s.WithdrawalState.Encode(b); err != nil {
		return fmt.Errorf("unable to encode starTransactionTypeFragmentWithdrawal#af3a2992: field withdrawal_state: %w", err)
	}
	return nil
}

// Decode implements bin.Decoder.
func (s *StarTransactionTypeFragmentWithdrawal) Decode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeFragmentWithdrawal#af3a2992 to nil")
	}
	if err := b.ConsumeID(StarTransactionTypeFragmentWithdrawalTypeID); err != nil {
		return fmt.Errorf("unable to decode starTransactionTypeFragmentWithdrawal#af3a2992: %w", err)
	}
	return s.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (s *StarTransactionTypeFragmentWithdrawal) DecodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeFragmentWithdrawal#af3a2992 to nil")
	}
	{
		value, err := DecodeRevenueWithdrawalState(b)
		if err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeFragmentWithdrawal#af3a2992: field withdrawal_state: %w", err)
		}
		s.WithdrawalState = value
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (s *StarTransactionTypeFragmentWithdrawal) EncodeTDLibJSON(b tdjson.Encoder) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeFragmentWithdrawal#af3a2992 as nil")
	}
	b.ObjStart()
	b.PutID("starTransactionTypeFragmentWithdrawal")
	b.Comma()
	b.FieldStart("withdrawal_state")
	if s.WithdrawalState == nil {
		return fmt.Errorf("unable to encode starTransactionTypeFragmentWithdrawal#af3a2992: field withdrawal_state is nil")
	}
	if err := s.WithdrawalState.EncodeTDLibJSON(b); err != nil {
		return fmt.Errorf("unable to encode starTransactionTypeFragmentWithdrawal#af3a2992: field withdrawal_state: %w", err)
	}
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *StarTransactionTypeFragmentWithdrawal) DecodeTDLibJSON(b tdjson.Decoder) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeFragmentWithdrawal#af3a2992 to nil")
	}

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

// GetWithdrawalState returns value of WithdrawalState field.
func (s *StarTransactionTypeFragmentWithdrawal) GetWithdrawalState() (value RevenueWithdrawalStateClass) {
	if s == nil {
		return
	}
	return s.WithdrawalState
}

// StarTransactionTypeTelegramAdsWithdrawal represents TL type `starTransactionTypeTelegramAdsWithdrawal#a58e8469`.
type StarTransactionTypeTelegramAdsWithdrawal struct {
}

// StarTransactionTypeTelegramAdsWithdrawalTypeID is TL type id of StarTransactionTypeTelegramAdsWithdrawal.
const StarTransactionTypeTelegramAdsWithdrawalTypeID = 0xa58e8469

// construct implements constructor of StarTransactionTypeClass.
func (s StarTransactionTypeTelegramAdsWithdrawal) construct() StarTransactionTypeClass { return &s }

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

	_ StarTransactionTypeClass = &StarTransactionTypeTelegramAdsWithdrawal{}
)

func (s *StarTransactionTypeTelegramAdsWithdrawal) Zero() bool {
	if s == nil {
		return true
	}

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (s *StarTransactionTypeTelegramAdsWithdrawal) Encode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeTelegramAdsWithdrawal#a58e8469 as nil")
	}
	b.PutID(StarTransactionTypeTelegramAdsWithdrawalTypeID)
	return s.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (s *StarTransactionTypeTelegramAdsWithdrawal) EncodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeTelegramAdsWithdrawal#a58e8469 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (s *StarTransactionTypeTelegramAdsWithdrawal) Decode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeTelegramAdsWithdrawal#a58e8469 to nil")
	}
	if err := b.ConsumeID(StarTransactionTypeTelegramAdsWithdrawalTypeID); err != nil {
		return fmt.Errorf("unable to decode starTransactionTypeTelegramAdsWithdrawal#a58e8469: %w", err)
	}
	return s.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (s *StarTransactionTypeTelegramAdsWithdrawal) DecodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeTelegramAdsWithdrawal#a58e8469 to nil")
	}
	return nil
}

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

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *StarTransactionTypeTelegramAdsWithdrawal) DecodeTDLibJSON(b tdjson.Decoder) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeTelegramAdsWithdrawal#a58e8469 to nil")
	}

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

// StarTransactionTypeTelegramAPIUsage represents TL type `starTransactionTypeTelegramApiUsage#27a82afe`.
type StarTransactionTypeTelegramAPIUsage struct {
	// The number of billed requests
	RequestCount int32
}

// StarTransactionTypeTelegramAPIUsageTypeID is TL type id of StarTransactionTypeTelegramAPIUsage.
const StarTransactionTypeTelegramAPIUsageTypeID = 0x27a82afe

// construct implements constructor of StarTransactionTypeClass.
func (s StarTransactionTypeTelegramAPIUsage) construct() StarTransactionTypeClass { return &s }

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

	_ StarTransactionTypeClass = &StarTransactionTypeTelegramAPIUsage{}
)

func (s *StarTransactionTypeTelegramAPIUsage) Zero() bool {
	if s == nil {
		return true
	}
	if !(s.RequestCount == 0) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (s *StarTransactionTypeTelegramAPIUsage) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "starTransactionTypeTelegramApiUsage",
		ID:   StarTransactionTypeTelegramAPIUsageTypeID,
	}
	if s == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "RequestCount",
			SchemaName: "request_count",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (s *StarTransactionTypeTelegramAPIUsage) Encode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeTelegramApiUsage#27a82afe as nil")
	}
	b.PutID(StarTransactionTypeTelegramAPIUsageTypeID)
	return s.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (s *StarTransactionTypeTelegramAPIUsage) EncodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeTelegramApiUsage#27a82afe as nil")
	}
	b.PutInt32(s.RequestCount)
	return nil
}

// Decode implements bin.Decoder.
func (s *StarTransactionTypeTelegramAPIUsage) Decode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeTelegramApiUsage#27a82afe to nil")
	}
	if err := b.ConsumeID(StarTransactionTypeTelegramAPIUsageTypeID); err != nil {
		return fmt.Errorf("unable to decode starTransactionTypeTelegramApiUsage#27a82afe: %w", err)
	}
	return s.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (s *StarTransactionTypeTelegramAPIUsage) DecodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeTelegramApiUsage#27a82afe to nil")
	}
	{
		value, err := b.Int32()
		if err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeTelegramApiUsage#27a82afe: field request_count: %w", err)
		}
		s.RequestCount = value
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (s *StarTransactionTypeTelegramAPIUsage) EncodeTDLibJSON(b tdjson.Encoder) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeTelegramApiUsage#27a82afe as nil")
	}
	b.ObjStart()
	b.PutID("starTransactionTypeTelegramApiUsage")
	b.Comma()
	b.FieldStart("request_count")
	b.PutInt32(s.RequestCount)
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *StarTransactionTypeTelegramAPIUsage) DecodeTDLibJSON(b tdjson.Decoder) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeTelegramApiUsage#27a82afe to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("starTransactionTypeTelegramApiUsage"); err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeTelegramApiUsage#27a82afe: %w", err)
			}
		case "request_count":
			value, err := b.Int32()
			if err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeTelegramApiUsage#27a82afe: field request_count: %w", err)
			}
			s.RequestCount = value
		default:
			return b.Skip()
		}
		return nil
	})
}

// GetRequestCount returns value of RequestCount field.
func (s *StarTransactionTypeTelegramAPIUsage) GetRequestCount() (value int32) {
	if s == nil {
		return
	}
	return s.RequestCount
}

// StarTransactionTypeBotPaidMediaPurchase represents TL type `starTransactionTypeBotPaidMediaPurchase#7f48cc6a`.
type StarTransactionTypeBotPaidMediaPurchase struct {
	// Identifier of the bot or the business account user that sent the paid media
	UserID int64
	// The bought media if the transaction wasn't refunded
	Media []PaidMediaClass
}

// StarTransactionTypeBotPaidMediaPurchaseTypeID is TL type id of StarTransactionTypeBotPaidMediaPurchase.
const StarTransactionTypeBotPaidMediaPurchaseTypeID = 0x7f48cc6a

// construct implements constructor of StarTransactionTypeClass.
func (s StarTransactionTypeBotPaidMediaPurchase) construct() StarTransactionTypeClass { return &s }

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

	_ StarTransactionTypeClass = &StarTransactionTypeBotPaidMediaPurchase{}
)

func (s *StarTransactionTypeBotPaidMediaPurchase) Zero() bool {
	if s == nil {
		return true
	}
	if !(s.UserID == 0) {
		return false
	}
	if !(s.Media == nil) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (s *StarTransactionTypeBotPaidMediaPurchase) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "starTransactionTypeBotPaidMediaPurchase",
		ID:   StarTransactionTypeBotPaidMediaPurchaseTypeID,
	}
	if s == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "UserID",
			SchemaName: "user_id",
		},
		{
			Name:       "Media",
			SchemaName: "media",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (s *StarTransactionTypeBotPaidMediaPurchase) Encode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeBotPaidMediaPurchase#7f48cc6a as nil")
	}
	b.PutID(StarTransactionTypeBotPaidMediaPurchaseTypeID)
	return s.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (s *StarTransactionTypeBotPaidMediaPurchase) EncodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeBotPaidMediaPurchase#7f48cc6a as nil")
	}
	b.PutInt53(s.UserID)
	b.PutInt(len(s.Media))
	for idx, v := range s.Media {
		if v == nil {
			return fmt.Errorf("unable to encode starTransactionTypeBotPaidMediaPurchase#7f48cc6a: field media element with index %d is nil", idx)
		}
		if err := v.EncodeBare(b); err != nil {
			return fmt.Errorf("unable to encode bare starTransactionTypeBotPaidMediaPurchase#7f48cc6a: field media element with index %d: %w", idx, err)
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func (s *StarTransactionTypeBotPaidMediaPurchase) Decode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeBotPaidMediaPurchase#7f48cc6a to nil")
	}
	if err := b.ConsumeID(StarTransactionTypeBotPaidMediaPurchaseTypeID); err != nil {
		return fmt.Errorf("unable to decode starTransactionTypeBotPaidMediaPurchase#7f48cc6a: %w", err)
	}
	return s.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (s *StarTransactionTypeBotPaidMediaPurchase) DecodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeBotPaidMediaPurchase#7f48cc6a to nil")
	}
	{
		value, err := b.Int53()
		if err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeBotPaidMediaPurchase#7f48cc6a: field user_id: %w", err)
		}
		s.UserID = value
	}
	{
		headerLen, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeBotPaidMediaPurchase#7f48cc6a: field media: %w", err)
		}

		if headerLen > 0 {
			s.Media = make([]PaidMediaClass, 0, headerLen%bin.PreallocateLimit)
		}
		for idx := 0; idx < headerLen; idx++ {
			value, err := DecodePaidMedia(b)
			if err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeBotPaidMediaPurchase#7f48cc6a: field media: %w", err)
			}
			s.Media = append(s.Media, value)
		}
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (s *StarTransactionTypeBotPaidMediaPurchase) EncodeTDLibJSON(b tdjson.Encoder) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeBotPaidMediaPurchase#7f48cc6a as nil")
	}
	b.ObjStart()
	b.PutID("starTransactionTypeBotPaidMediaPurchase")
	b.Comma()
	b.FieldStart("user_id")
	b.PutInt53(s.UserID)
	b.Comma()
	b.FieldStart("media")
	b.ArrStart()
	for idx, v := range s.Media {
		if v == nil {
			return fmt.Errorf("unable to encode starTransactionTypeBotPaidMediaPurchase#7f48cc6a: field media element with index %d is nil", idx)
		}
		if err := v.EncodeTDLibJSON(b); err != nil {
			return fmt.Errorf("unable to encode starTransactionTypeBotPaidMediaPurchase#7f48cc6a: field media element with index %d: %w", idx, err)
		}
		b.Comma()
	}
	b.StripComma()
	b.ArrEnd()
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *StarTransactionTypeBotPaidMediaPurchase) DecodeTDLibJSON(b tdjson.Decoder) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeBotPaidMediaPurchase#7f48cc6a to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("starTransactionTypeBotPaidMediaPurchase"); err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeBotPaidMediaPurchase#7f48cc6a: %w", err)
			}
		case "user_id":
			value, err := b.Int53()
			if err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeBotPaidMediaPurchase#7f48cc6a: field user_id: %w", err)
			}
			s.UserID = value
		case "media":
			if err := b.Arr(func(b tdjson.Decoder) error {
				value, err := DecodeTDLibJSONPaidMedia(b)
				if err != nil {
					return fmt.Errorf("unable to decode starTransactionTypeBotPaidMediaPurchase#7f48cc6a: field media: %w", err)
				}
				s.Media = append(s.Media, value)
				return nil
			}); err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeBotPaidMediaPurchase#7f48cc6a: field media: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

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

// GetMedia returns value of Media field.
func (s *StarTransactionTypeBotPaidMediaPurchase) GetMedia() (value []PaidMediaClass) {
	if s == nil {
		return
	}
	return s.Media
}

// StarTransactionTypeBotPaidMediaSale represents TL type `starTransactionTypeBotPaidMediaSale#6e07eeb2`.
type StarTransactionTypeBotPaidMediaSale struct {
	// Identifier of the user that bought the media
	UserID int64
	// The bought media
	Media []PaidMediaClass
	// Bot-provided payload
	Payload string
	// Information about the affiliate which received commission from the transaction; may be
	// null if none
	Affiliate AffiliateInfo
}

// StarTransactionTypeBotPaidMediaSaleTypeID is TL type id of StarTransactionTypeBotPaidMediaSale.
const StarTransactionTypeBotPaidMediaSaleTypeID = 0x6e07eeb2

// construct implements constructor of StarTransactionTypeClass.
func (s StarTransactionTypeBotPaidMediaSale) construct() StarTransactionTypeClass { return &s }

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

	_ StarTransactionTypeClass = &StarTransactionTypeBotPaidMediaSale{}
)

func (s *StarTransactionTypeBotPaidMediaSale) Zero() bool {
	if s == nil {
		return true
	}
	if !(s.UserID == 0) {
		return false
	}
	if !(s.Media == nil) {
		return false
	}
	if !(s.Payload == "") {
		return false
	}
	if !(s.Affiliate.Zero()) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (s *StarTransactionTypeBotPaidMediaSale) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "starTransactionTypeBotPaidMediaSale",
		ID:   StarTransactionTypeBotPaidMediaSaleTypeID,
	}
	if s == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "UserID",
			SchemaName: "user_id",
		},
		{
			Name:       "Media",
			SchemaName: "media",
		},
		{
			Name:       "Payload",
			SchemaName: "payload",
		},
		{
			Name:       "Affiliate",
			SchemaName: "affiliate",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (s *StarTransactionTypeBotPaidMediaSale) Encode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeBotPaidMediaSale#6e07eeb2 as nil")
	}
	b.PutID(StarTransactionTypeBotPaidMediaSaleTypeID)
	return s.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (s *StarTransactionTypeBotPaidMediaSale) EncodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeBotPaidMediaSale#6e07eeb2 as nil")
	}
	b.PutInt53(s.UserID)
	b.PutInt(len(s.Media))
	for idx, v := range s.Media {
		if v == nil {
			return fmt.Errorf("unable to encode starTransactionTypeBotPaidMediaSale#6e07eeb2: field media element with index %d is nil", idx)
		}
		if err := v.EncodeBare(b); err != nil {
			return fmt.Errorf("unable to encode bare starTransactionTypeBotPaidMediaSale#6e07eeb2: field media element with index %d: %w", idx, err)
		}
	}
	b.PutString(s.Payload)
	if err := s.Affiliate.Encode(b); err != nil {
		return fmt.Errorf("unable to encode starTransactionTypeBotPaidMediaSale#6e07eeb2: field affiliate: %w", err)
	}
	return nil
}

// Decode implements bin.Decoder.
func (s *StarTransactionTypeBotPaidMediaSale) Decode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeBotPaidMediaSale#6e07eeb2 to nil")
	}
	if err := b.ConsumeID(StarTransactionTypeBotPaidMediaSaleTypeID); err != nil {
		return fmt.Errorf("unable to decode starTransactionTypeBotPaidMediaSale#6e07eeb2: %w", err)
	}
	return s.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (s *StarTransactionTypeBotPaidMediaSale) DecodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeBotPaidMediaSale#6e07eeb2 to nil")
	}
	{
		value, err := b.Int53()
		if err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeBotPaidMediaSale#6e07eeb2: field user_id: %w", err)
		}
		s.UserID = value
	}
	{
		headerLen, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeBotPaidMediaSale#6e07eeb2: field media: %w", err)
		}

		if headerLen > 0 {
			s.Media = make([]PaidMediaClass, 0, headerLen%bin.PreallocateLimit)
		}
		for idx := 0; idx < headerLen; idx++ {
			value, err := DecodePaidMedia(b)
			if err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeBotPaidMediaSale#6e07eeb2: field media: %w", err)
			}
			s.Media = append(s.Media, value)
		}
	}
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeBotPaidMediaSale#6e07eeb2: field payload: %w", err)
		}
		s.Payload = value
	}
	{
		if err := s.Affiliate.Decode(b); err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeBotPaidMediaSale#6e07eeb2: field affiliate: %w", err)
		}
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (s *StarTransactionTypeBotPaidMediaSale) EncodeTDLibJSON(b tdjson.Encoder) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeBotPaidMediaSale#6e07eeb2 as nil")
	}
	b.ObjStart()
	b.PutID("starTransactionTypeBotPaidMediaSale")
	b.Comma()
	b.FieldStart("user_id")
	b.PutInt53(s.UserID)
	b.Comma()
	b.FieldStart("media")
	b.ArrStart()
	for idx, v := range s.Media {
		if v == nil {
			return fmt.Errorf("unable to encode starTransactionTypeBotPaidMediaSale#6e07eeb2: field media element with index %d is nil", idx)
		}
		if err := v.EncodeTDLibJSON(b); err != nil {
			return fmt.Errorf("unable to encode starTransactionTypeBotPaidMediaSale#6e07eeb2: field media element with index %d: %w", idx, err)
		}
		b.Comma()
	}
	b.StripComma()
	b.ArrEnd()
	b.Comma()
	b.FieldStart("payload")
	b.PutString(s.Payload)
	b.Comma()
	b.FieldStart("affiliate")
	if err := s.Affiliate.EncodeTDLibJSON(b); err != nil {
		return fmt.Errorf("unable to encode starTransactionTypeBotPaidMediaSale#6e07eeb2: field affiliate: %w", err)
	}
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *StarTransactionTypeBotPaidMediaSale) DecodeTDLibJSON(b tdjson.Decoder) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeBotPaidMediaSale#6e07eeb2 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("starTransactionTypeBotPaidMediaSale"); err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeBotPaidMediaSale#6e07eeb2: %w", err)
			}
		case "user_id":
			value, err := b.Int53()
			if err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeBotPaidMediaSale#6e07eeb2: field user_id: %w", err)
			}
			s.UserID = value
		case "media":
			if err := b.Arr(func(b tdjson.Decoder) error {
				value, err := DecodeTDLibJSONPaidMedia(b)
				if err != nil {
					return fmt.Errorf("unable to decode starTransactionTypeBotPaidMediaSale#6e07eeb2: field media: %w", err)
				}
				s.Media = append(s.Media, value)
				return nil
			}); err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeBotPaidMediaSale#6e07eeb2: field media: %w", err)
			}
		case "payload":
			value, err := b.String()
			if err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeBotPaidMediaSale#6e07eeb2: field payload: %w", err)
			}
			s.Payload = value
		case "affiliate":
			if err := s.Affiliate.DecodeTDLibJSON(b); err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeBotPaidMediaSale#6e07eeb2: field affiliate: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

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

// GetMedia returns value of Media field.
func (s *StarTransactionTypeBotPaidMediaSale) GetMedia() (value []PaidMediaClass) {
	if s == nil {
		return
	}
	return s.Media
}

// GetPayload returns value of Payload field.
func (s *StarTransactionTypeBotPaidMediaSale) GetPayload() (value string) {
	if s == nil {
		return
	}
	return s.Payload
}

// GetAffiliate returns value of Affiliate field.
func (s *StarTransactionTypeBotPaidMediaSale) GetAffiliate() (value AffiliateInfo) {
	if s == nil {
		return
	}
	return s.Affiliate
}

// StarTransactionTypeChannelPaidMediaPurchase represents TL type `starTransactionTypeChannelPaidMediaPurchase#9016d4f5`.
type StarTransactionTypeChannelPaidMediaPurchase struct {
	// Identifier of the channel chat that sent the paid media
	ChatID int64
	// Identifier of the corresponding message with paid media; can be 0 or an identifier of
	// a deleted message
	MessageID int64
	// The bought media if the transaction wasn't refunded
	Media []PaidMediaClass
}

// StarTransactionTypeChannelPaidMediaPurchaseTypeID is TL type id of StarTransactionTypeChannelPaidMediaPurchase.
const StarTransactionTypeChannelPaidMediaPurchaseTypeID = 0x9016d4f5

// construct implements constructor of StarTransactionTypeClass.
func (s StarTransactionTypeChannelPaidMediaPurchase) construct() StarTransactionTypeClass { return &s }

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

	_ StarTransactionTypeClass = &StarTransactionTypeChannelPaidMediaPurchase{}
)

func (s *StarTransactionTypeChannelPaidMediaPurchase) Zero() bool {
	if s == nil {
		return true
	}
	if !(s.ChatID == 0) {
		return false
	}
	if !(s.MessageID == 0) {
		return false
	}
	if !(s.Media == nil) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (s *StarTransactionTypeChannelPaidMediaPurchase) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "starTransactionTypeChannelPaidMediaPurchase",
		ID:   StarTransactionTypeChannelPaidMediaPurchaseTypeID,
	}
	if s == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "ChatID",
			SchemaName: "chat_id",
		},
		{
			Name:       "MessageID",
			SchemaName: "message_id",
		},
		{
			Name:       "Media",
			SchemaName: "media",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (s *StarTransactionTypeChannelPaidMediaPurchase) Encode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeChannelPaidMediaPurchase#9016d4f5 as nil")
	}
	b.PutID(StarTransactionTypeChannelPaidMediaPurchaseTypeID)
	return s.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (s *StarTransactionTypeChannelPaidMediaPurchase) EncodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeChannelPaidMediaPurchase#9016d4f5 as nil")
	}
	b.PutInt53(s.ChatID)
	b.PutInt53(s.MessageID)
	b.PutInt(len(s.Media))
	for idx, v := range s.Media {
		if v == nil {
			return fmt.Errorf("unable to encode starTransactionTypeChannelPaidMediaPurchase#9016d4f5: field media element with index %d is nil", idx)
		}
		if err := v.EncodeBare(b); err != nil {
			return fmt.Errorf("unable to encode bare starTransactionTypeChannelPaidMediaPurchase#9016d4f5: field media element with index %d: %w", idx, err)
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func (s *StarTransactionTypeChannelPaidMediaPurchase) Decode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeChannelPaidMediaPurchase#9016d4f5 to nil")
	}
	if err := b.ConsumeID(StarTransactionTypeChannelPaidMediaPurchaseTypeID); err != nil {
		return fmt.Errorf("unable to decode starTransactionTypeChannelPaidMediaPurchase#9016d4f5: %w", err)
	}
	return s.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (s *StarTransactionTypeChannelPaidMediaPurchase) DecodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeChannelPaidMediaPurchase#9016d4f5 to nil")
	}
	{
		value, err := b.Int53()
		if err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeChannelPaidMediaPurchase#9016d4f5: field chat_id: %w", err)
		}
		s.ChatID = value
	}
	{
		value, err := b.Int53()
		if err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeChannelPaidMediaPurchase#9016d4f5: field message_id: %w", err)
		}
		s.MessageID = value
	}
	{
		headerLen, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeChannelPaidMediaPurchase#9016d4f5: field media: %w", err)
		}

		if headerLen > 0 {
			s.Media = make([]PaidMediaClass, 0, headerLen%bin.PreallocateLimit)
		}
		for idx := 0; idx < headerLen; idx++ {
			value, err := DecodePaidMedia(b)
			if err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeChannelPaidMediaPurchase#9016d4f5: field media: %w", err)
			}
			s.Media = append(s.Media, value)
		}
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (s *StarTransactionTypeChannelPaidMediaPurchase) EncodeTDLibJSON(b tdjson.Encoder) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeChannelPaidMediaPurchase#9016d4f5 as nil")
	}
	b.ObjStart()
	b.PutID("starTransactionTypeChannelPaidMediaPurchase")
	b.Comma()
	b.FieldStart("chat_id")
	b.PutInt53(s.ChatID)
	b.Comma()
	b.FieldStart("message_id")
	b.PutInt53(s.MessageID)
	b.Comma()
	b.FieldStart("media")
	b.ArrStart()
	for idx, v := range s.Media {
		if v == nil {
			return fmt.Errorf("unable to encode starTransactionTypeChannelPaidMediaPurchase#9016d4f5: field media element with index %d is nil", idx)
		}
		if err := v.EncodeTDLibJSON(b); err != nil {
			return fmt.Errorf("unable to encode starTransactionTypeChannelPaidMediaPurchase#9016d4f5: field media element with index %d: %w", idx, err)
		}
		b.Comma()
	}
	b.StripComma()
	b.ArrEnd()
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *StarTransactionTypeChannelPaidMediaPurchase) DecodeTDLibJSON(b tdjson.Decoder) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeChannelPaidMediaPurchase#9016d4f5 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("starTransactionTypeChannelPaidMediaPurchase"); err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeChannelPaidMediaPurchase#9016d4f5: %w", err)
			}
		case "chat_id":
			value, err := b.Int53()
			if err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeChannelPaidMediaPurchase#9016d4f5: field chat_id: %w", err)
			}
			s.ChatID = value
		case "message_id":
			value, err := b.Int53()
			if err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeChannelPaidMediaPurchase#9016d4f5: field message_id: %w", err)
			}
			s.MessageID = value
		case "media":
			if err := b.Arr(func(b tdjson.Decoder) error {
				value, err := DecodeTDLibJSONPaidMedia(b)
				if err != nil {
					return fmt.Errorf("unable to decode starTransactionTypeChannelPaidMediaPurchase#9016d4f5: field media: %w", err)
				}
				s.Media = append(s.Media, value)
				return nil
			}); err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeChannelPaidMediaPurchase#9016d4f5: field media: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// GetChatID returns value of ChatID field.
func (s *StarTransactionTypeChannelPaidMediaPurchase) GetChatID() (value int64) {
	if s == nil {
		return
	}
	return s.ChatID
}

// GetMessageID returns value of MessageID field.
func (s *StarTransactionTypeChannelPaidMediaPurchase) GetMessageID() (value int64) {
	if s == nil {
		return
	}
	return s.MessageID
}

// GetMedia returns value of Media field.
func (s *StarTransactionTypeChannelPaidMediaPurchase) GetMedia() (value []PaidMediaClass) {
	if s == nil {
		return
	}
	return s.Media
}

// StarTransactionTypeChannelPaidMediaSale represents TL type `starTransactionTypeChannelPaidMediaSale#eace92ef`.
type StarTransactionTypeChannelPaidMediaSale struct {
	// Identifier of the user that bought the media
	UserID int64
	// Identifier of the corresponding message with paid media; can be 0 or an identifier of
	// a deleted message
	MessageID int64
	// The bought media
	Media []PaidMediaClass
}

// StarTransactionTypeChannelPaidMediaSaleTypeID is TL type id of StarTransactionTypeChannelPaidMediaSale.
const StarTransactionTypeChannelPaidMediaSaleTypeID = 0xeace92ef

// construct implements constructor of StarTransactionTypeClass.
func (s StarTransactionTypeChannelPaidMediaSale) construct() StarTransactionTypeClass { return &s }

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

	_ StarTransactionTypeClass = &StarTransactionTypeChannelPaidMediaSale{}
)

func (s *StarTransactionTypeChannelPaidMediaSale) Zero() bool {
	if s == nil {
		return true
	}
	if !(s.UserID == 0) {
		return false
	}
	if !(s.MessageID == 0) {
		return false
	}
	if !(s.Media == nil) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (s *StarTransactionTypeChannelPaidMediaSale) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "starTransactionTypeChannelPaidMediaSale",
		ID:   StarTransactionTypeChannelPaidMediaSaleTypeID,
	}
	if s == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "UserID",
			SchemaName: "user_id",
		},
		{
			Name:       "MessageID",
			SchemaName: "message_id",
		},
		{
			Name:       "Media",
			SchemaName: "media",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (s *StarTransactionTypeChannelPaidMediaSale) Encode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeChannelPaidMediaSale#eace92ef as nil")
	}
	b.PutID(StarTransactionTypeChannelPaidMediaSaleTypeID)
	return s.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (s *StarTransactionTypeChannelPaidMediaSale) EncodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeChannelPaidMediaSale#eace92ef as nil")
	}
	b.PutInt53(s.UserID)
	b.PutInt53(s.MessageID)
	b.PutInt(len(s.Media))
	for idx, v := range s.Media {
		if v == nil {
			return fmt.Errorf("unable to encode starTransactionTypeChannelPaidMediaSale#eace92ef: field media element with index %d is nil", idx)
		}
		if err := v.EncodeBare(b); err != nil {
			return fmt.Errorf("unable to encode bare starTransactionTypeChannelPaidMediaSale#eace92ef: field media element with index %d: %w", idx, err)
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func (s *StarTransactionTypeChannelPaidMediaSale) Decode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeChannelPaidMediaSale#eace92ef to nil")
	}
	if err := b.ConsumeID(StarTransactionTypeChannelPaidMediaSaleTypeID); err != nil {
		return fmt.Errorf("unable to decode starTransactionTypeChannelPaidMediaSale#eace92ef: %w", err)
	}
	return s.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (s *StarTransactionTypeChannelPaidMediaSale) DecodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeChannelPaidMediaSale#eace92ef to nil")
	}
	{
		value, err := b.Int53()
		if err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeChannelPaidMediaSale#eace92ef: field user_id: %w", err)
		}
		s.UserID = value
	}
	{
		value, err := b.Int53()
		if err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeChannelPaidMediaSale#eace92ef: field message_id: %w", err)
		}
		s.MessageID = value
	}
	{
		headerLen, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeChannelPaidMediaSale#eace92ef: field media: %w", err)
		}

		if headerLen > 0 {
			s.Media = make([]PaidMediaClass, 0, headerLen%bin.PreallocateLimit)
		}
		for idx := 0; idx < headerLen; idx++ {
			value, err := DecodePaidMedia(b)
			if err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeChannelPaidMediaSale#eace92ef: field media: %w", err)
			}
			s.Media = append(s.Media, value)
		}
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (s *StarTransactionTypeChannelPaidMediaSale) EncodeTDLibJSON(b tdjson.Encoder) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeChannelPaidMediaSale#eace92ef as nil")
	}
	b.ObjStart()
	b.PutID("starTransactionTypeChannelPaidMediaSale")
	b.Comma()
	b.FieldStart("user_id")
	b.PutInt53(s.UserID)
	b.Comma()
	b.FieldStart("message_id")
	b.PutInt53(s.MessageID)
	b.Comma()
	b.FieldStart("media")
	b.ArrStart()
	for idx, v := range s.Media {
		if v == nil {
			return fmt.Errorf("unable to encode starTransactionTypeChannelPaidMediaSale#eace92ef: field media element with index %d is nil", idx)
		}
		if err := v.EncodeTDLibJSON(b); err != nil {
			return fmt.Errorf("unable to encode starTransactionTypeChannelPaidMediaSale#eace92ef: field media element with index %d: %w", idx, err)
		}
		b.Comma()
	}
	b.StripComma()
	b.ArrEnd()
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *StarTransactionTypeChannelPaidMediaSale) DecodeTDLibJSON(b tdjson.Decoder) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeChannelPaidMediaSale#eace92ef to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("starTransactionTypeChannelPaidMediaSale"); err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeChannelPaidMediaSale#eace92ef: %w", err)
			}
		case "user_id":
			value, err := b.Int53()
			if err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeChannelPaidMediaSale#eace92ef: field user_id: %w", err)
			}
			s.UserID = value
		case "message_id":
			value, err := b.Int53()
			if err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeChannelPaidMediaSale#eace92ef: field message_id: %w", err)
			}
			s.MessageID = value
		case "media":
			if err := b.Arr(func(b tdjson.Decoder) error {
				value, err := DecodeTDLibJSONPaidMedia(b)
				if err != nil {
					return fmt.Errorf("unable to decode starTransactionTypeChannelPaidMediaSale#eace92ef: field media: %w", err)
				}
				s.Media = append(s.Media, value)
				return nil
			}); err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeChannelPaidMediaSale#eace92ef: field media: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

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

// GetMessageID returns value of MessageID field.
func (s *StarTransactionTypeChannelPaidMediaSale) GetMessageID() (value int64) {
	if s == nil {
		return
	}
	return s.MessageID
}

// GetMedia returns value of Media field.
func (s *StarTransactionTypeChannelPaidMediaSale) GetMedia() (value []PaidMediaClass) {
	if s == nil {
		return
	}
	return s.Media
}

// StarTransactionTypeBotInvoicePurchase represents TL type `starTransactionTypeBotInvoicePurchase#1dddac0c`.
type StarTransactionTypeBotInvoicePurchase struct {
	// Identifier of the bot or the business account user that created the invoice
	UserID int64
	// Information about the bought product
	ProductInfo ProductInfo
}

// StarTransactionTypeBotInvoicePurchaseTypeID is TL type id of StarTransactionTypeBotInvoicePurchase.
const StarTransactionTypeBotInvoicePurchaseTypeID = 0x1dddac0c

// construct implements constructor of StarTransactionTypeClass.
func (s StarTransactionTypeBotInvoicePurchase) construct() StarTransactionTypeClass { return &s }

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

	_ StarTransactionTypeClass = &StarTransactionTypeBotInvoicePurchase{}
)

func (s *StarTransactionTypeBotInvoicePurchase) Zero() bool {
	if s == nil {
		return true
	}
	if !(s.UserID == 0) {
		return false
	}
	if !(s.ProductInfo.Zero()) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (s *StarTransactionTypeBotInvoicePurchase) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "starTransactionTypeBotInvoicePurchase",
		ID:   StarTransactionTypeBotInvoicePurchaseTypeID,
	}
	if s == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "UserID",
			SchemaName: "user_id",
		},
		{
			Name:       "ProductInfo",
			SchemaName: "product_info",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (s *StarTransactionTypeBotInvoicePurchase) Encode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeBotInvoicePurchase#1dddac0c as nil")
	}
	b.PutID(StarTransactionTypeBotInvoicePurchaseTypeID)
	return s.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (s *StarTransactionTypeBotInvoicePurchase) EncodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeBotInvoicePurchase#1dddac0c as nil")
	}
	b.PutInt53(s.UserID)
	if err := s.ProductInfo.Encode(b); err != nil {
		return fmt.Errorf("unable to encode starTransactionTypeBotInvoicePurchase#1dddac0c: field product_info: %w", err)
	}
	return nil
}

// Decode implements bin.Decoder.
func (s *StarTransactionTypeBotInvoicePurchase) Decode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeBotInvoicePurchase#1dddac0c to nil")
	}
	if err := b.ConsumeID(StarTransactionTypeBotInvoicePurchaseTypeID); err != nil {
		return fmt.Errorf("unable to decode starTransactionTypeBotInvoicePurchase#1dddac0c: %w", err)
	}
	return s.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (s *StarTransactionTypeBotInvoicePurchase) DecodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeBotInvoicePurchase#1dddac0c to nil")
	}
	{
		value, err := b.Int53()
		if err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeBotInvoicePurchase#1dddac0c: field user_id: %w", err)
		}
		s.UserID = value
	}
	{
		if err := s.ProductInfo.Decode(b); err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeBotInvoicePurchase#1dddac0c: field product_info: %w", err)
		}
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (s *StarTransactionTypeBotInvoicePurchase) EncodeTDLibJSON(b tdjson.Encoder) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeBotInvoicePurchase#1dddac0c as nil")
	}
	b.ObjStart()
	b.PutID("starTransactionTypeBotInvoicePurchase")
	b.Comma()
	b.FieldStart("user_id")
	b.PutInt53(s.UserID)
	b.Comma()
	b.FieldStart("product_info")
	if err := s.ProductInfo.EncodeTDLibJSON(b); err != nil {
		return fmt.Errorf("unable to encode starTransactionTypeBotInvoicePurchase#1dddac0c: field product_info: %w", err)
	}
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *StarTransactionTypeBotInvoicePurchase) DecodeTDLibJSON(b tdjson.Decoder) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeBotInvoicePurchase#1dddac0c to nil")
	}

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

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

// GetProductInfo returns value of ProductInfo field.
func (s *StarTransactionTypeBotInvoicePurchase) GetProductInfo() (value ProductInfo) {
	if s == nil {
		return
	}
	return s.ProductInfo
}

// StarTransactionTypeBotInvoiceSale represents TL type `starTransactionTypeBotInvoiceSale#5b7d8d2f`.
type StarTransactionTypeBotInvoiceSale struct {
	// Identifier of the user that bought the product
	UserID int64
	// Information about the bought product
	ProductInfo ProductInfo
	// Invoice payload
	InvoicePayload []byte
	// Information about the affiliate which received commission from the transaction; may be
	// null if none
	Affiliate AffiliateInfo
}

// StarTransactionTypeBotInvoiceSaleTypeID is TL type id of StarTransactionTypeBotInvoiceSale.
const StarTransactionTypeBotInvoiceSaleTypeID = 0x5b7d8d2f

// construct implements constructor of StarTransactionTypeClass.
func (s StarTransactionTypeBotInvoiceSale) construct() StarTransactionTypeClass { return &s }

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

	_ StarTransactionTypeClass = &StarTransactionTypeBotInvoiceSale{}
)

func (s *StarTransactionTypeBotInvoiceSale) Zero() bool {
	if s == nil {
		return true
	}
	if !(s.UserID == 0) {
		return false
	}
	if !(s.ProductInfo.Zero()) {
		return false
	}
	if !(s.InvoicePayload == nil) {
		return false
	}
	if !(s.Affiliate.Zero()) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (s *StarTransactionTypeBotInvoiceSale) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "starTransactionTypeBotInvoiceSale",
		ID:   StarTransactionTypeBotInvoiceSaleTypeID,
	}
	if s == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "UserID",
			SchemaName: "user_id",
		},
		{
			Name:       "ProductInfo",
			SchemaName: "product_info",
		},
		{
			Name:       "InvoicePayload",
			SchemaName: "invoice_payload",
		},
		{
			Name:       "Affiliate",
			SchemaName: "affiliate",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (s *StarTransactionTypeBotInvoiceSale) Encode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeBotInvoiceSale#5b7d8d2f as nil")
	}
	b.PutID(StarTransactionTypeBotInvoiceSaleTypeID)
	return s.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (s *StarTransactionTypeBotInvoiceSale) EncodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeBotInvoiceSale#5b7d8d2f as nil")
	}
	b.PutInt53(s.UserID)
	if err := s.ProductInfo.Encode(b); err != nil {
		return fmt.Errorf("unable to encode starTransactionTypeBotInvoiceSale#5b7d8d2f: field product_info: %w", err)
	}
	b.PutBytes(s.InvoicePayload)
	if err := s.Affiliate.Encode(b); err != nil {
		return fmt.Errorf("unable to encode starTransactionTypeBotInvoiceSale#5b7d8d2f: field affiliate: %w", err)
	}
	return nil
}

// Decode implements bin.Decoder.
func (s *StarTransactionTypeBotInvoiceSale) Decode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeBotInvoiceSale#5b7d8d2f to nil")
	}
	if err := b.ConsumeID(StarTransactionTypeBotInvoiceSaleTypeID); err != nil {
		return fmt.Errorf("unable to decode starTransactionTypeBotInvoiceSale#5b7d8d2f: %w", err)
	}
	return s.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (s *StarTransactionTypeBotInvoiceSale) DecodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeBotInvoiceSale#5b7d8d2f to nil")
	}
	{
		value, err := b.Int53()
		if err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeBotInvoiceSale#5b7d8d2f: field user_id: %w", err)
		}
		s.UserID = value
	}
	{
		if err := s.ProductInfo.Decode(b); err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeBotInvoiceSale#5b7d8d2f: field product_info: %w", err)
		}
	}
	{
		value, err := b.Bytes()
		if err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeBotInvoiceSale#5b7d8d2f: field invoice_payload: %w", err)
		}
		s.InvoicePayload = value
	}
	{
		if err := s.Affiliate.Decode(b); err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeBotInvoiceSale#5b7d8d2f: field affiliate: %w", err)
		}
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (s *StarTransactionTypeBotInvoiceSale) EncodeTDLibJSON(b tdjson.Encoder) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeBotInvoiceSale#5b7d8d2f as nil")
	}
	b.ObjStart()
	b.PutID("starTransactionTypeBotInvoiceSale")
	b.Comma()
	b.FieldStart("user_id")
	b.PutInt53(s.UserID)
	b.Comma()
	b.FieldStart("product_info")
	if err := s.ProductInfo.EncodeTDLibJSON(b); err != nil {
		return fmt.Errorf("unable to encode starTransactionTypeBotInvoiceSale#5b7d8d2f: field product_info: %w", err)
	}
	b.Comma()
	b.FieldStart("invoice_payload")
	b.PutBytes(s.InvoicePayload)
	b.Comma()
	b.FieldStart("affiliate")
	if err := s.Affiliate.EncodeTDLibJSON(b); err != nil {
		return fmt.Errorf("unable to encode starTransactionTypeBotInvoiceSale#5b7d8d2f: field affiliate: %w", err)
	}
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *StarTransactionTypeBotInvoiceSale) DecodeTDLibJSON(b tdjson.Decoder) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeBotInvoiceSale#5b7d8d2f to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("starTransactionTypeBotInvoiceSale"); err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeBotInvoiceSale#5b7d8d2f: %w", err)
			}
		case "user_id":
			value, err := b.Int53()
			if err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeBotInvoiceSale#5b7d8d2f: field user_id: %w", err)
			}
			s.UserID = value
		case "product_info":
			if err := s.ProductInfo.DecodeTDLibJSON(b); err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeBotInvoiceSale#5b7d8d2f: field product_info: %w", err)
			}
		case "invoice_payload":
			value, err := b.Bytes()
			if err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeBotInvoiceSale#5b7d8d2f: field invoice_payload: %w", err)
			}
			s.InvoicePayload = value
		case "affiliate":
			if err := s.Affiliate.DecodeTDLibJSON(b); err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeBotInvoiceSale#5b7d8d2f: field affiliate: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

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

// GetProductInfo returns value of ProductInfo field.
func (s *StarTransactionTypeBotInvoiceSale) GetProductInfo() (value ProductInfo) {
	if s == nil {
		return
	}
	return s.ProductInfo
}

// GetInvoicePayload returns value of InvoicePayload field.
func (s *StarTransactionTypeBotInvoiceSale) GetInvoicePayload() (value []byte) {
	if s == nil {
		return
	}
	return s.InvoicePayload
}

// GetAffiliate returns value of Affiliate field.
func (s *StarTransactionTypeBotInvoiceSale) GetAffiliate() (value AffiliateInfo) {
	if s == nil {
		return
	}
	return s.Affiliate
}

// StarTransactionTypeBotSubscriptionPurchase represents TL type `starTransactionTypeBotSubscriptionPurchase#40bf1355`.
type StarTransactionTypeBotSubscriptionPurchase struct {
	// Identifier of the bot or the business account user that created the subscription link
	UserID int64
	// The number of seconds between consecutive Telegram Star debitings
	SubscriptionPeriod int32
	// Information about the bought subscription
	ProductInfo ProductInfo
}

// StarTransactionTypeBotSubscriptionPurchaseTypeID is TL type id of StarTransactionTypeBotSubscriptionPurchase.
const StarTransactionTypeBotSubscriptionPurchaseTypeID = 0x40bf1355

// construct implements constructor of StarTransactionTypeClass.
func (s StarTransactionTypeBotSubscriptionPurchase) construct() StarTransactionTypeClass { return &s }

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

	_ StarTransactionTypeClass = &StarTransactionTypeBotSubscriptionPurchase{}
)

func (s *StarTransactionTypeBotSubscriptionPurchase) Zero() bool {
	if s == nil {
		return true
	}
	if !(s.UserID == 0) {
		return false
	}
	if !(s.SubscriptionPeriod == 0) {
		return false
	}
	if !(s.ProductInfo.Zero()) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (s *StarTransactionTypeBotSubscriptionPurchase) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "starTransactionTypeBotSubscriptionPurchase",
		ID:   StarTransactionTypeBotSubscriptionPurchaseTypeID,
	}
	if s == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "UserID",
			SchemaName: "user_id",
		},
		{
			Name:       "SubscriptionPeriod",
			SchemaName: "subscription_period",
		},
		{
			Name:       "ProductInfo",
			SchemaName: "product_info",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (s *StarTransactionTypeBotSubscriptionPurchase) Encode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeBotSubscriptionPurchase#40bf1355 as nil")
	}
	b.PutID(StarTransactionTypeBotSubscriptionPurchaseTypeID)
	return s.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (s *StarTransactionTypeBotSubscriptionPurchase) EncodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeBotSubscriptionPurchase#40bf1355 as nil")
	}
	b.PutInt53(s.UserID)
	b.PutInt32(s.SubscriptionPeriod)
	if err := s.ProductInfo.Encode(b); err != nil {
		return fmt.Errorf("unable to encode starTransactionTypeBotSubscriptionPurchase#40bf1355: field product_info: %w", err)
	}
	return nil
}

// Decode implements bin.Decoder.
func (s *StarTransactionTypeBotSubscriptionPurchase) Decode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeBotSubscriptionPurchase#40bf1355 to nil")
	}
	if err := b.ConsumeID(StarTransactionTypeBotSubscriptionPurchaseTypeID); err != nil {
		return fmt.Errorf("unable to decode starTransactionTypeBotSubscriptionPurchase#40bf1355: %w", err)
	}
	return s.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (s *StarTransactionTypeBotSubscriptionPurchase) DecodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeBotSubscriptionPurchase#40bf1355 to nil")
	}
	{
		value, err := b.Int53()
		if err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeBotSubscriptionPurchase#40bf1355: field user_id: %w", err)
		}
		s.UserID = value
	}
	{
		value, err := b.Int32()
		if err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeBotSubscriptionPurchase#40bf1355: field subscription_period: %w", err)
		}
		s.SubscriptionPeriod = value
	}
	{
		if err := s.ProductInfo.Decode(b); err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeBotSubscriptionPurchase#40bf1355: field product_info: %w", err)
		}
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (s *StarTransactionTypeBotSubscriptionPurchase) EncodeTDLibJSON(b tdjson.Encoder) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeBotSubscriptionPurchase#40bf1355 as nil")
	}
	b.ObjStart()
	b.PutID("starTransactionTypeBotSubscriptionPurchase")
	b.Comma()
	b.FieldStart("user_id")
	b.PutInt53(s.UserID)
	b.Comma()
	b.FieldStart("subscription_period")
	b.PutInt32(s.SubscriptionPeriod)
	b.Comma()
	b.FieldStart("product_info")
	if err := s.ProductInfo.EncodeTDLibJSON(b); err != nil {
		return fmt.Errorf("unable to encode starTransactionTypeBotSubscriptionPurchase#40bf1355: field product_info: %w", err)
	}
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *StarTransactionTypeBotSubscriptionPurchase) DecodeTDLibJSON(b tdjson.Decoder) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeBotSubscriptionPurchase#40bf1355 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("starTransactionTypeBotSubscriptionPurchase"); err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeBotSubscriptionPurchase#40bf1355: %w", err)
			}
		case "user_id":
			value, err := b.Int53()
			if err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeBotSubscriptionPurchase#40bf1355: field user_id: %w", err)
			}
			s.UserID = value
		case "subscription_period":
			value, err := b.Int32()
			if err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeBotSubscriptionPurchase#40bf1355: field subscription_period: %w", err)
			}
			s.SubscriptionPeriod = value
		case "product_info":
			if err := s.ProductInfo.DecodeTDLibJSON(b); err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeBotSubscriptionPurchase#40bf1355: field product_info: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

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

// GetSubscriptionPeriod returns value of SubscriptionPeriod field.
func (s *StarTransactionTypeBotSubscriptionPurchase) GetSubscriptionPeriod() (value int32) {
	if s == nil {
		return
	}
	return s.SubscriptionPeriod
}

// GetProductInfo returns value of ProductInfo field.
func (s *StarTransactionTypeBotSubscriptionPurchase) GetProductInfo() (value ProductInfo) {
	if s == nil {
		return
	}
	return s.ProductInfo
}

// StarTransactionTypeBotSubscriptionSale represents TL type `starTransactionTypeBotSubscriptionSale#1f686889`.
type StarTransactionTypeBotSubscriptionSale struct {
	// Identifier of the user that bought the subscription
	UserID int64
	// The number of seconds between consecutive Telegram Star debitings
	SubscriptionPeriod int32
	// Information about the bought subscription
	ProductInfo ProductInfo
	// Invoice payload
	InvoicePayload []byte
	// Information about the affiliate which received commission from the transaction; may be
	// null if none
	Affiliate AffiliateInfo
}

// StarTransactionTypeBotSubscriptionSaleTypeID is TL type id of StarTransactionTypeBotSubscriptionSale.
const StarTransactionTypeBotSubscriptionSaleTypeID = 0x1f686889

// construct implements constructor of StarTransactionTypeClass.
func (s StarTransactionTypeBotSubscriptionSale) construct() StarTransactionTypeClass { return &s }

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

	_ StarTransactionTypeClass = &StarTransactionTypeBotSubscriptionSale{}
)

func (s *StarTransactionTypeBotSubscriptionSale) Zero() bool {
	if s == nil {
		return true
	}
	if !(s.UserID == 0) {
		return false
	}
	if !(s.SubscriptionPeriod == 0) {
		return false
	}
	if !(s.ProductInfo.Zero()) {
		return false
	}
	if !(s.InvoicePayload == nil) {
		return false
	}
	if !(s.Affiliate.Zero()) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (s *StarTransactionTypeBotSubscriptionSale) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "starTransactionTypeBotSubscriptionSale",
		ID:   StarTransactionTypeBotSubscriptionSaleTypeID,
	}
	if s == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "UserID",
			SchemaName: "user_id",
		},
		{
			Name:       "SubscriptionPeriod",
			SchemaName: "subscription_period",
		},
		{
			Name:       "ProductInfo",
			SchemaName: "product_info",
		},
		{
			Name:       "InvoicePayload",
			SchemaName: "invoice_payload",
		},
		{
			Name:       "Affiliate",
			SchemaName: "affiliate",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (s *StarTransactionTypeBotSubscriptionSale) Encode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeBotSubscriptionSale#1f686889 as nil")
	}
	b.PutID(StarTransactionTypeBotSubscriptionSaleTypeID)
	return s.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (s *StarTransactionTypeBotSubscriptionSale) EncodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeBotSubscriptionSale#1f686889 as nil")
	}
	b.PutInt53(s.UserID)
	b.PutInt32(s.SubscriptionPeriod)
	if err := s.ProductInfo.Encode(b); err != nil {
		return fmt.Errorf("unable to encode starTransactionTypeBotSubscriptionSale#1f686889: field product_info: %w", err)
	}
	b.PutBytes(s.InvoicePayload)
	if err := s.Affiliate.Encode(b); err != nil {
		return fmt.Errorf("unable to encode starTransactionTypeBotSubscriptionSale#1f686889: field affiliate: %w", err)
	}
	return nil
}

// Decode implements bin.Decoder.
func (s *StarTransactionTypeBotSubscriptionSale) Decode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeBotSubscriptionSale#1f686889 to nil")
	}
	if err := b.ConsumeID(StarTransactionTypeBotSubscriptionSaleTypeID); err != nil {
		return fmt.Errorf("unable to decode starTransactionTypeBotSubscriptionSale#1f686889: %w", err)
	}
	return s.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (s *StarTransactionTypeBotSubscriptionSale) DecodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeBotSubscriptionSale#1f686889 to nil")
	}
	{
		value, err := b.Int53()
		if err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeBotSubscriptionSale#1f686889: field user_id: %w", err)
		}
		s.UserID = value
	}
	{
		value, err := b.Int32()
		if err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeBotSubscriptionSale#1f686889: field subscription_period: %w", err)
		}
		s.SubscriptionPeriod = value
	}
	{
		if err := s.ProductInfo.Decode(b); err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeBotSubscriptionSale#1f686889: field product_info: %w", err)
		}
	}
	{
		value, err := b.Bytes()
		if err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeBotSubscriptionSale#1f686889: field invoice_payload: %w", err)
		}
		s.InvoicePayload = value
	}
	{
		if err := s.Affiliate.Decode(b); err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeBotSubscriptionSale#1f686889: field affiliate: %w", err)
		}
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (s *StarTransactionTypeBotSubscriptionSale) EncodeTDLibJSON(b tdjson.Encoder) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeBotSubscriptionSale#1f686889 as nil")
	}
	b.ObjStart()
	b.PutID("starTransactionTypeBotSubscriptionSale")
	b.Comma()
	b.FieldStart("user_id")
	b.PutInt53(s.UserID)
	b.Comma()
	b.FieldStart("subscription_period")
	b.PutInt32(s.SubscriptionPeriod)
	b.Comma()
	b.FieldStart("product_info")
	if err := s.ProductInfo.EncodeTDLibJSON(b); err != nil {
		return fmt.Errorf("unable to encode starTransactionTypeBotSubscriptionSale#1f686889: field product_info: %w", err)
	}
	b.Comma()
	b.FieldStart("invoice_payload")
	b.PutBytes(s.InvoicePayload)
	b.Comma()
	b.FieldStart("affiliate")
	if err := s.Affiliate.EncodeTDLibJSON(b); err != nil {
		return fmt.Errorf("unable to encode starTransactionTypeBotSubscriptionSale#1f686889: field affiliate: %w", err)
	}
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *StarTransactionTypeBotSubscriptionSale) DecodeTDLibJSON(b tdjson.Decoder) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeBotSubscriptionSale#1f686889 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("starTransactionTypeBotSubscriptionSale"); err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeBotSubscriptionSale#1f686889: %w", err)
			}
		case "user_id":
			value, err := b.Int53()
			if err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeBotSubscriptionSale#1f686889: field user_id: %w", err)
			}
			s.UserID = value
		case "subscription_period":
			value, err := b.Int32()
			if err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeBotSubscriptionSale#1f686889: field subscription_period: %w", err)
			}
			s.SubscriptionPeriod = value
		case "product_info":
			if err := s.ProductInfo.DecodeTDLibJSON(b); err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeBotSubscriptionSale#1f686889: field product_info: %w", err)
			}
		case "invoice_payload":
			value, err := b.Bytes()
			if err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeBotSubscriptionSale#1f686889: field invoice_payload: %w", err)
			}
			s.InvoicePayload = value
		case "affiliate":
			if err := s.Affiliate.DecodeTDLibJSON(b); err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeBotSubscriptionSale#1f686889: field affiliate: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

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

// GetSubscriptionPeriod returns value of SubscriptionPeriod field.
func (s *StarTransactionTypeBotSubscriptionSale) GetSubscriptionPeriod() (value int32) {
	if s == nil {
		return
	}
	return s.SubscriptionPeriod
}

// GetProductInfo returns value of ProductInfo field.
func (s *StarTransactionTypeBotSubscriptionSale) GetProductInfo() (value ProductInfo) {
	if s == nil {
		return
	}
	return s.ProductInfo
}

// GetInvoicePayload returns value of InvoicePayload field.
func (s *StarTransactionTypeBotSubscriptionSale) GetInvoicePayload() (value []byte) {
	if s == nil {
		return
	}
	return s.InvoicePayload
}

// GetAffiliate returns value of Affiliate field.
func (s *StarTransactionTypeBotSubscriptionSale) GetAffiliate() (value AffiliateInfo) {
	if s == nil {
		return
	}
	return s.Affiliate
}

// StarTransactionTypeChannelSubscriptionPurchase represents TL type `starTransactionTypeChannelSubscriptionPurchase#380eb3d1`.
type StarTransactionTypeChannelSubscriptionPurchase struct {
	// Identifier of the channel chat that created the subscription
	ChatID int64
	// The number of seconds between consecutive Telegram Star debitings
	SubscriptionPeriod int32
}

// StarTransactionTypeChannelSubscriptionPurchaseTypeID is TL type id of StarTransactionTypeChannelSubscriptionPurchase.
const StarTransactionTypeChannelSubscriptionPurchaseTypeID = 0x380eb3d1

// construct implements constructor of StarTransactionTypeClass.
func (s StarTransactionTypeChannelSubscriptionPurchase) construct() StarTransactionTypeClass {
	return &s
}

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

	_ StarTransactionTypeClass = &StarTransactionTypeChannelSubscriptionPurchase{}
)

func (s *StarTransactionTypeChannelSubscriptionPurchase) Zero() bool {
	if s == nil {
		return true
	}
	if !(s.ChatID == 0) {
		return false
	}
	if !(s.SubscriptionPeriod == 0) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (s *StarTransactionTypeChannelSubscriptionPurchase) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "starTransactionTypeChannelSubscriptionPurchase",
		ID:   StarTransactionTypeChannelSubscriptionPurchaseTypeID,
	}
	if s == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "ChatID",
			SchemaName: "chat_id",
		},
		{
			Name:       "SubscriptionPeriod",
			SchemaName: "subscription_period",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (s *StarTransactionTypeChannelSubscriptionPurchase) Encode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeChannelSubscriptionPurchase#380eb3d1 as nil")
	}
	b.PutID(StarTransactionTypeChannelSubscriptionPurchaseTypeID)
	return s.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (s *StarTransactionTypeChannelSubscriptionPurchase) EncodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeChannelSubscriptionPurchase#380eb3d1 as nil")
	}
	b.PutInt53(s.ChatID)
	b.PutInt32(s.SubscriptionPeriod)
	return nil
}

// Decode implements bin.Decoder.
func (s *StarTransactionTypeChannelSubscriptionPurchase) Decode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeChannelSubscriptionPurchase#380eb3d1 to nil")
	}
	if err := b.ConsumeID(StarTransactionTypeChannelSubscriptionPurchaseTypeID); err != nil {
		return fmt.Errorf("unable to decode starTransactionTypeChannelSubscriptionPurchase#380eb3d1: %w", err)
	}
	return s.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (s *StarTransactionTypeChannelSubscriptionPurchase) DecodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeChannelSubscriptionPurchase#380eb3d1 to nil")
	}
	{
		value, err := b.Int53()
		if err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeChannelSubscriptionPurchase#380eb3d1: field chat_id: %w", err)
		}
		s.ChatID = value
	}
	{
		value, err := b.Int32()
		if err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeChannelSubscriptionPurchase#380eb3d1: field subscription_period: %w", err)
		}
		s.SubscriptionPeriod = value
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (s *StarTransactionTypeChannelSubscriptionPurchase) EncodeTDLibJSON(b tdjson.Encoder) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeChannelSubscriptionPurchase#380eb3d1 as nil")
	}
	b.ObjStart()
	b.PutID("starTransactionTypeChannelSubscriptionPurchase")
	b.Comma()
	b.FieldStart("chat_id")
	b.PutInt53(s.ChatID)
	b.Comma()
	b.FieldStart("subscription_period")
	b.PutInt32(s.SubscriptionPeriod)
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *StarTransactionTypeChannelSubscriptionPurchase) DecodeTDLibJSON(b tdjson.Decoder) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeChannelSubscriptionPurchase#380eb3d1 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("starTransactionTypeChannelSubscriptionPurchase"); err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeChannelSubscriptionPurchase#380eb3d1: %w", err)
			}
		case "chat_id":
			value, err := b.Int53()
			if err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeChannelSubscriptionPurchase#380eb3d1: field chat_id: %w", err)
			}
			s.ChatID = value
		case "subscription_period":
			value, err := b.Int32()
			if err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeChannelSubscriptionPurchase#380eb3d1: field subscription_period: %w", err)
			}
			s.SubscriptionPeriod = value
		default:
			return b.Skip()
		}
		return nil
	})
}

// GetChatID returns value of ChatID field.
func (s *StarTransactionTypeChannelSubscriptionPurchase) GetChatID() (value int64) {
	if s == nil {
		return
	}
	return s.ChatID
}

// GetSubscriptionPeriod returns value of SubscriptionPeriod field.
func (s *StarTransactionTypeChannelSubscriptionPurchase) GetSubscriptionPeriod() (value int32) {
	if s == nil {
		return
	}
	return s.SubscriptionPeriod
}

// StarTransactionTypeChannelSubscriptionSale represents TL type `starTransactionTypeChannelSubscriptionSale#fe127c82`.
type StarTransactionTypeChannelSubscriptionSale struct {
	// Identifier of the user that bought the subscription
	UserID int64
	// The number of seconds between consecutive Telegram Star debitings
	SubscriptionPeriod int32
}

// StarTransactionTypeChannelSubscriptionSaleTypeID is TL type id of StarTransactionTypeChannelSubscriptionSale.
const StarTransactionTypeChannelSubscriptionSaleTypeID = 0xfe127c82

// construct implements constructor of StarTransactionTypeClass.
func (s StarTransactionTypeChannelSubscriptionSale) construct() StarTransactionTypeClass { return &s }

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

	_ StarTransactionTypeClass = &StarTransactionTypeChannelSubscriptionSale{}
)

func (s *StarTransactionTypeChannelSubscriptionSale) Zero() bool {
	if s == nil {
		return true
	}
	if !(s.UserID == 0) {
		return false
	}
	if !(s.SubscriptionPeriod == 0) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (s *StarTransactionTypeChannelSubscriptionSale) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "starTransactionTypeChannelSubscriptionSale",
		ID:   StarTransactionTypeChannelSubscriptionSaleTypeID,
	}
	if s == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "UserID",
			SchemaName: "user_id",
		},
		{
			Name:       "SubscriptionPeriod",
			SchemaName: "subscription_period",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (s *StarTransactionTypeChannelSubscriptionSale) Encode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeChannelSubscriptionSale#fe127c82 as nil")
	}
	b.PutID(StarTransactionTypeChannelSubscriptionSaleTypeID)
	return s.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (s *StarTransactionTypeChannelSubscriptionSale) EncodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeChannelSubscriptionSale#fe127c82 as nil")
	}
	b.PutInt53(s.UserID)
	b.PutInt32(s.SubscriptionPeriod)
	return nil
}

// Decode implements bin.Decoder.
func (s *StarTransactionTypeChannelSubscriptionSale) Decode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeChannelSubscriptionSale#fe127c82 to nil")
	}
	if err := b.ConsumeID(StarTransactionTypeChannelSubscriptionSaleTypeID); err != nil {
		return fmt.Errorf("unable to decode starTransactionTypeChannelSubscriptionSale#fe127c82: %w", err)
	}
	return s.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (s *StarTransactionTypeChannelSubscriptionSale) DecodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeChannelSubscriptionSale#fe127c82 to nil")
	}
	{
		value, err := b.Int53()
		if err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeChannelSubscriptionSale#fe127c82: field user_id: %w", err)
		}
		s.UserID = value
	}
	{
		value, err := b.Int32()
		if err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeChannelSubscriptionSale#fe127c82: field subscription_period: %w", err)
		}
		s.SubscriptionPeriod = value
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (s *StarTransactionTypeChannelSubscriptionSale) EncodeTDLibJSON(b tdjson.Encoder) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeChannelSubscriptionSale#fe127c82 as nil")
	}
	b.ObjStart()
	b.PutID("starTransactionTypeChannelSubscriptionSale")
	b.Comma()
	b.FieldStart("user_id")
	b.PutInt53(s.UserID)
	b.Comma()
	b.FieldStart("subscription_period")
	b.PutInt32(s.SubscriptionPeriod)
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *StarTransactionTypeChannelSubscriptionSale) DecodeTDLibJSON(b tdjson.Decoder) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeChannelSubscriptionSale#fe127c82 to nil")
	}

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

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

// GetSubscriptionPeriod returns value of SubscriptionPeriod field.
func (s *StarTransactionTypeChannelSubscriptionSale) GetSubscriptionPeriod() (value int32) {
	if s == nil {
		return
	}
	return s.SubscriptionPeriod
}

// StarTransactionTypeGiftPurchase represents TL type `starTransactionTypeGiftPurchase#939390e0`.
type StarTransactionTypeGiftPurchase struct {
	// Identifier of the user or the channel that received the gift
	OwnerID MessageSenderClass
	// The gift
	Gift Gift
}

// StarTransactionTypeGiftPurchaseTypeID is TL type id of StarTransactionTypeGiftPurchase.
const StarTransactionTypeGiftPurchaseTypeID = 0x939390e0

// construct implements constructor of StarTransactionTypeClass.
func (s StarTransactionTypeGiftPurchase) construct() StarTransactionTypeClass { return &s }

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

	_ StarTransactionTypeClass = &StarTransactionTypeGiftPurchase{}
)

func (s *StarTransactionTypeGiftPurchase) Zero() bool {
	if s == nil {
		return true
	}
	if !(s.OwnerID == nil) {
		return false
	}
	if !(s.Gift.Zero()) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (s *StarTransactionTypeGiftPurchase) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "starTransactionTypeGiftPurchase",
		ID:   StarTransactionTypeGiftPurchaseTypeID,
	}
	if s == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "OwnerID",
			SchemaName: "owner_id",
		},
		{
			Name:       "Gift",
			SchemaName: "gift",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (s *StarTransactionTypeGiftPurchase) Encode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeGiftPurchase#939390e0 as nil")
	}
	b.PutID(StarTransactionTypeGiftPurchaseTypeID)
	return s.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (s *StarTransactionTypeGiftPurchase) EncodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeGiftPurchase#939390e0 as nil")
	}
	if s.OwnerID == nil {
		return fmt.Errorf("unable to encode starTransactionTypeGiftPurchase#939390e0: field owner_id is nil")
	}
	if err := s.OwnerID.Encode(b); err != nil {
		return fmt.Errorf("unable to encode starTransactionTypeGiftPurchase#939390e0: field owner_id: %w", err)
	}
	if err := s.Gift.Encode(b); err != nil {
		return fmt.Errorf("unable to encode starTransactionTypeGiftPurchase#939390e0: field gift: %w", err)
	}
	return nil
}

// Decode implements bin.Decoder.
func (s *StarTransactionTypeGiftPurchase) Decode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeGiftPurchase#939390e0 to nil")
	}
	if err := b.ConsumeID(StarTransactionTypeGiftPurchaseTypeID); err != nil {
		return fmt.Errorf("unable to decode starTransactionTypeGiftPurchase#939390e0: %w", err)
	}
	return s.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (s *StarTransactionTypeGiftPurchase) DecodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeGiftPurchase#939390e0 to nil")
	}
	{
		value, err := DecodeMessageSender(b)
		if err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeGiftPurchase#939390e0: field owner_id: %w", err)
		}
		s.OwnerID = value
	}
	{
		if err := s.Gift.Decode(b); err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeGiftPurchase#939390e0: field gift: %w", err)
		}
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (s *StarTransactionTypeGiftPurchase) EncodeTDLibJSON(b tdjson.Encoder) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeGiftPurchase#939390e0 as nil")
	}
	b.ObjStart()
	b.PutID("starTransactionTypeGiftPurchase")
	b.Comma()
	b.FieldStart("owner_id")
	if s.OwnerID == nil {
		return fmt.Errorf("unable to encode starTransactionTypeGiftPurchase#939390e0: field owner_id is nil")
	}
	if err := s.OwnerID.EncodeTDLibJSON(b); err != nil {
		return fmt.Errorf("unable to encode starTransactionTypeGiftPurchase#939390e0: field owner_id: %w", err)
	}
	b.Comma()
	b.FieldStart("gift")
	if err := s.Gift.EncodeTDLibJSON(b); err != nil {
		return fmt.Errorf("unable to encode starTransactionTypeGiftPurchase#939390e0: field gift: %w", err)
	}
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *StarTransactionTypeGiftPurchase) DecodeTDLibJSON(b tdjson.Decoder) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeGiftPurchase#939390e0 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("starTransactionTypeGiftPurchase"); err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeGiftPurchase#939390e0: %w", err)
			}
		case "owner_id":
			value, err := DecodeTDLibJSONMessageSender(b)
			if err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeGiftPurchase#939390e0: field owner_id: %w", err)
			}
			s.OwnerID = value
		case "gift":
			if err := s.Gift.DecodeTDLibJSON(b); err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeGiftPurchase#939390e0: field gift: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// GetOwnerID returns value of OwnerID field.
func (s *StarTransactionTypeGiftPurchase) GetOwnerID() (value MessageSenderClass) {
	if s == nil {
		return
	}
	return s.OwnerID
}

// GetGift returns value of Gift field.
func (s *StarTransactionTypeGiftPurchase) GetGift() (value Gift) {
	if s == nil {
		return
	}
	return s.Gift
}

// StarTransactionTypeGiftTransfer represents TL type `starTransactionTypeGiftTransfer#9614f7`.
type StarTransactionTypeGiftTransfer struct {
	// Identifier of the user or the channel that received the gift
	OwnerID MessageSenderClass
	// The gift
	Gift UpgradedGift
}

// StarTransactionTypeGiftTransferTypeID is TL type id of StarTransactionTypeGiftTransfer.
const StarTransactionTypeGiftTransferTypeID = 0x9614f7

// construct implements constructor of StarTransactionTypeClass.
func (s StarTransactionTypeGiftTransfer) construct() StarTransactionTypeClass { return &s }

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

	_ StarTransactionTypeClass = &StarTransactionTypeGiftTransfer{}
)

func (s *StarTransactionTypeGiftTransfer) Zero() bool {
	if s == nil {
		return true
	}
	if !(s.OwnerID == nil) {
		return false
	}
	if !(s.Gift.Zero()) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (s *StarTransactionTypeGiftTransfer) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "starTransactionTypeGiftTransfer",
		ID:   StarTransactionTypeGiftTransferTypeID,
	}
	if s == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "OwnerID",
			SchemaName: "owner_id",
		},
		{
			Name:       "Gift",
			SchemaName: "gift",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (s *StarTransactionTypeGiftTransfer) Encode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeGiftTransfer#9614f7 as nil")
	}
	b.PutID(StarTransactionTypeGiftTransferTypeID)
	return s.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (s *StarTransactionTypeGiftTransfer) EncodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeGiftTransfer#9614f7 as nil")
	}
	if s.OwnerID == nil {
		return fmt.Errorf("unable to encode starTransactionTypeGiftTransfer#9614f7: field owner_id is nil")
	}
	if err := s.OwnerID.Encode(b); err != nil {
		return fmt.Errorf("unable to encode starTransactionTypeGiftTransfer#9614f7: field owner_id: %w", err)
	}
	if err := s.Gift.Encode(b); err != nil {
		return fmt.Errorf("unable to encode starTransactionTypeGiftTransfer#9614f7: field gift: %w", err)
	}
	return nil
}

// Decode implements bin.Decoder.
func (s *StarTransactionTypeGiftTransfer) Decode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeGiftTransfer#9614f7 to nil")
	}
	if err := b.ConsumeID(StarTransactionTypeGiftTransferTypeID); err != nil {
		return fmt.Errorf("unable to decode starTransactionTypeGiftTransfer#9614f7: %w", err)
	}
	return s.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (s *StarTransactionTypeGiftTransfer) DecodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeGiftTransfer#9614f7 to nil")
	}
	{
		value, err := DecodeMessageSender(b)
		if err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeGiftTransfer#9614f7: field owner_id: %w", err)
		}
		s.OwnerID = value
	}
	{
		if err := s.Gift.Decode(b); err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeGiftTransfer#9614f7: field gift: %w", err)
		}
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (s *StarTransactionTypeGiftTransfer) EncodeTDLibJSON(b tdjson.Encoder) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeGiftTransfer#9614f7 as nil")
	}
	b.ObjStart()
	b.PutID("starTransactionTypeGiftTransfer")
	b.Comma()
	b.FieldStart("owner_id")
	if s.OwnerID == nil {
		return fmt.Errorf("unable to encode starTransactionTypeGiftTransfer#9614f7: field owner_id is nil")
	}
	if err := s.OwnerID.EncodeTDLibJSON(b); err != nil {
		return fmt.Errorf("unable to encode starTransactionTypeGiftTransfer#9614f7: field owner_id: %w", err)
	}
	b.Comma()
	b.FieldStart("gift")
	if err := s.Gift.EncodeTDLibJSON(b); err != nil {
		return fmt.Errorf("unable to encode starTransactionTypeGiftTransfer#9614f7: field gift: %w", err)
	}
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *StarTransactionTypeGiftTransfer) DecodeTDLibJSON(b tdjson.Decoder) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeGiftTransfer#9614f7 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("starTransactionTypeGiftTransfer"); err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeGiftTransfer#9614f7: %w", err)
			}
		case "owner_id":
			value, err := DecodeTDLibJSONMessageSender(b)
			if err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeGiftTransfer#9614f7: field owner_id: %w", err)
			}
			s.OwnerID = value
		case "gift":
			if err := s.Gift.DecodeTDLibJSON(b); err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeGiftTransfer#9614f7: field gift: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// GetOwnerID returns value of OwnerID field.
func (s *StarTransactionTypeGiftTransfer) GetOwnerID() (value MessageSenderClass) {
	if s == nil {
		return
	}
	return s.OwnerID
}

// GetGift returns value of Gift field.
func (s *StarTransactionTypeGiftTransfer) GetGift() (value UpgradedGift) {
	if s == nil {
		return
	}
	return s.Gift
}

// StarTransactionTypeGiftSale represents TL type `starTransactionTypeGiftSale#64d61157`.
type StarTransactionTypeGiftSale struct {
	// Identifier of the user that sent the gift
	UserID int64
	// The gift
	Gift Gift
}

// StarTransactionTypeGiftSaleTypeID is TL type id of StarTransactionTypeGiftSale.
const StarTransactionTypeGiftSaleTypeID = 0x64d61157

// construct implements constructor of StarTransactionTypeClass.
func (s StarTransactionTypeGiftSale) construct() StarTransactionTypeClass { return &s }

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

	_ StarTransactionTypeClass = &StarTransactionTypeGiftSale{}
)

func (s *StarTransactionTypeGiftSale) Zero() bool {
	if s == nil {
		return true
	}
	if !(s.UserID == 0) {
		return false
	}
	if !(s.Gift.Zero()) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (s *StarTransactionTypeGiftSale) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "starTransactionTypeGiftSale",
		ID:   StarTransactionTypeGiftSaleTypeID,
	}
	if s == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "UserID",
			SchemaName: "user_id",
		},
		{
			Name:       "Gift",
			SchemaName: "gift",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (s *StarTransactionTypeGiftSale) Encode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeGiftSale#64d61157 as nil")
	}
	b.PutID(StarTransactionTypeGiftSaleTypeID)
	return s.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (s *StarTransactionTypeGiftSale) EncodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeGiftSale#64d61157 as nil")
	}
	b.PutInt53(s.UserID)
	if err := s.Gift.Encode(b); err != nil {
		return fmt.Errorf("unable to encode starTransactionTypeGiftSale#64d61157: field gift: %w", err)
	}
	return nil
}

// Decode implements bin.Decoder.
func (s *StarTransactionTypeGiftSale) Decode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeGiftSale#64d61157 to nil")
	}
	if err := b.ConsumeID(StarTransactionTypeGiftSaleTypeID); err != nil {
		return fmt.Errorf("unable to decode starTransactionTypeGiftSale#64d61157: %w", err)
	}
	return s.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (s *StarTransactionTypeGiftSale) DecodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeGiftSale#64d61157 to nil")
	}
	{
		value, err := b.Int53()
		if err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeGiftSale#64d61157: field user_id: %w", err)
		}
		s.UserID = value
	}
	{
		if err := s.Gift.Decode(b); err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeGiftSale#64d61157: field gift: %w", err)
		}
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (s *StarTransactionTypeGiftSale) EncodeTDLibJSON(b tdjson.Encoder) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeGiftSale#64d61157 as nil")
	}
	b.ObjStart()
	b.PutID("starTransactionTypeGiftSale")
	b.Comma()
	b.FieldStart("user_id")
	b.PutInt53(s.UserID)
	b.Comma()
	b.FieldStart("gift")
	if err := s.Gift.EncodeTDLibJSON(b); err != nil {
		return fmt.Errorf("unable to encode starTransactionTypeGiftSale#64d61157: field gift: %w", err)
	}
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *StarTransactionTypeGiftSale) DecodeTDLibJSON(b tdjson.Decoder) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeGiftSale#64d61157 to nil")
	}

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

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

// GetGift returns value of Gift field.
func (s *StarTransactionTypeGiftSale) GetGift() (value Gift) {
	if s == nil {
		return
	}
	return s.Gift
}

// StarTransactionTypeGiftUpgrade represents TL type `starTransactionTypeGiftUpgrade#da4e8319`.
type StarTransactionTypeGiftUpgrade struct {
	// Identifier of the user that initially sent the gift
	UserID int64
	// The upgraded gift
	Gift UpgradedGift
}

// StarTransactionTypeGiftUpgradeTypeID is TL type id of StarTransactionTypeGiftUpgrade.
const StarTransactionTypeGiftUpgradeTypeID = 0xda4e8319

// construct implements constructor of StarTransactionTypeClass.
func (s StarTransactionTypeGiftUpgrade) construct() StarTransactionTypeClass { return &s }

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

	_ StarTransactionTypeClass = &StarTransactionTypeGiftUpgrade{}
)

func (s *StarTransactionTypeGiftUpgrade) Zero() bool {
	if s == nil {
		return true
	}
	if !(s.UserID == 0) {
		return false
	}
	if !(s.Gift.Zero()) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (s *StarTransactionTypeGiftUpgrade) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "starTransactionTypeGiftUpgrade",
		ID:   StarTransactionTypeGiftUpgradeTypeID,
	}
	if s == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "UserID",
			SchemaName: "user_id",
		},
		{
			Name:       "Gift",
			SchemaName: "gift",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (s *StarTransactionTypeGiftUpgrade) Encode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeGiftUpgrade#da4e8319 as nil")
	}
	b.PutID(StarTransactionTypeGiftUpgradeTypeID)
	return s.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (s *StarTransactionTypeGiftUpgrade) EncodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeGiftUpgrade#da4e8319 as nil")
	}
	b.PutInt53(s.UserID)
	if err := s.Gift.Encode(b); err != nil {
		return fmt.Errorf("unable to encode starTransactionTypeGiftUpgrade#da4e8319: field gift: %w", err)
	}
	return nil
}

// Decode implements bin.Decoder.
func (s *StarTransactionTypeGiftUpgrade) Decode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeGiftUpgrade#da4e8319 to nil")
	}
	if err := b.ConsumeID(StarTransactionTypeGiftUpgradeTypeID); err != nil {
		return fmt.Errorf("unable to decode starTransactionTypeGiftUpgrade#da4e8319: %w", err)
	}
	return s.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (s *StarTransactionTypeGiftUpgrade) DecodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeGiftUpgrade#da4e8319 to nil")
	}
	{
		value, err := b.Int53()
		if err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeGiftUpgrade#da4e8319: field user_id: %w", err)
		}
		s.UserID = value
	}
	{
		if err := s.Gift.Decode(b); err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeGiftUpgrade#da4e8319: field gift: %w", err)
		}
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (s *StarTransactionTypeGiftUpgrade) EncodeTDLibJSON(b tdjson.Encoder) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeGiftUpgrade#da4e8319 as nil")
	}
	b.ObjStart()
	b.PutID("starTransactionTypeGiftUpgrade")
	b.Comma()
	b.FieldStart("user_id")
	b.PutInt53(s.UserID)
	b.Comma()
	b.FieldStart("gift")
	if err := s.Gift.EncodeTDLibJSON(b); err != nil {
		return fmt.Errorf("unable to encode starTransactionTypeGiftUpgrade#da4e8319: field gift: %w", err)
	}
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *StarTransactionTypeGiftUpgrade) DecodeTDLibJSON(b tdjson.Decoder) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeGiftUpgrade#da4e8319 to nil")
	}

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

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

// GetGift returns value of Gift field.
func (s *StarTransactionTypeGiftUpgrade) GetGift() (value UpgradedGift) {
	if s == nil {
		return
	}
	return s.Gift
}

// StarTransactionTypeUpgradedGiftPurchase represents TL type `starTransactionTypeUpgradedGiftPurchase#fc7af6f9`.
type StarTransactionTypeUpgradedGiftPurchase struct {
	// Identifier of the user that sold the gift
	UserID int64
	// The gift
	Gift UpgradedGift
}

// StarTransactionTypeUpgradedGiftPurchaseTypeID is TL type id of StarTransactionTypeUpgradedGiftPurchase.
const StarTransactionTypeUpgradedGiftPurchaseTypeID = 0xfc7af6f9

// construct implements constructor of StarTransactionTypeClass.
func (s StarTransactionTypeUpgradedGiftPurchase) construct() StarTransactionTypeClass { return &s }

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

	_ StarTransactionTypeClass = &StarTransactionTypeUpgradedGiftPurchase{}
)

func (s *StarTransactionTypeUpgradedGiftPurchase) Zero() bool {
	if s == nil {
		return true
	}
	if !(s.UserID == 0) {
		return false
	}
	if !(s.Gift.Zero()) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (s *StarTransactionTypeUpgradedGiftPurchase) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "starTransactionTypeUpgradedGiftPurchase",
		ID:   StarTransactionTypeUpgradedGiftPurchaseTypeID,
	}
	if s == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "UserID",
			SchemaName: "user_id",
		},
		{
			Name:       "Gift",
			SchemaName: "gift",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (s *StarTransactionTypeUpgradedGiftPurchase) Encode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeUpgradedGiftPurchase#fc7af6f9 as nil")
	}
	b.PutID(StarTransactionTypeUpgradedGiftPurchaseTypeID)
	return s.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (s *StarTransactionTypeUpgradedGiftPurchase) EncodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeUpgradedGiftPurchase#fc7af6f9 as nil")
	}
	b.PutInt53(s.UserID)
	if err := s.Gift.Encode(b); err != nil {
		return fmt.Errorf("unable to encode starTransactionTypeUpgradedGiftPurchase#fc7af6f9: field gift: %w", err)
	}
	return nil
}

// Decode implements bin.Decoder.
func (s *StarTransactionTypeUpgradedGiftPurchase) Decode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeUpgradedGiftPurchase#fc7af6f9 to nil")
	}
	if err := b.ConsumeID(StarTransactionTypeUpgradedGiftPurchaseTypeID); err != nil {
		return fmt.Errorf("unable to decode starTransactionTypeUpgradedGiftPurchase#fc7af6f9: %w", err)
	}
	return s.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (s *StarTransactionTypeUpgradedGiftPurchase) DecodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeUpgradedGiftPurchase#fc7af6f9 to nil")
	}
	{
		value, err := b.Int53()
		if err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeUpgradedGiftPurchase#fc7af6f9: field user_id: %w", err)
		}
		s.UserID = value
	}
	{
		if err := s.Gift.Decode(b); err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeUpgradedGiftPurchase#fc7af6f9: field gift: %w", err)
		}
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (s *StarTransactionTypeUpgradedGiftPurchase) EncodeTDLibJSON(b tdjson.Encoder) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeUpgradedGiftPurchase#fc7af6f9 as nil")
	}
	b.ObjStart()
	b.PutID("starTransactionTypeUpgradedGiftPurchase")
	b.Comma()
	b.FieldStart("user_id")
	b.PutInt53(s.UserID)
	b.Comma()
	b.FieldStart("gift")
	if err := s.Gift.EncodeTDLibJSON(b); err != nil {
		return fmt.Errorf("unable to encode starTransactionTypeUpgradedGiftPurchase#fc7af6f9: field gift: %w", err)
	}
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *StarTransactionTypeUpgradedGiftPurchase) DecodeTDLibJSON(b tdjson.Decoder) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeUpgradedGiftPurchase#fc7af6f9 to nil")
	}

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

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

// GetGift returns value of Gift field.
func (s *StarTransactionTypeUpgradedGiftPurchase) GetGift() (value UpgradedGift) {
	if s == nil {
		return
	}
	return s.Gift
}

// StarTransactionTypeUpgradedGiftSale represents TL type `starTransactionTypeUpgradedGiftSale#79b5a9bb`.
type StarTransactionTypeUpgradedGiftSale struct {
	// Identifier of the user that bought the gift
	UserID int64
	// The gift
	Gift UpgradedGift
	// Information about commission received by Telegram from the transaction
	Affiliate AffiliateInfo
}

// StarTransactionTypeUpgradedGiftSaleTypeID is TL type id of StarTransactionTypeUpgradedGiftSale.
const StarTransactionTypeUpgradedGiftSaleTypeID = 0x79b5a9bb

// construct implements constructor of StarTransactionTypeClass.
func (s StarTransactionTypeUpgradedGiftSale) construct() StarTransactionTypeClass { return &s }

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

	_ StarTransactionTypeClass = &StarTransactionTypeUpgradedGiftSale{}
)

func (s *StarTransactionTypeUpgradedGiftSale) Zero() bool {
	if s == nil {
		return true
	}
	if !(s.UserID == 0) {
		return false
	}
	if !(s.Gift.Zero()) {
		return false
	}
	if !(s.Affiliate.Zero()) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (s *StarTransactionTypeUpgradedGiftSale) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "starTransactionTypeUpgradedGiftSale",
		ID:   StarTransactionTypeUpgradedGiftSaleTypeID,
	}
	if s == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "UserID",
			SchemaName: "user_id",
		},
		{
			Name:       "Gift",
			SchemaName: "gift",
		},
		{
			Name:       "Affiliate",
			SchemaName: "affiliate",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (s *StarTransactionTypeUpgradedGiftSale) Encode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeUpgradedGiftSale#79b5a9bb as nil")
	}
	b.PutID(StarTransactionTypeUpgradedGiftSaleTypeID)
	return s.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (s *StarTransactionTypeUpgradedGiftSale) EncodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeUpgradedGiftSale#79b5a9bb as nil")
	}
	b.PutInt53(s.UserID)
	if err := s.Gift.Encode(b); err != nil {
		return fmt.Errorf("unable to encode starTransactionTypeUpgradedGiftSale#79b5a9bb: field gift: %w", err)
	}
	if err := s.Affiliate.Encode(b); err != nil {
		return fmt.Errorf("unable to encode starTransactionTypeUpgradedGiftSale#79b5a9bb: field affiliate: %w", err)
	}
	return nil
}

// Decode implements bin.Decoder.
func (s *StarTransactionTypeUpgradedGiftSale) Decode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeUpgradedGiftSale#79b5a9bb to nil")
	}
	if err := b.ConsumeID(StarTransactionTypeUpgradedGiftSaleTypeID); err != nil {
		return fmt.Errorf("unable to decode starTransactionTypeUpgradedGiftSale#79b5a9bb: %w", err)
	}
	return s.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (s *StarTransactionTypeUpgradedGiftSale) DecodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeUpgradedGiftSale#79b5a9bb to nil")
	}
	{
		value, err := b.Int53()
		if err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeUpgradedGiftSale#79b5a9bb: field user_id: %w", err)
		}
		s.UserID = value
	}
	{
		if err := s.Gift.Decode(b); err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeUpgradedGiftSale#79b5a9bb: field gift: %w", err)
		}
	}
	{
		if err := s.Affiliate.Decode(b); err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeUpgradedGiftSale#79b5a9bb: field affiliate: %w", err)
		}
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (s *StarTransactionTypeUpgradedGiftSale) EncodeTDLibJSON(b tdjson.Encoder) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeUpgradedGiftSale#79b5a9bb as nil")
	}
	b.ObjStart()
	b.PutID("starTransactionTypeUpgradedGiftSale")
	b.Comma()
	b.FieldStart("user_id")
	b.PutInt53(s.UserID)
	b.Comma()
	b.FieldStart("gift")
	if err := s.Gift.EncodeTDLibJSON(b); err != nil {
		return fmt.Errorf("unable to encode starTransactionTypeUpgradedGiftSale#79b5a9bb: field gift: %w", err)
	}
	b.Comma()
	b.FieldStart("affiliate")
	if err := s.Affiliate.EncodeTDLibJSON(b); err != nil {
		return fmt.Errorf("unable to encode starTransactionTypeUpgradedGiftSale#79b5a9bb: field affiliate: %w", err)
	}
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *StarTransactionTypeUpgradedGiftSale) DecodeTDLibJSON(b tdjson.Decoder) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeUpgradedGiftSale#79b5a9bb to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("starTransactionTypeUpgradedGiftSale"); err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeUpgradedGiftSale#79b5a9bb: %w", err)
			}
		case "user_id":
			value, err := b.Int53()
			if err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeUpgradedGiftSale#79b5a9bb: field user_id: %w", err)
			}
			s.UserID = value
		case "gift":
			if err := s.Gift.DecodeTDLibJSON(b); err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeUpgradedGiftSale#79b5a9bb: field gift: %w", err)
			}
		case "affiliate":
			if err := s.Affiliate.DecodeTDLibJSON(b); err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeUpgradedGiftSale#79b5a9bb: field affiliate: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

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

// GetGift returns value of Gift field.
func (s *StarTransactionTypeUpgradedGiftSale) GetGift() (value UpgradedGift) {
	if s == nil {
		return
	}
	return s.Gift
}

// GetAffiliate returns value of Affiliate field.
func (s *StarTransactionTypeUpgradedGiftSale) GetAffiliate() (value AffiliateInfo) {
	if s == nil {
		return
	}
	return s.Affiliate
}

// StarTransactionTypeChannelPaidReactionSend represents TL type `starTransactionTypeChannelPaidReactionSend#c02667c0`.
type StarTransactionTypeChannelPaidReactionSend struct {
	// Identifier of the channel chat
	ChatID int64
	// Identifier of the reacted message; can be 0 or an identifier of a deleted message
	MessageID int64
}

// StarTransactionTypeChannelPaidReactionSendTypeID is TL type id of StarTransactionTypeChannelPaidReactionSend.
const StarTransactionTypeChannelPaidReactionSendTypeID = 0xc02667c0

// construct implements constructor of StarTransactionTypeClass.
func (s StarTransactionTypeChannelPaidReactionSend) construct() StarTransactionTypeClass { return &s }

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

	_ StarTransactionTypeClass = &StarTransactionTypeChannelPaidReactionSend{}
)

func (s *StarTransactionTypeChannelPaidReactionSend) Zero() bool {
	if s == nil {
		return true
	}
	if !(s.ChatID == 0) {
		return false
	}
	if !(s.MessageID == 0) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (s *StarTransactionTypeChannelPaidReactionSend) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "starTransactionTypeChannelPaidReactionSend",
		ID:   StarTransactionTypeChannelPaidReactionSendTypeID,
	}
	if s == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "ChatID",
			SchemaName: "chat_id",
		},
		{
			Name:       "MessageID",
			SchemaName: "message_id",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (s *StarTransactionTypeChannelPaidReactionSend) Encode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeChannelPaidReactionSend#c02667c0 as nil")
	}
	b.PutID(StarTransactionTypeChannelPaidReactionSendTypeID)
	return s.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (s *StarTransactionTypeChannelPaidReactionSend) EncodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeChannelPaidReactionSend#c02667c0 as nil")
	}
	b.PutInt53(s.ChatID)
	b.PutInt53(s.MessageID)
	return nil
}

// Decode implements bin.Decoder.
func (s *StarTransactionTypeChannelPaidReactionSend) Decode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeChannelPaidReactionSend#c02667c0 to nil")
	}
	if err := b.ConsumeID(StarTransactionTypeChannelPaidReactionSendTypeID); err != nil {
		return fmt.Errorf("unable to decode starTransactionTypeChannelPaidReactionSend#c02667c0: %w", err)
	}
	return s.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (s *StarTransactionTypeChannelPaidReactionSend) DecodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeChannelPaidReactionSend#c02667c0 to nil")
	}
	{
		value, err := b.Int53()
		if err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeChannelPaidReactionSend#c02667c0: field chat_id: %w", err)
		}
		s.ChatID = value
	}
	{
		value, err := b.Int53()
		if err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeChannelPaidReactionSend#c02667c0: field message_id: %w", err)
		}
		s.MessageID = value
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (s *StarTransactionTypeChannelPaidReactionSend) EncodeTDLibJSON(b tdjson.Encoder) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeChannelPaidReactionSend#c02667c0 as nil")
	}
	b.ObjStart()
	b.PutID("starTransactionTypeChannelPaidReactionSend")
	b.Comma()
	b.FieldStart("chat_id")
	b.PutInt53(s.ChatID)
	b.Comma()
	b.FieldStart("message_id")
	b.PutInt53(s.MessageID)
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *StarTransactionTypeChannelPaidReactionSend) DecodeTDLibJSON(b tdjson.Decoder) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeChannelPaidReactionSend#c02667c0 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("starTransactionTypeChannelPaidReactionSend"); err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeChannelPaidReactionSend#c02667c0: %w", err)
			}
		case "chat_id":
			value, err := b.Int53()
			if err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeChannelPaidReactionSend#c02667c0: field chat_id: %w", err)
			}
			s.ChatID = value
		case "message_id":
			value, err := b.Int53()
			if err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeChannelPaidReactionSend#c02667c0: field message_id: %w", err)
			}
			s.MessageID = value
		default:
			return b.Skip()
		}
		return nil
	})
}

// GetChatID returns value of ChatID field.
func (s *StarTransactionTypeChannelPaidReactionSend) GetChatID() (value int64) {
	if s == nil {
		return
	}
	return s.ChatID
}

// GetMessageID returns value of MessageID field.
func (s *StarTransactionTypeChannelPaidReactionSend) GetMessageID() (value int64) {
	if s == nil {
		return
	}
	return s.MessageID
}

// StarTransactionTypeChannelPaidReactionReceive represents TL type `starTransactionTypeChannelPaidReactionReceive#23d6f9eb`.
type StarTransactionTypeChannelPaidReactionReceive struct {
	// Identifier of the user that added the paid reaction
	UserID int64
	// Identifier of the reacted message; can be 0 or an identifier of a deleted message
	MessageID int64
}

// StarTransactionTypeChannelPaidReactionReceiveTypeID is TL type id of StarTransactionTypeChannelPaidReactionReceive.
const StarTransactionTypeChannelPaidReactionReceiveTypeID = 0x23d6f9eb

// construct implements constructor of StarTransactionTypeClass.
func (s StarTransactionTypeChannelPaidReactionReceive) construct() StarTransactionTypeClass {
	return &s
}

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

	_ StarTransactionTypeClass = &StarTransactionTypeChannelPaidReactionReceive{}
)

func (s *StarTransactionTypeChannelPaidReactionReceive) Zero() bool {
	if s == nil {
		return true
	}
	if !(s.UserID == 0) {
		return false
	}
	if !(s.MessageID == 0) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (s *StarTransactionTypeChannelPaidReactionReceive) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "starTransactionTypeChannelPaidReactionReceive",
		ID:   StarTransactionTypeChannelPaidReactionReceiveTypeID,
	}
	if s == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "UserID",
			SchemaName: "user_id",
		},
		{
			Name:       "MessageID",
			SchemaName: "message_id",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (s *StarTransactionTypeChannelPaidReactionReceive) Encode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeChannelPaidReactionReceive#23d6f9eb as nil")
	}
	b.PutID(StarTransactionTypeChannelPaidReactionReceiveTypeID)
	return s.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (s *StarTransactionTypeChannelPaidReactionReceive) EncodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeChannelPaidReactionReceive#23d6f9eb as nil")
	}
	b.PutInt53(s.UserID)
	b.PutInt53(s.MessageID)
	return nil
}

// Decode implements bin.Decoder.
func (s *StarTransactionTypeChannelPaidReactionReceive) Decode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeChannelPaidReactionReceive#23d6f9eb to nil")
	}
	if err := b.ConsumeID(StarTransactionTypeChannelPaidReactionReceiveTypeID); err != nil {
		return fmt.Errorf("unable to decode starTransactionTypeChannelPaidReactionReceive#23d6f9eb: %w", err)
	}
	return s.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (s *StarTransactionTypeChannelPaidReactionReceive) DecodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeChannelPaidReactionReceive#23d6f9eb to nil")
	}
	{
		value, err := b.Int53()
		if err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeChannelPaidReactionReceive#23d6f9eb: field user_id: %w", err)
		}
		s.UserID = value
	}
	{
		value, err := b.Int53()
		if err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeChannelPaidReactionReceive#23d6f9eb: field message_id: %w", err)
		}
		s.MessageID = value
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (s *StarTransactionTypeChannelPaidReactionReceive) EncodeTDLibJSON(b tdjson.Encoder) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeChannelPaidReactionReceive#23d6f9eb as nil")
	}
	b.ObjStart()
	b.PutID("starTransactionTypeChannelPaidReactionReceive")
	b.Comma()
	b.FieldStart("user_id")
	b.PutInt53(s.UserID)
	b.Comma()
	b.FieldStart("message_id")
	b.PutInt53(s.MessageID)
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *StarTransactionTypeChannelPaidReactionReceive) DecodeTDLibJSON(b tdjson.Decoder) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeChannelPaidReactionReceive#23d6f9eb to nil")
	}

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

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

// GetMessageID returns value of MessageID field.
func (s *StarTransactionTypeChannelPaidReactionReceive) GetMessageID() (value int64) {
	if s == nil {
		return
	}
	return s.MessageID
}

// StarTransactionTypeAffiliateProgramCommission represents TL type `starTransactionTypeAffiliateProgramCommission#9a637573`.
type StarTransactionTypeAffiliateProgramCommission struct {
	// Identifier of the chat that created the affiliate program
	ChatID int64
	// The number of Telegram Stars received by the affiliate for each 1000 Telegram Stars
	// received by the program owner
	CommissionPerMille int32
}

// StarTransactionTypeAffiliateProgramCommissionTypeID is TL type id of StarTransactionTypeAffiliateProgramCommission.
const StarTransactionTypeAffiliateProgramCommissionTypeID = 0x9a637573

// construct implements constructor of StarTransactionTypeClass.
func (s StarTransactionTypeAffiliateProgramCommission) construct() StarTransactionTypeClass {
	return &s
}

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

	_ StarTransactionTypeClass = &StarTransactionTypeAffiliateProgramCommission{}
)

func (s *StarTransactionTypeAffiliateProgramCommission) Zero() bool {
	if s == nil {
		return true
	}
	if !(s.ChatID == 0) {
		return false
	}
	if !(s.CommissionPerMille == 0) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (s *StarTransactionTypeAffiliateProgramCommission) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "starTransactionTypeAffiliateProgramCommission",
		ID:   StarTransactionTypeAffiliateProgramCommissionTypeID,
	}
	if s == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "ChatID",
			SchemaName: "chat_id",
		},
		{
			Name:       "CommissionPerMille",
			SchemaName: "commission_per_mille",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (s *StarTransactionTypeAffiliateProgramCommission) Encode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeAffiliateProgramCommission#9a637573 as nil")
	}
	b.PutID(StarTransactionTypeAffiliateProgramCommissionTypeID)
	return s.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (s *StarTransactionTypeAffiliateProgramCommission) EncodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeAffiliateProgramCommission#9a637573 as nil")
	}
	b.PutInt53(s.ChatID)
	b.PutInt32(s.CommissionPerMille)
	return nil
}

// Decode implements bin.Decoder.
func (s *StarTransactionTypeAffiliateProgramCommission) Decode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeAffiliateProgramCommission#9a637573 to nil")
	}
	if err := b.ConsumeID(StarTransactionTypeAffiliateProgramCommissionTypeID); err != nil {
		return fmt.Errorf("unable to decode starTransactionTypeAffiliateProgramCommission#9a637573: %w", err)
	}
	return s.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (s *StarTransactionTypeAffiliateProgramCommission) DecodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeAffiliateProgramCommission#9a637573 to nil")
	}
	{
		value, err := b.Int53()
		if err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeAffiliateProgramCommission#9a637573: field chat_id: %w", err)
		}
		s.ChatID = value
	}
	{
		value, err := b.Int32()
		if err != nil {
			return fmt.Errorf("unable to decode starTransactionTypeAffiliateProgramCommission#9a637573: field commission_per_mille: %w", err)
		}
		s.CommissionPerMille = value
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (s *StarTransactionTypeAffiliateProgramCommission) EncodeTDLibJSON(b tdjson.Encoder) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeAffiliateProgramCommission#9a637573 as nil")
	}
	b.ObjStart()
	b.PutID("starTransactionTypeAffiliateProgramCommission")
	b.Comma()
	b.FieldStart("chat_id")
	b.PutInt53(s.ChatID)
	b.Comma()
	b.FieldStart("commission_per_mille")
	b.PutInt32(s.CommissionPerMille)
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *StarTransactionTypeAffiliateProgramCommission) DecodeTDLibJSON(b tdjson.Decoder) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeAffiliateProgramCommission#9a637573 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("starTransactionTypeAffiliateProgramCommission"); err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeAffiliateProgramCommission#9a637573: %w", err)
			}
		case "chat_id":
			value, err := b.Int53()
			if err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeAffiliateProgramCommission#9a637573: field chat_id: %w", err)
			}
			s.ChatID = value
		case "commission_per_mille":
			value, err := b.Int32()
			if err != nil {
				return fmt.Errorf("unable to decode starTransactionTypeAffiliateProgramCommission#9a637573: field commission_per_mille: %w", err)
			}
			s.CommissionPerMille = value
		default:
			return b.Skip()
		}
		return nil
	})
}

// GetChatID returns value of ChatID field.
func (s *StarTransactionTypeAffiliateProgramCommission) GetChatID() (value int64) {
	if s == nil {
		return
	}
	return s.ChatID
}

// GetCommissionPerMille returns value of CommissionPerMille field.
func (s *StarTransactionTypeAffiliateProgramCommission) GetCommissionPerMille() (value int32) {
	if s == nil {
		return
	}
	return s.CommissionPerMille
}

// StarTransactionTypePaidMessageSend represents TL type `starTransactionTypePaidMessageSend#9a196465`.
type StarTransactionTypePaidMessageSend struct {
	// Identifier of the chat that received the payment
	ChatID int64
	// Number of sent paid messages
	MessageCount int32
}

// StarTransactionTypePaidMessageSendTypeID is TL type id of StarTransactionTypePaidMessageSend.
const StarTransactionTypePaidMessageSendTypeID = 0x9a196465

// construct implements constructor of StarTransactionTypeClass.
func (s StarTransactionTypePaidMessageSend) construct() StarTransactionTypeClass { return &s }

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

	_ StarTransactionTypeClass = &StarTransactionTypePaidMessageSend{}
)

func (s *StarTransactionTypePaidMessageSend) Zero() bool {
	if s == nil {
		return true
	}
	if !(s.ChatID == 0) {
		return false
	}
	if !(s.MessageCount == 0) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (s *StarTransactionTypePaidMessageSend) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "starTransactionTypePaidMessageSend",
		ID:   StarTransactionTypePaidMessageSendTypeID,
	}
	if s == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "ChatID",
			SchemaName: "chat_id",
		},
		{
			Name:       "MessageCount",
			SchemaName: "message_count",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (s *StarTransactionTypePaidMessageSend) Encode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypePaidMessageSend#9a196465 as nil")
	}
	b.PutID(StarTransactionTypePaidMessageSendTypeID)
	return s.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (s *StarTransactionTypePaidMessageSend) EncodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypePaidMessageSend#9a196465 as nil")
	}
	b.PutInt53(s.ChatID)
	b.PutInt32(s.MessageCount)
	return nil
}

// Decode implements bin.Decoder.
func (s *StarTransactionTypePaidMessageSend) Decode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypePaidMessageSend#9a196465 to nil")
	}
	if err := b.ConsumeID(StarTransactionTypePaidMessageSendTypeID); err != nil {
		return fmt.Errorf("unable to decode starTransactionTypePaidMessageSend#9a196465: %w", err)
	}
	return s.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (s *StarTransactionTypePaidMessageSend) DecodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypePaidMessageSend#9a196465 to nil")
	}
	{
		value, err := b.Int53()
		if err != nil {
			return fmt.Errorf("unable to decode starTransactionTypePaidMessageSend#9a196465: field chat_id: %w", err)
		}
		s.ChatID = value
	}
	{
		value, err := b.Int32()
		if err != nil {
			return fmt.Errorf("unable to decode starTransactionTypePaidMessageSend#9a196465: field message_count: %w", err)
		}
		s.MessageCount = value
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (s *StarTransactionTypePaidMessageSend) EncodeTDLibJSON(b tdjson.Encoder) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypePaidMessageSend#9a196465 as nil")
	}
	b.ObjStart()
	b.PutID("starTransactionTypePaidMessageSend")
	b.Comma()
	b.FieldStart("chat_id")
	b.PutInt53(s.ChatID)
	b.Comma()
	b.FieldStart("message_count")
	b.PutInt32(s.MessageCount)
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *StarTransactionTypePaidMessageSend) DecodeTDLibJSON(b tdjson.Decoder) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypePaidMessageSend#9a196465 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("starTransactionTypePaidMessageSend"); err != nil {
				return fmt.Errorf("unable to decode starTransactionTypePaidMessageSend#9a196465: %w", err)
			}
		case "chat_id":
			value, err := b.Int53()
			if err != nil {
				return fmt.Errorf("unable to decode starTransactionTypePaidMessageSend#9a196465: field chat_id: %w", err)
			}
			s.ChatID = value
		case "message_count":
			value, err := b.Int32()
			if err != nil {
				return fmt.Errorf("unable to decode starTransactionTypePaidMessageSend#9a196465: field message_count: %w", err)
			}
			s.MessageCount = value
		default:
			return b.Skip()
		}
		return nil
	})
}

// GetChatID returns value of ChatID field.
func (s *StarTransactionTypePaidMessageSend) GetChatID() (value int64) {
	if s == nil {
		return
	}
	return s.ChatID
}

// GetMessageCount returns value of MessageCount field.
func (s *StarTransactionTypePaidMessageSend) GetMessageCount() (value int32) {
	if s == nil {
		return
	}
	return s.MessageCount
}

// StarTransactionTypePaidMessageReceive represents TL type `starTransactionTypePaidMessageReceive#d7a83dc6`.
type StarTransactionTypePaidMessageReceive struct {
	// Identifier of the sender of the message
	SenderID MessageSenderClass
	// Number of received paid messages
	MessageCount int32
	// The number of Telegram Stars received by the Telegram for each 1000 Telegram Stars
	// paid for message sending
	CommissionPerMille int32
	// The amount of Telegram Stars that were received by Telegram; can be negative for
	// refunds
	CommissionStarAmount StarAmount
}

// StarTransactionTypePaidMessageReceiveTypeID is TL type id of StarTransactionTypePaidMessageReceive.
const StarTransactionTypePaidMessageReceiveTypeID = 0xd7a83dc6

// construct implements constructor of StarTransactionTypeClass.
func (s StarTransactionTypePaidMessageReceive) construct() StarTransactionTypeClass { return &s }

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

	_ StarTransactionTypeClass = &StarTransactionTypePaidMessageReceive{}
)

func (s *StarTransactionTypePaidMessageReceive) Zero() bool {
	if s == nil {
		return true
	}
	if !(s.SenderID == nil) {
		return false
	}
	if !(s.MessageCount == 0) {
		return false
	}
	if !(s.CommissionPerMille == 0) {
		return false
	}
	if !(s.CommissionStarAmount.Zero()) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (s *StarTransactionTypePaidMessageReceive) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "starTransactionTypePaidMessageReceive",
		ID:   StarTransactionTypePaidMessageReceiveTypeID,
	}
	if s == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "SenderID",
			SchemaName: "sender_id",
		},
		{
			Name:       "MessageCount",
			SchemaName: "message_count",
		},
		{
			Name:       "CommissionPerMille",
			SchemaName: "commission_per_mille",
		},
		{
			Name:       "CommissionStarAmount",
			SchemaName: "commission_star_amount",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (s *StarTransactionTypePaidMessageReceive) Encode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypePaidMessageReceive#d7a83dc6 as nil")
	}
	b.PutID(StarTransactionTypePaidMessageReceiveTypeID)
	return s.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (s *StarTransactionTypePaidMessageReceive) EncodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypePaidMessageReceive#d7a83dc6 as nil")
	}
	if s.SenderID == nil {
		return fmt.Errorf("unable to encode starTransactionTypePaidMessageReceive#d7a83dc6: field sender_id is nil")
	}
	if err := s.SenderID.Encode(b); err != nil {
		return fmt.Errorf("unable to encode starTransactionTypePaidMessageReceive#d7a83dc6: field sender_id: %w", err)
	}
	b.PutInt32(s.MessageCount)
	b.PutInt32(s.CommissionPerMille)
	if err := s.CommissionStarAmount.Encode(b); err != nil {
		return fmt.Errorf("unable to encode starTransactionTypePaidMessageReceive#d7a83dc6: field commission_star_amount: %w", err)
	}
	return nil
}

// Decode implements bin.Decoder.
func (s *StarTransactionTypePaidMessageReceive) Decode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypePaidMessageReceive#d7a83dc6 to nil")
	}
	if err := b.ConsumeID(StarTransactionTypePaidMessageReceiveTypeID); err != nil {
		return fmt.Errorf("unable to decode starTransactionTypePaidMessageReceive#d7a83dc6: %w", err)
	}
	return s.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (s *StarTransactionTypePaidMessageReceive) DecodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypePaidMessageReceive#d7a83dc6 to nil")
	}
	{
		value, err := DecodeMessageSender(b)
		if err != nil {
			return fmt.Errorf("unable to decode starTransactionTypePaidMessageReceive#d7a83dc6: field sender_id: %w", err)
		}
		s.SenderID = value
	}
	{
		value, err := b.Int32()
		if err != nil {
			return fmt.Errorf("unable to decode starTransactionTypePaidMessageReceive#d7a83dc6: field message_count: %w", err)
		}
		s.MessageCount = value
	}
	{
		value, err := b.Int32()
		if err != nil {
			return fmt.Errorf("unable to decode starTransactionTypePaidMessageReceive#d7a83dc6: field commission_per_mille: %w", err)
		}
		s.CommissionPerMille = value
	}
	{
		if err := s.CommissionStarAmount.Decode(b); err != nil {
			return fmt.Errorf("unable to decode starTransactionTypePaidMessageReceive#d7a83dc6: field commission_star_amount: %w", err)
		}
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (s *StarTransactionTypePaidMessageReceive) EncodeTDLibJSON(b tdjson.Encoder) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypePaidMessageReceive#d7a83dc6 as nil")
	}
	b.ObjStart()
	b.PutID("starTransactionTypePaidMessageReceive")
	b.Comma()
	b.FieldStart("sender_id")
	if s.SenderID == nil {
		return fmt.Errorf("unable to encode starTransactionTypePaidMessageReceive#d7a83dc6: field sender_id is nil")
	}
	if err := s.SenderID.EncodeTDLibJSON(b); err != nil {
		return fmt.Errorf("unable to encode starTransactionTypePaidMessageReceive#d7a83dc6: field sender_id: %w", err)
	}
	b.Comma()
	b.FieldStart("message_count")
	b.PutInt32(s.MessageCount)
	b.Comma()
	b.FieldStart("commission_per_mille")
	b.PutInt32(s.CommissionPerMille)
	b.Comma()
	b.FieldStart("commission_star_amount")
	if err := s.CommissionStarAmount.EncodeTDLibJSON(b); err != nil {
		return fmt.Errorf("unable to encode starTransactionTypePaidMessageReceive#d7a83dc6: field commission_star_amount: %w", err)
	}
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *StarTransactionTypePaidMessageReceive) DecodeTDLibJSON(b tdjson.Decoder) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypePaidMessageReceive#d7a83dc6 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("starTransactionTypePaidMessageReceive"); err != nil {
				return fmt.Errorf("unable to decode starTransactionTypePaidMessageReceive#d7a83dc6: %w", err)
			}
		case "sender_id":
			value, err := DecodeTDLibJSONMessageSender(b)
			if err != nil {
				return fmt.Errorf("unable to decode starTransactionTypePaidMessageReceive#d7a83dc6: field sender_id: %w", err)
			}
			s.SenderID = value
		case "message_count":
			value, err := b.Int32()
			if err != nil {
				return fmt.Errorf("unable to decode starTransactionTypePaidMessageReceive#d7a83dc6: field message_count: %w", err)
			}
			s.MessageCount = value
		case "commission_per_mille":
			value, err := b.Int32()
			if err != nil {
				return fmt.Errorf("unable to decode starTransactionTypePaidMessageReceive#d7a83dc6: field commission_per_mille: %w", err)
			}
			s.CommissionPerMille = value
		case "commission_star_amount":
			if err := s.CommissionStarAmount.DecodeTDLibJSON(b); err != nil {
				return fmt.Errorf("unable to decode starTransactionTypePaidMessageReceive#d7a83dc6: field commission_star_amount: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// GetSenderID returns value of SenderID field.
func (s *StarTransactionTypePaidMessageReceive) GetSenderID() (value MessageSenderClass) {
	if s == nil {
		return
	}
	return s.SenderID
}

// GetMessageCount returns value of MessageCount field.
func (s *StarTransactionTypePaidMessageReceive) GetMessageCount() (value int32) {
	if s == nil {
		return
	}
	return s.MessageCount
}

// GetCommissionPerMille returns value of CommissionPerMille field.
func (s *StarTransactionTypePaidMessageReceive) GetCommissionPerMille() (value int32) {
	if s == nil {
		return
	}
	return s.CommissionPerMille
}

// GetCommissionStarAmount returns value of CommissionStarAmount field.
func (s *StarTransactionTypePaidMessageReceive) GetCommissionStarAmount() (value StarAmount) {
	if s == nil {
		return
	}
	return s.CommissionStarAmount
}

// StarTransactionTypePremiumPurchase represents TL type `starTransactionTypePremiumPurchase#3b7db803`.
type StarTransactionTypePremiumPurchase struct {
	// Identifier of the user that received the Telegram Premium subscription
	UserID int64
	// Number of months the Telegram Premium subscription will be active
	MonthCount int32
	// A sticker to be shown in the transaction information; may be null if unknown
	Sticker Sticker
}

// StarTransactionTypePremiumPurchaseTypeID is TL type id of StarTransactionTypePremiumPurchase.
const StarTransactionTypePremiumPurchaseTypeID = 0x3b7db803

// construct implements constructor of StarTransactionTypeClass.
func (s StarTransactionTypePremiumPurchase) construct() StarTransactionTypeClass { return &s }

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

	_ StarTransactionTypeClass = &StarTransactionTypePremiumPurchase{}
)

func (s *StarTransactionTypePremiumPurchase) Zero() bool {
	if s == nil {
		return true
	}
	if !(s.UserID == 0) {
		return false
	}
	if !(s.MonthCount == 0) {
		return false
	}
	if !(s.Sticker.Zero()) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (s *StarTransactionTypePremiumPurchase) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "starTransactionTypePremiumPurchase",
		ID:   StarTransactionTypePremiumPurchaseTypeID,
	}
	if s == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "UserID",
			SchemaName: "user_id",
		},
		{
			Name:       "MonthCount",
			SchemaName: "month_count",
		},
		{
			Name:       "Sticker",
			SchemaName: "sticker",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (s *StarTransactionTypePremiumPurchase) Encode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypePremiumPurchase#3b7db803 as nil")
	}
	b.PutID(StarTransactionTypePremiumPurchaseTypeID)
	return s.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (s *StarTransactionTypePremiumPurchase) EncodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypePremiumPurchase#3b7db803 as nil")
	}
	b.PutInt53(s.UserID)
	b.PutInt32(s.MonthCount)
	if err := s.Sticker.Encode(b); err != nil {
		return fmt.Errorf("unable to encode starTransactionTypePremiumPurchase#3b7db803: field sticker: %w", err)
	}
	return nil
}

// Decode implements bin.Decoder.
func (s *StarTransactionTypePremiumPurchase) Decode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypePremiumPurchase#3b7db803 to nil")
	}
	if err := b.ConsumeID(StarTransactionTypePremiumPurchaseTypeID); err != nil {
		return fmt.Errorf("unable to decode starTransactionTypePremiumPurchase#3b7db803: %w", err)
	}
	return s.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (s *StarTransactionTypePremiumPurchase) DecodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypePremiumPurchase#3b7db803 to nil")
	}
	{
		value, err := b.Int53()
		if err != nil {
			return fmt.Errorf("unable to decode starTransactionTypePremiumPurchase#3b7db803: field user_id: %w", err)
		}
		s.UserID = value
	}
	{
		value, err := b.Int32()
		if err != nil {
			return fmt.Errorf("unable to decode starTransactionTypePremiumPurchase#3b7db803: field month_count: %w", err)
		}
		s.MonthCount = value
	}
	{
		if err := s.Sticker.Decode(b); err != nil {
			return fmt.Errorf("unable to decode starTransactionTypePremiumPurchase#3b7db803: field sticker: %w", err)
		}
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (s *StarTransactionTypePremiumPurchase) EncodeTDLibJSON(b tdjson.Encoder) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypePremiumPurchase#3b7db803 as nil")
	}
	b.ObjStart()
	b.PutID("starTransactionTypePremiumPurchase")
	b.Comma()
	b.FieldStart("user_id")
	b.PutInt53(s.UserID)
	b.Comma()
	b.FieldStart("month_count")
	b.PutInt32(s.MonthCount)
	b.Comma()
	b.FieldStart("sticker")
	if err := s.Sticker.EncodeTDLibJSON(b); err != nil {
		return fmt.Errorf("unable to encode starTransactionTypePremiumPurchase#3b7db803: field sticker: %w", err)
	}
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *StarTransactionTypePremiumPurchase) DecodeTDLibJSON(b tdjson.Decoder) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypePremiumPurchase#3b7db803 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("starTransactionTypePremiumPurchase"); err != nil {
				return fmt.Errorf("unable to decode starTransactionTypePremiumPurchase#3b7db803: %w", err)
			}
		case "user_id":
			value, err := b.Int53()
			if err != nil {
				return fmt.Errorf("unable to decode starTransactionTypePremiumPurchase#3b7db803: field user_id: %w", err)
			}
			s.UserID = value
		case "month_count":
			value, err := b.Int32()
			if err != nil {
				return fmt.Errorf("unable to decode starTransactionTypePremiumPurchase#3b7db803: field month_count: %w", err)
			}
			s.MonthCount = value
		case "sticker":
			if err := s.Sticker.DecodeTDLibJSON(b); err != nil {
				return fmt.Errorf("unable to decode starTransactionTypePremiumPurchase#3b7db803: field sticker: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

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

// GetMonthCount returns value of MonthCount field.
func (s *StarTransactionTypePremiumPurchase) GetMonthCount() (value int32) {
	if s == nil {
		return
	}
	return s.MonthCount
}

// GetSticker returns value of Sticker field.
func (s *StarTransactionTypePremiumPurchase) GetSticker() (value Sticker) {
	if s == nil {
		return
	}
	return s.Sticker
}

// StarTransactionTypeBusinessBotTransferSend represents TL type `starTransactionTypeBusinessBotTransferSend#48ca7526`.
type StarTransactionTypeBusinessBotTransferSend struct {
	// Identifier of the bot that received Telegram Stars
	UserID int64
}

// StarTransactionTypeBusinessBotTransferSendTypeID is TL type id of StarTransactionTypeBusinessBotTransferSend.
const StarTransactionTypeBusinessBotTransferSendTypeID = 0x48ca7526

// construct implements constructor of StarTransactionTypeClass.
func (s StarTransactionTypeBusinessBotTransferSend) construct() StarTransactionTypeClass { return &s }

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

	_ StarTransactionTypeClass = &StarTransactionTypeBusinessBotTransferSend{}
)

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

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (s *StarTransactionTypeBusinessBotTransferSend) Encode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeBusinessBotTransferSend#48ca7526 as nil")
	}
	b.PutID(StarTransactionTypeBusinessBotTransferSendTypeID)
	return s.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (s *StarTransactionTypeBusinessBotTransferSend) EncodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeBusinessBotTransferSend#48ca7526 as nil")
	}
	b.PutInt53(s.UserID)
	return nil
}

// Decode implements bin.Decoder.
func (s *StarTransactionTypeBusinessBotTransferSend) Decode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeBusinessBotTransferSend#48ca7526 to nil")
	}
	if err := b.ConsumeID(StarTransactionTypeBusinessBotTransferSendTypeID); err != nil {
		return fmt.Errorf("unable to decode starTransactionTypeBusinessBotTransferSend#48ca7526: %w", err)
	}
	return s.DecodeBare(b)
}

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

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (s *StarTransactionTypeBusinessBotTransferSend) EncodeTDLibJSON(b tdjson.Encoder) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeBusinessBotTransferSend#48ca7526 as nil")
	}
	b.ObjStart()
	b.PutID("starTransactionTypeBusinessBotTransferSend")
	b.Comma()
	b.FieldStart("user_id")
	b.PutInt53(s.UserID)
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *StarTransactionTypeBusinessBotTransferSend) DecodeTDLibJSON(b tdjson.Decoder) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeBusinessBotTransferSend#48ca7526 to nil")
	}

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

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

// StarTransactionTypeBusinessBotTransferReceive represents TL type `starTransactionTypeBusinessBotTransferReceive#1fbd418a`.
type StarTransactionTypeBusinessBotTransferReceive struct {
	// Identifier of the user that sent Telegram Stars
	UserID int64
}

// StarTransactionTypeBusinessBotTransferReceiveTypeID is TL type id of StarTransactionTypeBusinessBotTransferReceive.
const StarTransactionTypeBusinessBotTransferReceiveTypeID = 0x1fbd418a

// construct implements constructor of StarTransactionTypeClass.
func (s StarTransactionTypeBusinessBotTransferReceive) construct() StarTransactionTypeClass {
	return &s
}

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

	_ StarTransactionTypeClass = &StarTransactionTypeBusinessBotTransferReceive{}
)

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

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (s *StarTransactionTypeBusinessBotTransferReceive) Encode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeBusinessBotTransferReceive#1fbd418a as nil")
	}
	b.PutID(StarTransactionTypeBusinessBotTransferReceiveTypeID)
	return s.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (s *StarTransactionTypeBusinessBotTransferReceive) EncodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeBusinessBotTransferReceive#1fbd418a as nil")
	}
	b.PutInt53(s.UserID)
	return nil
}

// Decode implements bin.Decoder.
func (s *StarTransactionTypeBusinessBotTransferReceive) Decode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeBusinessBotTransferReceive#1fbd418a to nil")
	}
	if err := b.ConsumeID(StarTransactionTypeBusinessBotTransferReceiveTypeID); err != nil {
		return fmt.Errorf("unable to decode starTransactionTypeBusinessBotTransferReceive#1fbd418a: %w", err)
	}
	return s.DecodeBare(b)
}

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

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (s *StarTransactionTypeBusinessBotTransferReceive) EncodeTDLibJSON(b tdjson.Encoder) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeBusinessBotTransferReceive#1fbd418a as nil")
	}
	b.ObjStart()
	b.PutID("starTransactionTypeBusinessBotTransferReceive")
	b.Comma()
	b.FieldStart("user_id")
	b.PutInt53(s.UserID)
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *StarTransactionTypeBusinessBotTransferReceive) DecodeTDLibJSON(b tdjson.Decoder) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeBusinessBotTransferReceive#1fbd418a to nil")
	}

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

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

// StarTransactionTypeUnsupported represents TL type `starTransactionTypeUnsupported#76cfcab2`.
type StarTransactionTypeUnsupported struct {
}

// StarTransactionTypeUnsupportedTypeID is TL type id of StarTransactionTypeUnsupported.
const StarTransactionTypeUnsupportedTypeID = 0x76cfcab2

// construct implements constructor of StarTransactionTypeClass.
func (s StarTransactionTypeUnsupported) construct() StarTransactionTypeClass { return &s }

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

	_ StarTransactionTypeClass = &StarTransactionTypeUnsupported{}
)

func (s *StarTransactionTypeUnsupported) Zero() bool {
	if s == nil {
		return true
	}

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (s *StarTransactionTypeUnsupported) Encode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeUnsupported#76cfcab2 as nil")
	}
	b.PutID(StarTransactionTypeUnsupportedTypeID)
	return s.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (s *StarTransactionTypeUnsupported) EncodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeUnsupported#76cfcab2 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (s *StarTransactionTypeUnsupported) Decode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeUnsupported#76cfcab2 to nil")
	}
	if err := b.ConsumeID(StarTransactionTypeUnsupportedTypeID); err != nil {
		return fmt.Errorf("unable to decode starTransactionTypeUnsupported#76cfcab2: %w", err)
	}
	return s.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (s *StarTransactionTypeUnsupported) DecodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeUnsupported#76cfcab2 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (s *StarTransactionTypeUnsupported) EncodeTDLibJSON(b tdjson.Encoder) error {
	if s == nil {
		return fmt.Errorf("can't encode starTransactionTypeUnsupported#76cfcab2 as nil")
	}
	b.ObjStart()
	b.PutID("starTransactionTypeUnsupported")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *StarTransactionTypeUnsupported) DecodeTDLibJSON(b tdjson.Decoder) error {
	if s == nil {
		return fmt.Errorf("can't decode starTransactionTypeUnsupported#76cfcab2 to nil")
	}

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

// StarTransactionTypeClassName is schema name of StarTransactionTypeClass.
const StarTransactionTypeClassName = "StarTransactionType"

// StarTransactionTypeClass represents StarTransactionType generic type.
//
// Example:
//
//	g, err := tdapi.DecodeStarTransactionType(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tdapi.StarTransactionTypePremiumBotDeposit: // starTransactionTypePremiumBotDeposit#d879090e
//	case *tdapi.StarTransactionTypeAppStoreDeposit: // starTransactionTypeAppStoreDeposit#8283941
//	case *tdapi.StarTransactionTypeGooglePlayDeposit: // starTransactionTypeGooglePlayDeposit#ecbdb656
//	case *tdapi.StarTransactionTypeFragmentDeposit: // starTransactionTypeFragmentDeposit#7625e44
//	case *tdapi.StarTransactionTypeUserDeposit: // starTransactionTypeUserDeposit#c2a18e9
//	case *tdapi.StarTransactionTypeGiveawayDeposit: // starTransactionTypeGiveawayDeposit#b16200c6
//	case *tdapi.StarTransactionTypeFragmentWithdrawal: // starTransactionTypeFragmentWithdrawal#af3a2992
//	case *tdapi.StarTransactionTypeTelegramAdsWithdrawal: // starTransactionTypeTelegramAdsWithdrawal#a58e8469
//	case *tdapi.StarTransactionTypeTelegramAPIUsage: // starTransactionTypeTelegramApiUsage#27a82afe
//	case *tdapi.StarTransactionTypeBotPaidMediaPurchase: // starTransactionTypeBotPaidMediaPurchase#7f48cc6a
//	case *tdapi.StarTransactionTypeBotPaidMediaSale: // starTransactionTypeBotPaidMediaSale#6e07eeb2
//	case *tdapi.StarTransactionTypeChannelPaidMediaPurchase: // starTransactionTypeChannelPaidMediaPurchase#9016d4f5
//	case *tdapi.StarTransactionTypeChannelPaidMediaSale: // starTransactionTypeChannelPaidMediaSale#eace92ef
//	case *tdapi.StarTransactionTypeBotInvoicePurchase: // starTransactionTypeBotInvoicePurchase#1dddac0c
//	case *tdapi.StarTransactionTypeBotInvoiceSale: // starTransactionTypeBotInvoiceSale#5b7d8d2f
//	case *tdapi.StarTransactionTypeBotSubscriptionPurchase: // starTransactionTypeBotSubscriptionPurchase#40bf1355
//	case *tdapi.StarTransactionTypeBotSubscriptionSale: // starTransactionTypeBotSubscriptionSale#1f686889
//	case *tdapi.StarTransactionTypeChannelSubscriptionPurchase: // starTransactionTypeChannelSubscriptionPurchase#380eb3d1
//	case *tdapi.StarTransactionTypeChannelSubscriptionSale: // starTransactionTypeChannelSubscriptionSale#fe127c82
//	case *tdapi.StarTransactionTypeGiftPurchase: // starTransactionTypeGiftPurchase#939390e0
//	case *tdapi.StarTransactionTypeGiftTransfer: // starTransactionTypeGiftTransfer#9614f7
//	case *tdapi.StarTransactionTypeGiftSale: // starTransactionTypeGiftSale#64d61157
//	case *tdapi.StarTransactionTypeGiftUpgrade: // starTransactionTypeGiftUpgrade#da4e8319
//	case *tdapi.StarTransactionTypeUpgradedGiftPurchase: // starTransactionTypeUpgradedGiftPurchase#fc7af6f9
//	case *tdapi.StarTransactionTypeUpgradedGiftSale: // starTransactionTypeUpgradedGiftSale#79b5a9bb
//	case *tdapi.StarTransactionTypeChannelPaidReactionSend: // starTransactionTypeChannelPaidReactionSend#c02667c0
//	case *tdapi.StarTransactionTypeChannelPaidReactionReceive: // starTransactionTypeChannelPaidReactionReceive#23d6f9eb
//	case *tdapi.StarTransactionTypeAffiliateProgramCommission: // starTransactionTypeAffiliateProgramCommission#9a637573
//	case *tdapi.StarTransactionTypePaidMessageSend: // starTransactionTypePaidMessageSend#9a196465
//	case *tdapi.StarTransactionTypePaidMessageReceive: // starTransactionTypePaidMessageReceive#d7a83dc6
//	case *tdapi.StarTransactionTypePremiumPurchase: // starTransactionTypePremiumPurchase#3b7db803
//	case *tdapi.StarTransactionTypeBusinessBotTransferSend: // starTransactionTypeBusinessBotTransferSend#48ca7526
//	case *tdapi.StarTransactionTypeBusinessBotTransferReceive: // starTransactionTypeBusinessBotTransferReceive#1fbd418a
//	case *tdapi.StarTransactionTypeUnsupported: // starTransactionTypeUnsupported#76cfcab2
//	default: panic(v)
//	}
type StarTransactionTypeClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() StarTransactionTypeClass

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

// DecodeStarTransactionType implements binary de-serialization for StarTransactionTypeClass.
func DecodeStarTransactionType(buf *bin.Buffer) (StarTransactionTypeClass, error) {
	id, err := buf.PeekID()
	if err != nil {
		return nil, err
	}
	switch id {
	case StarTransactionTypePremiumBotDepositTypeID:
		// Decoding starTransactionTypePremiumBotDeposit#d879090e.
		v := StarTransactionTypePremiumBotDeposit{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case StarTransactionTypeAppStoreDepositTypeID:
		// Decoding starTransactionTypeAppStoreDeposit#8283941.
		v := StarTransactionTypeAppStoreDeposit{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case StarTransactionTypeGooglePlayDepositTypeID:
		// Decoding starTransactionTypeGooglePlayDeposit#ecbdb656.
		v := StarTransactionTypeGooglePlayDeposit{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case StarTransactionTypeFragmentDepositTypeID:
		// Decoding starTransactionTypeFragmentDeposit#7625e44.
		v := StarTransactionTypeFragmentDeposit{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case StarTransactionTypeUserDepositTypeID:
		// Decoding starTransactionTypeUserDeposit#c2a18e9.
		v := StarTransactionTypeUserDeposit{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case StarTransactionTypeGiveawayDepositTypeID:
		// Decoding starTransactionTypeGiveawayDeposit#b16200c6.
		v := StarTransactionTypeGiveawayDeposit{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case StarTransactionTypeFragmentWithdrawalTypeID:
		// Decoding starTransactionTypeFragmentWithdrawal#af3a2992.
		v := StarTransactionTypeFragmentWithdrawal{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case StarTransactionTypeTelegramAdsWithdrawalTypeID:
		// Decoding starTransactionTypeTelegramAdsWithdrawal#a58e8469.
		v := StarTransactionTypeTelegramAdsWithdrawal{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case StarTransactionTypeTelegramAPIUsageTypeID:
		// Decoding starTransactionTypeTelegramApiUsage#27a82afe.
		v := StarTransactionTypeTelegramAPIUsage{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case StarTransactionTypeBotPaidMediaPurchaseTypeID:
		// Decoding starTransactionTypeBotPaidMediaPurchase#7f48cc6a.
		v := StarTransactionTypeBotPaidMediaPurchase{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case StarTransactionTypeBotPaidMediaSaleTypeID:
		// Decoding starTransactionTypeBotPaidMediaSale#6e07eeb2.
		v := StarTransactionTypeBotPaidMediaSale{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case StarTransactionTypeChannelPaidMediaPurchaseTypeID:
		// Decoding starTransactionTypeChannelPaidMediaPurchase#9016d4f5.
		v := StarTransactionTypeChannelPaidMediaPurchase{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case StarTransactionTypeChannelPaidMediaSaleTypeID:
		// Decoding starTransactionTypeChannelPaidMediaSale#eace92ef.
		v := StarTransactionTypeChannelPaidMediaSale{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case StarTransactionTypeBotInvoicePurchaseTypeID:
		// Decoding starTransactionTypeBotInvoicePurchase#1dddac0c.
		v := StarTransactionTypeBotInvoicePurchase{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case StarTransactionTypeBotInvoiceSaleTypeID:
		// Decoding starTransactionTypeBotInvoiceSale#5b7d8d2f.
		v := StarTransactionTypeBotInvoiceSale{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case StarTransactionTypeBotSubscriptionPurchaseTypeID:
		// Decoding starTransactionTypeBotSubscriptionPurchase#40bf1355.
		v := StarTransactionTypeBotSubscriptionPurchase{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case StarTransactionTypeBotSubscriptionSaleTypeID:
		// Decoding starTransactionTypeBotSubscriptionSale#1f686889.
		v := StarTransactionTypeBotSubscriptionSale{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case StarTransactionTypeChannelSubscriptionPurchaseTypeID:
		// Decoding starTransactionTypeChannelSubscriptionPurchase#380eb3d1.
		v := StarTransactionTypeChannelSubscriptionPurchase{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case StarTransactionTypeChannelSubscriptionSaleTypeID:
		// Decoding starTransactionTypeChannelSubscriptionSale#fe127c82.
		v := StarTransactionTypeChannelSubscriptionSale{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case StarTransactionTypeGiftPurchaseTypeID:
		// Decoding starTransactionTypeGiftPurchase#939390e0.
		v := StarTransactionTypeGiftPurchase{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case StarTransactionTypeGiftTransferTypeID:
		// Decoding starTransactionTypeGiftTransfer#9614f7.
		v := StarTransactionTypeGiftTransfer{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case StarTransactionTypeGiftSaleTypeID:
		// Decoding starTransactionTypeGiftSale#64d61157.
		v := StarTransactionTypeGiftSale{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case StarTransactionTypeGiftUpgradeTypeID:
		// Decoding starTransactionTypeGiftUpgrade#da4e8319.
		v := StarTransactionTypeGiftUpgrade{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case StarTransactionTypeUpgradedGiftPurchaseTypeID:
		// Decoding starTransactionTypeUpgradedGiftPurchase#fc7af6f9.
		v := StarTransactionTypeUpgradedGiftPurchase{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case StarTransactionTypeUpgradedGiftSaleTypeID:
		// Decoding starTransactionTypeUpgradedGiftSale#79b5a9bb.
		v := StarTransactionTypeUpgradedGiftSale{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case StarTransactionTypeChannelPaidReactionSendTypeID:
		// Decoding starTransactionTypeChannelPaidReactionSend#c02667c0.
		v := StarTransactionTypeChannelPaidReactionSend{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case StarTransactionTypeChannelPaidReactionReceiveTypeID:
		// Decoding starTransactionTypeChannelPaidReactionReceive#23d6f9eb.
		v := StarTransactionTypeChannelPaidReactionReceive{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case StarTransactionTypeAffiliateProgramCommissionTypeID:
		// Decoding starTransactionTypeAffiliateProgramCommission#9a637573.
		v := StarTransactionTypeAffiliateProgramCommission{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case StarTransactionTypePaidMessageSendTypeID:
		// Decoding starTransactionTypePaidMessageSend#9a196465.
		v := StarTransactionTypePaidMessageSend{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case StarTransactionTypePaidMessageReceiveTypeID:
		// Decoding starTransactionTypePaidMessageReceive#d7a83dc6.
		v := StarTransactionTypePaidMessageReceive{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case StarTransactionTypePremiumPurchaseTypeID:
		// Decoding starTransactionTypePremiumPurchase#3b7db803.
		v := StarTransactionTypePremiumPurchase{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case StarTransactionTypeBusinessBotTransferSendTypeID:
		// Decoding starTransactionTypeBusinessBotTransferSend#48ca7526.
		v := StarTransactionTypeBusinessBotTransferSend{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case StarTransactionTypeBusinessBotTransferReceiveTypeID:
		// Decoding starTransactionTypeBusinessBotTransferReceive#1fbd418a.
		v := StarTransactionTypeBusinessBotTransferReceive{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case StarTransactionTypeUnsupportedTypeID:
		// Decoding starTransactionTypeUnsupported#76cfcab2.
		v := StarTransactionTypeUnsupported{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	default:
		return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", bin.NewUnexpectedID(id))
	}
}

// DecodeTDLibJSONStarTransactionType implements binary de-serialization for StarTransactionTypeClass.
func DecodeTDLibJSONStarTransactionType(buf tdjson.Decoder) (StarTransactionTypeClass, error) {
	id, err := buf.FindTypeID()
	if err != nil {
		return nil, err
	}
	switch id {
	case "starTransactionTypePremiumBotDeposit":
		// Decoding starTransactionTypePremiumBotDeposit#d879090e.
		v := StarTransactionTypePremiumBotDeposit{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case "starTransactionTypeAppStoreDeposit":
		// Decoding starTransactionTypeAppStoreDeposit#8283941.
		v := StarTransactionTypeAppStoreDeposit{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case "starTransactionTypeGooglePlayDeposit":
		// Decoding starTransactionTypeGooglePlayDeposit#ecbdb656.
		v := StarTransactionTypeGooglePlayDeposit{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case "starTransactionTypeFragmentDeposit":
		// Decoding starTransactionTypeFragmentDeposit#7625e44.
		v := StarTransactionTypeFragmentDeposit{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case "starTransactionTypeUserDeposit":
		// Decoding starTransactionTypeUserDeposit#c2a18e9.
		v := StarTransactionTypeUserDeposit{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case "starTransactionTypeGiveawayDeposit":
		// Decoding starTransactionTypeGiveawayDeposit#b16200c6.
		v := StarTransactionTypeGiveawayDeposit{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case "starTransactionTypeFragmentWithdrawal":
		// Decoding starTransactionTypeFragmentWithdrawal#af3a2992.
		v := StarTransactionTypeFragmentWithdrawal{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case "starTransactionTypeTelegramAdsWithdrawal":
		// Decoding starTransactionTypeTelegramAdsWithdrawal#a58e8469.
		v := StarTransactionTypeTelegramAdsWithdrawal{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case "starTransactionTypeTelegramApiUsage":
		// Decoding starTransactionTypeTelegramApiUsage#27a82afe.
		v := StarTransactionTypeTelegramAPIUsage{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case "starTransactionTypeBotPaidMediaPurchase":
		// Decoding starTransactionTypeBotPaidMediaPurchase#7f48cc6a.
		v := StarTransactionTypeBotPaidMediaPurchase{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case "starTransactionTypeBotPaidMediaSale":
		// Decoding starTransactionTypeBotPaidMediaSale#6e07eeb2.
		v := StarTransactionTypeBotPaidMediaSale{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case "starTransactionTypeChannelPaidMediaPurchase":
		// Decoding starTransactionTypeChannelPaidMediaPurchase#9016d4f5.
		v := StarTransactionTypeChannelPaidMediaPurchase{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case "starTransactionTypeChannelPaidMediaSale":
		// Decoding starTransactionTypeChannelPaidMediaSale#eace92ef.
		v := StarTransactionTypeChannelPaidMediaSale{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case "starTransactionTypeBotInvoicePurchase":
		// Decoding starTransactionTypeBotInvoicePurchase#1dddac0c.
		v := StarTransactionTypeBotInvoicePurchase{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case "starTransactionTypeBotInvoiceSale":
		// Decoding starTransactionTypeBotInvoiceSale#5b7d8d2f.
		v := StarTransactionTypeBotInvoiceSale{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case "starTransactionTypeBotSubscriptionPurchase":
		// Decoding starTransactionTypeBotSubscriptionPurchase#40bf1355.
		v := StarTransactionTypeBotSubscriptionPurchase{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case "starTransactionTypeBotSubscriptionSale":
		// Decoding starTransactionTypeBotSubscriptionSale#1f686889.
		v := StarTransactionTypeBotSubscriptionSale{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case "starTransactionTypeChannelSubscriptionPurchase":
		// Decoding starTransactionTypeChannelSubscriptionPurchase#380eb3d1.
		v := StarTransactionTypeChannelSubscriptionPurchase{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case "starTransactionTypeChannelSubscriptionSale":
		// Decoding starTransactionTypeChannelSubscriptionSale#fe127c82.
		v := StarTransactionTypeChannelSubscriptionSale{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case "starTransactionTypeGiftPurchase":
		// Decoding starTransactionTypeGiftPurchase#939390e0.
		v := StarTransactionTypeGiftPurchase{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case "starTransactionTypeGiftTransfer":
		// Decoding starTransactionTypeGiftTransfer#9614f7.
		v := StarTransactionTypeGiftTransfer{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case "starTransactionTypeGiftSale":
		// Decoding starTransactionTypeGiftSale#64d61157.
		v := StarTransactionTypeGiftSale{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case "starTransactionTypeGiftUpgrade":
		// Decoding starTransactionTypeGiftUpgrade#da4e8319.
		v := StarTransactionTypeGiftUpgrade{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case "starTransactionTypeUpgradedGiftPurchase":
		// Decoding starTransactionTypeUpgradedGiftPurchase#fc7af6f9.
		v := StarTransactionTypeUpgradedGiftPurchase{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case "starTransactionTypeUpgradedGiftSale":
		// Decoding starTransactionTypeUpgradedGiftSale#79b5a9bb.
		v := StarTransactionTypeUpgradedGiftSale{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case "starTransactionTypeChannelPaidReactionSend":
		// Decoding starTransactionTypeChannelPaidReactionSend#c02667c0.
		v := StarTransactionTypeChannelPaidReactionSend{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case "starTransactionTypeChannelPaidReactionReceive":
		// Decoding starTransactionTypeChannelPaidReactionReceive#23d6f9eb.
		v := StarTransactionTypeChannelPaidReactionReceive{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case "starTransactionTypeAffiliateProgramCommission":
		// Decoding starTransactionTypeAffiliateProgramCommission#9a637573.
		v := StarTransactionTypeAffiliateProgramCommission{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case "starTransactionTypePaidMessageSend":
		// Decoding starTransactionTypePaidMessageSend#9a196465.
		v := StarTransactionTypePaidMessageSend{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case "starTransactionTypePaidMessageReceive":
		// Decoding starTransactionTypePaidMessageReceive#d7a83dc6.
		v := StarTransactionTypePaidMessageReceive{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case "starTransactionTypePremiumPurchase":
		// Decoding starTransactionTypePremiumPurchase#3b7db803.
		v := StarTransactionTypePremiumPurchase{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case "starTransactionTypeBusinessBotTransferSend":
		// Decoding starTransactionTypeBusinessBotTransferSend#48ca7526.
		v := StarTransactionTypeBusinessBotTransferSend{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case "starTransactionTypeBusinessBotTransferReceive":
		// Decoding starTransactionTypeBusinessBotTransferReceive#1fbd418a.
		v := StarTransactionTypeBusinessBotTransferReceive{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	case "starTransactionTypeUnsupported":
		// Decoding starTransactionTypeUnsupported#76cfcab2.
		v := StarTransactionTypeUnsupported{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err)
		}
		return &v, nil
	default:
		return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", tdjson.NewUnexpectedID(id))
	}
}

// StarTransactionType boxes the StarTransactionTypeClass providing a helper.
type StarTransactionTypeBox struct {
	StarTransactionType StarTransactionTypeClass
}

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

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

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

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