<?php
/**
 * API Loader functionality.
 *
 * @package Postomatic
 * This file contains the API_Loader class that initializes all API endpoints.
 */

namespace Postomatic\Core;

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

/**
 * API_Loader class.
 *
 * Handles the loading and initialization of API endpoints.
 */
class API_Loader {

	/**
	 * Initializes API endpoints.
	 *
	 * @return void
	 */
	public static function load_api_endpoints() {

		// Initialize the endpoint.
		\Postomatic\Api\Code_Endpoint::init();
		\Postomatic\Api\Custom_Search::init();
		\Postomatic\Api\One_Time_Code_Ajax::init();
		\Postomatic\Api\Post_Maker::init();
		\Postomatic\Api\Autopilot_Endpoint::init();
		\Postomatic\Api\Similar_Titles_Search::init();

		/*
		 * Proxies the blog-posts sync and agreement signature through the server,
		 * so the API service key no longer has to be printed into admin pages for
		 * JavaScript to call the remote service directly.
		 */
		\Postomatic\Api\Api_Proxy_Handler::init();

		// Puts cancelled posts back into the generation queue.
		\Postomatic\Api\Regenerate_Post_Handler::init();

		// Handles the AJAX endpoint that refreshes the API key after a 401 response.
		new \Postomatic\Api\Activate_Handler();

		// Initialize the Blog_Analyzer class (uses constructor-based initialization).
		new \Postomatic\Api\Blog_Analyzer();

		// Initialize the Content_Goal_Types_Handler class (uses constructor-based initialization).
		new \Postomatic\Api\Content_Goal_Types_Handler();

		// Initialize the Product_Handler class (uses constructor-based initialization).
		new \Postomatic\Api\Product_Handler();

		// Initialize the Languages_Handler class (uses constructor-based initialization).
		new \Postomatic\Api\Languages_Handler();

		// Initialize the Autopilot_Handler class (uses constructor-based initialization).
		new \Postomatic\Api\Autopilot_Handler();

		// Initialize the Credit_Handler class (uses constructor-based initialization).
		new \Postomatic\Api\Credit_Handler();

		// Initialize the Credit_Scores_Handler class (uses constructor-based initialization).
		new \Postomatic\Api\Credit_Scores_Handler();

		// Initialize the Speakers_Handler class (uses constructor-based initialization).
		new \Postomatic\Api\Speakers_Handler();

		// Initialize the Countries_Handler class (uses constructor-based initialization).
		new \Postomatic\Api\Countries_Handler();

		// Initialize the Recent_Posts_Handler class (uses constructor-based initialization).
		new \Postomatic\Api\Recent_Posts_Handler();

		// Initialize the Plan_Handler class (uses constructor-based initialization).
		new \Postomatic\Api\Plan_Handler();

		// Initialize the Pricing_Plans_Handler class (uses constructor-based initialization).
		new \Postomatic\Api\Pricing_Plans_Handler();

		// Initialize the Pricing_Credits_Handler class (uses constructor-based initialization).
		new \Postomatic\Api\Pricing_Credits_Handler();

		// Initialize the Credit_Access_Handler class (uses constructor-based initialization).
		new \Postomatic\Api\Credit_Access_Handler();

		// Initialize the Delete_Post_Handler class (uses constructor-based initialization).
		new \Postomatic\Api\Delete_Post_Handler();
	}
}
