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

// AccountUpdatePasswordSettingsRequest represents TL type `account.updatePasswordSettings#a59b102f`.
// Set a new 2FA password
//
// See https://core.telegram.org/method/account.updatePasswordSettings for reference.
type AccountUpdatePasswordSettingsRequest struct {
	// The old password (see SRPĀ¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/srp
	Password InputCheckPasswordSRPClass
	// The new password (see SRPĀ¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/srp
	NewSettings AccountPasswordInputSettings
}

// AccountUpdatePasswordSettingsRequestTypeID is TL type id of AccountUpdatePasswordSettingsRequest.
const AccountUpdatePasswordSettingsRequestTypeID = 0xa59b102f

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

func ( *AccountUpdatePasswordSettingsRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Password == nil) {
		return false
	}
	if !(.NewSettings.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills AccountUpdatePasswordSettingsRequest from given interface.
func ( *AccountUpdatePasswordSettingsRequest) ( interface {
	() ( InputCheckPasswordSRPClass)
	() ( AccountPasswordInputSettings)
}) {
	.Password = .()
	.NewSettings = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *AccountUpdatePasswordSettingsRequest) () tdp.Type {
	 := tdp.Type{
		Name: "account.updatePasswordSettings",
		ID:   AccountUpdatePasswordSettingsRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Password",
			SchemaName: "password",
		},
		{
			Name:       "NewSettings",
			SchemaName: "new_settings",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *AccountUpdatePasswordSettingsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.updatePasswordSettings#a59b102f as nil")
	}
	.PutID(AccountUpdatePasswordSettingsRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountUpdatePasswordSettingsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.updatePasswordSettings#a59b102f as nil")
	}
	if .Password == nil {
		return fmt.Errorf("unable to encode account.updatePasswordSettings#a59b102f: field password is nil")
	}
	if  := .Password.Encode();  != nil {
		return fmt.Errorf("unable to encode account.updatePasswordSettings#a59b102f: field password: %w", )
	}
	if  := .NewSettings.Encode();  != nil {
		return fmt.Errorf("unable to encode account.updatePasswordSettings#a59b102f: field new_settings: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AccountUpdatePasswordSettingsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.updatePasswordSettings#a59b102f to nil")
	}
	{
		,  := DecodeInputCheckPasswordSRP()
		if  != nil {
			return fmt.Errorf("unable to decode account.updatePasswordSettings#a59b102f: field password: %w", )
		}
		.Password = 
	}
	{
		if  := .NewSettings.Decode();  != nil {
			return fmt.Errorf("unable to decode account.updatePasswordSettings#a59b102f: field new_settings: %w", )
		}
	}
	return nil
}

// GetPassword returns value of Password field.
func ( *AccountUpdatePasswordSettingsRequest) () ( InputCheckPasswordSRPClass) {
	if  == nil {
		return
	}
	return .Password
}

// GetNewSettings returns value of NewSettings field.
func ( *AccountUpdatePasswordSettingsRequest) () ( AccountPasswordInputSettings) {
	if  == nil {
		return
	}
	return .NewSettings
}

// GetPasswordAsNotEmpty returns mapped value of Password field.
func ( *AccountUpdatePasswordSettingsRequest) () (*InputCheckPasswordSRP, bool) {
	return .Password.AsNotEmpty()
}

// AccountUpdatePasswordSettings invokes method account.updatePasswordSettings#a59b102f returning error if any.
// Set a new 2FA password
//
// Possible errors:
//
//	400 EMAIL_INVALID: The specified email is invalid.
//	400 EMAIL_UNCONFIRMED: Email unconfirmed.
//	400 EMAIL_UNCONFIRMED_%d: The provided email isn't confirmed, %d is the length of the verification code that was just sent to the email: use account.verifyEmail to enter the received verification code and enable the recovery email.
//	400 NEW_SALT_INVALID: The new salt is invalid.
//	400 NEW_SETTINGS_EMPTY: No password is set on the current account, and no new password was specified in new_settings.
//	400 NEW_SETTINGS_INVALID: The new password settings are invalid.
//	400 PASSWORD_HASH_INVALID: The provided password hash is invalid.
//	400 SRP_ID_INVALID: Invalid SRP ID provided.
//	400 SRP_PASSWORD_CHANGED: Password has changed.
//
// See https://core.telegram.org/method/account.updatePasswordSettings for reference.
func ( *Client) ( context.Context,  *AccountUpdatePasswordSettingsRequest) (bool, error) {
	var  BoolBox

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