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

// ReportSponsoredResultOk represents TL type `reportSponsoredResultOk#f857a690`.
type ReportSponsoredResultOk struct {
}

// ReportSponsoredResultOkTypeID is TL type id of ReportSponsoredResultOk.
const ReportSponsoredResultOkTypeID = 0xf857a690

// construct implements constructor of ReportSponsoredResultClass.
func (r ReportSponsoredResultOk) construct() ReportSponsoredResultClass { return &r }

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

	_ ReportSponsoredResultClass = &ReportSponsoredResultOk{}
)

func (r *ReportSponsoredResultOk) Zero() bool {
	if r == nil {
		return true
	}

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (r *ReportSponsoredResultOk) Encode(b *bin.Buffer) error {
	if r == nil {
		return fmt.Errorf("can't encode reportSponsoredResultOk#f857a690 as nil")
	}
	b.PutID(ReportSponsoredResultOkTypeID)
	return r.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (r *ReportSponsoredResultOk) EncodeBare(b *bin.Buffer) error {
	if r == nil {
		return fmt.Errorf("can't encode reportSponsoredResultOk#f857a690 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (r *ReportSponsoredResultOk) Decode(b *bin.Buffer) error {
	if r == nil {
		return fmt.Errorf("can't decode reportSponsoredResultOk#f857a690 to nil")
	}
	if err := b.ConsumeID(ReportSponsoredResultOkTypeID); err != nil {
		return fmt.Errorf("unable to decode reportSponsoredResultOk#f857a690: %w", err)
	}
	return r.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (r *ReportSponsoredResultOk) DecodeBare(b *bin.Buffer) error {
	if r == nil {
		return fmt.Errorf("can't decode reportSponsoredResultOk#f857a690 to nil")
	}
	return nil
}

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

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (r *ReportSponsoredResultOk) DecodeTDLibJSON(b tdjson.Decoder) error {
	if r == nil {
		return fmt.Errorf("can't decode reportSponsoredResultOk#f857a690 to nil")
	}

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

// ReportSponsoredResultFailed represents TL type `reportSponsoredResultFailed#496a77e6`.
type ReportSponsoredResultFailed struct {
}

// ReportSponsoredResultFailedTypeID is TL type id of ReportSponsoredResultFailed.
const ReportSponsoredResultFailedTypeID = 0x496a77e6

// construct implements constructor of ReportSponsoredResultClass.
func (r ReportSponsoredResultFailed) construct() ReportSponsoredResultClass { return &r }

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

	_ ReportSponsoredResultClass = &ReportSponsoredResultFailed{}
)

func (r *ReportSponsoredResultFailed) Zero() bool {
	if r == nil {
		return true
	}

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (r *ReportSponsoredResultFailed) Encode(b *bin.Buffer) error {
	if r == nil {
		return fmt.Errorf("can't encode reportSponsoredResultFailed#496a77e6 as nil")
	}
	b.PutID(ReportSponsoredResultFailedTypeID)
	return r.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (r *ReportSponsoredResultFailed) EncodeBare(b *bin.Buffer) error {
	if r == nil {
		return fmt.Errorf("can't encode reportSponsoredResultFailed#496a77e6 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (r *ReportSponsoredResultFailed) Decode(b *bin.Buffer) error {
	if r == nil {
		return fmt.Errorf("can't decode reportSponsoredResultFailed#496a77e6 to nil")
	}
	if err := b.ConsumeID(ReportSponsoredResultFailedTypeID); err != nil {
		return fmt.Errorf("unable to decode reportSponsoredResultFailed#496a77e6: %w", err)
	}
	return r.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (r *ReportSponsoredResultFailed) DecodeBare(b *bin.Buffer) error {
	if r == nil {
		return fmt.Errorf("can't decode reportSponsoredResultFailed#496a77e6 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (r *ReportSponsoredResultFailed) EncodeTDLibJSON(b tdjson.Encoder) error {
	if r == nil {
		return fmt.Errorf("can't encode reportSponsoredResultFailed#496a77e6 as nil")
	}
	b.ObjStart()
	b.PutID("reportSponsoredResultFailed")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (r *ReportSponsoredResultFailed) DecodeTDLibJSON(b tdjson.Decoder) error {
	if r == nil {
		return fmt.Errorf("can't decode reportSponsoredResultFailed#496a77e6 to nil")
	}

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

// ReportSponsoredResultOptionRequired represents TL type `reportSponsoredResultOptionRequired#4cc421d5`.
type ReportSponsoredResultOptionRequired struct {
	// Title for the option choice
	Title string
	// List of available options
	Options []ReportOption
}

// ReportSponsoredResultOptionRequiredTypeID is TL type id of ReportSponsoredResultOptionRequired.
const ReportSponsoredResultOptionRequiredTypeID = 0x4cc421d5

// construct implements constructor of ReportSponsoredResultClass.
func (r ReportSponsoredResultOptionRequired) construct() ReportSponsoredResultClass { return &r }

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

	_ ReportSponsoredResultClass = &ReportSponsoredResultOptionRequired{}
)

func (r *ReportSponsoredResultOptionRequired) Zero() bool {
	if r == nil {
		return true
	}
	if !(r.Title == "") {
		return false
	}
	if !(r.Options == nil) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (r *ReportSponsoredResultOptionRequired) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "reportSponsoredResultOptionRequired",
		ID:   ReportSponsoredResultOptionRequiredTypeID,
	}
	if r == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Title",
			SchemaName: "title",
		},
		{
			Name:       "Options",
			SchemaName: "options",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (r *ReportSponsoredResultOptionRequired) Encode(b *bin.Buffer) error {
	if r == nil {
		return fmt.Errorf("can't encode reportSponsoredResultOptionRequired#4cc421d5 as nil")
	}
	b.PutID(ReportSponsoredResultOptionRequiredTypeID)
	return r.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (r *ReportSponsoredResultOptionRequired) EncodeBare(b *bin.Buffer) error {
	if r == nil {
		return fmt.Errorf("can't encode reportSponsoredResultOptionRequired#4cc421d5 as nil")
	}
	b.PutString(r.Title)
	b.PutInt(len(r.Options))
	for idx, v := range r.Options {
		if err := v.EncodeBare(b); err != nil {
			return fmt.Errorf("unable to encode bare reportSponsoredResultOptionRequired#4cc421d5: field options element with index %d: %w", idx, err)
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func (r *ReportSponsoredResultOptionRequired) Decode(b *bin.Buffer) error {
	if r == nil {
		return fmt.Errorf("can't decode reportSponsoredResultOptionRequired#4cc421d5 to nil")
	}
	if err := b.ConsumeID(ReportSponsoredResultOptionRequiredTypeID); err != nil {
		return fmt.Errorf("unable to decode reportSponsoredResultOptionRequired#4cc421d5: %w", err)
	}
	return r.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (r *ReportSponsoredResultOptionRequired) DecodeBare(b *bin.Buffer) error {
	if r == nil {
		return fmt.Errorf("can't decode reportSponsoredResultOptionRequired#4cc421d5 to nil")
	}
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode reportSponsoredResultOptionRequired#4cc421d5: field title: %w", err)
		}
		r.Title = value
	}
	{
		headerLen, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode reportSponsoredResultOptionRequired#4cc421d5: field options: %w", err)
		}

		if headerLen > 0 {
			r.Options = make([]ReportOption, 0, headerLen%bin.PreallocateLimit)
		}
		for idx := 0; idx < headerLen; idx++ {
			var value ReportOption
			if err := value.DecodeBare(b); err != nil {
				return fmt.Errorf("unable to decode bare reportSponsoredResultOptionRequired#4cc421d5: field options: %w", err)
			}
			r.Options = append(r.Options, value)
		}
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (r *ReportSponsoredResultOptionRequired) EncodeTDLibJSON(b tdjson.Encoder) error {
	if r == nil {
		return fmt.Errorf("can't encode reportSponsoredResultOptionRequired#4cc421d5 as nil")
	}
	b.ObjStart()
	b.PutID("reportSponsoredResultOptionRequired")
	b.Comma()
	b.FieldStart("title")
	b.PutString(r.Title)
	b.Comma()
	b.FieldStart("options")
	b.ArrStart()
	for idx, v := range r.Options {
		if err := v.EncodeTDLibJSON(b); err != nil {
			return fmt.Errorf("unable to encode reportSponsoredResultOptionRequired#4cc421d5: field options 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 (r *ReportSponsoredResultOptionRequired) DecodeTDLibJSON(b tdjson.Decoder) error {
	if r == nil {
		return fmt.Errorf("can't decode reportSponsoredResultOptionRequired#4cc421d5 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("reportSponsoredResultOptionRequired"); err != nil {
				return fmt.Errorf("unable to decode reportSponsoredResultOptionRequired#4cc421d5: %w", err)
			}
		case "title":
			value, err := b.String()
			if err != nil {
				return fmt.Errorf("unable to decode reportSponsoredResultOptionRequired#4cc421d5: field title: %w", err)
			}
			r.Title = value
		case "options":
			if err := b.Arr(func(b tdjson.Decoder) error {
				var value ReportOption
				if err := value.DecodeTDLibJSON(b); err != nil {
					return fmt.Errorf("unable to decode reportSponsoredResultOptionRequired#4cc421d5: field options: %w", err)
				}
				r.Options = append(r.Options, value)
				return nil
			}); err != nil {
				return fmt.Errorf("unable to decode reportSponsoredResultOptionRequired#4cc421d5: field options: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

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

// GetOptions returns value of Options field.
func (r *ReportSponsoredResultOptionRequired) GetOptions() (value []ReportOption) {
	if r == nil {
		return
	}
	return r.Options
}

// ReportSponsoredResultAdsHidden represents TL type `reportSponsoredResultAdsHidden#e9cf7715`.
type ReportSponsoredResultAdsHidden struct {
}

// ReportSponsoredResultAdsHiddenTypeID is TL type id of ReportSponsoredResultAdsHidden.
const ReportSponsoredResultAdsHiddenTypeID = 0xe9cf7715

// construct implements constructor of ReportSponsoredResultClass.
func (r ReportSponsoredResultAdsHidden) construct() ReportSponsoredResultClass { return &r }

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

	_ ReportSponsoredResultClass = &ReportSponsoredResultAdsHidden{}
)

func (r *ReportSponsoredResultAdsHidden) Zero() bool {
	if r == nil {
		return true
	}

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (r *ReportSponsoredResultAdsHidden) Encode(b *bin.Buffer) error {
	if r == nil {
		return fmt.Errorf("can't encode reportSponsoredResultAdsHidden#e9cf7715 as nil")
	}
	b.PutID(ReportSponsoredResultAdsHiddenTypeID)
	return r.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (r *ReportSponsoredResultAdsHidden) EncodeBare(b *bin.Buffer) error {
	if r == nil {
		return fmt.Errorf("can't encode reportSponsoredResultAdsHidden#e9cf7715 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (r *ReportSponsoredResultAdsHidden) Decode(b *bin.Buffer) error {
	if r == nil {
		return fmt.Errorf("can't decode reportSponsoredResultAdsHidden#e9cf7715 to nil")
	}
	if err := b.ConsumeID(ReportSponsoredResultAdsHiddenTypeID); err != nil {
		return fmt.Errorf("unable to decode reportSponsoredResultAdsHidden#e9cf7715: %w", err)
	}
	return r.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (r *ReportSponsoredResultAdsHidden) DecodeBare(b *bin.Buffer) error {
	if r == nil {
		return fmt.Errorf("can't decode reportSponsoredResultAdsHidden#e9cf7715 to nil")
	}
	return nil
}

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

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (r *ReportSponsoredResultAdsHidden) DecodeTDLibJSON(b tdjson.Decoder) error {
	if r == nil {
		return fmt.Errorf("can't decode reportSponsoredResultAdsHidden#e9cf7715 to nil")
	}

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

// ReportSponsoredResultPremiumRequired represents TL type `reportSponsoredResultPremiumRequired#fcb27b51`.
type ReportSponsoredResultPremiumRequired struct {
}

// ReportSponsoredResultPremiumRequiredTypeID is TL type id of ReportSponsoredResultPremiumRequired.
const ReportSponsoredResultPremiumRequiredTypeID = 0xfcb27b51

// construct implements constructor of ReportSponsoredResultClass.
func (r ReportSponsoredResultPremiumRequired) construct() ReportSponsoredResultClass { return &r }

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

	_ ReportSponsoredResultClass = &ReportSponsoredResultPremiumRequired{}
)

func (r *ReportSponsoredResultPremiumRequired) Zero() bool {
	if r == nil {
		return true
	}

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (r *ReportSponsoredResultPremiumRequired) Encode(b *bin.Buffer) error {
	if r == nil {
		return fmt.Errorf("can't encode reportSponsoredResultPremiumRequired#fcb27b51 as nil")
	}
	b.PutID(ReportSponsoredResultPremiumRequiredTypeID)
	return r.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (r *ReportSponsoredResultPremiumRequired) EncodeBare(b *bin.Buffer) error {
	if r == nil {
		return fmt.Errorf("can't encode reportSponsoredResultPremiumRequired#fcb27b51 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (r *ReportSponsoredResultPremiumRequired) Decode(b *bin.Buffer) error {
	if r == nil {
		return fmt.Errorf("can't decode reportSponsoredResultPremiumRequired#fcb27b51 to nil")
	}
	if err := b.ConsumeID(ReportSponsoredResultPremiumRequiredTypeID); err != nil {
		return fmt.Errorf("unable to decode reportSponsoredResultPremiumRequired#fcb27b51: %w", err)
	}
	return r.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (r *ReportSponsoredResultPremiumRequired) DecodeBare(b *bin.Buffer) error {
	if r == nil {
		return fmt.Errorf("can't decode reportSponsoredResultPremiumRequired#fcb27b51 to nil")
	}
	return nil
}

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

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (r *ReportSponsoredResultPremiumRequired) DecodeTDLibJSON(b tdjson.Decoder) error {
	if r == nil {
		return fmt.Errorf("can't decode reportSponsoredResultPremiumRequired#fcb27b51 to nil")
	}

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

// ReportSponsoredResultClassName is schema name of ReportSponsoredResultClass.
const ReportSponsoredResultClassName = "ReportSponsoredResult"

// ReportSponsoredResultClass represents ReportSponsoredResult generic type.
//
// Example:
//
//	g, err := tdapi.DecodeReportSponsoredResult(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tdapi.ReportSponsoredResultOk: // reportSponsoredResultOk#f857a690
//	case *tdapi.ReportSponsoredResultFailed: // reportSponsoredResultFailed#496a77e6
//	case *tdapi.ReportSponsoredResultOptionRequired: // reportSponsoredResultOptionRequired#4cc421d5
//	case *tdapi.ReportSponsoredResultAdsHidden: // reportSponsoredResultAdsHidden#e9cf7715
//	case *tdapi.ReportSponsoredResultPremiumRequired: // reportSponsoredResultPremiumRequired#fcb27b51
//	default: panic(v)
//	}
type ReportSponsoredResultClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() ReportSponsoredResultClass

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

// DecodeReportSponsoredResult implements binary de-serialization for ReportSponsoredResultClass.
func DecodeReportSponsoredResult(buf *bin.Buffer) (ReportSponsoredResultClass, error) {
	id, err := buf.PeekID()
	if err != nil {
		return nil, err
	}
	switch id {
	case ReportSponsoredResultOkTypeID:
		// Decoding reportSponsoredResultOk#f857a690.
		v := ReportSponsoredResultOk{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode ReportSponsoredResultClass: %w", err)
		}
		return &v, nil
	case ReportSponsoredResultFailedTypeID:
		// Decoding reportSponsoredResultFailed#496a77e6.
		v := ReportSponsoredResultFailed{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode ReportSponsoredResultClass: %w", err)
		}
		return &v, nil
	case ReportSponsoredResultOptionRequiredTypeID:
		// Decoding reportSponsoredResultOptionRequired#4cc421d5.
		v := ReportSponsoredResultOptionRequired{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode ReportSponsoredResultClass: %w", err)
		}
		return &v, nil
	case ReportSponsoredResultAdsHiddenTypeID:
		// Decoding reportSponsoredResultAdsHidden#e9cf7715.
		v := ReportSponsoredResultAdsHidden{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode ReportSponsoredResultClass: %w", err)
		}
		return &v, nil
	case ReportSponsoredResultPremiumRequiredTypeID:
		// Decoding reportSponsoredResultPremiumRequired#fcb27b51.
		v := ReportSponsoredResultPremiumRequired{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode ReportSponsoredResultClass: %w", err)
		}
		return &v, nil
	default:
		return nil, fmt.Errorf("unable to decode ReportSponsoredResultClass: %w", bin.NewUnexpectedID(id))
	}
}

// DecodeTDLibJSONReportSponsoredResult implements binary de-serialization for ReportSponsoredResultClass.
func DecodeTDLibJSONReportSponsoredResult(buf tdjson.Decoder) (ReportSponsoredResultClass, error) {
	id, err := buf.FindTypeID()
	if err != nil {
		return nil, err
	}
	switch id {
	case "reportSponsoredResultOk":
		// Decoding reportSponsoredResultOk#f857a690.
		v := ReportSponsoredResultOk{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode ReportSponsoredResultClass: %w", err)
		}
		return &v, nil
	case "reportSponsoredResultFailed":
		// Decoding reportSponsoredResultFailed#496a77e6.
		v := ReportSponsoredResultFailed{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode ReportSponsoredResultClass: %w", err)
		}
		return &v, nil
	case "reportSponsoredResultOptionRequired":
		// Decoding reportSponsoredResultOptionRequired#4cc421d5.
		v := ReportSponsoredResultOptionRequired{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode ReportSponsoredResultClass: %w", err)
		}
		return &v, nil
	case "reportSponsoredResultAdsHidden":
		// Decoding reportSponsoredResultAdsHidden#e9cf7715.
		v := ReportSponsoredResultAdsHidden{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode ReportSponsoredResultClass: %w", err)
		}
		return &v, nil
	case "reportSponsoredResultPremiumRequired":
		// Decoding reportSponsoredResultPremiumRequired#fcb27b51.
		v := ReportSponsoredResultPremiumRequired{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode ReportSponsoredResultClass: %w", err)
		}
		return &v, nil
	default:
		return nil, fmt.Errorf("unable to decode ReportSponsoredResultClass: %w", tdjson.NewUnexpectedID(id))
	}
}

// ReportSponsoredResult boxes the ReportSponsoredResultClass providing a helper.
type ReportSponsoredResultBox struct {
	ReportSponsoredResult ReportSponsoredResultClass
}

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

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

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

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