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

import { ChannelMessage } from '../ChannelMessage';

/**
 * Holds the parameters of the policy compliant native event.
 */
export class IsPolicyCompliantInMessage extends ChannelMessage {
	/**
	 * The identifier of the operation.
	 */
	operationId: string;

	/**
	 * True if the {@link Authenticator} is compliant with the policy of the server.
	 */
	isPolicyCompliant: boolean;

	/**
	 * Default constructor for {@link IsPolicyCompliantInMessage}.
	 *
	 * @param operationId the identifier of the operation.
	 * @param isPolicyCompliant true if the {@link Authenticator} is compliant with the policy of the server.
	 */
	constructor(operationId: string, isPolicyCompliant: boolean) {
		super();
		this.operationId = operationId;
		this.isPolicyCompliant = isPolicyCompliant;
	}

	/**
	 * Alternate constructor that creates an {@link IsPolicyCompliantInMessage} from a json.
	 *
	 * @param json contains the source for instance creation.
	 * @returns the created instance.
	 */
	static fromJson(json: any): IsPolicyCompliantInMessage {
		const operationId = json.operationId;
		const isPolicyCompliant = json.isPolicyCompliant;

		return new IsPolicyCompliantInMessage(operationId, isPolicyCompliant);
	}
}
