<?php
/**
 * File: Ecre_API.php
 *
 * Description: This file contains the Ecre_API class which handles the registration of the Echo Rewards Pro REST API endpoints.
 * The class is initialized and the API endpoints are registered when the 'rest_api_init' action is triggered.
 *
 * @package ECRE
 */

namespace ECRE;

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

if ( ! class_exists( 'Ecre_API' ) ) {

	/**
	 * Class Ecre_API
	 *
	 * Handles the registration of the Echo Rewards Pro REST API endpoints.
	 */
	class Ecre_API {

		/**
		 * Ecre_API constructor.
		 *
		 * Initializes the class by registering the REST API endpoints.
		 */
		public function __construct() {
			add_action( 'rest_api_init', array( $this, 'ecre_register_api' ) );
		}

		/**
		 * Registers the Echo Rewards Pro REST API endpoints.
		 *
		 * This function is hooked to the 'rest_api_init' action and is responsible
		 * for instantiating the classes that handle the API endpoints.
		 */
		public function ecre_register_api() {
			$coupons_info = new Api\Ecre_Referral();
			$coupons_info->register_routes();

			$ecre_settings = new Api\Ecre_Settings();
			$ecre_settings->register_routes();
		}
	}
}
