//
// Copyright © 2024 Nevis Security AG. All rights reserved.
//

import NevisMobileAuthentication

actor PasswordChangeOperation: StandardOperation {
	typealias T = ()

	// MARK: Properties

	private(set) var state: OperationState
	let onSuccess: SuccessHandler
	let onError: ErrorHandler
	let passwordChanger: PasswordChanger

	// MARK: Initialization

	init(operationId: String, method: ReactMethod) {
		self.state = NoOperationState()
		self.onSuccess = OnSuccessImpl(operationId: operationId, method: method).onSuccess
		self.onError = OnErrorImpl(operationId: operationId, method: method).onError
		self.passwordChanger = PasswordChangerImpl(operationId: operationId)
	}

	// MARK: Public Interface

	func update(state: PasswordChangeOperationState) -> PasswordChangeOperation {
		self.state = state
		return self
	}
}
