mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-05 12:12:18 +00:00
Add missing API endpoints.
This commit is contained in:
@@ -80,9 +80,10 @@ class TransactionController extends Controller
|
||||
/** @var TransactionJournal $journal */
|
||||
foreach ($filtered as $journal) {
|
||||
$array[] = [
|
||||
'id' => $journal->id,
|
||||
'name' => $journal->description,
|
||||
'description' => $journal->description,
|
||||
'id' => $journal->id,
|
||||
'transaction_group_id' => $journal->transaction_group_id,
|
||||
'name' => $journal->description,
|
||||
'description' => $journal->description,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -90,22 +91,14 @@ class TransactionController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches in the titles of all transaction journals.
|
||||
* The result is limited to the top 15 unique results.
|
||||
*
|
||||
* If the query is numeric, it will append the journal with that particular ID.
|
||||
*
|
||||
* @param AutocompleteRequest $request
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function allJournalsWithID(AutocompleteRequest $request): JsonResponse
|
||||
public function transactionsWithID(AutocompleteRequest $request): JsonResponse
|
||||
{
|
||||
$data = $request->getData();
|
||||
$array = [];
|
||||
$result = new Collection;
|
||||
|
||||
|
||||
if (is_numeric($data['query'])) {
|
||||
// search for group, not journal.
|
||||
$firstResult = $this->groupRepository->find((int) $data['query']);
|
||||
@@ -120,12 +113,16 @@ class TransactionController extends Controller
|
||||
$result = $this->repository->searchJournalDescriptions($data['query'], $data['limit']);
|
||||
}
|
||||
|
||||
// limit and unique
|
||||
$array = [];
|
||||
|
||||
/** @var TransactionJournal $journal */
|
||||
foreach ($result as $journal) {
|
||||
$array[] = [
|
||||
'id' => $journal->id,
|
||||
'name' => printf('#%d: %s', $journal->id, $journal->description),
|
||||
'description' => $journal->description,
|
||||
'id' => $journal->id,
|
||||
'transaction_group_id' => $journal->transaction_group_id,
|
||||
'name' => sprintf('#%d: %s', $journal->transaction_group_id, $journal->description),
|
||||
'description' => sprintf('#%d: %s', $journal->transaction_group_id, $journal->description),
|
||||
];
|
||||
}
|
||||
|
||||
|
@@ -40,6 +40,7 @@ use FireflyIII\Support\Http\Api\TransactionFilter;
|
||||
use FireflyIII\Transformers\AttachmentTransformer;
|
||||
use FireflyIII\Transformers\PiggyBankEventTransformer;
|
||||
use FireflyIII\Transformers\TransactionGroupTransformer;
|
||||
use FireflyIII\Transformers\TransactionLinkTransformer;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -57,12 +58,9 @@ class TransactionController extends Controller
|
||||
{
|
||||
use TransactionFilter;
|
||||
|
||||
/** @var TransactionGroupRepositoryInterface Group repository. */
|
||||
private $groupRepository;
|
||||
/** @var JournalAPIRepositoryInterface Journal API repos */
|
||||
private $journalAPIRepository;
|
||||
/** @var JournalRepositoryInterface The journal repository */
|
||||
private $repository;
|
||||
private TransactionGroupRepositoryInterface $groupRepository;
|
||||
private JournalAPIRepositoryInterface $journalAPIRepository;
|
||||
private JournalRepositoryInterface $repository;
|
||||
|
||||
/**
|
||||
* TransactionController constructor.
|
||||
@@ -112,6 +110,29 @@ class TransactionController extends Controller
|
||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionGroup $transactionGroup
|
||||
*
|
||||
* @return JsonResponse
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function transactionLinks(TransactionGroup $transactionGroup): JsonResponse
|
||||
{
|
||||
$manager = $this->getManager();
|
||||
$journalLinks = new Collection;
|
||||
foreach ($transactionGroup->transactionJournals as $transactionJournal) {
|
||||
$journalLinks = $this->journalAPIRepository->getJournalLinks($transactionJournal)->merge($journalLinks);
|
||||
}
|
||||
|
||||
/** @var TransactionLinkTransformer $transformer */
|
||||
$transformer = app(TransactionLinkTransformer::class);
|
||||
$transformer->setParameters($this->parameters);
|
||||
|
||||
$resource = new FractalCollection($journalLinks, $transformer, 'transaction_links');
|
||||
|
||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
|
@@ -43,9 +43,7 @@ use League\Fractal\Resource\Item;
|
||||
*/
|
||||
class UserController extends Controller
|
||||
{
|
||||
|
||||
/** @var UserRepositoryInterface The user repository */
|
||||
private $repository;
|
||||
private UserRepositoryInterface $repository;
|
||||
|
||||
/**
|
||||
* UserController constructor.
|
||||
|
Reference in New Issue
Block a user