<?php

declare(strict_types=1);

namespace FormConnector\API;

use FormConnector\API\Endpoints\LicenseEndpoints;
use FormConnector\API\Endpoints\HealthEndpoints;
use FormConnector\API\Endpoints\CareHQEndpoints;
use FormConnector\API\Endpoints\HomesEndpoints;
use FormConnector\API\Endpoints\FormsEndpoints;
use FormConnector\API\Endpoints\LogsEndpoints;
use FormConnector\API\Endpoints\SettingsEndpoints;
use FormConnector\API\Endpoints\StartupEndpoints;
use FormConnector\API\Endpoints\RetryEndpoints;
use FormConnector\API\Endpoints\AnalyticsEndpoints;
use FormConnector\API\Endpoints\HealthPingEndpoints;
use FormConnector\API\Endpoints\AIEndpoints;
use FormConnector\API\Endpoints\AttributionEndpoints;

/**
 * REST API coordinator for the Form Connector plugin.
 * 
 * This class serves as the main entry point for registering all REST API endpoints.
 * Individual endpoint groups are organized in separate files under the Endpoints directory.
 */
class RestAPI {

	/**
	 * Register REST API routes.
	 */
	public static function register(): void {
		add_action('rest_api_init', [self::class, 'register_routes']);
	}

	/**
	 * Register all routes by delegating to individual endpoint classes.
	 */
	public static function register_routes(): void {
		// License management endpoints
		LicenseEndpoints::register();

		// Health check and dashboard endpoints
		HealthEndpoints::register();

		// CareHQ API settings and locations
		CareHQEndpoints::register();

		// Homes management
		HomesEndpoints::register();

		// Forms discovery and mappings
		FormsEndpoints::register();

		// Submission logs
		LogsEndpoints::register();

		// Plugin settings
		SettingsEndpoints::register();

		// Startup validation (called once on admin page load)
		StartupEndpoints::register();

		// Retry queue management
		RetryEndpoints::register();

		// Analytics tracking
		AnalyticsEndpoints::register();

		// CareHQ health ping (manual reconnect)
		HealthPingEndpoints::register();

		// AI mapping suggestions
		AIEndpoints::register();

		// Attribution analytics
		AttributionEndpoints::register();
	}
}
