<?php

use App\Http\Controllers\Api\WincarApiController;
use App\Http\Controllers\Payments\TilopayPaymentController;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
*/

// Rutas Públicas
Route::post('/register', [WincarApiController::class, 'register']);
Route::post('/login', [WincarApiController::class, 'login']);
Route::get('/raffles', [WincarApiController::class, 'listRaffles']);
Route::get('/raffles/{raffle}', [WincarApiController::class, 'showRaffle']);
Route::get('/raffles/{raffle}/numbers', [WincarApiController::class, 'listNumbers']);
Route::get('/banners', [WincarApiController::class, 'listBanners']);
Route::get('/stories', [WincarApiController::class, 'listStories']);
Route::get('/winners', [WincarApiController::class, 'winners']);
Route::get('/settings', [WincarApiController::class, 'getSettings']);
Route::get('/payments/tilopay/callback', [TilopayPaymentController::class, 'callback'])->name('tilopay.callback');
Route::get('/payments/tilopay/mock-checkout', [TilopayPaymentController::class, 'mockCheckout']);

// Rutas Protegidas (Requieren autenticación Sanctum)
Route::middleware('auth:sanctum')->group(function () {
    Route::get('/profile', [WincarApiController::class, 'profile']);
    Route::put('/profile', [WincarApiController::class, 'updateProfile']);
    Route::post('/cards/quote', [WincarApiController::class, 'quotePurchase']);
    Route::post('/cards/reserve', [WincarApiController::class, 'reserveTickets']);
    Route::get('/cards/pending', [WincarApiController::class, 'pendingCards']);
    Route::post('/cards/reveal', [WincarApiController::class, 'revealCards']);
    Route::get('/albums', [WincarApiController::class, 'myAlbums']);
    Route::get('/transactions/{transaction}/cards', [WincarApiController::class, 'transactionCards']);
    Route::get('/raffles/{raffle}/album', [WincarApiController::class, 'raffleAlbum']);
    Route::post('/raffles/{raffle}/check-numbers', [WincarApiController::class, 'checkNumbers']);
    Route::post('/tickets/reserve', [WincarApiController::class, 'reserveTickets']);
    Route::post('/tickets/payment', [WincarApiController::class, 'submitPurchasePayment']);
    Route::post('/payments/tilopay/checkout', [TilopayPaymentController::class, 'checkout']);
    Route::post('/wallet/tilopay/recharge', [TilopayPaymentController::class, 'walletRecharge']);
    Route::get('/wallet/history', [WincarApiController::class, 'walletHistory']);
    Route::post('/wallet/withdraw', [WincarApiController::class, 'requestWithdrawal']);
    Route::post('/wallet/deposit', [WincarApiController::class, 'requestDeposit']);
    Route::post('/user/fcm-token', [WincarApiController::class, 'updateFcmToken']);
    Route::get('/reseller/dashboard', [WincarApiController::class, 'resellerDashboard']);
    Route::post('/reseller/apply', [WincarApiController::class, 'applyAsReseller']);
    Route::get('/reseller/application-status', [WincarApiController::class, 'getResellerApplicationStatus']);
    Route::get('/referrals', [WincarApiController::class, 'myReferrals']);
    Route::post('/keys/open-chest', [WincarApiController::class, 'openChest']);
    Route::get('/raffles/{raffle}/available-number', [WincarApiController::class, 'getAvailableNumber']);
    Route::get('/notifications', [WincarApiController::class, 'listNotifications']);
    Route::post('/notifications/read', [WincarApiController::class, 'markNotificationsRead']);
    Route::get('/support/messages', [WincarApiController::class, 'getSupportMessages']);
    Route::post('/support/send', [WincarApiController::class, 'sendSupportMessage']);
});
