Commit 60accc37 authored by Jacob Priddy's avatar Jacob Priddy 👌
Browse files

fix documentation bugs and entries documentation as well as a entry

entity bug
parent e2ee052c
......@@ -24,11 +24,11 @@ class AttemptsController extends ApiController
*
* @authenticated
* @paginated
* @queryParam start date The beginning date to filter attempts by. Example: 2020-06-02 08:11:45
* @queryParam end date The ending date to filter attempts by. Example: 2020-06-02 08:11:45
* @queryParam door_id int The door id to filter on. Example: 1
* @queryParam start The beginning date to filter attempts by. Example: 2000-06-02 08:11:45
* @queryParam end The ending date to filter attempts by. Example: 2920-06-02 08:11:45
* @queryParam door_id The door id to filter on. Example: 1
*
* @response 422 {"message":"The given data was invalid.","errors":{"start":["The start is not a valid date."],"end":["The end is not a valid date."],"door_id":["The door id must be an integer."]}}
* @response 422 {"message":"The given data was invalid.","errors":{"start":["The start is not a valid date."],"end":["The end is not a valid date."],"door_id":["The door id must be an integer."]}}
*
* @param \Source\UseCases\Attempts\GetAttempts\GetAttemptsUseCase $attempts
* @return \Illuminate\Http\JsonResponse
......@@ -42,9 +42,9 @@ class AttemptsController extends ApiController
$this->authorizer->protect(Permissions::LOGS_READ);
$this->validate($this->request, [
'start' => 'date',
'end' => 'date',
'door_id' => 'integer',
'start' => 'nullable|date',
'end' => 'nullable|date',
'door_id' => 'nullable|integer',
]);
$presenter = new GetAttemptsAPIPresenter();
......
......@@ -75,8 +75,8 @@ class DoorController extends ApiController
* @urlParam doorcode required The doorcode to query. Example: 123456*00110
* @queryParam foresight Number of minutes ahead of now to get the open mode times for. Example: 720
*
* @response 422 {"message":"The given data was invalid.","errors":{"foresight":["The foresight must be an
* integer."]}}
* @response 422
* {"message":"The given data was invalid.","errors":{"foresight":["The foresight must be an integer."]}}
* @response 403
* {"events":[{"begins_at":"2020-06-03T11:54:07-07:00","ends_at":"2020-06-03T11:55:07-07:00"},{"begins_at":"2020-06-03T11:55:07-07:00","ends_at":"2020-06-03T12:15:07-07:00"},{"begins_at":"2020-06-03T21:54:07-07:00","ends_at":"2020-06-03T21:55:07-07:00"}]}
*
......@@ -104,8 +104,8 @@ class DoorController extends ApiController
* @authenticated
* @queryParam foresight Number of minutes ahead of now to get the open mode times for. Example: 720
*
* @response 422 {"message":"The given data was invalid.","errors":{"foresight":["The foresight must be an
* integer."]}}
* @response 422
* {"message":"The given data was invalid.","errors":{"foresight":["The foresight must be an integer."]}}
*
* @return \Illuminate\Http\JsonResponse
* @throws \Illuminate\Validation\ValidationException
......
......@@ -93,8 +93,8 @@ class DoorsController extends ApiController
* This endpoint creates a new door in the system.
*
* @authenticated
* @bodyParam location required Door Number or location describing where it is such as `CSP165`. Example: CSP165
* @bodyParam name required The unique name for the door. Must be unique. Example: Engineering Lecture Hall
* @bodyParam location string required Door Number or location describing where it is such as `CSP165`. Example: CSP165
* @bodyParam name string required The unique name for the door. Must be unique. Example: Engineering Lecture Hall
*
* @param \Source\UseCases\Doors\CreateDoor\CreateDoorUseCase $createDoor
* @return \Illuminate\Http\JsonResponse
......@@ -122,12 +122,12 @@ class DoorsController extends ApiController
/**
* Update Door
*
* This route updaets a door in the system. It does not modify the associated door token.
* This route updates a door in the system. It does not modify the associated door token.
*
* @authenticated
* @urlParam doorId required The application ID of the door to update. Example: 2
* @bodyParam location Door Number or location describing where it is such as `CSP165`. Example: CSP166
* @bodyParam name The unique name for the door. Must be unique. Example: Not the Engineering Lecture Hall
* @bodyParam location string Door Number or location describing where it is such as `CSP165`. Example: CSP166
* @bodyParam name string The unique name for the door. Must be unique. Example: Not the Engineering Lecture Hall
*
* @param \Source\UseCases\Doors\UpdateDoor\UpdateDoorUseCase $updateDoor
* @param string $doorId
......@@ -209,6 +209,14 @@ class DoorsController extends ApiController
}
/**
* Door Groups
*
* This endpoint gets the list of groups that a door is apart of.
*
* @paginated
* @authenticated
* @urlParam doorId required The door ID to get the groups for. Example: 1
*
* @param \Source\UseCases\DoorGroup\GetDoorGroups\GetDoorGroupsUseCase $doorGroups
* @param string $doorId
* @return \Illuminate\Http\JsonResponse
......
......@@ -7,9 +7,29 @@ use Source\Authorization\Permissions;
use Source\UseCases\Entries\APIPresenter;
use Source\UseCases\Entries\GetEntries\GetEntriesUseCase;
/**
* @group Door Entry Logs
*
* These endpoints are for accessing entry attempts. A door entry gets logged when a known user is allowed or denied
* from a door.
*/
class EntriesController extends ApiController
{
/**
* Get Entries
*
* Filters door entries based upon several query parameters. If no parameters are given, all door entries are
* returned in a paginated fashion.
*
* @authenticated
* @paginated
* @queryParam start The beginning date to filter entries by. Example: 2000-06-02 08:11:45
* @queryParam end The ending date to filter entries by. Example: 2920-06-02 08:11:45
* @queryParam door_id The door id to filter entries on. Example: 1
* @queryParam user_id The user id to filter entries on. Example: 420
*
* @response 422 {"message":"The given data was invalid.","errors":{"start":["The start is not a valid date."],"end":["The end is not a valid date."],"door_id":["The door id must be an integer."],"user_id":["The user id must be an integer."]}}
*
* @param \Source\UseCases\Entries\GetEntries\GetEntriesUseCase $userEntries
* @return \Illuminate\Http\JsonResponse
* @throws \Illuminate\Validation\ValidationException
......@@ -21,10 +41,10 @@ class EntriesController extends ApiController
$this->authorizer->protect(Permissions::LOGS_READ);
$this->validate($this->request, [
'start' => 'date',
'end' => 'date',
'door_id' => 'integer',
'user_id' => 'integer',
'start' => 'nullable|date',
'end' => 'nullable|date',
'door_id' => 'nullable|integer',
'user_id' => 'nullable|integer',
]);
$presenter = new APIPresenter();
......
......@@ -68,7 +68,7 @@ Route::group(['middleware' => 'auth:api'], static function () {
->name('doors.regenerate');
Route::delete('{doorId}', [DoorsController::class, 'delete'])->name('doors.delete');
Route::get('{doorId}/groups', [DoorsController::class, 'getGroupsForDoor']);
Route::get('{doorId}/groups', [DoorsController::class, 'getGroupsForDoor'])->name('doors.groups');
Route::post('{doorId}/group/{groupId}', [DoorsController::class, 'addDoorToGroup']);
Route::delete('{doorId}/group/{groupId}', [DoorsController::class, 'removeDoorFromGroup']);
});
......
......@@ -108,6 +108,10 @@ class Entry
*/
public function isBetween(?Carbon $begin, ?Carbon $end): bool
{
if (!$this->createdAt) {
return true;
}
if ($begin && $end) {
return $this->createdAt->isBetween($begin, $end);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment