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

import { PlatformOperation } from './PlatformOperation';
import { DeviceInformationCheckResult } from '../../operations/deviceInformation/DeviceInformationCheckResult';

/**
 * Helps in following the states of device information check during method channel calls.
 */
export class DeviceInformationCheckPlatformOperation extends PlatformOperation {
	operationId: string;

	/**
	 * The callback that will be invoked by the SDK with the {@link DeviceInformationCheckResult}
	 * containing the configuration mismatches an errors (if any) that occurred.
	 */
	onResult?: (result: DeviceInformationCheckResult) => void;

	constructor(operationId: string, onResult?: (result: DeviceInformationCheckResult) => void) {
		super();
		this.operationId = operationId;
		this.onResult = onResult;
	}

	/**
	 * Provides a way to handle the result of the device information check method channel call.
	 *
	 * @param result the result of the method channel call.
	 */
	handleResult(result: DeviceInformationCheckResult) {
		this.onResult?.(result);
	}
}
