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

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

/**
 * Holds the parameters of the device information sync result call.
 */
export class DeviceInformationSyncResultMessage extends ChannelMessage {
	/**
	 * The identifier of the operation.
	 */
	operationId: string;

	/**
	 * The result of the device information sync call.
	 */
	result: DeviceInformationSyncResult;

	/**
	 * Default constructor for {@link DeviceInformationSyncResultMessage}.
	 *
	 * @param operationId the identifier of the operation.
	 * @param result the result of the device information sync call.
	 */
	private constructor(operationId: string, result: DeviceInformationSyncResult) {
		super();
		this.operationId = operationId;
		this.result = result;
	}

	/**
	 * Alternate constructor that creates an {@link DeviceInformationCheckResultMessage} from a json.
	 *
	 * @param json contains the source for instance creation.
	 * @returns the created instance.
	 */
	static fromJson(json: any): DeviceInformationSyncResultMessage {
		return new DeviceInformationSyncResultMessage(
			json.operationId,
			DeviceInformationSyncResult.fromJson(json.result)
		);
	}
}
