Code cleanup.

This commit is contained in:
James Cole 2023-12-20 19:35:52 +01:00
parent c4f6366642
commit 64ec0cf62e
No known key found for this signature in database
GPG Key ID: B49A324B7EAD6D80
997 changed files with 12908 additions and 28136 deletions
.ci/php-cs-fixer
app/Api/V1/Controllers
Autocomplete
Chart
Controller.php
Data
Insight
Models

View File

@ -23,11 +23,11 @@ $current = __DIR__;
$paths = [
$current . '/../../app',
$current . '/../../config',
$current . '/../../database',
$current . '/../../routes',
$current . '/../../tests',
$current . '/../../resources/lang',
// $current . '/../../config',
// $current . '/../../database',
// $current . '/../../routes',
// $current . '/../../tests',
// $current . '/../../resources/lang',
];
$finder = PhpCsFixer\Finder::create()
@ -36,15 +36,27 @@ $finder = PhpCsFixer\Finder::create()
$config = new PhpCsFixer\Config();
return $config->setRules([
'@PHP83Migration' => true,
'@PhpCsFixer:risky' => true,
'@PSR12:risky' => true,
'declare_strict_types' => true,
'strict_param' => true,
'comment_to_phpdoc' => false, // breaks phpstan lines in combination with PHPStorm.
'array_syntax' => ['syntax' => 'short'],
'native_function_invocation' => false, // annoying
'php_unit_data_provider_name' => false, // bloody annoying long test names
'static_lambda' => false, // breaks the Response macro for API's.
'no_unused_imports' => true,
'@PhpCsFixer' => true,
'@PHP83Migration' => true,
'@PhpCsFixer:risky' => true,
'@PSR12:risky' => true,
'declare_strict_types' => true,
'strict_param' => true,
'comment_to_phpdoc' => false, // breaks phpstan lines in combination with PHPStorm.
'array_syntax' => ['syntax' => 'short'],
'native_function_invocation' => false, // annoying
'php_unit_data_provider_name' => false, // bloody annoying long test names
'static_lambda' => false, // breaks the Response macro for API's.
'phpdoc_summary' => false, // annoying.
'single_space_around_construct' => [
'constructs_followed_by_a_single_space' => [
'protected',
],
],
'statement_indentation' => true,
'type_declaration_spaces' => false,
'cast_spaces' => false,
'binary_operator_spaces' => false,
])
->setFinder($finder);

View File

@ -32,7 +32,6 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Support\Http\Api\AccountFilter;
use FireflyIII\User;
use Illuminate\Http\JsonResponse;
use JsonException;
/**
* Class AccountController
@ -61,17 +60,14 @@ class AccountController extends Controller
return $next($request);
}
);
$this->balanceTypes = [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE,];
$this->balanceTypes = [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE];
}
/**
* Documentation for this endpoint:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/autocomplete/getAccountsAC
*
* @param AutocompleteRequest $request
*
* @return JsonResponse
* @throws JsonException
* @throws \JsonException
* @throws FireflyException
* @throws FireflyException
*/

View File

