From 14735350acc3c8a8989e4714935eaf045d43c191 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Jaussoin?= Date: Mon, 12 Jan 2026 11:16:15 +0100 Subject: [PATCH] Fix FLEXIAPI-431 Complete missing admin account dictionnary documentation Fix FLEXIAPI-432 Add a DELETE dictionary endpoint + test and documentation --- .../Admin/Account/DictionaryController.php | 6 ++++ .../accounts/dictionary.blade.php | 17 +++++++++- flexiapi/routes/api.php | 1 + .../Feature/ApiAccountDictionaryTest.php | 34 +++++++++++++++++-- 4 files changed, 54 insertions(+), 4 deletions(-) diff --git a/flexiapi/app/Http/Controllers/Api/Admin/Account/DictionaryController.php b/flexiapi/app/Http/Controllers/Api/Admin/Account/DictionaryController.php index 2d44564..2e79e6c 100644 --- a/flexiapi/app/Http/Controllers/Api/Admin/Account/DictionaryController.php +++ b/flexiapi/app/Http/Controllers/Api/Admin/Account/DictionaryController.php @@ -58,4 +58,10 @@ class DictionaryController extends Controller return $request->space->accounts() ->findOrFail($accountId)->dictionaryEntries()->where('key', $key)->delete(); } + + public function clear(Request $request, int $accountId) + { + return $request->space->accounts() + ->findOrFail($accountId)->dictionaryEntries()->delete(); + } } diff --git a/flexiapi/resources/views/api/documentation/accounts/dictionary.blade.php b/flexiapi/resources/views/api/documentation/accounts/dictionary.blade.php index ca3fb0e..737dd87 100644 --- a/flexiapi/resources/views/api/documentation/accounts/dictionary.blade.php +++ b/flexiapi/resources/views/api/documentation/accounts/dictionary.blade.php @@ -5,6 +5,16 @@ Get all the account dictionary entries. +### `DELETE /accounts/{id}/dictionary/clear` +Admin + +Clear all the account dictionary entries. + +### `GET /accounts/{id}/dictionary/{key}` +Admin + +Get an account dictionary entry. + ### `POST /accounts/{id}/dictionary/{key}` Admin @@ -12,4 +22,9 @@ Add or update a new entry to the dictionary JSON parameters: -* `value` **required**, the entry value \ No newline at end of file +* `value` **required**, the entry value + +### `DELETE /accounts/{id}/dictionary/{key}` +Admin + +Delete an account dictionary entry. \ No newline at end of file diff --git a/flexiapi/routes/api.php b/flexiapi/routes/api.php index 5ed31f0..a6e3e72 100644 --- a/flexiapi/routes/api.php +++ b/flexiapi/routes/api.php @@ -190,6 +190,7 @@ Route::group(['middleware' => ['auth.jwt', 'auth.digest_or_key', 'auth.check_blo Route::prefix('accounts/{id}/dictionary')->controller(DictionaryController::class)->group(function () { Route::get('/', 'index'); + Route::delete('/', 'clear'); Route::get('{key}', 'show'); Route::post('{key}', 'set'); Route::delete('{key}', 'destroy'); diff --git a/flexiapi/tests/Feature/ApiAccountDictionaryTest.php b/flexiapi/tests/Feature/ApiAccountDictionaryTest.php index cd92451..e6fc9e2 100644 --- a/flexiapi/tests/Feature/ApiAccountDictionaryTest.php +++ b/flexiapi/tests/Feature/ApiAccountDictionaryTest.php @@ -80,7 +80,7 @@ class ApiAccountDictionaryTest extends TestCase $this->keyAuthenticated($admin) ->get($this->route . '/' . $account->id . '/dictionary/') ->assertStatus(200) - ->assertJson([ + ->assertExactJson([ $key => $newValue ]); @@ -93,7 +93,7 @@ class ApiAccountDictionaryTest extends TestCase $this->keyAuthenticated($admin) ->get($this->route . '/' . $account->id . '/dictionary/') ->assertStatus(200) - ->assertJson([ + ->assertExactJson([ $key => $newValue, $secondKey => $newValue ]); @@ -106,8 +106,36 @@ class ApiAccountDictionaryTest extends TestCase $this->keyAuthenticated($admin) ->get($this->route . '/' . $account->id . '/dictionary/') ->assertStatus(200) - ->assertJson([ + ->assertExactJson([ $secondKey => $newValue ]); + + // Clear + $this->keyAuthenticated($admin) + ->json($this->method, $this->route . '/' . $account->id . '/dictionary/' . $key, [ + 'value' => $value + ])->assertStatus(201); + + $this->keyAuthenticated($admin) + ->json($this->method, $this->route . '/' . $account->id . '/dictionary/' . $secondKey, [ + 'value' => $newValue + ])->assertStatus(201); + + $this->keyAuthenticated($admin) + ->get($this->route . '/' . $account->id . '/dictionary/') + ->assertStatus(200) + ->assertExactJson([ + $key => $value, + $secondKey => $newValue + ]); + + $this->keyAuthenticated($admin) + ->delete($this->route . '/' . $account->id . '/dictionary/') + ->assertStatus(200); + + $this->keyAuthenticated($admin) + ->get($this->route . '/' . $account->id . '/dictionary/') + ->assertStatus(200) + ->assertExactJson([]); } }