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

// AccountSendVerifyEmailCodeRequest represents TL type `account.sendVerifyEmailCode#98e037bb`.
// Send an email verification code.
//
// See https://core.telegram.org/method/account.sendVerifyEmailCode for reference.
type AccountSendVerifyEmailCodeRequest struct {
	// Verification purpose.
	Purpose EmailVerifyPurposeClass
	// The email where to send the code.
	Email string
}

// AccountSendVerifyEmailCodeRequestTypeID is TL type id of AccountSendVerifyEmailCodeRequest.
const AccountSendVerifyEmailCodeRequestTypeID = 0x98e037bb

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

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

	return true
}

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

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

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

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

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

// Encode implements bin.Encoder.
func ( *AccountSendVerifyEmailCodeRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.sendVerifyEmailCode#98e037bb as nil")
	}
	.PutID(AccountSendVerifyEmailCodeRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountSendVerifyEmailCodeRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.sendVerifyEmailCode#98e037bb as nil")
	}
	if .Purpose == nil {
		return fmt.Errorf("unable to encode account.sendVerifyEmailCode#98e037bb: field purpose is nil")
	}
	if  := .Purpose.Encode();  != nil {
		return fmt.Errorf("unable to encode account.sendVerifyEmailCode#98e037bb: field purpose: %w", )
	}
	.PutString(.Email)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AccountSendVerifyEmailCodeRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.sendVerifyEmailCode#98e037bb to nil")
	}
	{
		,  := DecodeEmailVerifyPurpose()
		if  != nil {
			return fmt.Errorf("unable to decode account.sendVerifyEmailCode#98e037bb: field purpose: %w", )
		}
		.Purpose = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode account.sendVerifyEmailCode#98e037bb: field email: %w", )
		}
		.Email = 
	}
	return nil
}

// GetPurpose returns value of Purpose field.
func ( *AccountSendVerifyEmailCodeRequest) () ( EmailVerifyPurposeClass) {
	if  == nil {
		return
	}
	return .Purpose
}

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

// AccountSendVerifyEmailCode invokes method account.sendVerifyEmailCode#98e037bb returning error if any.
// Send an email verification code.
//
// Possible errors:
//
//	400 EMAIL_INVALID: The specified email is invalid.
//	400 EMAIL_NOT_SETUP: In order to change the login email with emailVerifyPurposeLoginChange, an existing login email must already be set using emailVerifyPurposeLoginSetup.
//	400 PHONE_HASH_EXPIRED: An invalid or expired phone_code_hash was provided.
//	400 PHONE_NUMBER_INVALID: The phone number is invalid.
//
// See https://core.telegram.org/method/account.sendVerifyEmailCode for reference.
func ( *Client) ( context.Context,  *AccountSendVerifyEmailCodeRequest) (*AccountSentEmailCode, error) {
	var  AccountSentEmailCode

	if  := .rpc.Invoke(, , &);  != nil {
		return nil, 
	}
	return &, nil
}