<?php
/**
 * Product Sync Hooks
 *
 * Wires WordPress AJAX and Action Scheduler hooks for product synchronization.
 *
 * @package    MOMCS_Sync
 * @subpackage MOMCS_Sync/includes/common/hooks
 */

declare(strict_types=1);

namespace MOMCS_Sync\Includes\Common\Hooks;

use MOMCS_Sync\Includes\Common\Controllers\Sync\Product_Sync_Controller;
use MOMCS_Sync\Includes\Common\Constants\Plugin_Constants;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Class Product_Sync_Hooks
 *
 * Registers hooks and delegates to `Product_Sync_Controller` methods.
 */
class Product_Sync_Hooks {
	/**
	 * Controller instance.
	 *
	 * @var Product_Sync_Controller
	 */
	private $controller;

	/**
	 * Constructor.
	 */
	public function __construct() {
		$this->controller = new Product_Sync_Controller();
		$this->register_hooks();
	}

	/**
	 * Register WordPress hooks.
	 *
	 * @return void
	 */
	private function register_hooks(): void {
		// Admin AJAX handlers.
		add_action( 'wp_ajax_momcs_sync_products_bulk', array( $this->controller, 'sync_products_bulk_ajax' ) );
		add_action( 'wp_ajax_momcs_get_channels', array( $this->controller, 'get_channels' ) );
		add_action( 'wp_ajax_momcs_unlist_products_bulk', array( $this->controller, 'unlist_products_bulk_ajax' ) );

		// Background Action Scheduler hooks.
		add_action( Plugin_Constants::CRON_SYNC_BULK, array( $this->controller, 'process_bulk_sync_action' ), 10, 2 );
		add_action( Plugin_Constants::CRON_UNLIST_BULK, array( $this->controller, 'process_bulk_unlist_action' ), 10, 2 );
	}
}
