<?php

use App\Http\Controllers\WhatsAppAnalyticsController;
use App\Http\Controllers\WhatsAppWebhookController;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

Route::get('/user', function (Request $request) {
    return $request->user();
})->middleware('auth:sanctum');

// Webhook de Meta (sin auth)
Route::get('/webhook/whatsapp',  [WhatsAppWebhookController::class, 'verify']);
Route::post('/webhook/whatsapp', [WhatsAppWebhookController::class, 'handle']);

// API para n8n (sin auth de usuario — proteger con token en n8n si se desea)
Route::middleware('auth:sanctum')->group(function () {
    Route::get('/whatsapp/stats', [WhatsAppAnalyticsController::class, 'stats']);
    Route::get('/whatsapp/logs',  [WhatsAppAnalyticsController::class, 'logs']);
});
