api.php 5.59 KB
Newer Older
1
2
<?php

3
use Illuminate\Support\Facades\Route;
Jacob Priddy's avatar
Jacob Priddy committed
4
use App\Http\Controllers\MeController;
Jacob Priddy's avatar
Jacob Priddy committed
5
use App\Http\Controllers\AuthController;
Jacob Priddy's avatar
Jacob Priddy committed
6
use App\Http\Controllers\DoorsController;
Jacob Priddy's avatar
Jacob Priddy committed
7
use App\Http\Controllers\UsersController;
Jacob Priddy's avatar
Jacob Priddy committed
8
use App\Http\Controllers\GroupsController;
9
use App\Http\Controllers\TokensController;
10
11
use App\Http\Controllers\EntriesController;
use App\Http\Controllers\AttemptsController;
12
use App\Http\Controllers\OverridesController;
Jacob Priddy's avatar
Jacob Priddy committed
13
use App\Http\Controllers\SchedulesController;
14
15
16
17
18
19
20
21
22
23
24

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
Jacob Priddy's avatar
Jacob Priddy committed
25
26
Route::post('login', [AuthController::class, 'login']);

Jacob Priddy's avatar
Jacob Priddy committed
27
Route::post('logout', [AuthController::class, 'samlLogout']);
28

Jacob Priddy's avatar
Jacob Priddy committed
29
Route::group(['middleware' => 'auth:api'], static function () {
30
31
32
33
34
35
    Route::group([
        'prefix' => 'users',
    ], static function () {
        Route::get('/', [UsersController::class, 'index']);
        Route::post('/', [UsersController::class, 'store']);
        Route::get('{userId}', [UsersController::class, 'get']);
36
        Route::patch('{userId}', [UsersController::class, 'update']);
37
        Route::delete('{userId}', [UsersController::class, 'delete']);
Jacob Priddy's avatar
Jacob Priddy committed
38

39
40
        Route::get('{userId}/entries', [EntriesController::class, 'userEntries']);

41
        Route::get('{userId}/groups', [UsersController::class, 'getGroupsForUser']);
Jacob Priddy's avatar
Jacob Priddy committed
42
43
        Route::post('{userId}/group/{groupId}', [UsersController::class, 'addUserToGroup']);
        Route::delete('{userId}/group/{groupId}', [UsersController::class, 'removeUserFromGroup']);
44
        Route::get('{userId}/tokens', [UsersController::class, 'tokens']);
45
        Route::get('{userId}/doors', [UsersController::class, 'doors']);
46
    });
47

Jacob Priddy's avatar
Jacob Priddy committed
48
49
50
51
52
53
54
    Route::group([
        'prefix' => 'groups',
    ], static function () {
        Route::get('/', [GroupsController::class, 'index']);
        Route::post('/', [GroupsController::class, 'store']);
        Route::get('{groupId}', [GroupsController::class, 'get']);
        Route::put('{groupId}', [GroupsController::class, 'update']);
Jacob Priddy's avatar
Jacob Priddy committed
55
        Route::delete('{groupId}', [GroupsController::class, 'delete']);
56
57

        Route::get('{groupId}/users', [GroupsController::class, 'getUsersForGroup']);
58
        Route::get('{groupId}/doors', [GroupsController::class, 'getDoorsForGroup']);
59
60
61

        Route::get('{groupId}/schedules', [SchedulesController::class, 'getForGroup']);
        Route::get('{groupId}/active', [SchedulesController::class, 'activeForGroup']);
Jacob Priddy's avatar
Jacob Priddy committed
62
63
    });

Jacob Priddy's avatar
Jacob Priddy committed
64
65
66
67
    Route::group([
        'prefix' => 'doors',
    ], static function () {
        Route::get('/', [DoorsController::class, 'index']);
Jacob Priddy's avatar
Jacob Priddy committed
68
        Route::post('/', [DoorsController::class, 'store']);
Jacob Priddy's avatar
Jacob Priddy committed
69
        Route::get('{doorId}', [DoorsController::class, 'get']);
70
        Route::patch('{doorId}', [DoorsController::class, 'update']);
Jacob Priddy's avatar
Jacob Priddy committed
71
        Route::post('/{doorId}/regenerate-token', [DoorsController::class, 'regenerateToken']);
Jacob Priddy's avatar
Jacob Priddy committed
72
        Route::delete('{doorId}', [DoorsController::class, 'delete']);
73

74
75
        Route::get('{doorId}/entries', [EntriesController::class, 'doorEntries']);

76
        Route::get('{doorId}/groups', [DoorsController::class, 'getGroupsForDoor']);
77
        Route::post('{doorId}/group/{groupId}', [DoorsController::class, 'addDoorToGroup']);
78
        Route::delete('{doorId}/group/{groupId}', [DoorsController::class, 'removeDoorFromGroup']);
79
80

        Route::get('{doorId}/overrides', [OverridesController::class, 'forDoor']);
Jacob Priddy's avatar
Jacob Priddy committed
81
82
    });

83
84
85
    Route::group([
        'prefix' => 'schedules',
    ], static function () {
Jacob Priddy's avatar
Jacob Priddy committed
86
        Route::get('/', [SchedulesController::class, 'between']);
87
        Route::get('{scheduleId}', [SchedulesController::class, 'get']);
88
        Route::post('/', [SchedulesController::class, 'create']);
Jacob Priddy's avatar
Jacob Priddy committed
89
        Route::patch('{scheduleId}', [SchedulesController::class, 'update']);
90
91
    });

92
93
94
95
96
97
    Route::group([
        'prefix' => 'tokens',
    ], static function () {
        Route::get('/', [TokensController::class, 'index']);
        Route::get('{tokenId}', [TokensController::class, 'get']);
        Route::post('/', [TokensController::class, 'store']);
98
        Route::patch('{tokenId}', [TokensController::class, 'update']);
99
100
101
        Route::post('{tokenId}/expire', [TokensController::class, 'expire']);
    });

102
103
104
    Route::group([
        'prefix' => 'entries',
    ], static function () {
Jacob Priddy's avatar
Jacob Priddy committed
105
        Route::get('/', [EntriesController::class, 'index']);
106
107
108
109
110
111
112
113
114
        Route::get('door/{doorId}/user/{userId}', [EntriesController::class, 'doorUserEntries']);
    });

    Route::group([
        'prefix' => 'attempts',
    ], static function () {
        Route::get('/', [AttemptsController::class, 'index']);
    });

115
116
117
118
119
    Route::group([
        'prefix' => 'overrides',
    ], static function () {
        Route::post('/', [OverridesController::class, 'create']);
        Route::get('/', [OverridesController::class, 'index']);
120
121
        Route::patch('{overrideId}', [OverridesController::class, 'update']);
        Route::get('{overrideId}', [OverridesController::class, 'get']);
122
123
124
    });


Jacob Priddy's avatar
Jacob Priddy committed
125
126
127
128
    Route::group([
        'prefix' => 'me',
    ], static function () {
        Route::get('/', [MeController::class, 'index']);
129
130
        Route::get('groups', [MeController::class, 'groups']);
        Route::get('tokens', [MeController::class, 'tokens']);
131
        Route::patch('/', [MeController::class, 'update']);
132
        Route::get('permissions', [MeController::class, 'permissions']);
133
        Route::get('/doors', [MeController::class, 'doors']);
Jacob Priddy's avatar
Jacob Priddy committed
134
    });
135
});