<?php
/**
 * Health response.
 *
 * @package flo-checkout
 */

namespace Flo_Checkout\Gateways\Shift4_APM\Responses;

use Exception;

defined( 'ABSPATH' ) || exit;

/**
 * Health response.
 */
class Health_Check_Response extends Abstract_Response {

	/**
	 * {@inheritDoc}
	 *
	 * @throws Exception If the health check failed.
	 */
	public function process(): Abstract_Response {
		parent::process();

		$body = $this->result->get_response_body();
		if ( 'OK' !== $body['health'] ) {
			throw new Exception( 'Health check failed.' );
		}

		return $this;
	}

	/**
	 * {@inheritDoc}
	 */
	protected function get_required_response_data_keys(): array {
		return array(
			'health',
		);
	}
}
