mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
Merge pull request #15549 from snipe/fixes/#15548_unify_audit_api_endpoints
Some checks are pending
Crowdin Action / upload-sources-to-crowdin (push) Waiting to run
Docker images (Alpine) / docker (push) Waiting to run
Docker images / docker (push) Waiting to run
Tests in MySQL / PHP ${{ matrix.php-version }} (8.1) (push) Waiting to run
Tests in MySQL / PHP ${{ matrix.php-version }} (8.2) (push) Waiting to run
Tests in MySQL / PHP ${{ matrix.php-version }} (8.3) (push) Waiting to run
Tests in SQLite / PHP ${{ matrix.php-version }} (8.1.1) (push) Waiting to run
Some checks are pending
Crowdin Action / upload-sources-to-crowdin (push) Waiting to run
Docker images (Alpine) / docker (push) Waiting to run
Docker images / docker (push) Waiting to run
Tests in MySQL / PHP ${{ matrix.php-version }} (8.1) (push) Waiting to run
Tests in MySQL / PHP ${{ matrix.php-version }} (8.2) (push) Waiting to run
Tests in MySQL / PHP ${{ matrix.php-version }} (8.3) (push) Waiting to run
Tests in SQLite / PHP ${{ matrix.php-version }} (8.1.1) (push) Waiting to run
Fixes #15548 - unify audit api endpoints
This commit is contained in:
commit
c38222e956
|
@ -56,6 +56,11 @@ class AssetsController extends Controller
|
||||||
public function index(Request $request, $action = null, $upcoming_status = null) : JsonResponse | array
|
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;
|
$filter_non_deprecable_assets = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -154,8 +159,8 @@ class AssetsController extends Controller
|
||||||
* Handle due and overdue audits and checkin dates
|
* Handle due and overdue audits and checkin dates
|
||||||
*/
|
*/
|
||||||
switch ($action) {
|
switch ($action) {
|
||||||
|
// Audit (singular) is left over from earlier legacy APIs
|
||||||
case 'audits' :
|
case 'audits' :
|
||||||
|
|
||||||
switch ($upcoming_status) {
|
switch ($upcoming_status) {
|
||||||
case 'due':
|
case 'due':
|
||||||
$assets->DueForAudit($settings);
|
$assets->DueForAudit($settings);
|
||||||
|
|
|
@ -495,24 +495,17 @@ Route::group(['prefix' => 'v1', 'middleware' => ['api', 'throttle:api']], functi
|
||||||
)->name('api.assets.show.byserial')
|
)->name('api.assets.show.byserial')
|
||||||
->where('any', '.*');
|
->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}',
|
Route::get('{action}/{upcoming_status}',
|
||||||
[
|
[
|
||||||
Api\AssetsController::class,
|
Api\AssetsController::class,
|
||||||
'index'
|
'index'
|
||||||
]
|
]
|
||||||
)->name('api.assets.list-upcoming')
|
)->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']);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue