<?php
namespace Kanzu\StoreVoiceAI;

// Prevent direct file access.
if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

use Kanzu\StoreVoiceAI\ResponseHandlers\Voice_Response_Handler;
use Kanzu\StoreVoiceAI\ResponseHandlers\Webhook_Handler;

class API_Endpoints {

    public function register_custom_voice_endpoints() {

        $voice_resp_handler = new Voice_Response_Handler();
        register_rest_route( 'storevoiceai/v1', '/voice/products/search', [
            'methods'               => 'POST',
            'callback'              => [$voice_resp_handler, 'handle_product_search_tool_call'],
            'permission_callback'   => [$voice_resp_handler, 'check_secret_key_permission'],
        ]);

        register_rest_route( 'storevoiceai/v1', '/voice/offers/search', [
            'methods'               => 'POST',
            'callback'              => [$voice_resp_handler, 'handle_offer_search_tool_call'],
            'permission_callback'   => [$voice_resp_handler, 'check_secret_key_permission'],
        ]);

        register_rest_route( 'storevoiceai/v1', '/voice/users/me', [
            'methods'               => 'POST',
            'callback'              => [$voice_resp_handler, 'handle_get_user_info_tool_call'],
            'permission_callback'   => [$voice_resp_handler, 'check_secret_key_permission'],
        ]);

        register_rest_route( 'storevoiceai/v1', '/voice/orders/search', [
            'methods'               => 'POST',
            'callback'              => [$voice_resp_handler, 'handle_get_order_details_tool_call'],
            'permission_callback'   => [$voice_resp_handler, 'check_secret_key_permission'],
        ]);

        $webhook_resp_handler = new Webhook_Handler();
        register_rest_route( 'storevoiceai/v1', '/webhooks/agent-created', [
            'methods'               => 'POST',
            'callback'              => [$webhook_resp_handler, 'handle_agent_creation_completed'],
            'permission_callback'   => [$webhook_resp_handler, 'check_secret_key_permission'],
        ]);
    }
    

}