@ -58,10 +58,6 @@ class BillController extends Controller
/**
* Documentation for this endpoint is at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/autocomplete/getBillsAC
*
* @param AutocompleteRequest $request
*
* @return JsonResponse
*/
public function bills(AutocompleteRequest $request): JsonResponse
{

View File

@ -58,10 +58,6 @@ class BudgetController extends Controller
/**
* Documentation for this endpoint is at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/autocomplete/getBudgetsAC
*
* @param AutocompleteRequest $request
*
* @return JsonResponse
*/
public function budgets(AutocompleteRequest $request): JsonResponse
{

View File

@ -58,10 +58,6 @@ class CategoryController extends Controller
/**
* Documentation for this endpoint is at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/autocomplete/getCategoriesAC
*
* @param AutocompleteRequest $request
*
* @return JsonResponse
*/
public function categories(AutocompleteRequest $request): JsonResponse
{

View File

@ -58,10 +58,6 @@ class CurrencyController extends Controller
/**
* Documentation for this endpoint is at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/autocomplete/getCurrenciesAC
*
* @param AutocompleteRequest $request
*
* @return JsonResponse
*/
public function currencies(AutocompleteRequest $request): JsonResponse
{
@ -87,9 +83,6 @@ class CurrencyController extends Controller
* Documentation for this endpoint is at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/autocomplete/getCurrenciesCodeAC
*
* @param AutocompleteRequest $request
*
* @return JsonResponse
* @deprecated
*/
public function currenciesWithCode(AutocompleteRequest $request): JsonResponse

View File

@ -58,10 +58,6 @@ class ObjectGroupController extends Controller
/**
* Documentation for this endpoint is at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/autocomplete/getObjectGroupsAC
*
* @param AutocompleteRequest $request
*
* @return JsonResponse
*/
public function objectGroups(AutocompleteRequest $request): JsonResponse
{

View File

@ -62,10 +62,6 @@ class PiggyBankController extends Controller
/**
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/autocomplete/getPiggiesAC
*
* @param AutocompleteRequest $request
*
* @return JsonResponse
*/
public function piggyBanks(AutocompleteRequest $request): JsonResponse
{
@ -97,10 +93,6 @@ class PiggyBankController extends Controller
/**
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/autocomplete/getPiggiesBalanceAC
*
* @param AutocompleteRequest $request
*
* @return JsonResponse
*/
public function piggyBanksWithBalance(AutocompleteRequest $request): JsonResponse
{
@ -108,6 +100,7 @@ class PiggyBankController extends Controller
$piggies = $this->piggyRepository->searchPiggyBank($data['query'], $this->parameters->get('limit'));
$defaultCurrency = app('amount')->getDefaultCurrency();
$response = [];
/** @var PiggyBank $piggy */
foreach ($piggies as $piggy) {
$currency = $this->accountRepository->getAccountCurrency($piggy->account) ?? $defaultCurrency;

View File

@ -56,10 +56,6 @@ class RecurrenceController extends Controller
/**
* This endpoint is documented at:
* * https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/autocomplete/getRecurringAC
*
* @param AutocompleteRequest $request
*
* @return JsonResponse
*/
public function recurring(AutocompleteRequest $request): JsonResponse
{

View File

@ -55,10 +55,6 @@ class RuleController extends Controller
/**
* This endpoint is documented at:
* * https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/autocomplete/getRulesAC
*
* @param AutocompleteRequest $request
*
* @return JsonResponse
*/
public function rules(AutocompleteRequest $request): JsonResponse
{

View File

@ -55,10 +55,6 @@ class RuleGroupController extends Controller
/**
* This endpoint is documented at:
* * https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/autocomplete/getRuleGroupsAC
*
* @param AutocompleteRequest $request
*
* @return JsonResponse
*/
public function ruleGroups(AutocompleteRequest $request): JsonResponse
{

View File

@ -58,10 +58,6 @@ class TagController extends Controller
/**
* This endpoint is documented at:
* * https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/autocomplete/getTagAC
*
* @param AutocompleteRequest $request
*
* @return JsonResponse
*/
public function tags(AutocompleteRequest $request): JsonResponse
{
@ -69,6 +65,7 @@ class TagController extends Controller
$result = $this->repository->searchTags($data['query'], $this->parameters->get('limit'));
$array = [];
/** @var Tag $tag */
foreach ($result as $tag) {
$array[] = [

View File

@ -63,10 +63,6 @@ class TransactionController extends Controller
/**
* This endpoint is documented at:
* * https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/autocomplete/getTransactionsAC
*
* @param AutocompleteRequest $request
*
* @return JsonResponse
*/
public function transactions(AutocompleteRequest $request): JsonResponse
{
@ -93,10 +89,6 @@ class TransactionController extends Controller
/**
* This endpoint is documented at:
* * https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/autocomplete/getTransactionsIDAC
*
* @param AutocompleteRequest $request
*
* @return JsonResponse
*/
public function transactionsWithID(AutocompleteRequest $request): JsonResponse
{

View File

@ -54,10 +54,6 @@ class TransactionTypeController extends Controller
/**
* This endpoint is documented at
* * https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/autocomplete/getTransactionTypesAC
*
* @param AutocompleteRequest $request
*
* @return JsonResponse
*/
public function transactionTypes(AutocompleteRequest $request): JsonResponse
{

View File

@ -35,7 +35,6 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Support\Http\Api\ApiSupport;
use FireflyIII\User;
use Illuminate\Http\JsonResponse;
use JsonException;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
@ -50,8 +49,6 @@ class AccountController extends Controller
/**
* AccountController constructor.
*
*/
public function __construct()
{
@ -72,11 +69,8 @@ class AccountController extends Controller
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/charts/getChartAccountOverview
*
* @param DateRequest $request
*
* @return JsonResponse
* @throws FireflyException
* @throws JsonException
* @throws \JsonException
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
@ -84,13 +78,16 @@ class AccountController extends Controller
{
// parameters for chart:
$dates = $request->getAll();
/** @var Carbon $start */
$start = $dates['start'];
/** @var Carbon $end */
$end = $dates['end'];
// user's preferences
$defaultSet = $this->repository->getAccountsByType([AccountType::ASSET])->pluck('id')->toArray();
/** @var Preference $frontPage */
$frontPage = app('preferences')->get('frontPageAccounts', $defaultSet);
$default = app('amount')->getDefaultCurrency();
@ -100,10 +97,10 @@ class AccountController extends Controller
$frontPage->save();
}
// get accounts:
$accounts = $this->repository->getAccountsById($frontPage->data);
$chartData = [];
/** @var Account $account */
foreach ($accounts as $account) {
$currency = $this->repository->getAccountCurrency($account);

View File

@ -42,8 +42,6 @@ use Symfony\Component\HttpFoundation\ParameterBag;
/**
* Class Controller.
*
*/
abstract class Controller extends BaseController
{
@ -52,6 +50,7 @@ abstract class Controller extends BaseController
use ValidatesRequests;
protected const string CONTENT_TYPE = 'application/vnd.api+json';
/** @var array<int, string> */
protected array $allowedSort;
protected ParameterBag $parameters;
@ -76,10 +75,41 @@ abstract class Controller extends BaseController
);
}
/**
* Method to help build URL's.
*/
final protected function buildParams(): string
{
$return = '?';
$params = [];
foreach ($this->parameters as $key => $value) {
if ('page' === $key) {
continue;
}
if ($value instanceof Carbon) {
$params[$key] = $value->format('Y-m-d');
continue;
}
$params[$key] = $value;
}
return $return.http_build_query($params);
}
final protected function getManager(): Manager
{
// create some objects:
$manager = new Manager();
$baseUrl = request()->getSchemeAndHttpHost().'/api/v1';
$manager->setSerializer(new JsonApiSerializer($baseUrl));
return $manager;
}
/**
* Method to grab all parameters from the URL.
*
* @return ParameterBag
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
@ -99,6 +129,7 @@ abstract class Controller extends BaseController
$dates = ['start', 'end', 'date'];
foreach ($dates as $field) {
$date = null;
try {
$date = request()->query->get($field);
} catch (BadRequestException $e) {
@ -111,7 +142,7 @@ abstract class Controller extends BaseController
if (null !== $date) {
try {
$obj = Carbon::parse((string)$date);
} catch (InvalidDateException | InvalidFormatException $e) {
} catch (InvalidDateException|InvalidFormatException $e) {
// don't care
app('log')->warning(
sprintf(
@ -139,12 +170,13 @@ abstract class Controller extends BaseController
if (null !== $value) {
$bag->set($integer, (int)$value);
}
if (null === $value &&
'limit' === $integer && // @phpstan-ignore-line
auth()->check()) {
if (null === $value
&& 'limit' === $integer // @phpstan-ignore-line
&& auth()->check()) {
// set default for user:
/** @var User $user */
$user = auth()->user();
/** @var Preference $pageSize */
$pageSize = (int)app('preferences')->getForUser($user, 'listPageSize', 50)->data;
$bag->set($integer, $pageSize);
@ -155,14 +187,10 @@ abstract class Controller extends BaseController
return $this->getSortParameters($bag);
}
/**
* @param ParameterBag $bag
*
* @return ParameterBag
*/
private function getSortParameters(ParameterBag $bag): ParameterBag
{
$sortParameters = [];
try {
$param = (string)request()->query->get('sort');
} catch (BadRequestException $e) {
@ -190,40 +218,4 @@ abstract class Controller extends BaseController
return $bag;
}
/**
* Method to help build URL's.
*
* @return string
*/
final protected function buildParams(): string
{
$return = '?';
$params = [];
foreach ($this->parameters as $key => $value) {
if ('page' === $key) {
continue;
}
if ($value instanceof Carbon) {
$params[$key] = $value->format('Y-m-d');
continue;
}
$params[$key] = $value;
}
return $return . http_build_query($params);
}
/**
* @return Manager
*/
final protected function getManager(): Manager
{
// create some objects:
$manager = new Manager();
$baseUrl = request()->getSchemeAndHttpHost() . '/api/v1';
$manager->setSerializer(new JsonApiSerializer($baseUrl));
return $manager;
}
}

View File

@ -44,9 +44,6 @@ class TransactionController extends Controller
{
private AccountRepositoryInterface $repository;
/**
*
*/
public function __construct()
{
parent::__construct();
@ -63,10 +60,6 @@ class TransactionController extends Controller
/**
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/data/bulkUpdateTransactions
*
* @param TransactionRequest $request
*
* @return JsonResponse
*/
public function update(TransactionRequest $request): JsonResponse
{
@ -90,8 +83,6 @@ class TransactionController extends Controller
/**
* @param array $params <array<string, array<string, int|string>>>
*
* @return bool
*/
private function isUpdateTransactionAccount(array $params): bool
{

View File

@ -57,9 +57,6 @@ class DestroyController extends Controller
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/data/destroyData
*
* @param DestroyRequest $request
*
* @return JsonResponse
* @throws FireflyException
*/
public function destroy(DestroyRequest $request): JsonResponse
@ -67,10 +64,10 @@ class DestroyController extends Controller
$objects = $request->getObjects();
$this->unused = $request->boolean('unused', false);
$allExceptAssets = [AccountType::BENEFICIARY, AccountType::CASH, AccountType::CREDITCARD, AccountType::DEFAULT, AccountType::EXPENSE, AccountType::IMPORT, AccountType::INITIAL_BALANCE, AccountType::LIABILITY_CREDIT, AccountType::RECONCILIATION, AccountType::REVENUE,];
$all = [AccountType::ASSET, AccountType::BENEFICIARY, AccountType::CASH, AccountType::CREDITCARD, AccountType::DEBT, AccountType::DEFAULT, AccountType::EXPENSE, AccountType::IMPORT, AccountType::INITIAL_BALANCE, AccountType::LIABILITY_CREDIT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::RECONCILIATION,];
$allExceptAssets = [AccountType::BENEFICIARY, AccountType::CASH, AccountType::CREDITCARD, AccountType::DEFAULT, AccountType::EXPENSE, AccountType::IMPORT, AccountType::INITIAL_BALANCE, AccountType::LIABILITY_CREDIT, AccountType::RECONCILIATION, AccountType::REVENUE];
$all = [AccountType::ASSET, AccountType::BENEFICIARY, AccountType::CASH, AccountType::CREDITCARD, AccountType::DEBT, AccountType::DEFAULT, AccountType::EXPENSE, AccountType::IMPORT, AccountType::INITIAL_BALANCE, AccountType::LIABILITY_CREDIT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::RECONCILIATION];
$liabilities = [AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::CREDITCARD];
$transactions = [TransactionType::WITHDRAWAL, TransactionType::DEPOSIT, TransactionType::TRANSFER, TransactionType::RECONCILIATION, TransactionType::OPENING_BALANCE,];
$transactions = [TransactionType::WITHDRAWAL, TransactionType::DEPOSIT, TransactionType::TRANSFER, TransactionType::RECONCILIATION, TransactionType::OPENING_BALANCE];
match ($objects) {
'budgets' => $this->destroyBudgets(),
@ -99,9 +96,6 @@ class DestroyController extends Controller
return response()->json([], 204);
}
/**
*
*/
private function destroyBudgets(): void
{
/** @var AvailableBudgetRepositoryInterface $abRepository */
@ -117,9 +111,6 @@ class DestroyController extends Controller
$budgetRepository->destroyAll();
}
/**
*
*/
private function destroyBills(): void
{
/** @var BillRepositoryInterface $repository */
@ -127,9 +118,6 @@ class DestroyController extends Controller
$repository->destroyAll();
}
/**
*
*/
private function destroyPiggyBanks(): void
{
/** @var PiggyBankRepositoryInterface $repository */
@ -137,9 +125,6 @@ class DestroyController extends Controller
$repository->destroyAll();
}
/**
*
*/
private function destroyRules(): void
{
/** @var RuleGroupRepositoryInterface $repository */
@ -147,9 +132,6 @@ class DestroyController extends Controller
$repository->destroyAll();
}
/**
*
*/
private function destroyRecurringTransactions(): void
{
/** @var RecurringRepositoryInterface $repository */
@ -157,9 +139,6 @@ class DestroyController extends Controller
$repository->destroyAll();
}
/**
*
*/
private function destroyCategories(): void
{
/** @var CategoryRepositoryInterface $categoryRepos */
@ -167,9 +146,6 @@ class DestroyController extends Controller
$categoryRepos->destroyAll();
}
/**
*
*/
private function destroyTags(): void
{
/** @var TagRepositoryInterface $tagRepository */
@ -177,9 +153,6 @@ class DestroyController extends Controller
$tagRepository->destroyAll();
}
/**
* @return void
*/
private function destroyObjectGroups(): void
{
/** @var ObjectGroupRepositoryInterface $repository */
@ -203,6 +176,7 @@ class DestroyController extends Controller
if (true === $this->unused && 0 === $count) {
app('log')->info(sprintf('Deleted unused account #%d "%s"', $account->id, $account->name));
$service->destroy($account, null);
continue;
}
if (false === $this->unused) {
@ -221,6 +195,7 @@ class DestroyController extends Controller
$repository = app(JournalRepositoryInterface::class);
$journals = $repository->findByType($types);
$service = app(JournalDestroyService::class);
/** @var TransactionJournal $journal */
foreach ($journals as $journal) {
$service->destroy($journal);

View File

@ -59,9 +59,6 @@ class ExportController extends Controller
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/data/exportAccounts
*
* @param ExportRequest $request
*
* @return LaravelResponse
* @throws ContainerExceptionInterface
* @throws FireflyException
* @throws NotFoundExceptionInterface
@ -76,9 +73,144 @@ class ExportController extends Controller
}
/**
* @param string $key
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/data/exportBills
*
* @return LaravelResponse
* @throws ContainerExceptionInterface
* @throws FireflyException
* @throws NotFoundExceptionInterface
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function bills(ExportRequest $request): LaravelResponse
{
$this->exporter->setExportBills(true);
return $this->returnExport('bills');
}
/**
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/data/exportBudgets
*
* @throws ContainerExceptionInterface
* @throws FireflyException
* @throws NotFoundExceptionInterface
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function budgets(ExportRequest $request): LaravelResponse
{
$this->exporter->setExportBudgets(true);
return $this->returnExport('budgets');
}
/**
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/data/exportCategories
*
* @throws ContainerExceptionInterface
* @throws FireflyException
* @throws NotFoundExceptionInterface
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function categories(ExportRequest $request): LaravelResponse
{
$this->exporter->setExportCategories(true);
return $this->returnExport('categories');
}
/**
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/data/exportPiggies
*
* @throws ContainerExceptionInterface
* @throws FireflyException
* @throws NotFoundExceptionInterface
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function piggyBanks(ExportRequest $request): LaravelResponse
{
$this->exporter->setExportPiggies(true);
return $this->returnExport('piggies');
}
/**
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/data/exportRecurring
*
* @throws ContainerExceptionInterface
* @throws FireflyException
* @throws NotFoundExceptionInterface
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function recurring(ExportRequest $request): LaravelResponse
{
$this->exporter->setExportRecurring(true);
return $this->returnExport('recurrences');
}
/**
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/data/exportRules
*
* @throws ContainerExceptionInterface
* @throws FireflyException
* @throws NotFoundExceptionInterface
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function rules(ExportRequest $request): LaravelResponse
{
$this->exporter->setExportRules(true);
return $this->returnExport('rules');
}
/**
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/data/exportTags
*
* @throws ContainerExceptionInterface
* @throws FireflyException
* @throws NotFoundExceptionInterface
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function tags(ExportRequest $request): LaravelResponse
{
$this->exporter->setExportTags(true);
return $this->returnExport('tags');
}
/**
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/data/exportTransactions
*
* @throws ContainerExceptionInterface
* @throws FireflyException
* @throws NotFoundExceptionInterface
*/
public function transactions(ExportRequest $request): LaravelResponse
{
$params = $request->getAll();
$this->exporter->setStart($params['start']);
$this->exporter->setEnd($params['end']);
$this->exporter->setAccounts($params['accounts']);
$this->exporter->setExportTransactions(true);
return $this->returnExport('transactions');
}
/**
* @throws FireflyException
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
@ -94,169 +226,15 @@ class ExportController extends Controller
$response
->header('Content-Description', 'File Transfer')
->header('Content-Type', 'application/octet-stream')
->header('Content-Disposition', 'attachment; filename=' . $fileName)
->header('Content-Disposition', 'attachment; filename='.$fileName)
->header('Content-Transfer-Encoding', 'binary')
->header('Connection', 'Keep-Alive')
->header('Expires', '0')
->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0')
->header('Pragma', 'public')
->header('Content-Length', (string)strlen($data[$key]));
->header('Content-Length', (string)strlen($data[$key]))
;
return $response;
}
/**
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/data/exportBills
*
* @param ExportRequest $request
*
* @return LaravelResponse
* @throws ContainerExceptionInterface
* @throws FireflyException
* @throws NotFoundExceptionInterface
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function bills(ExportRequest $request): LaravelResponse
{
$this->exporter->setExportBills(true);
return $this->returnExport('bills');
}
/**
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/data/exportBudgets
*
* @param ExportRequest $request
*
* @return LaravelResponse
* @throws ContainerExceptionInterface
* @throws FireflyException
* @throws NotFoundExceptionInterface
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function budgets(ExportRequest $request): LaravelResponse
{
$this->exporter->setExportBudgets(true);
return $this->returnExport('budgets');
}
/**
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/data/exportCategories
*
* @param ExportRequest $request
*
* @return LaravelResponse
* @throws ContainerExceptionInterface
* @throws FireflyException
* @throws NotFoundExceptionInterface
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function categories(ExportRequest $request): LaravelResponse
{
$this->exporter->setExportCategories(true);
return $this->returnExport('categories');
}
/**
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/data/exportPiggies
*
* @param ExportRequest $request
*
* @return LaravelResponse
* @throws ContainerExceptionInterface
* @throws FireflyException
* @throws NotFoundExceptionInterface
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function piggyBanks(ExportRequest $request): LaravelResponse
{
$this->exporter->setExportPiggies(true);
return $this->returnExport('piggies');
}
/**
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/data/exportRecurring
*
* @param ExportRequest $request
*
* @return LaravelResponse
* @throws ContainerExceptionInterface
* @throws FireflyException
* @throws NotFoundExceptionInterface
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function recurring(ExportRequest $request): LaravelResponse
{
$this->exporter->setExportRecurring(true);
return $this->returnExport('recurrences');
}
/**
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/data/exportRules
*
* @param ExportRequest $request
*
* @return LaravelResponse
* @throws ContainerExceptionInterface
* @throws FireflyException
* @throws NotFoundExceptionInterface
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function rules(ExportRequest $request): LaravelResponse
{
$this->exporter->setExportRules(true);
return $this->returnExport('rules');
}
/**
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/data/exportTags
*
* @param ExportRequest $request
*
* @return LaravelResponse
* @throws ContainerExceptionInterface
* @throws FireflyException
* @throws NotFoundExceptionInterface
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function tags(ExportRequest $request): LaravelResponse
{
$this->exporter->setExportTags(true);
return $this->returnExport('tags');
}
/**
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/data/exportTransactions
*
* @param ExportRequest $request
*
* @return LaravelResponse
* @throws ContainerExceptionInterface
* @throws FireflyException
* @throws NotFoundExceptionInterface
*/
public function transactions(ExportRequest $request): LaravelResponse
{
$params = $request->getAll();
$this->exporter->setStart($params['start']);
$this->exporter->setEnd($params['end']);
$this->exporter->setAccounts($params['accounts']);
$this->exporter->setExportTransactions(true);
return $this->returnExport('transactions');
}
}

View File

@ -47,8 +47,6 @@ class PurgeController extends Controller
* TODO cleanup and use repositories.
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/data/purgeData
*
* @return JsonResponse
*/
public function purge(): JsonResponse
{
@ -65,7 +63,9 @@ class PurgeController extends Controller
// piggies
$set = PiggyBank::leftJoin('accounts', 'accounts.id', 'piggy_banks.account_id')
->where('accounts.user_id', $user->id)->onlyTrashed()->get(['piggy_banks.*']);
->where('accounts.user_id', $user->id)->onlyTrashed()->get(['piggy_banks.*'])
;
/** @var PiggyBank $piggy */
foreach ($set as $piggy) {
$piggy->forceDelete();
@ -86,7 +86,6 @@ class PurgeController extends Controller
// tags
Tag::whereUserId($user->id)->onlyTrashed()->forceDelete();
// accounts
Account::whereUserId($user->id)->onlyTrashed()->forceDelete();

View File

@ -32,7 +32,6 @@ use FireflyIII\Support\Http\Api\ApiSupport;
use Illuminate\Http\JsonResponse;
/**
*
* Class AccountController
*
* Shows expense information grouped or limited by date.
@ -47,8 +46,6 @@ class AccountController extends Controller
/**
* AccountController constructor.
*
*/
public function __construct()
{
@ -70,10 +67,6 @@ class AccountController extends Controller
/**
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/insight/insightExpenseAsset
*
* @param GenericRequest $request
*
* @return JsonResponse
*/
public function asset(GenericRequest $request): JsonResponse
{
@ -101,10 +94,6 @@ class AccountController extends Controller
/**
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/insight/insightExpenseExpense
*
* @param GenericRequest $request
*
* @return JsonResponse
*/
public function expense(GenericRequest $request): JsonResponse
{

View File

@ -60,10 +60,6 @@ class BillController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/insight/insightExpenseBill
*
* Expenses per bill, possibly filtered by bill and account.
*
* @param GenericRequest $request
*
* @return JsonResponse
*/
public function bill(GenericRequest $request): JsonResponse
{
@ -123,10 +119,6 @@ class BillController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/insight/insightExpenseNoBill
*
* Expenses for no bill filtered by account.
*
* @param GenericRequest $request
*
* @return JsonResponse
*/
public function noBill(GenericRequest $request): JsonResponse
{

View File

@ -43,8 +43,6 @@ class BudgetController extends Controller
/**
* AccountController constructor.
*
*/
public function __construct()
{
@ -67,10 +65,6 @@ class BudgetController extends Controller
/**
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/insight/insightExpenseBudget
*
* @param GenericRequest $request
*
* @return JsonResponse
*/
public function budget(GenericRequest $request): JsonResponse
{
@ -82,9 +76,11 @@ class BudgetController extends Controller
if (0 === $budgets->count()) {
$budgets = $this->repository->getActiveBudgets();
}
/** @var Budget $budget */
foreach ($budgets as $budget) {
$expenses = $this->opsRepository->sumExpenses($start, $end, $assetAccounts, new Collection([$budget]));
/** @var array $expense */
foreach ($expenses as $expense) {
$result[] = [
@ -104,10 +100,6 @@ class BudgetController extends Controller
/**
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/insight/insightExpenseNoBudget
*
* @param GenericRequest $request
*
* @return JsonResponse
*/
public function noBudget(GenericRequest $request): JsonResponse
{
@ -116,6 +108,7 @@ class BudgetController extends Controller
$assetAccounts = $request->getAssetAccounts();
$result = [];
$expenses = $this->noRepository->sumExpenses($start, $end, $assetAccounts);
/** @var array $expense */
foreach ($expenses as $expense) {
$result[] = [

View File

@ -44,8 +44,6 @@ class CategoryController extends Controller
/**
* AccountController constructor.
*
*/
public function __construct()
{
@ -68,10 +66,6 @@ class CategoryController extends Controller
/**
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/insight/insightTransferCategory
*
* @param GenericRequest $request
*
* @return JsonResponse
*/
public function category(GenericRequest $request): JsonResponse
{
@ -83,9 +77,11 @@ class CategoryController extends Controller
if (0 === $categories->count()) {
$categories = $this->repository->getCategories();
}
/** @var Category $category */
foreach ($categories as $category) {
$expenses = $this->opsRepository->sumExpenses($start, $end, $assetAccounts, new Collection([$category]));
/** @var array $expense */
foreach ($expenses as $expense) {
$result[] = [
@ -105,10 +101,6 @@ class CategoryController extends Controller
/**
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/insight/insightTransferNoCategory
*
* @param GenericRequest $request
*
* @return JsonResponse
*/
public function noCategory(GenericRequest $request): JsonResponse
{
@ -117,6 +109,7 @@ class CategoryController extends Controller
$assetAccounts = $request->getAssetAccounts();
$result = [];
$expenses = $this->noRepository->sumExpenses($start, $end, $assetAccounts);
/** @var array $expense */
foreach ($expenses as $expense) {
$result[] = [

View File

@ -37,10 +37,6 @@ class PeriodController extends Controller
/**
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/insight/insightExpenseTotal
*
* @param GenericRequest $request
*
* @return JsonResponse
*/
public function total(GenericRequest $request): JsonResponse
{

View File

@ -59,10 +59,6 @@ class TagController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/insight/insightExpenseNoTag
*
* Expenses for no tag filtered by account.
*
* @param GenericRequest $request
*
* @return JsonResponse
*/
public function noTag(GenericRequest $request): JsonResponse
{
@ -112,10 +108,6 @@ class TagController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/insight/insightExpenseTag
*
* Expenses per tag, possibly filtered by tag and account.
*
* @param GenericRequest $request
*
* @return JsonResponse
*/
public function tag(GenericRequest $request): JsonResponse
{
@ -135,6 +127,7 @@ class TagController extends Controller
$collector->setTypes([TransactionType::WITHDRAWAL])->setRange($start, $end)->setSourceAccounts($accounts);
$collector->setTags($tags);
$genericSet = $collector->getExtractedJournals();
/** @var array $journal */
foreach ($genericSet as $journal) {
$currencyId = (int)$journal['currency_id'];

View File

@ -32,7 +32,6 @@ use FireflyIII\Support\Http\Api\ApiSupport;
use Illuminate\Http\JsonResponse;
/**
*
* Class AccountController
*
* Shows income information grouped or limited by date.
@ -47,8 +46,6 @@ class AccountController extends Controller
/**
* AccountController constructor.
*
*/
public function __construct()
{
@ -70,10 +67,6 @@ class AccountController extends Controller
/**
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/insight/insightIncomeAsset
*
* @param GenericRequest $request
*
* @return JsonResponse
*/
public function asset(GenericRequest $request): JsonResponse
{
@ -82,6 +75,7 @@ class AccountController extends Controller
$assetAccounts = $request->getAssetAccounts();
$income = $this->opsRepository->sumIncomeByDestination($start, $end, $assetAccounts);
$result = [];
/** @var array $entry */
foreach ($income as $entry) {
$result[] = [
@ -100,10 +94,6 @@ class AccountController extends Controller
/**
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/insight/insightIncomeRevenue
*
* @param GenericRequest $request
*
* @return JsonResponse
*/
public function revenue(GenericRequest $request): JsonResponse
{

View File

@ -44,8 +44,6 @@ class CategoryController extends Controller
/**
* AccountController constructor.
*
*/
public function __construct()
{
@ -68,10 +66,6 @@ class CategoryController extends Controller
/**
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/insight/insightIncomeCategory
*
* @param GenericRequest $request
*
* @return JsonResponse
*/
public function category(GenericRequest $request): JsonResponse
{
@ -83,9 +77,11 @@ class CategoryController extends Controller
if (0 === $categories->count()) {
$categories = $this->repository->getCategories();
}
/** @var Category $category */
foreach ($categories as $category) {
$expenses = $this->opsRepository->sumIncome($start, $end, $assetAccounts, new Collection([$category]));
/** @var array $expense */
foreach ($expenses as $expense) {
$result[] = [
@ -105,10 +101,6 @@ class CategoryController extends Controller
/**
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/insight/insightIncomeNoCategory
*
* @param GenericRequest $request
*
* @return JsonResponse
*/
public function noCategory(GenericRequest $request): JsonResponse
{
@ -117,6 +109,7 @@ class CategoryController extends Controller
$assetAccounts = $request->getAssetAccounts();
$result = [];
$expenses = $this->noRepository->sumIncome($start, $end, $assetAccounts);
/** @var array $expense */
foreach ($expenses as $expense) {
$result[] = [

View File

@ -37,10 +37,6 @@ class PeriodController extends Controller
/**
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/insight/insightIncomeTotal
*
* @param GenericRequest $request
*
* @return JsonResponse
*/
public function total(GenericRequest $request): JsonResponse
{

View File

@ -60,10 +60,6 @@ class TagController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/insight/insightIncomeTag
*
* Expenses for no tag filtered by account.
*
* @param GenericRequest $request
*
* @return JsonResponse
*/
public function noTag(GenericRequest $request): JsonResponse
{
@ -116,10 +112,6 @@ class TagController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/insight/insightIncomeNoTag
*
* Expenses per tag, possibly filtered by tag and account.
*
* @param GenericRequest $request
*
* @return JsonResponse
*/
public function tag(GenericRequest $request): JsonResponse
{
@ -139,6 +131,7 @@ class TagController extends Controller
$collector->setTypes([TransactionType::DEPOSIT])->setRange($start, $end)->setDestinationAccounts($accounts);
$collector->setTags($tags);
$genericSet = $collector->getExtractedJournals();
/** @var array $journal */
foreach ($genericSet as $journal) {
$currencyId = (int)$journal['currency_id'];

View File

@ -40,8 +40,6 @@ class AccountController extends Controller
/**
* AccountController constructor.
*
*/
public function __construct()
{
@ -60,10 +58,6 @@ class AccountController extends Controller
/**
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/insight/insightTransfers
*
* @param GenericRequest $request
*
* @return JsonResponse
*/
public function asset(GenericRequest $request): JsonResponse
{

View File

@ -43,8 +43,6 @@ class CategoryController extends Controller
/**
* AccountController constructor.
*
*/
public function __construct()
{
@ -67,10 +65,6 @@ class CategoryController extends Controller
/**
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/insight/insightTransferCategory
*
* @param GenericRequest $request
*
* @return JsonResponse
*/
public function category(GenericRequest $request): JsonResponse
{
@ -82,9 +76,11 @@ class CategoryController extends Controller
if (0 === $categories->count()) {
$categories = $this->repository->getCategories();
}
/** @var Category $category */
foreach ($categories as $category) {
$expenses = $this->opsRepository->sumTransfers($start, $end, $assetAccounts, new Collection([$category]));
/** @var array $expense */
foreach ($expenses as $expense) {
$result[] = [
@ -104,10 +100,6 @@ class CategoryController extends Controller
/**
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/insight/insightTransferNoCategory
*
* @param GenericRequest $request
*
* @return JsonResponse
*/
public function noCategory(GenericRequest $request): JsonResponse
{
@ -116,6 +108,7 @@ class CategoryController extends Controller
$assetAccounts = $request->getAssetAccounts();
$result = [];
$expenses = $this->noRepository->sumTransfers($start, $end, $assetAccounts);
/** @var array $expense */
foreach ($expenses as $expense) {
$result[] = [

View File

@ -37,10 +37,6 @@ class PeriodController extends Controller
/**
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/insight/insightTransferTotal
*
* @param GenericRequest $request
*
* @return JsonResponse
*/
public function total(GenericRequest $request): JsonResponse
{

View File

@ -57,10 +57,6 @@ class TagController extends Controller
/**
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/insight/insightTransferNoTag
*
* @param GenericRequest $request
*
* @return JsonResponse
*/
public function noTag(GenericRequest $request): JsonResponse
{
@ -113,10 +109,6 @@ class TagController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/insight/insightTransferTag
*
* Transfers per tag, possibly filtered by tag and account.
*
* @param GenericRequest $request
*
* @return JsonResponse
*/
public function tag(GenericRequest $request): JsonResponse
{
@ -136,6 +128,7 @@ class TagController extends Controller
$collector->setTypes([TransactionType::TRANSFER])->setRange($start, $end)->setDestinationAccounts($accounts);
$collector->setTags($tags);
$genericSet = $collector->getExtractedJournals();
/** @var array $journal */
foreach ($genericSet as $journal) {
$currencyId = (int)$journal['currency_id'];

View File

@ -39,8 +39,6 @@ class DestroyController extends Controller
/**
* AccountController constructor.
*
*/
public function __construct()
{
@ -60,10 +58,6 @@ class DestroyController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/accounts/deleteAccount
*
* Remove the specified resource from storage.
*
* @param Account $account
*
* @return JsonResponse
*/
public function destroy(Account $account): JsonResponse
{

View File

@ -53,8 +53,6 @@ class ListController extends Controller
/**
* AccountController constructor.
*
*/
public function __construct()
{
@ -73,9 +71,6 @@ class ListController extends Controller
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/accounts/listAttachmentByAccount
*
* @param Account $account
*
* @return JsonResponse
* @throws FireflyException
*/
public function attachments(Account $account): JsonResponse
@ -89,7 +84,7 @@ class ListController extends Controller
// make paginator:
$paginator = new LengthAwarePaginator($attachments, $count, $pageSize, $this->parameters->get('page'));
$paginator->setPath(route('api.v1.accounts.attachments', [$account->id]) . $this->buildParams());
$paginator->setPath(route('api.v1.accounts.attachments', [$account->id]).$this->buildParams());
/** @var AttachmentTransformer $transformer */
$transformer = app(AttachmentTransformer::class);
@ -105,9 +100,6 @@ class ListController extends Controller
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/accounts/listPiggyBankByAccount
*
* @param Account $account
*
* @return JsonResponse
* @throws FireflyException
*/
public function piggyBanks(Account $account): JsonResponse
@ -125,7 +117,7 @@ class ListController extends Controller
// make paginator:
$paginator = new LengthAwarePaginator($piggyBanks, $count, $pageSize, $this->parameters->get('page'));
$paginator->setPath(route('api.v1.accounts.piggy-banks', [$account->id]) . $this->buildParams());
$paginator->setPath(route('api.v1.accounts.piggy-banks', [$account->id]).$this->buildParams());
/** @var PiggyBankTransformer $transformer */
$transformer = app(PiggyBankTransformer::class);
@ -143,11 +135,6 @@ class ListController extends Controller
*
* Show all transaction groups related to the account.
*
*
* @param Request $request
* @param Account $account
*
* @return JsonResponse
* @throws FireflyException
*/
public function transactions(Request $request, Account $account): JsonResponse
@ -157,6 +144,7 @@ class ListController extends Controller
$this->parameters->set('type', $type);
$types = $this->mapTransactionTypes($this->parameters->get('type'));
$manager = $this->getManager();
/** @var User $admin */
$admin = auth()->user();
@ -164,7 +152,8 @@ class ListController extends Controller
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
$collector->setUser($admin)->setAccounts(new Collection([$account]))
->withAPIInformation()->setLimit($pageSize)->setPage($this->parameters->get('page'))->setTypes($types);
->withAPIInformation()->setLimit($pageSize)->setPage($this->parameters->get('page'))->setTypes($types)
;
if (null !== $this->parameters->get('start')) {
$collector->setStart($this->parameters->get('start'));
@ -174,7 +163,7 @@ class ListController extends Controller
}
$paginator = $collector->getPaginatedGroups();
$paginator->setPath(route('api.v1.accounts.transactions', [$account->id]) . $this->buildParams());
$paginator->setPath(route('api.v1.accounts.transactions', [$account->id]).$this->buildParams());
$groups = $paginator->getCollection();
/** @var TransactionGroupTransformer $transformer */

View File

@ -49,8 +49,6 @@ class ShowController extends Controller
/**
* AccountController constructor.
*
*/
public function __construct()
{
@ -71,9 +69,6 @@ class ShowController extends Controller
*
* Display a listing of the resource.
*
* @param Request $request
*
* @return JsonResponse
* @throws FireflyException
*/
public function index(Request $request): JsonResponse
@ -93,12 +88,11 @@ class ShowController extends Controller
// continue sort:
$accounts = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
// make paginator:
$paginator = new LengthAwarePaginator($accounts, $count, $pageSize, $this->parameters->get('page'));
$paginator->setPath(route('api.v1.accounts.index') . $this->buildParams());
$paginator->setPath(route('api.v1.accounts.index').$this->buildParams());
/** @var AccountTransformer $transformer */
$transformer = app(AccountTransformer::class);
@ -115,10 +109,6 @@ class ShowController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/accounts/getAccount
*
* Show single instance.
*
* @param Account $account
*
* @return JsonResponse
*/
public function show(Account $account): JsonResponse
{

View File

@ -41,8 +41,6 @@ class StoreController extends Controller
/**
* AccountController constructor.
*
*/
public function __construct()
{
@ -62,10 +60,6 @@ class StoreController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/accounts/storeAccount
*
* Store a new instance.
*
* @param StoreRequest $request
*
* @return JsonResponse
*/
public function store(StoreRequest $request): JsonResponse
{

View File

@ -42,8 +42,6 @@ class UpdateController extends Controller
/**
* AccountController constructor.
*
*/
public function __construct()
{
@ -63,17 +61,12 @@ class UpdateController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/accounts/updateAccount
*
* Update account.
*
* @param UpdateRequest $request
* @param Account $account
*
* @return JsonResponse
*/
public function update(UpdateRequest $request, Account $account): JsonResponse
{
app('log')->debug(sprintf('Now in %s', __METHOD__));
$data = $request->getUpdateData();
$data['type'] = config('firefly.shortNamesByFullName.' . $account->accountType->type);
$data['type'] = config('firefly.shortNamesByFullName.'.$account->accountType->type);
$account = $this->repository->update($account, $data);
$manager = $this->getManager();
$account->refresh();

View File

@ -39,8 +39,6 @@ class DestroyController extends Controller
/**
* DestroyController constructor.
*
*/
public function __construct()
{
@ -63,11 +61,6 @@ class DestroyController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/attachments/deleteAttachment
*
* Remove the specified resource from storage.
*
*
* @param Attachment $attachment
*
* @return JsonResponse
*/
public function destroy(Attachment $attachment): JsonResponse
{

View File

@ -46,8 +46,6 @@ class ShowController extends Controller
/**
* ShowController constructor.
*
*/
public function __construct()
{
@ -71,10 +69,7 @@ class ShowController extends Controller
*
* Download an attachment.
*
* @param Attachment $attachment
*
* @return LaravelResponse
* @throws FireflyException
* @throws FireflyException
*/
public function download(Attachment $attachment): LaravelResponse
{
@ -96,16 +91,18 @@ class ShowController extends Controller
$response
->header('Content-Description', 'File Transfer')
->header('Content-Type', 'application/octet-stream')
->header('Content-Disposition', 'attachment; filename=' . $quoted)
->header('Content-Disposition', 'attachment; filename='.$quoted)
->header('Content-Transfer-Encoding', 'binary')
->header('Connection', 'Keep-Alive')
->header('Expires', '0')
->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0')
->header('Pragma', 'public')
->header('Content-Length', (string)strlen($content));
->header('Content-Length', (string)strlen($content))
;
return $response;
}
throw new FireflyException('200003: File does not exist.');
}
@ -115,7 +112,6 @@ class ShowController extends Controller
*
* Display a listing of the resource.
*
* @return JsonResponse
* @throws FireflyException
*/
public function index(): JsonResponse
@ -132,7 +128,7 @@ class ShowController extends Controller
// make paginator:
$paginator = new LengthAwarePaginator($attachments, $count, $pageSize, $this->parameters->get('page'));
$paginator->setPath(route('api.v1.attachments.index') . $this->buildParams());
$paginator->setPath(route('api.v1.attachments.index').$this->buildParams());
/** @var AttachmentTransformer $transformer */
$transformer = app(AttachmentTransformer::class);
@ -149,14 +145,11 @@ class ShowController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/attachments/getAttachment
*
* Display the specified resource.
*
* @param Attachment $attachment
*
* @return JsonResponse
*/
public function show(Attachment $attachment): JsonResponse
{
$manager = $this->getManager();
/** @var AttachmentTransformer $transformer */
$transformer = app(AttachmentTransformer::class);
$transformer->setParameters($this->parameters);

View File

@ -45,8 +45,6 @@ class StoreController extends Controller
/**
* StoreController constructor.
*
*/
public function __construct()
{
@ -70,9 +68,6 @@ class StoreController extends Controller
*
* Store a newly created resource in storage.
*
* @param StoreRequest $request
*
* @return JsonResponse
* @throws FireflyException
*/
public function store(StoreRequest $request): JsonResponse
@ -93,12 +88,6 @@ class StoreController extends Controller
/**
* Upload an attachment.
*
*
* @param Request $request
* @param Attachment $attachment
*
* @return JsonResponse
*/
public function upload(Request $request, Attachment $attachment): JsonResponse
{

View File

@ -42,8 +42,6 @@ class UpdateController extends Controller
/**
* UpdateController constructor.
*
*/
public function __construct()
{
@ -66,11 +64,6 @@ class UpdateController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/attachments/updateAttachment
*
* Update the specified resource in storage.
*
* @param UpdateRequest $request
* @param Attachment $attachment
*
* @return JsonResponse
*/
public function update(UpdateRequest $request, Attachment $attachment): JsonResponse
{

View File

@ -44,8 +44,6 @@ class ShowController extends Controller
/**
* AvailableBudgetController constructor.
*
*/
public function __construct()
{
@ -68,7 +66,6 @@ class ShowController extends Controller
*
* Display a listing of the resource.
*
* @return JsonResponse
* @throws FireflyException
*/
public function index(): JsonResponse
@ -88,7 +85,7 @@ class ShowController extends Controller
// make paginator:
$paginator = new LengthAwarePaginator($availableBudgets, $count, $pageSize, $this->parameters->get('page'));
$paginator->setPath(route('api.v1.available-budgets.index') . $this->buildParams());
$paginator->setPath(route('api.v1.available-budgets.index').$this->buildParams());
/** @var AvailableBudgetTransformer $transformer */
$transformer = app(AvailableBudgetTransformer::class);
@ -105,10 +102,6 @@ class ShowController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/available_budgets/getAvailableBudget
*
* Display the specified resource.
*
* @param AvailableBudget $availableBudget
*
* @return JsonResponse
*/
public function show(AvailableBudget $availableBudget): JsonResponse
{

View File

@ -37,8 +37,6 @@ class DestroyController extends Controller
/**
* BillController constructor.
*
*/
public function __construct()
{
@ -58,10 +56,6 @@ class DestroyController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/bills/deleteBill
*
* Remove the specified resource from storage.
*
* @param Bill $bill
*
* @return JsonResponse
*/
public function destroy(Bill $bill): JsonResponse
{

View File

@ -50,8 +50,6 @@ class ListController extends Controller
/**
* BillController constructor.
*
*/
public function __construct()
{
@ -72,9 +70,6 @@ class ListController extends Controller
*
* Display a listing of the resource.
*
* @param Bill $bill
*
* @return JsonResponse
* @throws FireflyException
*/
public function attachments(Bill $bill): JsonResponse
@ -88,7 +83,7 @@ class ListController extends Controller
// make paginator:
$paginator = new LengthAwarePaginator($attachments, $count, $pageSize, $this->parameters->get('page'));
$paginator->setPath(route('api.v1.bills.attachments', [$bill->id]) . $this->buildParams());
$paginator->setPath(route('api.v1.bills.attachments', [$bill->id]).$this->buildParams());
/** @var AttachmentTransformer $transformer */
$transformer = app(AttachmentTransformer::class);
@ -106,9 +101,6 @@ class ListController extends Controller
*
* List all of them.
*
* @param Bill $bill
*
* @return JsonResponse
* @throws FireflyException
*/
public function rules(Bill $bill): JsonResponse
@ -125,7 +117,7 @@ class ListController extends Controller
// make paginator:
$paginator = new LengthAwarePaginator($rules, $count, $pageSize, $this->parameters->get('page'));
$paginator->setPath(route('api.v1.bills.rules', [$bill->id]) . $this->buildParams());
$paginator->setPath(route('api.v1.bills.rules', [$bill->id]).$this->buildParams());
/** @var RuleTransformer $transformer */
$transformer = app(RuleTransformer::class);
@ -142,11 +134,6 @@ class ListController extends Controller
*
* Show all transactions.
*
* @param Request $request
*
* @param Bill $bill
*
* @return JsonResponse
* @throws FireflyException
*/
public function transactions(Request $request, Bill $bill): JsonResponse
@ -175,7 +162,8 @@ class ListController extends Controller
// set page to retrieve
->setPage($this->parameters->get('page'))
// set types of transactions to return.
->setTypes($types);
->setTypes($types)
;
if (null !== $this->parameters->get('start')) {
$collector->setStart($this->parameters->get('start'));
@ -186,7 +174,7 @@ class ListController extends Controller
// get paginator.
$paginator = $collector->getPaginatedGroups();
$paginator->setPath(route('api.v1.bills.transactions', [$bill->id]) . $this->buildParams());
$paginator->setPath(route('api.v1.bills.transactions', [$bill->id]).$this->buildParams());
$transactions = $paginator->getCollection();
/** @var TransactionGroupTransformer $transformer */

View File

@ -43,8 +43,6 @@ class ShowController extends Controller
/**
* BillController constructor.
*
*/
public function __construct()
{
@ -65,7 +63,6 @@ class ShowController extends Controller
*
* Display a listing of the resource.
*
* @return JsonResponse
* @throws FireflyException
*/
public function index(): JsonResponse
@ -93,14 +90,11 @@ class ShowController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/bills/getBill
*
* Show the specified bill.
*
* @param Bill $bill
*
* @return JsonResponse
*/
public function show(Bill $bill): JsonResponse
{
$manager = $this->getManager();
/** @var BillTransformer $transformer */
$transformer = app(BillTransformer::class);
$transformer->setParameters($this->parameters);

View File

@ -43,8 +43,6 @@ class StoreController extends Controller
/**
* BillController constructor.
*
*/
public function __construct()
{
@ -65,9 +63,6 @@ class StoreController extends Controller
*
* Store a bill.
*
* @param StoreRequest $request
*
* @return JsonResponse
* @throws FireflyException
*/
public function store(StoreRequest $request): JsonResponse

View File

@ -40,8 +40,6 @@ class UpdateController extends Controller
/**
* BillController constructor.
*
*/
public function __construct()
{
@ -61,11 +59,6 @@ class UpdateController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/bills/updateBill
*
* Update a bill.
*
* @param UpdateRequest $request
* @param Bill $bill
*
* @return JsonResponse
*/
public function update(UpdateRequest $request, Bill $bill): JsonResponse
{

View File

@ -37,8 +37,6 @@ class DestroyController extends Controller
/**
* DestroyController constructor.
*
*/
public function __construct()
{
@ -58,10 +56,6 @@ class DestroyController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/budgets/deleteBudget
*
* Remove the specified resource from storage.
*
* @param Budget $budget
*
* @return JsonResponse
*/
public function destroy(Budget $budget): JsonResponse
{

View File

@ -40,9 +40,7 @@ use Illuminate\Pagination\LengthAwarePaginator;
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
use League\Fractal\Resource\Collection as FractalCollection;
/***
* Class ListController
*/
// Class ListController
class ListController extends Controller
{
use TransactionFilter;
@ -52,8 +50,6 @@ class ListController extends Controller
/**
* ListController constructor.
*
*/
public function __construct()
{
@ -74,9 +70,6 @@ class ListController extends Controller
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/budgets/listAttachmentByBudget
*
* @param Budget $budget
*
* @return JsonResponse
* @throws FireflyException
*/
public function attachments(Budget $budget): JsonResponse
@ -90,7 +83,7 @@ class ListController extends Controller
// make paginator:
$paginator = new LengthAwarePaginator($attachments, $count, $pageSize, $this->parameters->get('page'));
$paginator->setPath(route('api.v1.budgets.attachments', [$budget->id]) . $this->buildParams());
$paginator->setPath(route('api.v1.budgets.attachments', [$budget->id]).$this->buildParams());
/** @var AttachmentTransformer $transformer */
$transformer = app(AttachmentTransformer::class);
@ -108,9 +101,6 @@ class ListController extends Controller
*
* Display a listing of the resource.
*
* @param Budget $budget
*
* @return JsonResponse
* @throws FireflyException
*/
public function budgetLimits(Budget $budget): JsonResponse
@ -122,7 +112,7 @@ class ListController extends Controller
$count = $collection->count();
$budgetLimits = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
$paginator = new LengthAwarePaginator($budgetLimits, $count, $pageSize, $this->parameters->get('page'));
$paginator->setPath(route('api.v1.budgets.budget-limits', [$budget->id]) . $this->buildParams());
$paginator->setPath(route('api.v1.budgets.budget-limits', [$budget->id]).$this->buildParams());
/** @var BudgetLimitTransformer $transformer */
$transformer = app(BudgetLimitTransformer::class);
@ -139,11 +129,6 @@ class ListController extends Controller
*
* Show all transactions.
*
* @param Request $request
*
* @param Budget $budget
*
* @return JsonResponse
* @throws FireflyException
*/
public function transactions(Request $request, Budget $budget): JsonResponse
@ -173,7 +158,8 @@ class ListController extends Controller
// set page to retrieve
->setPage($this->parameters->get('page'))
// set types of transactions to return.
->setTypes($types);
->setTypes($types)
;
if (null !== $this->parameters->get('start')) {
$collector->setStart($this->parameters->get('start'));
@ -183,7 +169,7 @@ class ListController extends Controller
}
$paginator = $collector->getPaginatedGroups();
$paginator->setPath(route('api.v1.budgets.transactions', [$budget->id]) . $this->buildParams());
$paginator->setPath(route('api.v1.budgets.transactions', [$budget->id]).$this->buildParams());
$transactions = $paginator->getCollection();
/** @var TransactionGroupTransformer $transformer */
@ -201,9 +187,6 @@ class ListController extends Controller
*
* Show all transactions.
*
* @param Request $request
*
* @return JsonResponse
* @throws FireflyException
*/
public function withoutBudget(Request $request): JsonResponse
@ -233,7 +216,8 @@ class ListController extends Controller
// set page to retrieve
->setPage($this->parameters->get('page'))
// set types of transactions to return.
->setTypes($types);
->setTypes($types)
;
if (null !== $this->parameters->get('start')) {
$collector->setStart($this->parameters->get('start'));
@ -243,7 +227,7 @@ class ListController extends Controller
}
$paginator = $collector->getPaginatedGroups();
$paginator->setPath(route('api.v1.budgets.without-budget') . $this->buildParams());
$paginator->setPath(route('api.v1.budgets.without-budget').$this->buildParams());
$transactions = $paginator->getCollection();
/** @var TransactionGroupTransformer $transformer */

View File

@ -45,8 +45,6 @@ class ShowController extends Controller
/**
* ListController constructor.
*
*/
public function __construct()
{
@ -69,7 +67,6 @@ class ShowController extends Controller
*
* Display a listing of the resource.
*
* @return JsonResponse
* @throws FireflyException
*/
public function index(): JsonResponse
@ -86,7 +83,7 @@ class ShowController extends Controller
// make paginator:
$paginator = new LengthAwarePaginator($budgets, $count, $pageSize, $this->parameters->get('page'));
$paginator->setPath(route('api.v1.budgets.index') . $this->buildParams());
$paginator->setPath(route('api.v1.budgets.index').$this->buildParams());
/** @var BudgetTransformer $transformer */
$transformer = app(BudgetTransformer::class);
@ -100,10 +97,6 @@ class ShowController extends Controller
/**
* Show a budget.
*
* @param Budget $budget
*
* @return JsonResponse
*/
public function show(Budget $budget): JsonResponse
{

View File

@ -40,8 +40,6 @@ class StoreController extends Controller
/**
* StoreController constructor.
*
*/
public function __construct()
{
@ -62,11 +60,7 @@ class StoreController extends Controller
*
* Store a budget.
*
* @param StoreRequest $request
*
* @return JsonResponse
* @throws FireflyException
*
*/
public function store(StoreRequest $request): JsonResponse
{

View File

@ -40,8 +40,6 @@ class UpdateController extends Controller
/**
* UpdateController constructor.
*
*/
public function __construct()
{
@ -61,11 +59,6 @@ class UpdateController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/budgets/updateBudget
*
* Update a budget.
*
* @param UpdateRequest $request
* @param Budget $budget
*
* @return JsonResponse
*/
public function update(UpdateRequest $request, Budget $budget): JsonResponse
{

View File

@ -40,8 +40,6 @@ class DestroyController extends Controller
/**
* BudgetLimitController constructor.
*
*/
public function __construct()
{
@ -64,10 +62,6 @@ class DestroyController extends Controller
*
* Remove the specified resource from storage.
*
* @param Budget $budget
* @param BudgetLimit $budgetLimit
*
* @return JsonResponse
* @throws FireflyException
*/
public function destroy(Budget $budget, BudgetLimit $budgetLimit): JsonResponse

View File

@ -48,11 +48,6 @@ class ListController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/budgets/listTransactionByBudgetLimit
* Show all transactions.
*
* @param Request $request
* @param Budget $budget
* @param BudgetLimit $budgetLimit
*
* @return JsonResponse
* @throws FireflyException
*/
public function transactions(Request $request, Budget $budget, BudgetLimit $budgetLimit): JsonResponse
@ -81,12 +76,13 @@ class ListController extends Controller
// set page to retrieve
->setPage($this->parameters->get('page'))
// set types of transactions to return.
->setTypes($types);
->setTypes($types)
;
$collector->setRange($budgetLimit->start_date, $budgetLimit->end_date);
$collector->setTypes($types);
$paginator = $collector->getPaginatedGroups();
$paginator->setPath(route('api.v1.budgets.limits.transactions', [$budget->id, $budgetLimit->id]) . $this->buildParams());
$paginator->setPath(route('api.v1.budgets.limits.transactions', [$budget->id, $budgetLimit->id]).$this->buildParams());
$transactions = $paginator->getCollection();
/** @var TransactionGroupTransformer $transformer */

View File

@ -48,8 +48,6 @@ class ShowController extends Controller
/**
* BudgetLimitController constructor.
*
*/
public function __construct()
{
@ -73,10 +71,6 @@ class ShowController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/budgets/listBudgetLimitByBudget
*
* Display a listing of the budget limits for this budget.
*
* @param Budget $budget
*
* @return JsonResponse
*/
public function index(Budget $budget): JsonResponse
{
@ -87,7 +81,7 @@ class ShowController extends Controller
$count = $collection->count();
$budgetLimits = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
$paginator = new LengthAwarePaginator($budgetLimits, $count, $pageSize, $this->parameters->get('page'));
$paginator->setPath(route('api.v1.budgets.limits.index', [$budget->id]) . $this->buildParams());
$paginator->setPath(route('api.v1.budgets.limits.index', [$budget->id]).$this->buildParams());
/** @var BudgetLimitTransformer $transformer */
$transformer = app(BudgetLimitTransformer::class);
@ -105,9 +99,6 @@ class ShowController extends Controller
*
* Display a listing of the budget limits for this budget.
*
* @param SameDateRequest $request
*
* @return JsonResponse
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function indexAll(SameDateRequest $request): JsonResponse
@ -119,7 +110,7 @@ class ShowController extends Controller
$count = $collection->count();
$budgetLimits = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
$paginator = new LengthAwarePaginator($budgetLimits, $count, $pageSize, $this->parameters->get('page'));
$paginator->setPath(route('api.v1.budget-limits.index') . $this->buildParams());
$paginator->setPath(route('api.v1.budget-limits.index').$this->buildParams());
/** @var BudgetLimitTransformer $transformer */
$transformer = app(BudgetLimitTransformer::class);
@ -135,10 +126,6 @@ class ShowController extends Controller
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/budgets/getBudgetLimit
*
* @param Budget $budget
* @param BudgetLimit $budgetLimit
*
* @return JsonResponse
* @throws FireflyException
*/
public function show(Budget $budget, BudgetLimit $budgetLimit): JsonResponse

View File

@ -41,8 +41,6 @@ class StoreController extends Controller
/**
* BudgetLimitController constructor.
*
*/
public function __construct()
{
@ -64,11 +62,6 @@ class StoreController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/budgets/storeBudgetLimit
*
* Store a newly created resource in storage.
*
* @param StoreRequest $request
* @param Budget $budget
*
* @return JsonResponse
*/
public function store(StoreRequest $request, Budget $budget): JsonResponse
{
@ -79,6 +72,7 @@ class StoreController extends Controller
$budgetLimit = $this->blRepository->store($data);
$manager = $this->getManager();
/** @var BudgetLimitTransformer $transformer */
$transformer = app(BudgetLimitTransformer::class);
$transformer->setParameters($this->parameters);

View File

@ -46,8 +46,6 @@ class UpdateController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/budgets/updateBudgetLimit
*
* BudgetLimitController constructor.
*
*/
public function __construct()
{
@ -69,11 +67,6 @@ class UpdateController extends Controller
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/budgets/updateBudgetLimit
*
* @param UpdateRequest $request
* @param Budget $budget
* @param BudgetLimit $budgetLimit
*
* @return JsonResponse
* @throws FireflyException
*/
public function update(UpdateRequest $request, Budget $budget, BudgetLimit $budgetLimit): JsonResponse

View File

@ -37,8 +37,6 @@ class DestroyController extends Controller
/**
* CategoryController constructor.
*
*/
public function __construct()
{
@ -58,10 +56,6 @@ class DestroyController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/categories/deleteCategory
*
* Remove the specified resource from storage.
*
* @param Category $category
*
* @return JsonResponse
*/
public function destroy(Category $category): JsonResponse
{

View File

@ -49,8 +49,6 @@ class ListController extends Controller
/**
* CategoryController constructor.
*
*/
public function __construct()
{
@ -69,9 +67,6 @@ class ListController extends Controller
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/categories/listAttachmentByCategory
*
* @param Category $category
*
* @return JsonResponse
* @throws FireflyException
*/
public function attachments(Category $category): JsonResponse
@ -85,7 +80,7 @@ class ListController extends Controller
// make paginator:
$paginator = new LengthAwarePaginator($attachments, $count, $pageSize, $this->parameters->get('page'));
$paginator->setPath(route('api.v1.categories.attachments', [$category->id]) . $this->buildParams());
$paginator->setPath(route('api.v1.categories.attachments', [$category->id]).$this->buildParams());
/** @var AttachmentTransformer $transformer */
$transformer = app(AttachmentTransformer::class);
@ -103,11 +98,6 @@ class ListController extends Controller
*
* Show all transactions.
*
* @param Request $request
*
* @param Category $category
*
* @return JsonResponse
* @throws FireflyException
*/
public function transactions(Request $request, Category $category): JsonResponse
@ -136,7 +126,8 @@ class ListController extends Controller
// set page to retrieve
->setPage($this->parameters->get('page'))
// set types of transactions to return.
->setTypes($types);
->setTypes($types)
;
if (null !== $this->parameters->get('start')) {
$collector->setStart($this->parameters->get('start'));
@ -146,7 +137,7 @@ class ListController extends Controller
}
$paginator = $collector->getPaginatedGroups();
$paginator->setPath(route('api.v1.categories.transactions', [$category->id]) . $this->buildParams());
$paginator->setPath(route('api.v1.categories.transactions', [$category->id]).$this->buildParams());
$transactions = $paginator->getCollection();
/** @var TransactionGroupTransformer $transformer */

View File

@ -43,8 +43,6 @@ class ShowController extends Controller
/**
* CategoryController constructor.
*
*/
public function __construct()
{
@ -65,7 +63,6 @@ class ShowController extends Controller
*
* Display a listing of the resource.
*
* @return JsonResponse
* @throws FireflyException
*/
public function index(): JsonResponse
@ -82,7 +79,7 @@ class ShowController extends Controller
// make paginator:
$paginator = new LengthAwarePaginator($categories, $count, $pageSize, $this->parameters->get('page'));
$paginator->setPath(route('api.v1.categories.index') . $this->buildParams());
$paginator->setPath(route('api.v1.categories.index').$this->buildParams());
/** @var CategoryTransformer $transformer */
$transformer = app(CategoryTransformer::class);
@ -98,10 +95,6 @@ class ShowController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/categories/getCategory
*
* Show the category.
*
* @param Category $category
*
* @return JsonResponse
*/
public function show(Category $category): JsonResponse
{

View File

@ -40,8 +40,6 @@ class StoreController extends Controller
/**
* CategoryController constructor.
*
*/
public function __construct()
{
@ -62,9 +60,6 @@ class StoreController extends Controller
*
* Store new category.
*
* @param StoreRequest $request
*
* @return JsonResponse
* @throws FireflyException
*/
public function store(StoreRequest $request): JsonResponse

View File

@ -40,8 +40,6 @@ class UpdateController extends Controller
/**
* CategoryController constructor.
*
*/
public function __construct()
{
@ -61,11 +59,6 @@ class UpdateController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/categories/updateCategory
*
* Update the category.
*
* @param UpdateRequest $request
* @param Category $category
*
* @return JsonResponse
*/
public function update(UpdateRequest $request, Category $category): JsonResponse
{

View File

@ -38,8 +38,6 @@ class DestroyController extends Controller
/**
* ObjectGroupController constructor.
*
*/
public function __construct()
{
@ -61,10 +59,6 @@ class DestroyController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/object_groups/deleteObjectGroup
*
* Remove the specified resource from storage.
*
* @param ObjectGroup $objectGroup
*
* @return JsonResponse
*/
public function destroy(ObjectGroup $objectGroup): JsonResponse
{

View File

@ -44,8 +44,6 @@ class ListController extends Controller
/**
* ObjectGroupController constructor.
*
*/
public function __construct()
{
@ -68,9 +66,6 @@ class ListController extends Controller
*
* List all bills in this object group
*
* @param ObjectGroup $objectGroup
*
* @return JsonResponse
* @throws FireflyException
*/
public function bills(ObjectGroup $objectGroup): JsonResponse
@ -85,7 +80,7 @@ class ListController extends Controller
// make paginator:
$paginator = new LengthAwarePaginator($bills, $count, $pageSize, $this->parameters->get('page'));
$paginator->setPath(route('api.v1.currencies.bills', [$objectGroup->id]) . $this->buildParams());
$paginator->setPath(route('api.v1.currencies.bills', [$objectGroup->id]).$this->buildParams());
/** @var BillTransformer $transformer */
$transformer = app(BillTransformer::class);
@ -103,9 +98,6 @@ class ListController extends Controller
*
* List all piggies under the object group.
*
* @param ObjectGroup $objectGroup
*
* @return JsonResponse
* @throws FireflyException
*/
public function piggyBanks(ObjectGroup $objectGroup): JsonResponse
@ -123,7 +115,7 @@ class ListController extends Controller
// make paginator:
$paginator = new LengthAwarePaginator($piggyBanks, $count, $pageSize, $this->parameters->get('page'));
$paginator->setPath(route('api.v1.object-groups.piggy-banks', [$objectGroup->id]) . $this->buildParams());
$paginator->setPath(route('api.v1.object-groups.piggy-banks', [$objectGroup->id]).$this->buildParams());
/** @var PiggyBankTransformer $transformer */
$transformer = app(PiggyBankTransformer::class);

View File

@ -43,8 +43,6 @@ class ShowController extends Controller
/**
* ObjectGroupController constructor.
*
*/
public function __construct()
{
@ -66,8 +64,6 @@ class ShowController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/object_groups/listObjectGroups
*
* Display a listing of the resource.
*
* @return JsonResponse
*/
public function index(): JsonResponse
{
@ -83,7 +79,7 @@ class ShowController extends Controller
// make paginator:
$paginator = new LengthAwarePaginator($objectGroups, $count, $pageSize, $this->parameters->get('page'));
$paginator->setPath(route('api.v1.object-groups.index') . $this->buildParams());
$paginator->setPath(route('api.v1.object-groups.index').$this->buildParams());
/** @var ObjectGroupTransformer $transformer */
$transformer = app(ObjectGroupTransformer::class);
@ -100,10 +96,6 @@ class ShowController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/object_groups/getObjectGroup
*
* Show single instance.
*
* @param ObjectGroup $objectGroup
*
* @return JsonResponse
*/
public function show(ObjectGroup $objectGroup): JsonResponse
{

View File

@ -41,8 +41,6 @@ class UpdateController extends Controller
/**
* ObjectGroupController constructor.
*
*/
public function __construct()
{
@ -62,11 +60,6 @@ class UpdateController extends Controller
/**
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/object_groups/updateObjectGroup
*
* @param UpdateRequest $request
* @param ObjectGroup $objectGroup
*
* @return JsonResponse
*/
public function update(UpdateRequest $request, ObjectGroup $objectGroup): JsonResponse
{

View File

@ -37,8 +37,6 @@ class DestroyController extends Controller
/**
* Constructor.
*
*/
public function __construct()
{
@ -58,10 +56,6 @@ class DestroyController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/piggy_banks/deletePiggyBank
*
* Delete the resource.
*
* @param PiggyBank $piggyBank
*
* @return JsonResponse
*/
public function destroy(PiggyBank $piggyBank): JsonResponse
{

View File

@ -43,8 +43,6 @@ class ListController extends Controller
/**
* Constructor.
*
*/
public function __construct()
{
@ -63,9 +61,6 @@ class ListController extends Controller
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/piggy_banks/listAttachmentByPiggyBank
*
* @param PiggyBank $piggyBank
*
* @return JsonResponse
* @throws FireflyException
*/
public function attachments(PiggyBank $piggyBank): JsonResponse
@ -79,7 +74,7 @@ class ListController extends Controller
// make paginator:
$paginator = new LengthAwarePaginator($attachments, $count, $pageSize, $this->parameters->get('page'));
$paginator->setPath(route('api.v1.piggy-banks.attachments', [$piggyBank->id]) . $this->buildParams());
$paginator->setPath(route('api.v1.piggy-banks.attachments', [$piggyBank->id]).$this->buildParams());
/** @var AttachmentTransformer $transformer */
$transformer = app(AttachmentTransformer::class);
@ -97,9 +92,6 @@ class ListController extends Controller
*
* List single resource.
*
* @param PiggyBank $piggyBank
*
* @return JsonResponse
* @throws FireflyException
*/
public function piggyBankEvents(PiggyBank $piggyBank): JsonResponse
@ -114,7 +106,7 @@ class ListController extends Controller
// make paginator:
$paginator = new LengthAwarePaginator($events, $count, $pageSize, $this->parameters->get('page'));
$paginator->setPath(route('api.v1.piggy-banks.events', [$piggyBank->id]) . $this->buildParams());
$paginator->setPath(route('api.v1.piggy-banks.events', [$piggyBank->id]).$this->buildParams());
/** @var PiggyBankEventTransformer $transformer */
$transformer = app(PiggyBankEventTransformer::class);

View File

@ -43,8 +43,6 @@ class ShowController extends Controller
/**
* Constructor.
*
*/
public function __construct()
{
@ -65,7 +63,6 @@ class ShowController extends Controller
*
* List all of them.
*
* @return JsonResponse
* @throws FireflyException
*/
public function index(): JsonResponse
@ -81,7 +78,7 @@ class ShowController extends Controller
// make paginator:
$paginator = new LengthAwarePaginator($piggyBanks, $count, $pageSize, $this->parameters->get('page'));
$paginator->setPath(route('api.v1.piggy-banks.index') . $this->buildParams());
$paginator->setPath(route('api.v1.piggy-banks.index').$this->buildParams());
/** @var PiggyBankTransformer $transformer */
$transformer = app(PiggyBankTransformer::class);
@ -98,10 +95,6 @@ class ShowController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/piggy_banks/getPiggyBank
*
* List single resource.
*
* @param PiggyBank $piggyBank
*
* @return JsonResponse
*/
public function show(PiggyBank $piggyBank): JsonResponse
{

View File

@ -40,8 +40,6 @@ class StoreController extends Controller
/**
* Constructor.
*
*/
public function __construct()
{
@ -62,9 +60,6 @@ class StoreController extends Controller
*
* Store new object.
*
* @param StoreRequest $request
*
* @return JsonResponse
* @throws FireflyException
*/
public function store(StoreRequest $request): JsonResponse

View File

@ -40,8 +40,6 @@ class UpdateController extends Controller
/**
* Constructor.
*
*/
public function __construct()
{
@ -61,11 +59,6 @@ class UpdateController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/piggy_banks/updatePiggyBank
*
* Update piggy bank.
*
* @param UpdateRequest $request
* @param PiggyBank $piggyBank
*
* @return JsonResponse
*/
public function update(UpdateRequest $request, PiggyBank $piggyBank): JsonResponse
{
@ -77,6 +70,7 @@ class UpdateController extends Controller
}
$manager = $this->getManager();
/** @var PiggyBankTransformer $transformer */
$transformer = app(PiggyBankTransformer::class);
$transformer->setParameters($this->parameters);

View File

@ -37,8 +37,6 @@ class DestroyController extends Controller
/**
* RecurrenceController constructor.
*
*/
public function __construct()
{
@ -58,10 +56,6 @@ class DestroyController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/recurrences/deleteRecurrence
*
* Delete the resource.
*
* @param Recurrence $recurrence
*
* @return JsonResponse
*/
public function destroy(Recurrence $recurrence): JsonResponse
{

View File

@ -47,8 +47,6 @@ class ListController extends Controller
/**
* RecurrenceController constructor.
*
*/
public function __construct()
{
@ -69,10 +67,6 @@ class ListController extends Controller
*
* Show transactions for this recurrence.
*
* @param Request $request
* @param Recurrence $recurrence
*
* @return JsonResponse
* @throws FireflyException
*/
public function transactions(Request $request, Recurrence $recurrence): JsonResponse
@ -103,7 +97,8 @@ class ListController extends Controller
// set page to retrieve
->setPage($this->parameters->get('page'))
// set types of transactions to return.
->setTypes($types);
->setTypes($types)
;
if (null !== $this->parameters->get('start')) {
$collector->setStart($this->parameters->get('start'));
@ -113,7 +108,7 @@ class ListController extends Controller
}
$paginator = $collector->getPaginatedGroups();
$paginator->setPath(route('api.v1.transactions.index') . $this->buildParams());
$paginator->setPath(route('api.v1.transactions.index').$this->buildParams());
$transactions = $paginator->getCollection();
/** @var TransactionGroupTransformer $transformer */

View File

@ -43,8 +43,6 @@ class ShowController extends Controller
/**
* RecurrenceController constructor.
*
*/
public function __construct()
{
@ -65,7 +63,6 @@ class ShowController extends Controller
*
* List all of them.
*
* @return JsonResponse
* @throws FireflyException
*/
public function index(): JsonResponse
@ -82,7 +79,7 @@ class ShowController extends Controller
// make paginator:
$paginator = new LengthAwarePaginator($piggyBanks, $count, $pageSize, $this->parameters->get('page'));
$paginator->setPath(route('api.v1.recurrences.index') . $this->buildParams());
$paginator->setPath(route('api.v1.recurrences.index').$this->buildParams());
/** @var RecurrenceTransformer $transformer */
$transformer = app(RecurrenceTransformer::class);
@ -99,10 +96,6 @@ class ShowController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/recurrences/getRecurrence
*
* List single resource.
*
* @param Recurrence $recurrence
*
* @return JsonResponse
*/
public function show(Recurrence $recurrence): JsonResponse
{

View File

@ -40,8 +40,6 @@ class StoreController extends Controller
/**
* RecurrenceController constructor.
*
*/
public function __construct()
{
@ -62,9 +60,6 @@ class StoreController extends Controller
*
* Store new object.
*
* @param StoreRequest $request
*
* @return JsonResponse
* @throws FireflyException
*/
public function store(StoreRequest $request): JsonResponse

View File

@ -40,8 +40,6 @@ class UpdateController extends Controller
/**
* RecurrenceController constructor.
*
*/
public function __construct()
{
@ -61,11 +59,6 @@ class UpdateController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/recurrences/updateRecurrence
*
* Update single recurrence.
*
* @param UpdateRequest $request
* @param Recurrence $recurrence
*
* @return JsonResponse
*/
public function update(UpdateRequest $request, Recurrence $recurrence): JsonResponse
{

View File

@ -38,8 +38,6 @@ class DestroyController extends Controller
/**
* RuleController constructor.
*
*/
public function __construct()
{
@ -62,10 +60,6 @@ class DestroyController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/rules/deleteRule
*
* Delete the resource.
*
* @param Rule $rule
*
* @return JsonResponse
*/
public function destroy(Rule $rule): JsonResponse
{

View File

@ -44,8 +44,6 @@ class ShowController extends Controller
/**
* RuleController constructor.
*
*/
public function __construct()
{
@ -69,7 +67,6 @@ class ShowController extends Controller
*
* List all of them.
*
* @return JsonResponse
* @throws FireflyException
*/
public function index(): JsonResponse
@ -86,7 +83,7 @@ class ShowController extends Controller
// make paginator:
$paginator = new LengthAwarePaginator($rules, $count, $pageSize, $this->parameters->get('page'));
$paginator->setPath(route('api.v1.rules.index') . $this->buildParams());
$paginator->setPath(route('api.v1.rules.index').$this->buildParams());
/** @var RuleTransformer $transformer */
$transformer = app(RuleTransformer::class);
@ -103,14 +100,11 @@ class ShowController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/rules/getRule
*
* List single resource.
*
* @param Rule $rule
*
* @return JsonResponse
*/
public function show(Rule $rule): JsonResponse
{
$manager = $this->getManager();
/** @var RuleTransformer $transformer */
$transformer = app(RuleTransformer::class);
$transformer->setParameters($this->parameters);

View File

@ -40,8 +40,6 @@ class StoreController extends Controller
/**
* RuleController constructor.
*
*/
public function __construct()
{
@ -64,15 +62,12 @@ class StoreController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/rules/storeRule
*
* Store new object.
*
* @param StoreRequest $request
*
* @return JsonResponse
*/
public function store(StoreRequest $request): JsonResponse
{
$rule = $this->ruleRepository->store($request->getAll());
$manager = $this->getManager();
/** @var RuleTransformer $transformer */
$transformer = app(RuleTransformer::class);
$transformer->setParameters($this->parameters);

View File

@ -46,8 +46,6 @@ class TriggerController extends Controller
/**
* RuleController constructor.
*
*/
public function __construct()
{
@ -68,11 +66,6 @@ class TriggerController extends Controller
/**
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/rules/testRule
*
* @param TestRequest $request
* @param Rule $rule
*
* @return JsonResponse
*/
public function testRule(TestRequest $request, Rule $rule): JsonResponse
{
@ -96,16 +89,16 @@ class TriggerController extends Controller
$ruleEngine->addOperator(['type' => 'account_id', 'value' => implode(',', $parameters['accounts'])]);
}
// file the rule(s)
$transactions = $ruleEngine->find();
$count = $transactions->count();
$paginator = new LengthAwarePaginator($transactions, $count, 31337, $this->parameters->get('page'));
$paginator->setPath(route('api.v1.rules.test', [$rule->id]) . $this->buildParams());
$paginator->setPath(route('api.v1.rules.test', [$rule->id]).$this->buildParams());
// resulting list is presented as JSON thing.
$manager = $this->getManager();
/** @var TransactionGroupTransformer $transformer */
$transformer = app(TransactionGroupTransformer::class);
$transformer->setParameters($this->parameters);
@ -121,11 +114,6 @@ class TriggerController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/rules/fireRule
*
* Execute the given rule group on a set of existing transactions.
*
* @param TriggerRequest $request
* @param Rule $rule
*
* @return JsonResponse
*/
public function triggerRule(TriggerRequest $request, Rule $rule): JsonResponse
{
@ -150,7 +138,6 @@ class TriggerController extends Controller
$ruleEngine->addOperator(['type' => 'account_id', 'value' => implode(',', $parameters['accounts'])]);
}
// fire the rule(s)
$ruleEngine->fire();

View File

@ -41,8 +41,6 @@ class UpdateController extends Controller
/**
* RuleController constructor.
*
*/
public function __construct()
{
@ -65,11 +63,6 @@ class UpdateController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/rules/updateRule
*
* Update a rule.
*
* @param UpdateRequest $request
* @param Rule $rule
*
* @return JsonResponse
*/
public function update(UpdateRequest $request, Rule $rule): JsonResponse
{

View File

@ -38,8 +38,6 @@ class DestroyController extends Controller
/**
* RuleGroupController constructor.
*
*/
public function __construct()
{
@ -62,10 +60,6 @@ class DestroyController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/rule_groups/deleteRuleGroup
*
* Delete the resource.
*
* @param RuleGroup $ruleGroup
*
* @return JsonResponse
*/
public function destroy(RuleGroup $ruleGroup): JsonResponse
{

View File

@ -43,8 +43,6 @@ class ListController extends Controller
/**
* RuleGroupController constructor.
*
*/
public function __construct()
{
@ -66,9 +64,6 @@ class ListController extends Controller
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/rule_groups/listRuleByGroup
*
* @param RuleGroup $group
*
* @return JsonResponse
* @throws FireflyException
*/
public function rules(RuleGroup $group): JsonResponse
@ -84,7 +79,7 @@ class ListController extends Controller
// make paginator:
$paginator = new LengthAwarePaginator($rules, $count, $pageSize, $this->parameters->get('page'));
$paginator->setPath(route('api.v1.rule-groups.rules', [$group->id]) . $this->buildParams());
$paginator->setPath(route('api.v1.rule-groups.rules', [$group->id]).$this->buildParams());
/** @var RuleTransformer $transformer */
$transformer = app(RuleTransformer::class);

View File

@ -44,8 +44,6 @@ class ShowController extends Controller
/**
* RuleGroupController constructor.
*
*/
public function __construct()
{
@ -68,7 +66,6 @@ class ShowController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/rule_groups/listRuleGroup
* List all of them.
*
* @return JsonResponse
* @throws FireflyException
*/
public function index(): JsonResponse
@ -84,7 +81,7 @@ class ShowController extends Controller
// make paginator:
$paginator = new LengthAwarePaginator($ruleGroups, $count, $pageSize, $this->parameters->get('page'));
$paginator->setPath(route('api.v1.rule-groups.index') . $this->buildParams());
$paginator->setPath(route('api.v1.rule-groups.index').$this->buildParams());
/** @var RuleGroupTransformer $transformer */
$transformer = app(RuleGroupTransformer::class);
@ -101,14 +98,11 @@ class ShowController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/rule_groups/getRuleGroup
*
* List single resource.
*
* @param RuleGroup $ruleGroup
*
* @return JsonResponse
*/
public function show(RuleGroup $ruleGroup): JsonResponse
{
$manager = $this->getManager();
/** @var RuleGroupTransformer $transformer */
$transformer = app(RuleGroupTransformer::class);
$transformer->setParameters($this->parameters);

View File

@ -42,8 +42,6 @@ class StoreController extends Controller
/**
* RuleGroupController constructor.
*
*/
public function __construct()
{
@ -69,10 +67,6 @@ class StoreController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/rule_groups/storeRuleGroup
*
* Store new object.
*
* @param StoreRequest $request
*
* @return JsonResponse
*/
public function store(StoreRequest $request): JsonResponse
{

View File

@ -23,7 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Controllers\Models\RuleGroup;
use Exception;
use FireflyIII\Api\V1\Controllers\Controller;
use FireflyIII\Api\V1\Requests\Models\RuleGroup\TestRequest;
use FireflyIII\Api\V1\Requests\Models\RuleGroup\TriggerRequest;
@ -47,8 +46,6 @@ class TriggerController extends Controller
/**
* RuleGroupController constructor.
*
*/
public function __construct()
{
@ -70,12 +67,7 @@ class TriggerController extends Controller
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/rule_groups/testRuleGroup
*
* @param TestRequest $request
* @param RuleGroup $group
*
* @return JsonResponse
* @throws FireflyException
*
*/
public function testGroup(TestRequest $request, RuleGroup $group): JsonResponse
{
@ -108,10 +100,11 @@ class TriggerController extends Controller
$count = $transactions->count();
$paginator = new LengthAwarePaginator($transactions, $count, 31337, $this->parameters->get('page'));
$paginator->setPath(route('api.v1.rule-groups.test', [$group->id]) . $this->buildParams());
$paginator->setPath(route('api.v1.rule-groups.test', [$group->id]).$this->buildParams());
// resulting list is presented as JSON thing.
$manager = $this->getManager();
/** @var TransactionGroupTransformer $transformer */
$transformer = app(TransactionGroupTransformer::class);
$transformer->setParameters($this->parameters);
@ -128,11 +121,7 @@ class TriggerController extends Controller
*
* Execute the given rule group on a set of existing transactions.
*
* @param TriggerRequest $request
* @param RuleGroup $group
*
* @return JsonResponse
* @throws Exception
* @throws \Exception
*/
public function triggerGroup(TriggerRequest $request, RuleGroup $group): JsonResponse
{

View File

@ -41,8 +41,6 @@ class UpdateController extends Controller
/**
* RuleGroupController constructor.
*
*/
public function __construct()
{
@ -65,11 +63,6 @@ class UpdateController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/rule_groups/updateRuleGroup
*
* Update a rule group.
*
* @param UpdateRequest $request
* @param RuleGroup $ruleGroup
*
* @return JsonResponse
*/
public function update(UpdateRequest $request, RuleGroup $ruleGroup): JsonResponse
{

View File

@ -38,8 +38,6 @@ class DestroyController extends Controller
/**
* TagController constructor.
*
*/
public function __construct()
{
@ -62,10 +60,6 @@ class DestroyController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/tags/deleteTag
*
* Delete the resource.
*
* @param Tag $tag
*
* @return JsonResponse
*/
public function destroy(Tag $tag): JsonResponse
{

View File

@ -49,8 +49,6 @@ class ListController extends Controller
/**
* TagController constructor.
*
*/
public function __construct()
{
@ -72,9 +70,6 @@ class ListController extends Controller
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/tags/listAttachmentByTag
*
* @param Tag $tag
*
* @return JsonResponse
* @throws FireflyException
*/
public function attachments(Tag $tag): JsonResponse
@ -88,7 +83,7 @@ class ListController extends Controller
// make paginator:
$paginator = new LengthAwarePaginator($attachments, $count, $pageSize, $this->parameters->get('page'));
$paginator->setPath(route('api.v1.tags.attachments', [$tag->id]) . $this->buildParams());
$paginator->setPath(route('api.v1.tags.attachments', [$tag->id]).$this->buildParams());
/** @var AttachmentTransformer $transformer */
$transformer = app(AttachmentTransformer::class);
@ -106,10 +101,6 @@ class ListController extends Controller
*
* Show all transactions.
*
* @param Request $request
* @param Tag $tag
*
* @return JsonResponse
* @throws FireflyException
*/
public function transactions(Request $request, Tag $tag): JsonResponse
@ -120,6 +111,7 @@ class ListController extends Controller
$types = $this->mapTransactionTypes($this->parameters->get('type'));
$manager = $this->getManager();
/** @var User $admin */
$admin = auth()->user();
@ -137,7 +129,8 @@ class ListController extends Controller
// set page to retrieve
->setPage($this->parameters->get('page'))
// set types of transactions to return.
->setTypes($types);
->setTypes($types)
;
if (null !== $this->parameters->get('start')) {
$collector->setStart($this->parameters->get('start'));
@ -146,7 +139,7 @@ class ListController extends Controller
$collector->setEnd($this->parameters->get('end'));
}
$paginator = $collector->getPaginatedGroups();
$paginator->setPath(route('api.v1.tags.transactions', [$tag->id]) . $this->buildParams());
$paginator->setPath(route('api.v1.tags.transactions', [$tag->id]).$this->buildParams());
$transactions = $paginator->getCollection();
/** @var TransactionGroupTransformer $transformer */

View File

@ -44,8 +44,6 @@ class ShowController extends Controller
/**
* TagController constructor.
*
*/
public function __construct()
{
@ -69,7 +67,6 @@ class ShowController extends Controller
*
* List all of them.
*
* @return JsonResponse
* @throws FireflyException
*/
public function index(): JsonResponse
@ -85,7 +82,7 @@ class ShowController extends Controller
// make paginator:
$paginator = new LengthAwarePaginator($rules, $count, $pageSize, $this->parameters->get('page'));
$paginator->setPath(route('api.v1.tags.index') . $this->buildParams());
$paginator->setPath(route('api.v1.tags.index').$this->buildParams());
/** @var TagTransformer $transformer */
$transformer = app(TagTransformer::class);
@ -102,14 +99,11 @@ class ShowController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/tags/getTag
*
* List single resource.
*
* @param Tag $tag
*
* @return JsonResponse
*/
public function show(Tag $tag): JsonResponse
{
$manager = $this->getManager();
/** @var TagTransformer $transformer */
$transformer = app(TagTransformer::class);
$transformer->setParameters($this->parameters);

View File

@ -40,8 +40,6 @@ class StoreController extends Controller
/**
* TagController constructor.
*
*/
public function __construct()
{
@ -64,15 +62,12 @@ class StoreController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/tags/storeTag
*
* Store new object.
*
* @param StoreRequest $request
*
* @return JsonResponse
*/
public function store(StoreRequest $request): JsonResponse
{
$rule = $this->repository->store($request->getAll());
$manager = $this->getManager();
/** @var TagTransformer $transformer */
$transformer = app(TagTransformer::class);
$transformer->setParameters($this->parameters);

View File

@ -41,8 +41,6 @@ class UpdateController extends Controller
/**
* TagController constructor.
*
*/
public function __construct()
{
@ -65,16 +63,12 @@ class UpdateController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/tags/updateTag
*
* Update a rule.
*
* @param UpdateRequest $request
* @param Tag $tag
*
* @return JsonResponse
*/
public function update(UpdateRequest $request, Tag $tag): JsonResponse
{
$rule = $this->repository->update($tag, $request->getAll());
$manager = $this->getManager();
/** @var TagTransformer $transformer */
$transformer = app(TagTransformer::class);
$transformer->setParameters($this->parameters);

View File

@ -44,8 +44,6 @@ class DestroyController extends Controller
/**
* TransactionController constructor.
*
*/
public function __construct()
{
@ -71,16 +69,13 @@ class DestroyController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/transactions/deleteTransaction
*
* Remove the specified resource from storage.
*
* @param TransactionGroup $transactionGroup
*
* @return JsonResponse
*/
public function destroy(TransactionGroup $transactionGroup): JsonResponse
{
app('log')->debug(sprintf('Now in %s', __METHOD__));
// grab asset account(s) from group:
$accounts = [];
/** @var TransactionJournal $journal */
foreach ($transactionGroup->transactionJournals as $journal) {
/** @var Transaction $transaction */
@ -111,10 +106,6 @@ class DestroyController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/transactions/deleteTransactionJournal
*
* Remove the specified resource from storage.
*
* @param TransactionJournal $transactionJournal
*
* @return JsonResponse
*/
public function destroyJournal(TransactionJournal $transactionJournal): JsonResponse
{

View File

@ -47,8 +47,6 @@ class ListController extends Controller
/**
* TransactionController constructor.
*
*/
public function __construct()
{
@ -70,9 +68,6 @@ class ListController extends Controller
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/transactions/listAttachmentByTransaction
*
* @param TransactionGroup $transactionGroup
*
* @return JsonResponse
* @throws FireflyException
*/
public function attachments(TransactionGroup $transactionGroup): JsonResponse
@ -89,7 +84,7 @@ class ListController extends Controller
// make paginator:
$paginator = new LengthAwarePaginator($attachments, $count, $pageSize, $this->parameters->get('page'));
$paginator->setPath(route('api.v1.transactions.attachments', [$transactionGroup->id]) . $this->buildParams());
$paginator->setPath(route('api.v1.transactions.attachments', [$transactionGroup->id]).$this->buildParams());
/** @var AttachmentTransformer $transformer */
$transformer = app(AttachmentTransformer::class);
@ -105,9 +100,6 @@ class ListController extends Controller
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/transactions/listEventByTransaction
*
* @param TransactionGroup $transactionGroup
*
* @return JsonResponse
* @throws FireflyException
*/
public function piggyBankEvents(TransactionGroup $transactionGroup): JsonResponse
@ -122,7 +114,7 @@ class ListController extends Controller
$events = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
// make paginator:
$paginator = new LengthAwarePaginator($events, $count, $pageSize, $this->parameters->get('page'));
$paginator->setPath(route('api.v1.transactions.piggy-bank-events', [$transactionGroup->id]) . $this->buildParams());
$paginator->setPath(route('api.v1.transactions.piggy-bank-events', [$transactionGroup->id]).$this->buildParams());
/** @var PiggyBankEventTransformer $transformer */
$transformer = app(PiggyBankEventTransformer::class);
@ -143,9 +135,6 @@ class ListController extends Controller
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/transactions/listLinksByJournal
*
* @param TransactionJournal $transactionJournal
*
* @return JsonResponse
* @throws FireflyException
*/
public function transactionLinks(TransactionJournal $transactionJournal): JsonResponse
@ -158,7 +147,7 @@ class ListController extends Controller
// make paginator:
$paginator = new LengthAwarePaginator($journalLinks, $count, $pageSize, $this->parameters->get('page'));
$paginator->setPath(route('api.v1.transaction-journals.transaction-links', [$transactionJournal->id]) . $this->buildParams());
$paginator->setPath(route('api.v1.transaction-journals.transaction-links', [$transactionJournal->id]).$this->buildParams());
/** @var TransactionLinkTransformer $transformer */
$transformer = app(TransactionLinkTransformer::class);

View File

@ -51,9 +51,6 @@ class ShowController extends Controller
*
* Show all transactions.
*
* @param Request $request
*
* @return JsonResponse
* @throws FireflyException
*/
public function index(Request $request): JsonResponse
@ -64,6 +61,7 @@ class ShowController extends Controller
$types = $this->mapTransactionTypes($this->parameters->get('type'));
$manager = $this->getManager();
/** @var User $admin */
$admin = auth()->user();
@ -79,12 +77,13 @@ class ShowController extends Controller
// set page to retrieve
->setPage($this->parameters->get('page'))
// set types of transactions to return.
->setTypes($types);
->setTypes($types)
;
if (null !== $this->parameters->get('start') || null !== $this->parameters->get('end')) {
$collector->setRange($this->parameters->get('start'), $this->parameters->get('end'));
}
$paginator = $collector->getPaginatedGroups();
$paginator->setPath(route('api.v1.transactions.index') . $this->buildParams());
$paginator->setPath(route('api.v1.transactions.index').$this->buildParams());
$transactions = $paginator->getCollection();
/** @var TransactionGroupTransformer $transformer */
@ -102,10 +101,6 @@ class ShowController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/transactions/getTransactionByJournal
*
* Show a single transaction, by transaction journal.
*
* @param TransactionJournal $transactionJournal
*
* @return JsonResponse
*/
public function showJournal(TransactionJournal $transactionJournal): JsonResponse
{
@ -117,16 +112,14 @@ class ShowController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/transactions/getTransaction
*
* Show a single transaction.
*
* @param TransactionGroup $transactionGroup
*
* @return JsonResponse
*/
public function show(TransactionGroup $transactionGroup): JsonResponse
{
$manager = $this->getManager();
/** @var User $admin */
$admin = auth()->user();
// use new group collector:
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
@ -135,12 +128,14 @@ class ShowController extends Controller
// filter on transaction group.
->setTransactionGroup($transactionGroup)
// all info needed for the API:
->withAPIInformation();
->withAPIInformation()
;
$selectedGroup = $collector->getGroups()->first();
if (null === $selectedGroup) {
throw new NotFoundHttpException();
}
/** @var TransactionGroupTransformer $transformer */
$transformer = app(TransactionGroupTransformer::class);
$transformer->setParameters($this->parameters);

View File

@ -38,7 +38,6 @@ use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Log;
use Illuminate\Validation\ValidationException;
use League\Fractal\Resource\Item;
use Validator;
/**
* Class StoreController
@ -51,8 +50,6 @@ class StoreController extends Controller
/**
* TransactionController constructor.
*
*/
public function __construct()
{
@ -76,9 +73,6 @@ class StoreController extends Controller
*
* Store a new transaction.
*
* @param StoreRequest $request
*
* @return JsonResponse
* @throws FireflyException|ValidationException
*/
public function store(StoreRequest $request): JsonResponse
@ -88,22 +82,25 @@ class StoreController extends Controller
$data['user'] = auth()->user()->id;
Log::channel('audit')
->info('Store new transaction over API.', $data);
->info('Store new transaction over API.', $data)
;
try {
$transactionGroup = $this->groupRepository->store($data);
} catch (DuplicateTransactionException $e) { // @phpstan-ignore-line
app('log')->warning('Caught a duplicate transaction. Return error message.');
$validator = Validator::make(
$validator = \Validator::make(
['transactions' => [['description' => $e->getMessage()]]],
['transactions.0.description' => new IsDuplicateTransaction()]
);
throw new ValidationException($validator); // @phpstan-ignore-line
} catch (FireflyException $e) { // @phpstan-ignore-line
app('log')->warning('Caught an exception. Return error message.');
app('log')->error($e->getMessage());
$message = sprintf('Internal exception: %s', $e->getMessage());
$validator = Validator::make(['transactions' => [['description' => $message]]], ['transactions.0.description' => new IsDuplicateTransaction()]);
$validator = \Validator::make(['transactions' => [['description' => $message]]], ['transactions.0.description' => new IsDuplicateTransaction()]);
throw new ValidationException($validator); // @phpstan-ignore-line
}
app('preferences')->mark();
@ -112,8 +109,10 @@ class StoreController extends Controller
event(new StoredTransactionGroup($transactionGroup, $applyRules, $fireWebhooks));
$manager = $this->getManager();
/** @var User $admin */
$admin = auth()->user();
// use new group collector:
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
@ -122,12 +121,14 @@ class StoreController extends Controller
// filter on transaction group.
->setTransactionGroup($transactionGroup)
// all info needed for the API:
->withAPIInformation();
->withAPIInformation()
;
$selectedGroup = $collector->getGroups()->first();
if (null === $selectedGroup) {
throw new FireflyException('200032: Cannot find transaction. Possibly, a rule deleted this transaction after its creation.');
}
/** @var TransactionGroupTransformer $transformer */
$transformer = app(TransactionGroupTransformer::class);
$transformer->setParameters($this->parameters);

View File

@ -44,8 +44,6 @@ class UpdateController extends Controller
/**
* TransactionController constructor.
*
*/
public function __construct()
{
@ -68,11 +66,6 @@ class UpdateController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/transactions/updateTransaction
*
* Update a transaction.
*
* @param UpdateRequest $request
* @param TransactionGroup $transactionGroup
*
* @return JsonResponse
*/
public function update(UpdateRequest $request, TransactionGroup $transactionGroup): JsonResponse
{
@ -89,6 +82,7 @@ class UpdateController extends Controller
/** @var User $admin */
$admin = auth()->user();
// use new group collector:
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
@ -97,12 +91,14 @@ class UpdateController extends Controller
// filter on transaction group.
->setTransactionGroup($transactionGroup)
// all info needed for the API:
->withAPIInformation();
->withAPIInformation()
;
$selectedGroup = $collector->getGroups()->first();
if (null === $selectedGroup) {
throw new NotFoundHttpException();
}
/** @var TransactionGroupTransformer $transformer */
$transformer = app(TransactionGroupTransformer::class);
$transformer->setParameters($this->parameters);

View File

@ -31,7 +31,6 @@ use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\Repositories\UserGroups\Currency\CurrencyRepositoryInterface;
use FireflyIII\User;
use Illuminate\Http\JsonResponse;
use Validator;
/**
* Class DestroyController
@ -43,8 +42,6 @@ class DestroyController extends Controller
/**
* CurrencyRepository constructor.
*
*/
public function __construct()
{
@ -66,9 +63,6 @@ class DestroyController extends Controller
*
* Remove the specified resource from storage.
*
* @param TransactionCurrency $currency
*
* @return JsonResponse
* @throws FireflyException
*/
public function destroy(TransactionCurrency $currency): JsonResponse
@ -80,15 +74,15 @@ class DestroyController extends Controller
if (!$this->userRepository->hasRole($admin, 'owner')) {
// access denied:
$messages = ['currency_code' => '200005: You need the "owner" role to do this.'];
Validator::make([], $rules, $messages)->validate();
\Validator::make([], $rules, $messages)->validate();
}
if ($this->repository->currencyInUse($currency)) {
$messages = ['currency_code' => '200006: Currency in use.'];
Validator::make([], $rules, $messages)->validate();
\Validator::make([], $rules, $messages)->validate();
}
if ($this->repository->isFallbackCurrency($currency)) {
$messages = ['currency_code' => '200026: Currency is fallback.'];
Validator::make([], $rules, $messages)->validate();
\Validator::make([], $rules, $messages)->validate();
}
$this->repository->destroy($currency);

Some files were not shown because too many files have changed in this diff Show More