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

// InviteGroupCallParticipantResultUserPrivacyRestricted represents TL type `inviteGroupCallParticipantResultUserPrivacyRestricted#328c5f9`.
type InviteGroupCallParticipantResultUserPrivacyRestricted struct {
}

// InviteGroupCallParticipantResultUserPrivacyRestrictedTypeID is TL type id of InviteGroupCallParticipantResultUserPrivacyRestricted.
const InviteGroupCallParticipantResultUserPrivacyRestrictedTypeID = 0x328c5f9

// construct implements constructor of InviteGroupCallParticipantResultClass.
func (i InviteGroupCallParticipantResultUserPrivacyRestricted) construct() InviteGroupCallParticipantResultClass {
	return &i
}

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

	_ InviteGroupCallParticipantResultClass = &InviteGroupCallParticipantResultUserPrivacyRestricted{}
)

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

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (i *InviteGroupCallParticipantResultUserPrivacyRestricted) Encode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode inviteGroupCallParticipantResultUserPrivacyRestricted#328c5f9 as nil")
	}
	b.PutID(InviteGroupCallParticipantResultUserPrivacyRestrictedTypeID)
	return i.EncodeBare(b)
}

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

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

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

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

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

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

// InviteGroupCallParticipantResultUserAlreadyParticipant represents TL type `inviteGroupCallParticipantResultUserAlreadyParticipant#276e1687`.
type InviteGroupCallParticipantResultUserAlreadyParticipant struct {
}

// InviteGroupCallParticipantResultUserAlreadyParticipantTypeID is TL type id of InviteGroupCallParticipantResultUserAlreadyParticipant.
const InviteGroupCallParticipantResultUserAlreadyParticipantTypeID = 0x276e1687

// construct implements constructor of InviteGroupCallParticipantResultClass.
func (i InviteGroupCallParticipantResultUserAlreadyParticipant) construct() InviteGroupCallParticipantResultClass {
	return &i
}

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

	_ InviteGroupCallParticipantResultClass = &InviteGroupCallParticipantResultUserAlreadyParticipant{}
)

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

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (i *InviteGroupCallParticipantResultUserAlreadyParticipant) Encode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode inviteGroupCallParticipantResultUserAlreadyParticipant#276e1687 as nil")
	}
	b.PutID(InviteGroupCallParticipantResultUserAlreadyParticipantTypeID)
	return i.EncodeBare(b)
}

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

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

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

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

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

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

// InviteGroupCallParticipantResultUserWasBanned represents TL type `inviteGroupCallParticipantResultUserWasBanned#f3d1eff3`.
type InviteGroupCallParticipantResultUserWasBanned struct {
}

// InviteGroupCallParticipantResultUserWasBannedTypeID is TL type id of InviteGroupCallParticipantResultUserWasBanned.
const InviteGroupCallParticipantResultUserWasBannedTypeID = 0xf3d1eff3

// construct implements constructor of InviteGroupCallParticipantResultClass.
func (i InviteGroupCallParticipantResultUserWasBanned) construct() InviteGroupCallParticipantResultClass {
	return &i
}

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

	_ InviteGroupCallParticipantResultClass = &InviteGroupCallParticipantResultUserWasBanned{}
)

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

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (i *InviteGroupCallParticipantResultUserWasBanned) Encode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode inviteGroupCallParticipantResultUserWasBanned#f3d1eff3 as nil")
	}
	b.PutID(InviteGroupCallParticipantResultUserWasBannedTypeID)
	return i.EncodeBare(b)
}

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

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

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

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

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

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

// InviteGroupCallParticipantResultSuccess represents TL type `inviteGroupCallParticipantResultSuccess#8de5f4cd`.
type InviteGroupCallParticipantResultSuccess struct {
	// Identifier of the chat with the invitation message
	ChatID int64
	// Identifier of the message
	MessageID int64
}

// InviteGroupCallParticipantResultSuccessTypeID is TL type id of InviteGroupCallParticipantResultSuccess.
const InviteGroupCallParticipantResultSuccessTypeID = 0x8de5f4cd

// construct implements constructor of InviteGroupCallParticipantResultClass.
func (i InviteGroupCallParticipantResultSuccess) construct() InviteGroupCallParticipantResultClass {
	return &i
}

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

	_ InviteGroupCallParticipantResultClass = &InviteGroupCallParticipantResultSuccess{}
)

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

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (i *InviteGroupCallParticipantResultSuccess) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "inviteGroupCallParticipantResultSuccess",
		ID:   InviteGroupCallParticipantResultSuccessTypeID,
	}
	if i == 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 (i *InviteGroupCallParticipantResultSuccess) Encode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode inviteGroupCallParticipantResultSuccess#8de5f4cd as nil")
	}
	b.PutID(InviteGroupCallParticipantResultSuccessTypeID)
	return i.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (i *InviteGroupCallParticipantResultSuccess) EncodeBare(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode inviteGroupCallParticipantResultSuccess#8de5f4cd as nil")
	}
	b.PutInt53(i.ChatID)
	b.PutInt53(i.MessageID)
	return nil
}

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

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

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

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

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

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

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

// InviteGroupCallParticipantResultClassName is schema name of InviteGroupCallParticipantResultClass.
const InviteGroupCallParticipantResultClassName = "InviteGroupCallParticipantResult"

// InviteGroupCallParticipantResultClass represents InviteGroupCallParticipantResult generic type.
//
// Example:
//
//	g, err := tdapi.DecodeInviteGroupCallParticipantResult(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tdapi.InviteGroupCallParticipantResultUserPrivacyRestricted: // inviteGroupCallParticipantResultUserPrivacyRestricted#328c5f9
//	case *tdapi.InviteGroupCallParticipantResultUserAlreadyParticipant: // inviteGroupCallParticipantResultUserAlreadyParticipant#276e1687
//	case *tdapi.InviteGroupCallParticipantResultUserWasBanned: // inviteGroupCallParticipantResultUserWasBanned#f3d1eff3
//	case *tdapi.InviteGroupCallParticipantResultSuccess: // inviteGroupCallParticipantResultSuccess#8de5f4cd
//	default: panic(v)
//	}
type InviteGroupCallParticipantResultClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() InviteGroupCallParticipantResultClass

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

// DecodeInviteGroupCallParticipantResult implements binary de-serialization for InviteGroupCallParticipantResultClass.
func DecodeInviteGroupCallParticipantResult(buf *bin.Buffer) (InviteGroupCallParticipantResultClass, error) {
	id, err := buf.PeekID()
	if err != nil {
		return nil, err
	}
	switch id {
	case InviteGroupCallParticipantResultUserPrivacyRestrictedTypeID:
		// Decoding inviteGroupCallParticipantResultUserPrivacyRestricted#328c5f9.
		v := InviteGroupCallParticipantResultUserPrivacyRestricted{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode InviteGroupCallParticipantResultClass: %w", err)
		}
		return &v, nil
	case InviteGroupCallParticipantResultUserAlreadyParticipantTypeID:
		// Decoding inviteGroupCallParticipantResultUserAlreadyParticipant#276e1687.
		v := InviteGroupCallParticipantResultUserAlreadyParticipant{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode InviteGroupCallParticipantResultClass: %w", err)
		}
		return &v, nil
	case InviteGroupCallParticipantResultUserWasBannedTypeID:
		// Decoding inviteGroupCallParticipantResultUserWasBanned#f3d1eff3.
		v := InviteGroupCallParticipantResultUserWasBanned{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode InviteGroupCallParticipantResultClass: %w", err)
		}
		return &v, nil
	case InviteGroupCallParticipantResultSuccessTypeID:
		// Decoding inviteGroupCallParticipantResultSuccess#8de5f4cd.
		v := InviteGroupCallParticipantResultSuccess{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode InviteGroupCallParticipantResultClass: %w", err)
		}
		return &v, nil
	default:
		return nil, fmt.Errorf("unable to decode InviteGroupCallParticipantResultClass: %w", bin.NewUnexpectedID(id))
	}
}

// DecodeTDLibJSONInviteGroupCallParticipantResult implements binary de-serialization for InviteGroupCallParticipantResultClass.
func DecodeTDLibJSONInviteGroupCallParticipantResult(buf tdjson.Decoder) (InviteGroupCallParticipantResultClass, error) {
	id, err := buf.FindTypeID()
	if err != nil {
		return nil, err
	}
	switch id {
	case "inviteGroupCallParticipantResultUserPrivacyRestricted":
		// Decoding inviteGroupCallParticipantResultUserPrivacyRestricted#328c5f9.
		v := InviteGroupCallParticipantResultUserPrivacyRestricted{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode InviteGroupCallParticipantResultClass: %w", err)
		}
		return &v, nil
	case "inviteGroupCallParticipantResultUserAlreadyParticipant":
		// Decoding inviteGroupCallParticipantResultUserAlreadyParticipant#276e1687.
		v := InviteGroupCallParticipantResultUserAlreadyParticipant{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode InviteGroupCallParticipantResultClass: %w", err)
		}
		return &v, nil
	case "inviteGroupCallParticipantResultUserWasBanned":
		// Decoding inviteGroupCallParticipantResultUserWasBanned#f3d1eff3.
		v := InviteGroupCallParticipantResultUserWasBanned{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode InviteGroupCallParticipantResultClass: %w", err)
		}
		return &v, nil
	case "inviteGroupCallParticipantResultSuccess":
		// Decoding inviteGroupCallParticipantResultSuccess#8de5f4cd.
		v := InviteGroupCallParticipantResultSuccess{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode InviteGroupCallParticipantResultClass: %w", err)
		}
		return &v, nil
	default:
		return nil, fmt.Errorf("unable to decode InviteGroupCallParticipantResultClass: %w", tdjson.NewUnexpectedID(id))
	}
}

// InviteGroupCallParticipantResult boxes the InviteGroupCallParticipantResultClass providing a helper.
type InviteGroupCallParticipantResultBox struct {
	InviteGroupCallParticipantResult InviteGroupCallParticipantResultClass
}

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

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

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

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