// Code generated by gotdgen, DO NOT EDIT.

package tg

import (
	
	
	
	
	

	

	
	
	
	
)

// No-op definition for keeping imports.
var (
	_ = bin.Buffer{}
	_ = context.Background()
	_ = fmt.Stringer(nil)
	_ = strings.Builder{}
	_ = errors.Is
	_ = multierr.AppendInto
	_ = sort.Ints
	_ = tdp.Format
	_ = tgerr.Error{}
	_ = tdjson.Encoder{}
)

// AuthCodeTypeSMS represents TL type `auth.codeTypeSms#72a3158c`.
// The next time, the authentication code will be delivered via an immediately canceled
// incoming call.
//
// See https://core.telegram.org/constructor/auth.codeTypeSms for reference.
type AuthCodeTypeSMS struct {
}

// AuthCodeTypeSMSTypeID is TL type id of AuthCodeTypeSMS.
const AuthCodeTypeSMSTypeID = 0x72a3158c

// construct implements constructor of AuthCodeTypeClass.
func ( AuthCodeTypeSMS) () AuthCodeTypeClass { return & }

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

	_ AuthCodeTypeClass = &AuthCodeTypeSMS{}
)

func ( *AuthCodeTypeSMS) () bool {
	if  == nil {
		return true
	}

	return true
}

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

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

// TypeName returns name of type in TL schema.
func (*AuthCodeTypeSMS) () string {
	return "auth.codeTypeSms"
}

// TypeInfo returns info about TL type.
func ( *AuthCodeTypeSMS) () tdp.Type {
	 := tdp.Type{
		Name: "auth.codeTypeSms",
		ID:   AuthCodeTypeSMSTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{}
	return 
}

// Encode implements bin.Encoder.
func ( *AuthCodeTypeSMS) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.codeTypeSms#72a3158c as nil")
	}
	.PutID(AuthCodeTypeSMSTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AuthCodeTypeSMS) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.codeTypeSms#72a3158c as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *AuthCodeTypeSMS) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode auth.codeTypeSms#72a3158c to nil")
	}
	if  := .ConsumeID(AuthCodeTypeSMSTypeID);  != nil {
		return fmt.Errorf("unable to decode auth.codeTypeSms#72a3158c: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *AuthCodeTypeSMS) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode auth.codeTypeSms#72a3158c to nil")
	}
	return nil
}

// AuthCodeTypeCall represents TL type `auth.codeTypeCall#741cd3e3`.
// The next time, the authentication code is to be delivered via an outgoing phone call.
//
// See https://core.telegram.org/constructor/auth.codeTypeCall for reference.
type AuthCodeTypeCall struct {
}

// AuthCodeTypeCallTypeID is TL type id of AuthCodeTypeCall.
const AuthCodeTypeCallTypeID = 0x741cd3e3

// construct implements constructor of AuthCodeTypeClass.
func ( AuthCodeTypeCall) () AuthCodeTypeClass { return & }

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

	_ AuthCodeTypeClass = &AuthCodeTypeCall{}
)

func ( *AuthCodeTypeCall) () bool {
	if  == nil {
		return true
	}

	return true
}

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

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

// TypeName returns name of type in TL schema.
func (*AuthCodeTypeCall) () string {
	return "auth.codeTypeCall"
}

// TypeInfo returns info about TL type.
func ( *AuthCodeTypeCall) () tdp.Type {
	 := tdp.Type{
		Name: "auth.codeTypeCall",
		ID:   AuthCodeTypeCallTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{}
	return 
}

// Encode implements bin.Encoder.
func ( *AuthCodeTypeCall) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.codeTypeCall#741cd3e3 as nil")
	}
	.PutID(AuthCodeTypeCallTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AuthCodeTypeCall) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.codeTypeCall#741cd3e3 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *AuthCodeTypeCall) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode auth.codeTypeCall#741cd3e3 to nil")
	}
	if  := .ConsumeID(AuthCodeTypeCallTypeID);  != nil {
		return fmt.Errorf("unable to decode auth.codeTypeCall#741cd3e3: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *AuthCodeTypeCall) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode auth.codeTypeCall#741cd3e3 to nil")
	}
	return nil
}

