<?php
if (!defined('ABSPATH')) {
    exit;
}

class Aysa_Offpage_Admin_Controller {
    private $admin;

    public function __construct($admin) {
        $this->admin = $admin;
    }

    public function register_hooks() {
        add_action('wp_ajax_aysa_get_link_orders', array($this->admin, 'handle_get_link_orders'));
        add_action('wp_ajax_aysa_get_order_details', array($this->admin, 'handle_get_order_details'));
        add_action('wp_ajax_aysa_retry_link_order', array($this->admin, 'handle_retry_link_order'));
        add_action('wp_ajax_aysa_get_wordtolink_api_url', array($this->admin, 'handle_get_wordtolink_api_url'));
        add_action('wp_ajax_aysa_adverlink_list_portals', array($this->admin, 'handle_adverlink_list_portals'));
        add_action('wp_ajax_aysa_adverlink_backlink_audit', array($this->admin, 'handle_adverlink_backlink_audit'));
        add_action('wp_ajax_aysa_adverlink_credit_balance', array($this->admin, 'handle_adverlink_credit_balance'));
        add_action('wp_ajax_aysa_adverlink_create_order', array($this->admin, 'handle_adverlink_create_order'));
        add_action('wp_ajax_aysa_adverlink_track_order', array($this->admin, 'handle_adverlink_track_order'));
        add_action('wp_ajax_aysa_adverlink_get_orders', array($this->admin, 'handle_adverlink_get_orders'));
        add_action('wp_ajax_aysa_adverlink_marketplace_diagnostics', array($this->admin, 'handle_adverlink_marketplace_diagnostics'));
        add_action('wp_ajax_aysa_adverlink_exchange_list_portals', array($this->admin, 'handle_adverlink_exchange_list_portals'));
        add_action('wp_ajax_aysa_adverlink_exchange_create_request', array($this->admin, 'handle_adverlink_exchange_create_request'));
        add_action('wp_ajax_aysa_adverlink_exchange_list_requests', array($this->admin, 'handle_adverlink_exchange_list_requests'));
        add_action('wp_ajax_aysa_adverlink_exchange_get_request', array($this->admin, 'handle_adverlink_exchange_get_request'));
        add_action('wp_ajax_aysa_adverlink_exchange_respond_request', array($this->admin, 'handle_adverlink_exchange_respond_request'));
        add_action('wp_ajax_aysa_adverlink_exchange_list_activation_candidates', array($this->admin, 'handle_adverlink_exchange_list_activation_candidates'));
        add_action('wp_ajax_aysa_adverlink_exchange_activate_link', array($this->admin, 'handle_adverlink_exchange_activate_link'));
        add_action('wp_ajax_aysa_adverlink_exchange_submit_publication', array($this->admin, 'handle_adverlink_exchange_submit_publication'));
        add_action('wp_ajax_aysa_adverlink_exchange_refresh_verification', array($this->admin, 'handle_adverlink_exchange_refresh_verification'));
        add_action('wp_ajax_aysa_adverlink_exchange_change_state', array($this->admin, 'handle_adverlink_exchange_change_state'));
        add_action('wp_ajax_aysa_adverlink_save_article_draft', array($this->admin, 'handle_adverlink_save_article_draft'));
        add_action('wp_ajax_aysa_adverlink_get_article_draft', array($this->admin, 'handle_adverlink_get_article_draft'));
        add_action('wp_ajax_aysa_adverlink_create_publisher_article_draft', array($this->admin, 'handle_adverlink_create_publisher_article_draft'));
        add_action('wp_ajax_aysa_adverlink_list_publisher_article_drafts', array($this->admin, 'handle_adverlink_list_publisher_article_drafts'));
        add_action('wp_ajax_aysa_adverlink_get_publisher_article_draft', array($this->admin, 'handle_adverlink_get_publisher_article_draft'));
        add_action('wp_ajax_aysa_adverlink_update_publisher_article_draft', array($this->admin, 'handle_adverlink_update_publisher_article_draft'));
        add_action('wp_ajax_aysa_adverlink_approve_publisher_article_draft', array($this->admin, 'handle_adverlink_approve_publisher_article_draft'));
        add_action('wp_ajax_aysa_adverlink_search_link_targets', array($this->admin, 'handle_adverlink_search_link_targets'));
        add_action('wp_ajax_aysa_adverlink_get_link_issues', array($this->admin, 'handle_adverlink_get_link_issues'));
        add_action('wp_ajax_aysa_adverlink_get_backlink_audit', array($this->admin, 'handle_adverlink_get_backlink_audit'));
        add_action('wp_ajax_aysa_competitor_backlinks_gap_insights', array($this->admin, 'handle_competitor_backlinks_gap_insights'));
        add_action('wp_ajax_aysa_competitor_backlinks_get_cached', array($this->admin, 'handle_competitor_backlinks_get_cached'));
        add_action('wp_ajax_aysa_offpage_async_start', array($this->admin, 'handle_offpage_async_start'));
        add_action('wp_ajax_aysa_offpage_async_status', array($this->admin, 'handle_offpage_async_status'));
        add_action('aysa_offpage_async_event', array($this->admin, 'run_offpage_async_event'), 10, 1);
        add_action('init', array($this->admin, 'schedule_adverlink_link_issues_cron'));
        add_action('aysa_adverlink_sync_link_issues_event', array($this->admin, 'handle_adverlink_cron_link_issues_sync'));
        add_action('init', array($this->admin, 'schedule_adverlink_subscription_renewal_cron'));
        add_action('aysa_adverlink_process_subscription_renewals_event', array($this->admin, 'handle_adverlink_cron_subscription_renewals'));
        add_action('init', array($this->admin, 'schedule_adverlink_exchange_verification_cron'));
        add_action('aysa_adverlink_exchange_verify_event', array($this->admin, 'handle_adverlink_cron_exchange_verification'));
    }
}
