From 50d3c36b6a33096cca433d64e0da90bede76046a Mon Sep 17 00:00:00 2001 From: James Cole Date: Mon, 21 Oct 2019 18:32:13 +0200 Subject: [PATCH] Fix #2752 --- app/Api/V1/Controllers/TransactionController.php | 13 +++++++++++++ routes/api.php | 11 +++++++++++ 2 files changed, 24 insertions(+) diff --git a/app/Api/V1/Controllers/TransactionController.php b/app/Api/V1/Controllers/TransactionController.php index c433c6e410..545126cbdb 100644 --- a/app/Api/V1/Controllers/TransactionController.php +++ b/app/Api/V1/Controllers/TransactionController.php @@ -251,6 +251,19 @@ class TransactionController extends Controller return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json'); } + /** + * Show a single transaction, by transaction journal. + * + * @param TransactionJournal $transactionJournal + * + * @return JsonResponse + * @codeCoverageIgnore + */ + public function showByJournal(TransactionJournal $transactionJournal): JsonResponse + { + return $this->show($transactionJournal->transactionGroup); + } + /** * Store a new transaction. * diff --git a/routes/api.php b/routes/api.php index 7eb615c0d7..7c0f479ae5 100644 --- a/routes/api.php +++ b/routes/api.php @@ -424,6 +424,17 @@ Route::group( } ); +// special group for transaction journals +Route::group( + ['namespace' => 'FireflyIII\Api\V1\Controllers', 'prefix' => 'journals', + 'as' => 'api.v1.journals.'], + static function () { + + // Transaction API routes: + Route::get('{tj}', ['uses' => 'TransactionController@showByJournal', 'as' => 'showByJournal']); + } +); + Route::group( ['middleware' => ['auth:api', 'bindings', \FireflyIII\Http\Middleware\IsAdmin::class], 'namespace' => 'FireflyIII\Api\V1\Controllers', 'prefix' => 'users',