// AuthCodeTypeFlashCall represents TL type `auth.codeTypeFlashCall#226ccefb`.
// The next time, the authentication code will be delivered via an immediately canceled
// incoming call.
//
// See https://core.telegram.org/constructor/auth.codeTypeFlashCall for reference.
type AuthCodeTypeFlashCall struct {
}

// AuthCodeTypeFlashCallTypeID is TL type id of AuthCodeTypeFlashCall.
const AuthCodeTypeFlashCallTypeID = 0x226ccefb

// construct implements constructor of AuthCodeTypeClass.
func ( AuthCodeTypeFlashCall) () AuthCodeTypeClass { return & }

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

	_ AuthCodeTypeClass = &AuthCodeTypeFlashCall{}
)

func ( *AuthCodeTypeFlashCall) () bool {
	if  == nil {
		return true
	}

	return true
}

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

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

// TypeName returns name of type in TL schema.
func (*AuthCodeTypeFlashCall) () string {
	return "auth.codeTypeFlashCall"
}

// TypeInfo returns info about TL type.
func ( *AuthCodeTypeFlashCall) () tdp.Type {
	 := tdp.Type{
		Name: "auth.codeTypeFlashCall",
		ID:   AuthCodeTypeFlashCallTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{}
	return 
}

// Encode implements bin.Encoder.
func ( *AuthCodeTypeFlashCall) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.codeTypeFlashCall#226ccefb as nil")
	}
	.PutID(AuthCodeTypeFlashCallTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AuthCodeTypeFlashCall) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.codeTypeFlashCall#226ccefb as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *AuthCodeTypeFlashCall) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode auth.codeTypeFlashCall#226ccefb to nil")
	}
	if  := .ConsumeID(AuthCodeTypeFlashCallTypeID);  != nil {
		return fmt.Errorf("unable to decode auth.codeTypeFlashCall#226ccefb: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *AuthCodeTypeFlashCall) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode auth.codeTypeFlashCall#226ccefb to nil")
	}
	return nil
}

// AuthCodeTypeMissedCall represents TL type `auth.codeTypeMissedCall#d61ad6ee`.
// The next time, the authentication code will be delivered via an immediately canceled
// incoming call, handled manually by the user.
//
// See https://core.telegram.org/constructor/auth.codeTypeMissedCall for reference.
type AuthCodeTypeMissedCall struct {
}

// AuthCodeTypeMissedCallTypeID is TL type id of AuthCodeTypeMissedCall.
const AuthCodeTypeMissedCallTypeID = 0xd61ad6ee

// construct implements constructor of AuthCodeTypeClass.
func ( AuthCodeTypeMissedCall) () AuthCodeTypeClass { return & }

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

	_ AuthCodeTypeClass = &AuthCodeTypeMissedCall{}
)

func ( *AuthCodeTypeMissedCall) () bool {
	if  == nil {
		return true
	}

	return true
}

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

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

// TypeName returns name of type in TL schema.
func (*AuthCodeTypeMissedCall) () string {
	return "auth.codeTypeMissedCall"
}

// TypeInfo returns info about TL type.
func ( *AuthCodeTypeMissedCall) () tdp.Type {
	 := tdp.Type{
		Name: "auth.codeTypeMissedCall",
		ID:   AuthCodeTypeMissedCallTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{}
	return 
}

// Encode implements bin.Encoder.
func ( *AuthCodeTypeMissedCall) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.codeTypeMissedCall#d61ad6ee as nil")
	}
	.PutID(AuthCodeTypeMissedCallTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AuthCodeTypeMissedCall) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.codeTypeMissedCall#d61ad6ee as nil")
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AuthCodeTypeMissedCall) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode auth.codeTypeMissedCall#d61ad6ee to nil")
	}
	return nil
}

// AuthCodeTypeFragmentSMS represents TL type `auth.codeTypeFragmentSms#6ed998c`.
// The next time, the authentication code will be delivered via fragment.comĀ¹
//
// Links:
//  1. https://fragment.com
//
// See https://core.telegram.org/constructor/auth.codeTypeFragmentSms for reference.
type AuthCodeTypeFragmentSMS struct {
}

// AuthCodeTypeFragmentSMSTypeID is TL type id of AuthCodeTypeFragmentSMS.
const AuthCodeTypeFragmentSMSTypeID = 0x6ed998c

