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

// AuthRecoverPasswordRequest represents TL type `auth.recoverPassword#37096c70`.
// Reset the 2FA password¹ using the recovery code sent using auth
// requestPasswordRecovery².
//
// Links:
//  1. https://core.telegram.org/api/srp
//  2. https://core.telegram.org/method/auth.requestPasswordRecovery
//
// See https://core.telegram.org/method/auth.recoverPassword for reference.
type AuthRecoverPasswordRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Code received via email
	Code string
	// New password
	//
	// Use SetNewSettings and GetNewSettings helpers.
	NewSettings AccountPasswordInputSettings
}

// AuthRecoverPasswordRequestTypeID is TL type id of AuthRecoverPasswordRequest.
const AuthRecoverPasswordRequestTypeID = 0x37096c70

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

func ( *AuthRecoverPasswordRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Code == "") {
		return false
	}
	if !(.NewSettings.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills AuthRecoverPasswordRequest from given interface.
func ( *AuthRecoverPasswordRequest) ( interface {
	() ( string)
	() ( AccountPasswordInputSettings,  bool)
}) {
	.Code = .()
	if ,  := .();  {
		.NewSettings = 
	}

}

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

// TypeName returns name of type in TL schema.
func (*AuthRecoverPasswordRequest) () string {
	return "auth.recoverPassword"
}

// TypeInfo returns info about TL type.
func ( *AuthRecoverPasswordRequest) () tdp.Type {
	 := tdp.Type{
		Name: "auth.recoverPassword",
		ID:   AuthRecoverPasswordRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Code",
			SchemaName: "code",
		},
		{
			Name:       "NewSettings",
			SchemaName: "new_settings",
			Null:       !.Flags.Has(0),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *AuthRecoverPasswordRequest) () {
	if !(.NewSettings.Zero()) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *AuthRecoverPasswordRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.recoverPassword#37096c70 as nil")
	}
	.PutID(AuthRecoverPasswordRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AuthRecoverPasswordRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.recoverPassword#37096c70 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode auth.recoverPassword#37096c70: field flags: %w", )
	}
	.PutString(.Code)
	if .Flags.Has(0) {
		if  := .NewSettings.Encode();  != nil {
			return fmt.Errorf("unable to encode auth.recoverPassword#37096c70: field new_settings: %w", )
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *AuthRecoverPasswordRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode auth.recoverPassword#37096c70 to nil")
	}
	if  := .ConsumeID(AuthRecoverPasswordRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode auth.recoverPassword#37096c70: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *AuthRecoverPasswordRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode auth.recoverPassword#37096c70 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode auth.recoverPassword#37096c70: field flags: %w", )
		}
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode auth.recoverPassword#37096c70: field code: %w", )
		}
		.Code = 
	}
	if .Flags.Has(0) {
		if  := .NewSettings.Decode();  != nil {
			return fmt.Errorf("unable to decode auth.recoverPassword#37096c70: field new_settings: %w", )
		}
	}
	return nil
}

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

// SetNewSettings sets value of NewSettings conditional field.
func ( *AuthRecoverPasswordRequest) ( AccountPasswordInputSettings) {
	.Flags.Set(0)
	.NewSettings = 
}

// GetNewSettings returns value of NewSettings conditional field and
// boolean which is true if field was set.
func ( *AuthRecoverPasswordRequest) () ( AccountPasswordInputSettings,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .NewSettings, true
}

// AuthRecoverPassword invokes method auth.recoverPassword#37096c70 returning error if any.
// Reset the 2FA password¹ using the recovery code sent using auth
// requestPasswordRecovery².
//
// Links:
//  1. https://core.telegram.org/api/srp
//  2. https://core.telegram.org/method/auth.requestPasswordRecovery
//
// Possible errors:
//
//	400 CODE_EMPTY: The provided code is empty.
//	400 NEW_SETTINGS_INVALID: The new password settings are invalid.
//
// See https://core.telegram.org/method/auth.recoverPassword for reference.
func ( *Client) ( context.Context,  *AuthRecoverPasswordRequest) (AuthAuthorizationClass, error) {
	var  AuthAuthorizationBox

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