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

import { PendingOutOfBandOperationsResult } from '../../../operations/outOfBand/PendingOutOfBandOperationsResult';
import { ChannelMessage } from '../ChannelMessage';

/**
 * Holds the parameters of the pending out-of-band operations result call.
 */
export class PendingOutOfBandOperationsResultMessage extends ChannelMessage {
	/**
	 * The identifier of the operation.
	 */
	operationId: string;

	/**
	 * The result of the pending out-of-band operations call.
	 */
	result: PendingOutOfBandOperationsResult;

	/**
	 * Default constructor for {@link PendingOutOfBandOperationsResultMessage}.
	 *
	 * @param operationId the identifier of the operation.
	 * @param result the result of the pending out-of-band operations call.
	 */
	private constructor(operationId: string, result: PendingOutOfBandOperationsResult) {
		super();
		this.operationId = operationId;
		this.result = result;
	}

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