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

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

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

	/**
	 * The callback that will be invoked by the SDK with the {@link DeviceInformationSyncResult}
	 * when the operation completes.
	 */
	onResult?: (result: DeviceInformationSyncResult) => void;

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

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