<?php

use App\Http\Controllers\API\AuthController;
use App\Http\Controllers\API\Contracts;
use App\Http\Controllers\API\Passport;
use App\Http\Controllers\API\PaymentsAPI;
use App\Http\Controllers\API\SearchIDdocument;
use App\Http\Controllers\API\TokensAPI;
use App\Http\Controllers\API\TokensIprsControllerAPI;
use App\Http\Controllers\Auth\LoginController;
use App\Http\Controllers\Auth\PasswordResetController;
use App\Http\Controllers\PaymentsController;
use App\Http\Controllers\PayRefController;
use App\Http\Controllers\TokenController;
use App\Http\Controllers\TokensController;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "api" middleware group. Make something great!
|
*/


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

//Login
Route::post('/login', [AuthController::class, 'login']);

//@TODO Protect this link
Route::prefix('v1')->group(function () {
    //ID search
    Route::prefix('verify')->group(function () {
        Route::get('id/{id}/serial/{serial}', [SearchIDdocument::class, 'id_check']);
    });
    //passport
    Route::prefix('verify')->group(function () {
        Route::get('passport/{passport_num}/id/{id_num}', [Passport::class, 'passport_check']);
    });
});


/**
 * Search with login AUTH
 */
Route::middleware('auth:sanctum')->group(function () {

    //payment
    Route::prefix('v1')->group(function () {
        //search
/*        Route::prefix('verify')->group(function () {
            Route::get('id/{id}/serial/{serial}', [SearchIDdocument::class, 'id_check']);
        });*/

        //Contract
        Route::prefix('contract')->group(function () {
            Route::get('cid/{contract}', [Contracts::class, 'show']);
        });

        //Tokens
        Route::prefix('query')->group(function () {
            Route::get('tokens/contract/{contract_id}', [TokensAPI::class, 'show']);
        });

        //Payments
        Route::post('create/payment', [PaymentsAPI::class, 'store']);

        Route::prefix('get')->group(function () {
            Route::get('payment/contract/{contract_id}', [PaymentsAPI::class, 'show']);
        });

    });

});

// logout
Route::middleware('auth:sanctum')->post('/logout', [AuthController::class, 'logout']);

//reset password
//Route::post('/forgot-password', [\App\Http\Controllers\Auth\PasswordResetAPI::class, 'sendResetLinkEmail']);
//Route::post('/reset-password', [PasswordResetController::class, 'reset']);
