Update API endpoints.

This commit is contained in:
James Cole
2021-09-18 05:26:31 +02:00
parent 4fcc659263
commit 190b6fb25f
20 changed files with 90 additions and 32 deletions

View File

@@ -61,6 +61,8 @@ class TransactionController extends Controller
}
/**
* This endpoint is documented at:
*
* @param TransactionRequest $request
*
* @return JsonResponse
@@ -69,12 +71,13 @@ class TransactionController extends Controller
{
$query = $request->getAll();
$params = $query['query'];
// this deserves better code, but for now a loop of basic if-statements
// to respond to what is in the $query.
// this is OK because only one thing can be in the query at the moment.
if ($this->updatesTransactionAccount($params)) {
$original = $this->repository->find((int)$params['where']['source_account_id']);
$destination = $this->repository->find((int)$params['update']['destination_account_id']);
$original = $this->repository->find((int)$params['where']['account_id']);
$destination = $this->repository->find((int)$params['update']['account_id']);
/** @var AccountDestroyService $service */
$service = app(AccountDestroyService::class);
@@ -91,7 +94,7 @@ class TransactionController extends Controller
*/
private function updatesTransactionAccount(array $params): bool
{
return array_key_exists('source_account_id', $params['where']) && array_key_exists('destination_account_id', $params['update']);
return array_key_exists('account_id', $params['where']) && array_key_exists('account_id', $params['update']);
}
}