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

// EmailVerificationCode represents TL type `emailVerificationCode#922e55a9`.
// Email verification code
//
// See https://core.telegram.org/constructor/emailVerificationCode for reference.
type EmailVerificationCode struct {
	// Received verification code
	Code string
}

// EmailVerificationCodeTypeID is TL type id of EmailVerificationCode.
const EmailVerificationCodeTypeID = 0x922e55a9

// construct implements constructor of EmailVerificationClass.
func ( EmailVerificationCode) () EmailVerificationClass { return & }

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

	_ EmailVerificationClass = &EmailVerificationCode{}
)

func ( *EmailVerificationCode) () bool {
	if  == nil {
		return true
	}
	if !(.Code == "") {
		return false
	}

	return true
}

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

// FillFrom fills EmailVerificationCode from given interface.
func ( *EmailVerificationCode) ( interface {
	() ( string)
}) {
	.Code = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *EmailVerificationCode) () tdp.Type {
	 := tdp.Type{
		Name: "emailVerificationCode",
		ID:   EmailVerificationCodeTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Code",
			SchemaName: "code",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *EmailVerificationCode) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode emailVerificationCode#922e55a9 as nil")
	}
	.PutID(EmailVerificationCodeTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *EmailVerificationCode) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode emailVerificationCode#922e55a9 as nil")
	}
	.PutString(.Code)
	return nil
}

// Decode implements bin.Decoder.
func ( *EmailVerificationCode) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode emailVerificationCode#922e55a9 to nil")
	}
	if  := .ConsumeID(EmailVerificationCodeTypeID);  != nil {
		return fmt.Errorf("unable to decode emailVerificationCode#922e55a9: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *EmailVerificationCode) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode emailVerificationCode#922e55a9 to nil")
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode emailVerificationCode#922e55a9: field code: %w", )
		}
		.Code = 
	}
	return nil
}

// GetCode returns value of Code field.
func ( *EmailVerificationCode) () ( string) {
	if  == nil {
		return
	}
	return .Code
}

// EmailVerificationGoogle represents TL type `emailVerificationGoogle#db909ec2`.
// Google ID email verification token
//
// See https://core.telegram.org/constructor/emailVerificationGoogle for reference.
type EmailVerificationGoogle struct {
	// Token
	Token string
}

// EmailVerificationGoogleTypeID is TL type id of EmailVerificationGoogle.
const EmailVerificationGoogleTypeID = 0xdb909ec2

// construct implements constructor of EmailVerificationClass.
func ( EmailVerificationGoogle) () EmailVerificationClass { return & }

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

	_ EmailVerificationClass = &EmailVerificationGoogle{}
)

func ( *EmailVerificationGoogle) () bool {
	if  == nil {
		return true
	}
	if !(.Token == "") {
		return false
	}

	return true
}

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

// FillFrom fills EmailVerificationGoogle from given interface.
func ( *EmailVerificationGoogle) ( interface {
	() ( string)
}) {
	.Token = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *EmailVerificationGoogle) () tdp.Type {
	 := tdp.Type{
		Name: "emailVerificationGoogle",
		ID:   EmailVerificationGoogleTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Token",
			SchemaName: "token",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *EmailVerificationGoogle) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode emailVerificationGoogle#db909ec2 as nil")
	}
	.PutID(EmailVerificationGoogleTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *EmailVerificationGoogle) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode emailVerificationGoogle#db909ec2 as nil")
	}
	.PutString(.Token)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *EmailVerificationGoogle) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode emailVerificationGoogle#db909ec2 to nil")
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode emailVerificationGoogle#db909ec2: field token: %w", )
		}
		.Token = 
	}
	return nil
}

// GetToken returns value of Token field.
func ( *EmailVerificationGoogle) () ( string) {
	if  == nil {
		return
	}
	return .Token
}

// EmailVerificationApple represents TL type `emailVerificationApple#96d074fd`.
// Apple ID email verification token
//
// See https://core.telegram.org/constructor/emailVerificationApple for reference.
type EmailVerificationApple struct {
	// Token
	Token string
}

// EmailVerificationAppleTypeID is TL type id of EmailVerificationApple.
const EmailVerificationAppleTypeID = 0x96d074fd

// construct implements constructor of EmailVerificationClass.
func ( EmailVerificationApple) () EmailVerificationClass { return & }

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

	_ EmailVerificationClass = &EmailVerificationApple{}
)

func ( *EmailVerificationApple) () bool {
	if  == nil {
		return true
	}
	if !(.Token == "") {
		return false
	}

	return true
}

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

// FillFrom fills EmailVerificationApple from given interface.
func ( *EmailVerificationApple) ( interface {
	() ( string)
}) {
	.Token = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *EmailVerificationApple) () tdp.Type {
	 := tdp.Type{
		Name: "emailVerificationApple",
		ID:   EmailVerificationAppleTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Token",
			SchemaName: "token",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *EmailVerificationApple) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode emailVerificationApple#96d074fd as nil")
	}
	.PutID(EmailVerificationAppleTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *EmailVerificationApple) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode emailVerificationApple#96d074fd as nil")
	}
	.PutString(.Token)
	return nil
}

// Decode implements bin.Decoder.
func ( *EmailVerificationApple) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode emailVerificationApple#96d074fd to nil")
	}
	if  := .ConsumeID(EmailVerificationAppleTypeID);  != nil {
		return fmt.Errorf("unable to decode emailVerificationApple#96d074fd: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *EmailVerificationApple) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode emailVerificationApple#96d074fd to nil")
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode emailVerificationApple#96d074fd: field token: %w", )
		}
		.Token = 
	}
	return nil
}

// GetToken returns value of Token field.
func ( *EmailVerificationApple) () ( string) {
	if  == nil {
		return
	}
	return .Token
}

// EmailVerificationClassName is schema name of EmailVerificationClass.
const EmailVerificationClassName = "EmailVerification"

// EmailVerificationClass represents EmailVerification generic type.
//
// See https://core.telegram.org/type/EmailVerification for reference.
//
// Example:
//
//	g, err := tg.DecodeEmailVerification(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.EmailVerificationCode: // emailVerificationCode#922e55a9
//	case *tg.EmailVerificationGoogle: // emailVerificationGoogle#db909ec2
//	case *tg.EmailVerificationApple: // emailVerificationApple#96d074fd
//	default: panic(v)
//	}
type EmailVerificationClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() EmailVerificationClass

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

// DecodeEmailVerification implements binary de-serialization for EmailVerificationClass.
func ( *bin.Buffer) (EmailVerificationClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case EmailVerificationCodeTypeID:
		// Decoding emailVerificationCode#922e55a9.
		 := EmailVerificationCode{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode EmailVerificationClass: %w", )
		}
		return &, nil
	case EmailVerificationGoogleTypeID:
		// Decoding emailVerificationGoogle#db909ec2.
		 := EmailVerificationGoogle{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode EmailVerificationClass: %w", )
		}
		return &, nil
	case EmailVerificationAppleTypeID:
		// Decoding emailVerificationApple#96d074fd.
		 := EmailVerificationApple{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode EmailVerificationClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode EmailVerificationClass: %w", bin.NewUnexpectedID())
	}
}

// EmailVerification boxes the EmailVerificationClass providing a helper.
type EmailVerificationBox struct {
	EmailVerification EmailVerificationClass
}

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

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