<?php

use App\Http\Controllers\Api\ServiceEventController;
use App\Http\Controllers\Api\V1\RoomController;
use App\Http\Controllers\Api\V1\ServiceRoomController;
use Illuminate\Support\Facades\Route;

Route::get('/health', fn () => response()->json(['status' => 'ok', 'app' => 'meet']));

Route::post('/service-events', ServiceEventController::class)->name('api.service-events');

Route::middleware(['auth.service:meet'])->prefix('service/v1')->group(function () {
    Route::get('/rooms/by-source', [ServiceRoomController::class, 'lookup'])->name('api.service.rooms.lookup');
    Route::post('/rooms', [ServiceRoomController::class, 'store'])->name('api.service.rooms.store');
    Route::get('/rooms/{room}', [ServiceRoomController::class, 'show'])->name('api.service.rooms.show');
    Route::patch('/rooms/{room}', [ServiceRoomController::class, 'update'])->name('api.service.rooms.update');
    Route::post('/rooms/{room}/cancel', [ServiceRoomController::class, 'cancel'])->name('api.service.rooms.cancel');
    Route::post('/rooms/{room}/start', [ServiceRoomController::class, 'start'])->name('api.service.rooms.start');
});

Route::middleware(['auth:sanctum', 'meet.setup'])->prefix('v1')->group(function () {
    Route::get('/rooms', [RoomController::class, 'index'])->name('api.rooms.index');
    Route::post('/rooms', [RoomController::class, 'store'])->name('api.rooms.store');
    Route::get('/rooms/{room}', [RoomController::class, 'show'])->name('api.rooms.show');
    Route::post('/rooms/{room}/start', [RoomController::class, 'start'])->name('api.rooms.start');
});
