<?php
/**
 * REST bootstrap.
 *
 * @package WPDudeProducts
 */

declare(strict_types=1);

namespace WPDude\Products\REST;

/**
 * Registers REST routes.
 */
final class REST_Loader {

	public const NAMESPACE = 'dude-commerce/v1';

	/**
	 * Register hooks.
	 */
	public function register(): void {
		add_action( 'rest_api_init', array( $this, 'register_routes' ) );
	}

	/**
	 * Register controllers.
	 */
	public function register_routes(): void {
		( new Checkout_Controller() )->register_routes();
		( new Webhook_Controller() )->register_routes();
		( new Confirm_Payment_Controller() )->register_routes();
		( new Order_Status_Controller() )->register_routes();

		$fs = function_exists( 'wpdude_dc_fs' ) ? wpdude_dc_fs() : null;
		if ( is_object( $fs ) && $fs->is__premium_only() ) {
			require_once WPDUDE_DC_PATH . 'src/Licensing/Premium_Bootstrap__premium_only.php';
			\WPDude\Products\Licensing\Premium_Bootstrap::register_rest_routes();
		}
	}
}