// construct implements constructor of AuthCodeTypeClass.
func ( AuthCodeTypeFragmentSMS) () AuthCodeTypeClass { return & }

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

	_ AuthCodeTypeClass = &AuthCodeTypeFragmentSMS{}
)

func ( *AuthCodeTypeFragmentSMS) () bool {
	if  == nil {
		return true
	}

	return true
}

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

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

// TypeName returns name of type in TL schema.
func (*AuthCodeTypeFragmentSMS) () string {
	return "auth.codeTypeFragmentSms"
}

// TypeInfo returns info about TL type.
func ( *AuthCodeTypeFragmentSMS) () tdp.Type {
	 := tdp.Type{
		Name: "auth.codeTypeFragmentSms",
		ID:   AuthCodeTypeFragmentSMSTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{}
	return 
}

// Encode implements bin.Encoder.
func ( *AuthCodeTypeFragmentSMS) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.codeTypeFragmentSms#6ed998c as nil")
	}
	.PutID(AuthCodeTypeFragmentSMSTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AuthCodeTypeFragmentSMS) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.codeTypeFragmentSms#6ed998c as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *AuthCodeTypeFragmentSMS) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode auth.codeTypeFragmentSms#6ed998c to nil")
	}
	if  := .ConsumeID(AuthCodeTypeFragmentSMSTypeID);  != nil {
		return fmt.Errorf("unable to decode auth.codeTypeFragmentSms#6ed998c: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *AuthCodeTypeFragmentSMS) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode auth.codeTypeFragmentSms#6ed998c to nil")
	}
	return nil
}

// AuthCodeTypeClassName is schema name of AuthCodeTypeClass.
const AuthCodeTypeClassName = "auth.CodeType"

// AuthCodeTypeClass represents auth.CodeType generic type.
//
// See https://core.telegram.org/type/auth.CodeType for reference.
//
// Example:
//
//	g, err := tg.DecodeAuthCodeType(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.AuthCodeTypeSMS: // auth.codeTypeSms#72a3158c
//	case *tg.AuthCodeTypeCall: // auth.codeTypeCall#741cd3e3
//	case *tg.AuthCodeTypeFlashCall: // auth.codeTypeFlashCall#226ccefb
//	case *tg.AuthCodeTypeMissedCall: // auth.codeTypeMissedCall#d61ad6ee
//	case *tg.AuthCodeTypeFragmentSMS: // auth.codeTypeFragmentSms#6ed998c
//	default: panic(v)
//	}
type AuthCodeTypeClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() AuthCodeTypeClass

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

// DecodeAuthCodeType implements binary de-serialization for AuthCodeTypeClass.
func ( *bin.Buffer) (AuthCodeTypeClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case AuthCodeTypeSMSTypeID:
		// Decoding auth.codeTypeSms#72a3158c.
		 := AuthCodeTypeSMS{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode AuthCodeTypeClass: %w", )
		}
		return &, nil
	case AuthCodeTypeCallTypeID:
		// Decoding auth.codeTypeCall#741cd3e3.
		 := AuthCodeTypeCall{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode AuthCodeTypeClass: %w", )
		}
		return &, nil
	case AuthCodeTypeFlashCallTypeID:
		// Decoding auth.codeTypeFlashCall#226ccefb.
		 := AuthCodeTypeFlashCall{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode AuthCodeTypeClass: %w", )
		}
		return &, nil
	case AuthCodeTypeMissedCallTypeID:
		// Decoding auth.codeTypeMissedCall#d61ad6ee.
		 := AuthCodeTypeMissedCall{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode AuthCodeTypeClass: %w", )
		}
		return &, nil
	case AuthCodeTypeFragmentSMSTypeID:
		// Decoding auth.codeTypeFragmentSms#6ed998c.
		 := AuthCodeTypeFragmentSMS{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode AuthCodeTypeClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode AuthCodeTypeClass: %w", bin.NewUnexpectedID())
	}
}

// AuthCodeType boxes the AuthCodeTypeClass providing a helper.
type AuthCodeTypeBox struct {
	CodeType AuthCodeTypeClass
}

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

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