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

import { HttpOperationMessage } from './HttpOperationMessage';
import { DeviceInformationMismatch } from '../../../operations/deviceInformation/DeviceInformationMismatch';
import { RequestHeaders } from '../../../operations/RequestHeaders';
import { TypedDeviceInformationMismatch } from '../../typed/TypedDeviceInformationMismatch';

/**
 * Holds the parameters of the device information sync platform channel call.
 */
export class DeviceInformationSyncMessage extends HttpOperationMessage {
	/**
	 * The identifier of the operation.
	 */
	operationId: string;

	/**
	 * Specifies the additional request headers that must be included in the HTTP requests sent by
	 * the operation.
	 */
	requestHeaders?: RequestHeaders;

	/**
	 * Specifies the configuration mismatches to be fixed.
	 */
	mismatches?: Array<TypedDeviceInformationMismatch>;

	/**
	 * Flag that tells whether the result callback is provided.
	 */
	onResultProvided: boolean;

	/**
	 * Default constructor for {@link DeviceInformationSyncMessage}.
	 *
	 * @param operationId the identifier of the operation.
	 * @param requestHeaders the additional request headers that must be included in the HTTP requests sent by the operation.
	 * @param mismatches the configuration mismatches to be fixed.
	 * @param onResultProvided the flag that tells whether the result callback is provided.
	 */
	constructor(
		operationId: string,
		onResultProvided: boolean,
		mismatches?: Array<DeviceInformationMismatch>,
		requestHeaders?: RequestHeaders
	) {
		super();
		this.operationId = operationId;
		this.onResultProvided = onResultProvided;
		this.requestHeaders = requestHeaders;
		if (mismatches) {
			this.mismatches = mismatches.map(TypedDeviceInformationMismatch.create);
		}
	}
}
