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

import NevisMobileAuthentication

struct RegistrationMethodHandler: MethodHandler {
	func execute(using client: MobileAuthenticationClient, method: ReactMethod, with message: ChannelInMessage) async {
		let message: RegistrationMessage = validate(message: message)
		let operation = RegistrationOperation(
			operationId: message.operationId,
			method: method,
			pinPolicy: message.pinPolicy
		)
		await OperationCache.shared.put(operation, using: message.operationId)

		await client.operations.registration
			.configure(by: message, operation: operation)
			.execute()
	}
}
