<?php

use Dingo\Api\Facade\API;
use Dingo\Api\Routing\Router;
use App\Http\Controllers\API\V1\Auth\MeAction;
use App\Http\Controllers\API\V1\Auth\LoginAction;
use App\Http\Controllers\API\V1\Auth\LogoutAction;
use App\Http\Controllers\API\V1\Auth\RefreshAction;
use App\Http\Controllers\API\V1\Pouzivatel\Notifications\Frontend\ListAction;
use App\Http\Controllers\API\V1\Pouzivatel\PushNotifications\Frontend\StoreUsersPushNotificationTokenAction;

$api = API::router();
$routeName = 'app.api.frontend.pouzivatelia';

$api->version('v1', ['middleware' => 'api'], function (Router $api) {
    $api->group([
        'prefix' => 'auth',
    ], function (Router $api) {
        $api->post('/login', LoginAction::class);
    });
});
$api->version('v1', ['middleware' => 'api_v1'], function (Router $api) {
    $api->group([
        'prefix' => 'auth',
    ], function (Router $api) {
        $api->get('/logout', LogoutAction::class);
        $api->get('/me', MeAction::class);
        $api->get('/refresh', RefreshAction::class);
    });
});

$api->version('v1', ['middleware' => ['api_v1', 'role:admin|technik|spravca_pek|prijem',],], function ($api) use ($routeName) {
    $api->group([
        'prefix' => 'pouzivatelia',
    ], function ($api) use ($routeName) {
        $api->group([
            'prefix' => 'push-notifikacie',
        ], function ($api) use ($routeName) {
            $api->post('/token', ['as' => "{$routeName}.push_notifications.token.create", 'uses' => StoreUsersPushNotificationTokenAction::class,]);
        });

        $api->group([
            'prefix' => 'notifikacie',
        ], function ($api) use ($routeName) {
            $api->get('/', ['as' => "{$routeName}.notifications.list", 'uses' => ListAction::class,]);
        });
    });
});
