<?php

/**
 * REST API route definitions.
 *
 * These routes are registered under the `easylink-automations/v1` namespace.
 * The $router variable is provided by HookProvider before this file is included.
 */

use EasyLinkAutomations\HTTP\Router\Route;
use EasyLinkAutomations\HTTP\Controllers\ActionController;
use EasyLinkAutomations\HTTP\Controllers\ConnectionController;
use EasyLinkAutomations\HTTP\Controllers\TriggerController;

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

// Protected catalog routes
Route::group(function (): void {
    // Trigger routes
    Route::get('triggers', [TriggerController::class, 'index']);
    Route::get('triggers/{slug}', [TriggerController::class, 'show']);

    // Action routes
    Route::get('actions', [ActionController::class, 'index']);
    Route::get('actions/{slug}', [ActionController::class, 'show']);
})->middleware('isAdmin');

// OAuth2 callback (public — called by external providers)
Route::get('auth/callback', [ConnectionController::class, 'oauthCallback'])->middleware('public');
