<?php

namespace GriffinForms\Admin\App\Html\Modals\Integrations;

/**
 * Integrations Modal - Requests Trait
 *
 * Registers AJAX handlers for integration-related operations.
 * Called during modal initialization to set up action hooks.
 */
trait Requests
{
    /**
     * Register AJAX handlers
     * Called automatically from setAll() method
     * Method name must be: set + PropertyName (where property is registerAjaxHandlers)
     */
    protected function setRegisterAjaxHandlers()
    {
        // Phase 1: Grid View
        add_action('wp_ajax_getIntegrationsList', [$this, 'getIntegrationsList']);

        // Phase 2: Info View
        add_action('wp_ajax_getIntegrationInfo', [$this, 'getIntegrationInfo']);

        // Phase 3b: Configuration Handlers
        add_action('wp_ajax_getIntegrationConfigurationForm', [$this, 'getIntegrationConfigurationForm']);
        add_action('wp_ajax_saveIntegrationConfiguration', [$this, 'saveIntegrationConfiguration']);

        // Phase 4: Testing & Enable/Disable
        add_action('wp_ajax_testIntegration', [$this, 'testIntegration']);
        add_action('wp_ajax_disableIntegration', [$this, 'disableIntegration']);

        // Per-form integration settings
        add_action('wp_ajax_getFormIntegrationSettings', [$this, 'getFormIntegrationSettings']);
        add_action('wp_ajax_saveFormIntegrationSettings', [$this, 'saveFormIntegrationSettings']);

        // WP7 Connectors: activate provider inline from chat sidebar
        add_action('wp_ajax_griffinforms_activate_provider_from_connector', [$this, 'activateProviderFromConnector']);
    }
}
