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

// AccountConfirmPasswordEmailRequest represents TL type `account.confirmPasswordEmail#8fdf1920`.
// Verify an email to use as 2FA recovery method¹.
//
// Links:
//  1. https://core.telegram.org/api/srp
//
// See https://core.telegram.org/method/account.confirmPasswordEmail for reference.
type AccountConfirmPasswordEmailRequest struct {
	// The phone code that was received after setting a recovery email¹
	//
	// Links:
	//  1) https://core.telegram.org/api/srp#email-verification
	Code string
}

// AccountConfirmPasswordEmailRequestTypeID is TL type id of AccountConfirmPasswordEmailRequest.
const AccountConfirmPasswordEmailRequestTypeID = 0x8fdf1920

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

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

	return true
}

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

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

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

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

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

// Encode implements bin.Encoder.
func ( *AccountConfirmPasswordEmailRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.confirmPasswordEmail#8fdf1920 as nil")
	}
	.PutID(AccountConfirmPasswordEmailRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountConfirmPasswordEmailRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.confirmPasswordEmail#8fdf1920 as nil")
	}
	.PutString(.Code)
	return nil
}

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

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

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

// AccountConfirmPasswordEmail invokes method account.confirmPasswordEmail#8fdf1920 returning error if any.
// Verify an email to use as 2FA recovery method¹.
//
// Links:
//  1. https://core.telegram.org/api/srp
//
// Possible errors:
//
//	400 CODE_INVALID: Code invalid.
//	400 EMAIL_HASH_EXPIRED: Email hash expired.
//
// See https://core.telegram.org/method/account.confirmPasswordEmail for reference.
func ( *Client) ( context.Context,  string) (bool, error) {
	var  BoolBox

	 := &AccountConfirmPasswordEmailRequest{
		Code: ,
	}
	if  := .rpc.Invoke(, , &);  != nil {
		return false, 
	}
	,  := .Bool.(*BoolTrue)
	return , nil
}