<?php
/**
 * Order HATEOAS request.
 *
 * @package flo-checkout
 */

namespace Flo_Checkout\Gateways\Shift4_APM\Requests;

use Exception;
use Flo_Checkout\Gateways\Shift4_APM\Enums\Request_Method;

defined( 'ABSPATH' ) || exit;

/**
 * HATEOAS request.
 */
trait Order_HATEOAS_Request_Trait {

	/**
	 * {@inheritDoc}
	 *
	 * @throws Exception If no request method is found in the link model.
	 */
	protected function get_request_method(): Request_Method {
		$method = $this->link_model->get_request_method();

		if ( ! $method ) {
			throw new Exception( 'No recognized request method found in the link model.' );
		}

		return $method;
	}


	/**
	 * {@inheritDoc}
	 */
	protected function get_url(): string {
		return $this->link_model->href;
	}

	/**
	 * Not needed for HATEOAS requests.
	 */
	protected function get_endpoint(): string {
		return '';
	}
}
