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

// EmailVerifyPurposeLoginSetup represents TL type `emailVerifyPurposeLoginSetup#4345be73`.
// Email verification purpose: setup login email
//
// See https://core.telegram.org/constructor/emailVerifyPurposeLoginSetup for reference.
type EmailVerifyPurposeLoginSetup struct {
	// Phone number
	PhoneNumber string
	// Phone code hash as specified by the documentation¹
	//
	// Links:
	//  1) https://core.telegram.org/api/auth#email-verification
	PhoneCodeHash string
}

// EmailVerifyPurposeLoginSetupTypeID is TL type id of EmailVerifyPurposeLoginSetup.
const EmailVerifyPurposeLoginSetupTypeID = 0x4345be73

// construct implements constructor of EmailVerifyPurposeClass.
func ( EmailVerifyPurposeLoginSetup) () EmailVerifyPurposeClass { return & }

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

	_ EmailVerifyPurposeClass = &EmailVerifyPurposeLoginSetup{}
)

func ( *EmailVerifyPurposeLoginSetup) () bool {
	if  == nil {
		return true
	}
	if !(.PhoneNumber == "") {
		return false
	}
	if !(.PhoneCodeHash == "") {
		return false
	}

	return true
}

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

// FillFrom fills EmailVerifyPurposeLoginSetup from given interface.
func ( *EmailVerifyPurposeLoginSetup) ( interface {
	() ( string)
	() ( string)
}) {
	.PhoneNumber = .()
	.PhoneCodeHash = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *EmailVerifyPurposeLoginSetup) () tdp.Type {
	 := tdp.Type{
		Name: "emailVerifyPurposeLoginSetup",
		ID:   EmailVerifyPurposeLoginSetupTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "PhoneNumber",
			SchemaName: "phone_number",
		},
		{
			Name:       "PhoneCodeHash",
			SchemaName: "phone_code_hash",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *EmailVerifyPurposeLoginSetup) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode emailVerifyPurposeLoginSetup#4345be73 as nil")
	}
	.PutID(EmailVerifyPurposeLoginSetupTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *EmailVerifyPurposeLoginSetup) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode emailVerifyPurposeLoginSetup#4345be73 as nil")
	}
	.PutString(.PhoneNumber)
	.PutString(.PhoneCodeHash)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *EmailVerifyPurposeLoginSetup) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode emailVerifyPurposeLoginSetup#4345be73 to nil")
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode emailVerifyPurposeLoginSetup#4345be73: field phone_number: %w", )
		}
		.PhoneNumber = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode emailVerifyPurposeLoginSetup#4345be73: field phone_code_hash: %w", )
		}
		.PhoneCodeHash = 
	}
	return nil
}

// GetPhoneNumber returns value of PhoneNumber field.
func ( *EmailVerifyPurposeLoginSetup) () ( string) {
	if  == nil {
		return
	}
	return .PhoneNumber
}

// GetPhoneCodeHash returns value of PhoneCodeHash field.
func ( *EmailVerifyPurposeLoginSetup) () ( string) {
	if  == nil {
		return
	}
	return .PhoneCodeHash
}

// EmailVerifyPurposeLoginChange represents TL type `emailVerifyPurposeLoginChange#527d22eb`.
// Email verification purpose: change login email
//
// See https://core.telegram.org/constructor/emailVerifyPurposeLoginChange for reference.
type EmailVerifyPurposeLoginChange struct {
}

// EmailVerifyPurposeLoginChangeTypeID is TL type id of EmailVerifyPurposeLoginChange.
const EmailVerifyPurposeLoginChangeTypeID = 0x527d22eb

// construct implements constructor of EmailVerifyPurposeClass.
func ( EmailVerifyPurposeLoginChange) () EmailVerifyPurposeClass { return & }

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

	_ EmailVerifyPurposeClass = &EmailVerifyPurposeLoginChange{}
)

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

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func ( *EmailVerifyPurposeLoginChange) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode emailVerifyPurposeLoginChange#527d22eb as nil")
	}
	.PutID(EmailVerifyPurposeLoginChangeTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *EmailVerifyPurposeLoginChange) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode emailVerifyPurposeLoginChange#527d22eb as nil")
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *EmailVerifyPurposeLoginChange) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode emailVerifyPurposeLoginChange#527d22eb to nil")
	}
	return nil
}

// EmailVerifyPurposePassport represents TL type `emailVerifyPurposePassport#bbf51685`.
// Verify an email for use in telegram passport¹
//
// Links:
//  1. https://core.telegram.org/api/passport
//
// See https://core.telegram.org/constructor/emailVerifyPurposePassport for reference.
type EmailVerifyPurposePassport struct {
}

// EmailVerifyPurposePassportTypeID is TL type id of EmailVerifyPurposePassport.
const EmailVerifyPurposePassportTypeID = 0xbbf51685

// construct implements constructor of EmailVerifyPurposeClass.
func ( EmailVerifyPurposePassport) () EmailVerifyPurposeClass { return & }

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

	_ EmailVerifyPurposeClass = &EmailVerifyPurposePassport{}
)

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

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func ( *EmailVerifyPurposePassport) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode emailVerifyPurposePassport#bbf51685 as nil")
	}
	.PutID(EmailVerifyPurposePassportTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *EmailVerifyPurposePassport) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode emailVerifyPurposePassport#bbf51685 as nil")
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *EmailVerifyPurposePassport) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode emailVerifyPurposePassport#bbf51685 to nil")
	}
	return nil
}

// EmailVerifyPurposeClassName is schema name of EmailVerifyPurposeClass.
const EmailVerifyPurposeClassName = "EmailVerifyPurpose"

// EmailVerifyPurposeClass represents EmailVerifyPurpose generic type.
//
// See https://core.telegram.org/type/EmailVerifyPurpose for reference.
//
// Example:
//
//	g, err := tg.DecodeEmailVerifyPurpose(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.EmailVerifyPurposeLoginSetup: // emailVerifyPurposeLoginSetup#4345be73
//	case *tg.EmailVerifyPurposeLoginChange: // emailVerifyPurposeLoginChange#527d22eb
//	case *tg.EmailVerifyPurposePassport: // emailVerifyPurposePassport#bbf51685
//	default: panic(v)
//	}
type EmailVerifyPurposeClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() EmailVerifyPurposeClass

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

// DecodeEmailVerifyPurpose implements binary de-serialization for EmailVerifyPurposeClass.
func ( *bin.Buffer) (EmailVerifyPurposeClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case EmailVerifyPurposeLoginSetupTypeID:
		// Decoding emailVerifyPurposeLoginSetup#4345be73.
		 := EmailVerifyPurposeLoginSetup{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode EmailVerifyPurposeClass: %w", )
		}
		return &, nil
	case EmailVerifyPurposeLoginChangeTypeID:
		// Decoding emailVerifyPurposeLoginChange#527d22eb.
		 := EmailVerifyPurposeLoginChange{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode EmailVerifyPurposeClass: %w", )
		}
		return &, nil
	case EmailVerifyPurposePassportTypeID:
		// Decoding emailVerifyPurposePassport#bbf51685.
		 := EmailVerifyPurposePassport{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode EmailVerifyPurposeClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode EmailVerifyPurposeClass: %w", bin.NewUnexpectedID())
	}
}

// EmailVerifyPurpose boxes the EmailVerifyPurposeClass providing a helper.
type EmailVerifyPurposeBox struct {
	EmailVerifyPurpose EmailVerifyPurposeClass
}

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

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