Skip to content

Commit

Permalink
Merge pull request #15549 from snipe/fixes/#15548_unify_audit_api_end…
Browse files Browse the repository at this point in the history
…points

Fixes #15548 - unify audit api endpoints
  • Loading branch information
snipe authored Sep 24, 2024
2 parents 8cf1e4d + 0ce5832 commit c38222e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
9 changes: 7 additions & 2 deletions app/Http/Controllers/Api/AssetsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ class AssetsController extends Controller
public function index(Request $request, $action = null, $upcoming_status = null) : JsonResponse | array
{


// This handles the legacy audit endpoints :(
if ($action == 'audit') {
$action = 'audits';
}
$filter_non_deprecable_assets = false;

/**
Expand Down Expand Up @@ -154,8 +159,8 @@ public function index(Request $request, $action = null, $upcoming_status = null)
* Handle due and overdue audits and checkin dates
*/
switch ($action) {
case 'audits':

// Audit (singular) is left over from earlier legacy APIs
case 'audits' :
switch ($upcoming_status) {
case 'due':
$assets->DueForAudit($settings);
Expand Down
11 changes: 2 additions & 9 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -495,24 +495,17 @@
)->name('api.assets.show.byserial')
->where('any', '.*');

// LEGACY URL - Get assets that are due or overdue for audit
Route::get('audit/{status}',
[
Api\AssetsController::class,
'index'
]
)->name('api.asset.to-audit');



// This gets the "due or overdue" API endpoints for audits and checkins
// This gets the "due or overdue" API endpoints for audit/audits and checkins
Route::get('{action}/{upcoming_status}',
[
Api\AssetsController::class,
'index'
]
)->name('api.assets.list-upcoming')
->where(['action' => 'audits|checkins', 'upcoming_status' => 'due|overdue|due-or-overdue']);
->where(['action' => 'audit|audits|checkins', 'upcoming_status' => 'due|overdue|due-or-overdue']);



Expand Down

0 comments on commit c38222e

Please sign in to comment.