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

// AccountEmailVerified represents TL type `account.emailVerified#2b96cd1b`.
// The email was verified correctly.
//
// See https://core.telegram.org/constructor/account.emailVerified for reference.
type AccountEmailVerified struct {
	// The verified email address.
	Email string
}

// AccountEmailVerifiedTypeID is TL type id of AccountEmailVerified.
const AccountEmailVerifiedTypeID = 0x2b96cd1b

// construct implements constructor of AccountEmailVerifiedClass.
func ( AccountEmailVerified) () AccountEmailVerifiedClass { return & }

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

	_ AccountEmailVerifiedClass = &AccountEmailVerified{}
)

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

	return true
}

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

// FillFrom fills AccountEmailVerified from given interface.
func ( *AccountEmailVerified) ( interface {
	() ( string)
}) {
	.Email = .()
}

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

// TypeName returns name of type in TL schema.
func (*AccountEmailVerified) () string {
	return "account.emailVerified"
}

// TypeInfo returns info about TL type.
func ( *AccountEmailVerified) () tdp.Type {
	 := tdp.Type{
		Name: "account.emailVerified",
		ID:   AccountEmailVerifiedTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Email",
			SchemaName: "email",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *AccountEmailVerified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.emailVerified#2b96cd1b as nil")
	}
	.PutID(AccountEmailVerifiedTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountEmailVerified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.emailVerified#2b96cd1b as nil")
	}
	.PutString(.Email)
	return nil
}

// Decode implements bin.Decoder.
func ( *AccountEmailVerified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.emailVerified#2b96cd1b to nil")
	}
	if  := .ConsumeID(AccountEmailVerifiedTypeID);  != nil {
		return fmt.Errorf("unable to decode account.emailVerified#2b96cd1b: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *AccountEmailVerified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.emailVerified#2b96cd1b to nil")
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode account.emailVerified#2b96cd1b: field email: %w", )
		}
		.Email = 
	}
	return nil
}

// GetEmail returns value of Email field.
func ( *AccountEmailVerified) () ( string) {
	if  == nil {
		return
	}
	return .Email
}

// AccountEmailVerifiedLogin represents TL type `account.emailVerifiedLogin#e1bb0d61`.
// The email was verified correctly, and a login code was just sent to it.
//
// See https://core.telegram.org/constructor/account.emailVerifiedLogin for reference.
type AccountEmailVerifiedLogin struct {
	// The verified email address.
	Email string
	// Info about the sent login codeĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/api/auth
	SentCode AuthSentCodeClass
}

// AccountEmailVerifiedLoginTypeID is TL type id of AccountEmailVerifiedLogin.
const AccountEmailVerifiedLoginTypeID = 0xe1bb0d61

// construct implements constructor of AccountEmailVerifiedClass.
func ( AccountEmailVerifiedLogin) () AccountEmailVerifiedClass { return & }

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

	_ AccountEmailVerifiedClass = &AccountEmailVerifiedLogin{}
)

func ( *AccountEmailVerifiedLogin) () bool {
	if  == nil {
		return true
	}
	if !(.Email == "") {
		return false
	}
	if !(.SentCode == nil) {
		return false
	}

	return true
}

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

// FillFrom fills AccountEmailVerifiedLogin from given interface.
func ( *AccountEmailVerifiedLogin) ( interface {
	() ( string)
	() ( AuthSentCodeClass)
}) {
	.Email = .()
	.SentCode = .()
}

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

// TypeName returns name of type in TL schema.
func (*AccountEmailVerifiedLogin) () string {
	return "account.emailVerifiedLogin"
}

// TypeInfo returns info about TL type.
func ( *AccountEmailVerifiedLogin) () tdp.Type {
	 := tdp.Type{
		Name: "account.emailVerifiedLogin",
		ID:   AccountEmailVerifiedLoginTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Email",
			SchemaName: "email",
		},
		{
			Name:       "SentCode",
			SchemaName: "sent_code",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *AccountEmailVerifiedLogin) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.emailVerifiedLogin#e1bb0d61 as nil")
	}
	.PutID(AccountEmailVerifiedLoginTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountEmailVerifiedLogin) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.emailVerifiedLogin#e1bb0d61 as nil")
	}
	.PutString(.Email)
	if .SentCode == nil {
		return fmt.Errorf("unable to encode account.emailVerifiedLogin#e1bb0d61: field sent_code is nil")
	}
	if  := .SentCode.Encode();  != nil {
		return fmt.Errorf("unable to encode account.emailVerifiedLogin#e1bb0d61: field sent_code: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AccountEmailVerifiedLogin) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.emailVerifiedLogin#e1bb0d61 to nil")
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode account.emailVerifiedLogin#e1bb0d61: field email: %w", )
		}
		.Email = 
	}
	{
		,  := DecodeAuthSentCode()
		if  != nil {
			return fmt.Errorf("unable to decode account.emailVerifiedLogin#e1bb0d61: field sent_code: %w", )
		}
		.SentCode = 
	}
	return nil
}

// GetEmail returns value of Email field.
func ( *AccountEmailVerifiedLogin) () ( string) {
	if  == nil {
		return
	}
	return .Email
}

// GetSentCode returns value of SentCode field.
func ( *AccountEmailVerifiedLogin) () ( AuthSentCodeClass) {
	if  == nil {
		return
	}
	return .SentCode
}

// AccountEmailVerifiedClassName is schema name of AccountEmailVerifiedClass.
const AccountEmailVerifiedClassName = "account.EmailVerified"

// AccountEmailVerifiedClass represents account.EmailVerified generic type.
//
// See https://core.telegram.org/type/account.EmailVerified for reference.
//
// Example:
//
//	g, err := tg.DecodeAccountEmailVerified(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.AccountEmailVerified: // account.emailVerified#2b96cd1b
//	case *tg.AccountEmailVerifiedLogin: // account.emailVerifiedLogin#e1bb0d61
//	default: panic(v)
//	}
type AccountEmailVerifiedClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() AccountEmailVerifiedClass

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

	// The verified email address.
	GetEmail() (value string)
}

// DecodeAccountEmailVerified implements binary de-serialization for AccountEmailVerifiedClass.
func ( *bin.Buffer) (AccountEmailVerifiedClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case AccountEmailVerifiedTypeID:
		// Decoding account.emailVerified#2b96cd1b.
		 := AccountEmailVerified{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode AccountEmailVerifiedClass: %w", )
		}
		return &, nil
	case AccountEmailVerifiedLoginTypeID:
		// Decoding account.emailVerifiedLogin#e1bb0d61.
		 := AccountEmailVerifiedLogin{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode AccountEmailVerifiedClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode AccountEmailVerifiedClass: %w", bin.NewUnexpectedID())
	}
}

// AccountEmailVerified boxes the AccountEmailVerifiedClass providing a helper.
type AccountEmailVerifiedBox struct {
	EmailVerified AccountEmailVerifiedClass
}

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

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