diff --git a/app/Api/V2/Controllers/JsonApi/AccountController.php b/app/Api/V2/Controllers/JsonApi/AccountController.php deleted file mode 100644 index e9f2c8bf62..0000000000 --- a/app/Api/V2/Controllers/JsonApi/AccountController.php +++ /dev/null @@ -1,113 +0,0 @@ -repository() - ->queryAll() - ->withRequest($request) - ->get() - ; - - // do something custom... - - return new DataResponse($models); - } - - /** - * Fetch zero to one JSON API resource by id. - * - * @return Responsable|Response - */ - public function show(AccountSchema $schema, AccountSingleQuery $request, Account $account) - { - Log::debug(__METHOD__); - $model = $schema->repository() - ->queryOne($account) - ->withRequest($request) - ->first() - ; - Log::debug(sprintf('%s again!', __METHOD__)); - - // do something custom... - - return new DataResponse($model); - } - - // public function readAccountBalances(AnonymousQuery $query, AccountBalanceSchema $schema, Account $account): Responsable - // { - // $schema = JsonApi::server()->schemas()->schemaFor('account-balances'); - // - // $models = $schema - // ->repository() - // ->queryAll() - // ->withRequest($query) - // ->withAccount($account) - // ->get() - // ; - // - // return DataResponse::make($models); - // } -} diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 1c7c0b5f17..e8352aa791 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -36,8 +36,6 @@ use Illuminate\Session\TokenMismatchException; use Illuminate\Support\Arr; use Illuminate\Validation\ValidationException as LaravelValidationException; use Laravel\Passport\Exceptions\OAuthServerException as LaravelOAuthException; -use LaravelJsonApi\Core\Exceptions\JsonApiException; -use LaravelJsonApi\Exceptions\ExceptionParser; use League\OAuth2\Server\Exception\OAuthServerException; use Symfony\Component\HttpFoundation\Exception\SuspiciousOperationException; use Symfony\Component\HttpFoundation\Response; @@ -65,7 +63,6 @@ class Handler extends ExceptionHandler HttpException::class, SuspiciousOperationException::class, BadHttpHeaderException::class, - JsonApiException::class, ]; /** @@ -73,9 +70,6 @@ class Handler extends ExceptionHandler */ public function register(): void { - $this->renderable( - ExceptionParser::make()->renderable() - ); } /** diff --git a/app/JsonApi/Rules/IsValidFilter.php b/app/JsonApi/Rules/IsValidFilter.php deleted file mode 100644 index 9c8b0a4319..0000000000 --- a/app/JsonApi/Rules/IsValidFilter.php +++ /dev/null @@ -1,54 +0,0 @@ -allowed = $keys; - $this->allowed[] = 'user_group_id'; - } - - #[\Override] - public function validate(string $attribute, mixed $value, \Closure $fail): void - { - if ('filter' !== $attribute) { - $fail('validation.bad_api_filter')->translate(); - } - if (!is_array($value)) { - $value = explode(',', $value); - } - foreach ($value as $key => $val) { - if (!in_array($key, $this->allowed, true)) { - $fail('validation.bad_api_filter')->translate(['filter' => $key]); - } - } - } -} diff --git a/app/JsonApi/Rules/IsValidPage.php b/app/JsonApi/Rules/IsValidPage.php deleted file mode 100644 index b0c1182818..0000000000 --- a/app/JsonApi/Rules/IsValidPage.php +++ /dev/null @@ -1,53 +0,0 @@ -allowed = $keys; - } - - #[\Override] - public function validate(string $attribute, mixed $value, \Closure $fail): void - { - if ('page' !== $attribute) { - $fail('validation.bad_api_filter')->translate(); - } - if (!is_array($value)) { - $value = explode(',', $value); - } - foreach ($value as $key => $val) { - if (!in_array($key, $this->allowed, true)) { - $fail('validation.bad_api_page')->translate(); - } - } - } -} diff --git a/app/JsonApi/V2/AccountBalances/AccountBalanceRepository.php b/app/JsonApi/V2/AccountBalances/AccountBalanceRepository.php deleted file mode 100644 index 38aa5bb460..0000000000 --- a/app/JsonApi/V2/AccountBalances/AccountBalanceRepository.php +++ /dev/null @@ -1,46 +0,0 @@ -withServer($this->server) - ->withSchema($this->schema) - ; - } -} diff --git a/app/JsonApi/V2/AccountBalances/AccountBalanceResource.php b/app/JsonApi/V2/AccountBalances/AccountBalanceResource.php deleted file mode 100644 index d4a6841575..0000000000 --- a/app/JsonApi/V2/AccountBalances/AccountBalanceResource.php +++ /dev/null @@ -1,44 +0,0 @@ - $this->resource->amount, - 'amount' => $this->resource->amount, - ]; - } - - /** - * Get the resource id. - */ - public function id(): string - { - return $this->resource->id; - } - - /** - * Get the resource's relationships. - * - * @param null|Request $request - */ - public function relationships($request): iterable - { - return [ - $this->relation('account')->withData($this->resource->getAccount()), - ]; - } -} diff --git a/app/JsonApi/V2/AccountBalances/AccountBalanceSchema.php b/app/JsonApi/V2/AccountBalances/AccountBalanceSchema.php deleted file mode 100644 index e0c2d13bb9..0000000000 --- a/app/JsonApi/V2/AccountBalances/AccountBalanceSchema.php +++ /dev/null @@ -1,50 +0,0 @@ -withServer($this->server) - ->withSchema($this) - ; - } -} diff --git a/app/JsonApi/V2/AccountBalances/Capabilities/AccountBalanceQuery.php b/app/JsonApi/V2/AccountBalances/Capabilities/AccountBalanceQuery.php deleted file mode 100644 index 6f4b6fd581..0000000000 --- a/app/JsonApi/V2/AccountBalances/Capabilities/AccountBalanceQuery.php +++ /dev/null @@ -1,59 +0,0 @@ -account = $account; - - return $this; - } -} diff --git a/app/JsonApi/V2/Accounts/AccountCollectionQuery.php b/app/JsonApi/V2/Accounts/AccountCollectionQuery.php deleted file mode 100644 index e4fac9c4e9..0000000000 --- a/app/JsonApi/V2/Accounts/AccountCollectionQuery.php +++ /dev/null @@ -1,77 +0,0 @@ - [ - 'nullable', - 'array', - JsonApiRule::fieldSets(), - ], - 'userGroupId' => [ - 'nullable', - 'integer', - new IsAllowedGroupAction(Account::class, request()->method()), - ], - 'startPeriod' => [ - 'nullable', - 'date', - new IsDateOrTime(), - new IsValidDateRange(), - ], - 'endPeriod' => [ - 'nullable', - 'date', - new IsDateOrTime(), - new IsValidDateRange(), - ], - 'filter' => [ - 'nullable', - 'array', - JsonApiRule::filter($validFilters), - new IsValidAccountType(), - ], - 'include' => [ - 'nullable', - 'string', - JsonApiRule::includePaths(), - ], - 'page' => [ - 'nullable', - 'array', - JsonApiRule::page(), - ], - 'sort' => [ - 'nullable', - 'string', - JsonApiRule::sort(), - ], - 'withCount' => [ - 'nullable', - 'string', - JsonApiRule::countable(), - ], - ]; - } -} diff --git a/app/JsonApi/V2/Accounts/AccountRepository.php b/app/JsonApi/V2/Accounts/AccountRepository.php deleted file mode 100644 index 039f52c355..0000000000 --- a/app/JsonApi/V2/Accounts/AccountRepository.php +++ /dev/null @@ -1,113 +0,0 @@ -enrichSingle($account); - } - - public function queryAll(): Capabilities\AccountQuery - { - Log::debug(__METHOD__); - - return Capabilities\AccountQuery::make() - ->withUserGroup($this->userGroup) - ->withServer($this->server) - ->withSchema($this->schema) - ; - } - - protected function crud(): Capabilities\CrudAccount - { - Log::debug(__METHOD__); - - return Capabilities\CrudAccount::make(); - } - - /** - * TODO piggy banks - * TODO transactions - */ - protected function relations(): CrudRelations - { - Log::debug(__METHOD__); - - return Capabilities\CrudAccountRelations::make(); - } -} diff --git a/app/JsonApi/V2/Accounts/AccountRequest.php b/app/JsonApi/V2/Accounts/AccountRequest.php deleted file mode 100644 index faf9cf9b78..0000000000 --- a/app/JsonApi/V2/Accounts/AccountRequest.php +++ /dev/null @@ -1,53 +0,0 @@ -convertString('type'); - // var_dump($types);exit; - - return [ - 'name' => ['required', 'max:1024', 'min:1'], // , new IsUniqueAccount() - 'account_type' => ['required', 'max:1024', 'min:1', sprintf('in:%s', $types)], - // 'iban' => ['iban', 'nullable', new UniqueIban(null, $type)], - // 'bic' => 'bic|nullable', - // 'account_number' => ['min:1', 'max:255', 'nullable', new UniqueAccountNumber(null, $type)], - // 'opening_balance' => 'numeric|required_with:opening_balance_date|nullable', - // 'opening_balance_date' => 'date|required_with:opening_balance|nullable', - // 'virtual_balance' => 'numeric|nullable', - // 'order' => 'numeric|nullable', - // 'currency_id' => 'numeric|exists:transaction_currencies,id', - // 'currency_code' => 'min:3|max:3|exists:transaction_currencies,code', - // 'active' => [new IsBoolean()], - // 'include_net_worth' => [new IsBoolean()], - // 'account_role' => sprintf('nullable|in:%s|required_if:type,asset', $accountRoles), - // 'credit_card_type' => sprintf('nullable|in:%s|required_if:account_role,ccAsset', $ccPaymentTypes), - // 'monthly_payment_date' => 'nullable|date|required_if:account_role,ccAsset|required_if:credit_card_type,monthlyFull', - // 'liability_type' => 'nullable|required_if:type,liability|required_if:type,liabilities|in:loan,debt,mortgage', - // 'liability_amount' => ['required_with:liability_start_date', new IsValidPositiveAmount()], - // 'liability_start_date' => 'required_with:liability_amount|date', - // 'liability_direction' => 'nullable|required_if:type,liability|required_if:type,liabilities|in:credit,debit', - // 'interest' => 'min:0|max:100|numeric', - // 'interest_period' => sprintf('nullable|in:%s', implode(',', config('firefly.interest_periods'))), - // 'notes' => 'min:0|max:32768', - ]; - } -} diff --git a/app/JsonApi/V2/Accounts/AccountResource.php b/app/JsonApi/V2/Accounts/AccountResource.php deleted file mode 100644 index c88e7405b7..0000000000 --- a/app/JsonApi/V2/Accounts/AccountResource.php +++ /dev/null @@ -1,83 +0,0 @@ - $this->resource->created_at, - 'updated_at' => $this->resource->updated_at, - 'name' => $this->resource->name, - 'active' => $this->resource->active, - 'order' => $this->resource->order, - 'iban' => $this->resource->iban, - 'account_type' => $this->resource->account_type_string, - 'account_role' => $this->resource->account_role, - 'account_number' => '' === $this->resource->account_number ? null : $this->resource->account_number, - - // currency (if the account has a currency setting, otherwise NULL). - 'currency_id' => $this->resource->currency_id, - 'currency_name' => $this->resource->currency_name, - 'currency_code' => $this->resource->currency_code, - 'currency_symbol' => $this->resource->currency_symbol, - 'currency_decimal_places' => $this->resource->currency_decimal_places, - 'is_multi_currency' => '1' === $this->resource->is_multi_currency, - - // balances - 'balance' => $this->resource->balance, - 'native_balance' => $this->resource->native_balance, - - // liability things - 'liability_direction' => $this->resource->liability_direction, - 'interest' => $this->resource->interest, - 'interest_period' => $this->resource->interest_period, - 'current_debt' => $this->resource->current_debt, // TODO may be removed in the future. - - // other things - 'last_activity' => $this->resource->last_activity, - - // object group - 'object_group_id' => $this->resource->object_group_id, - 'object_group_title' => $this->resource->object_group_title, - 'object_group_order' => $this->resource->object_group_order, - ]; - } - - /** - * Get the resource id. - */ - public function id(): string - { - return (string) $this->resource->id; - } - - /** - * Get the resource's relationships. - * - * @param null|Request $request - */ - public function relationships($request): iterable - { - return [ - $this->relation('user')->withData($this->resource->user), - ]; - } -} diff --git a/app/JsonApi/V2/Accounts/AccountResourceOld.php b/app/JsonApi/V2/Accounts/AccountResourceOld.php deleted file mode 100644 index 5e2298b873..0000000000 --- a/app/JsonApi/V2/Accounts/AccountResourceOld.php +++ /dev/null @@ -1,115 +0,0 @@ - $this->resource->created_at, - 'updated_at' => $this->resource->updated_at, - 'name' => $this->resource->name, - - // 'virtual_balance' => $this->resource->virtual_balance, - // 'native_balance' => $this->resource->native_balance, - // 'user' => $this->resource->user_array, - // 'balances' => [] - // - - // balance (in currency, on date) - // 'current_balance' => $this->resource->current_balance, - // 'current_balance' => app('steam')->bcround(app('steam')->balance($account, $date), $decimalPlaces), - // 'current_balance_date' => $date->toAtomString(), - - // 'notes' => $this->repository->getNoteText($account), - // 'monthly_payment_date' => $monthlyPaymentDate, - // 'credit_card_type' => $creditCardType, - // 'account_number' => $this->repository->getMetaValue($account, 'account_number'), - // 'bic' => $this->repository->getMetaValue($account, 'BIC'), - // 'opening_balance' => $openingBalance, - // 'opening_balance_date' => $openingBalanceDate, - // 'liability_type' => $liabilityType, - // 'liability_direction' => $liabilityDirection, - // 'interest' => $interest, - // 'interest_period' => $interestPeriod, - // 'current_debt' => $this->repository->getMetaValue($account, 'current_debt'), - // 'include_net_worth' => $includeNetWorth, - // 'longitude' => $longitude, - // 'latitude' => $latitude, - // 'zoom_level' => $zoomLevel, - - // 'order' => $order, - - // 'native_currency_id' => (string) $this->default->id, - // 'native_currency_code' => $this->default->code, - // 'native_currency_symbol' => $this->default->symbol, - // 'native_currency_decimal_places' => $this->default->decimal_places, - // - // // balance: - // 'current_balance' => $balance, - // 'native_current_balance' => $nativeBalance, - // 'current_balance_date' => $this->getDate()->endOfDay()->toAtomString(), - // - // // balance difference - // 'balance_difference' => $balanceDiff, - // 'native_balance_difference' => $nativeBalanceDiff, - // 'balance_difference_start' => $diffStart, - // 'balance_difference_end' => $diffEnd, - // - // - // // liability stuff - // 'liability_type' => $liabilityType, - // - // // object group - // 'object_group_id' => null !== $objectGroupId ? (string) $objectGroupId : null, - // 'object_group_order' => $objectGroupOrder, - // 'object_group_title' => $objectGroupTitle, - // 'notes' => $this->repository->getNoteText($account), - // 'monthly_payment_date' => $monthlyPaymentDate, - // 'credit_card_type' => $creditCardType, - // 'bic' => $this->repository->getMetaValue($account, 'BIC'), - // 'virtual_balance' => number_format((float) $account->virtual_balance, $decimalPlaces, '.', ''), - // 'opening_balance' => $openingBalance, - // 'opening_balance_date' => $openingBalanceDate, - // 'include_net_worth' => $includeNetWorth, - // 'longitude' => $longitude, - // 'latitude' => $latitude, - // 'zoom_level' => $zoomLevel, - ]; - } - - /** - * Get the resource's relationships. - * - * @param null|Request $request - */ - public function relationships($request): iterable - { - return [ - $this->relation('user')->withData($this->resource->user), - $this->relation('currency')->withData($this->resource->transactionCurrency), - // $this->relation('account_balances')->withData($this->resource->balances), - ]; - } -} diff --git a/app/JsonApi/V2/Accounts/AccountSchema.php b/app/JsonApi/V2/Accounts/AccountSchema.php deleted file mode 100644 index 707b722b1a..0000000000 --- a/app/JsonApi/V2/Accounts/AccountSchema.php +++ /dev/null @@ -1,112 +0,0 @@ -sortable(), - Attribute::make('active')->sortable(), - Attribute::make('order')->sortable(), - Attribute::make('iban')->sortable(), - Attribute::make('account_type'), - Attribute::make('account_role'), - Attribute::make('account_number')->sortable(), - - // currency - Attribute::make('currency_id'), - Attribute::make('currency_name'), - Attribute::make('currency_code'), - Attribute::make('currency_symbol'), - Attribute::make('currency_decimal_places'), - Attribute::make('is_multi_currency'), - - // balance - Attribute::make('balance')->sortable(), - Attribute::make('native_balance')->sortable(), - - // liability things - Attribute::make('liability_direction'), - Attribute::make('interest'), - Attribute::make('interest_period'), - // Attribute::make('current_debt')->sortable(), - - // TODO credit card fields. - - // dynamic data - Attribute::make('last_activity')->sortable(), - Attribute::make('balance_difference')->sortable(), // only used for sort. - - // group - Attribute::make('object_group_id'), - Attribute::make('object_group_title'), - Attribute::make('object_group_order'), - - // relations. - HasOne::make('user')->readOnly(), - ]; - } - - /** - * Get the resource filters. - */ - public function filters(): array - { - Log::debug(__METHOD__); - $array = []; - $config = config('api.valid_api_filters')[Account::class]; - foreach ($config as $entry) { - $array[] = Filter::make($entry); - } - - return $array; - } - - public function pagination(): EnumerablePagination - { - Log::debug(__METHOD__); - - return EnumerablePagination::make(); - } - - public function repository(): AccountRepository - { - Log::debug(__METHOD__); - $this->setUserGroup($this->server->getUsergroup()); - - return AccountRepository::make() - ->withServer($this->server) - ->withSchema($this) - ->withUserGroup($this->userGroup) - ; - } -} diff --git a/app/JsonApi/V2/Accounts/AccountSchemaOld.php b/app/JsonApi/V2/Accounts/AccountSchemaOld.php deleted file mode 100644 index 9494cb937b..0000000000 --- a/app/JsonApi/V2/Accounts/AccountSchemaOld.php +++ /dev/null @@ -1,69 +0,0 @@ -sortable()->readOnly(), - DateTime::make('updated_at')->sortable()->readOnly(), - Str::make('name')->sortable(), - // Str::make('account_type'), - // Str::make('virtual_balance'), - // Str::make('iban'), - // Boolean::make('active'), - // Number::make('order'), - HasOne::make('user')->readOnly(), - // HasMany::make('account_balances'), - ]; - } - - /** - * Filters mentioned here can be used to filter the results. - * TODO write down exactly how this works. - */ - public function filters(): array - { - return [ - WhereIdIn::make($this), - ]; - } - - /** - * Get the resource paginator. - */ - public function pagination(): ?Paginator - { - return PagePagination::make(); - } -} diff --git a/app/JsonApi/V2/Accounts/AccountSingleQuery.php b/app/JsonApi/V2/Accounts/AccountSingleQuery.php deleted file mode 100644 index b6729dc444..0000000000 --- a/app/JsonApi/V2/Accounts/AccountSingleQuery.php +++ /dev/null @@ -1,45 +0,0 @@ - [ - 'nullable', - 'array', - JsonApiRule::fieldSets(), - ], - 'filter' => [ - 'nullable', - 'array', - JsonApiRule::filter()->forget('id'), - ], - 'include' => [ - 'nullable', - 'string', - JsonApiRule::includePaths(), - ], - 'page' => JsonApiRule::notSupported(), - 'sort' => JsonApiRule::notSupported(), - 'withCount' => [ - 'nullable', - 'string', - JsonApiRule::countable(), - ], - ]; - } -} diff --git a/app/JsonApi/V2/Accounts/Capabilities/AccountQuery.php b/app/JsonApi/V2/Accounts/Capabilities/AccountQuery.php deleted file mode 100644 index efd2dae2de..0000000000 --- a/app/JsonApi/V2/Accounts/Capabilities/AccountQuery.php +++ /dev/null @@ -1,142 +0,0 @@ -queryParameters->sortFields(); - - // collect pagination based on the page - $pagination = $this->filtersPagination($this->queryParameters->page()); - - // check if we need all accounts, regardless of pagination - // This is necessary when the user wants to sort on specific params. - $needsAll = $this->needsFullDataset(Account::class, $sort); - - // params that were not recognised, may be my own custom stuff. - $otherParams = $this->getOtherParams($this->queryParameters->unrecognisedParameters()); - - // start the query - $query = $this->userGroup->accounts(); - - // add sort and filter parameters to the query. - $query = $this->addSortParams(Account::class, $query, $sort); - $query = $this->addFilterParams(Account::class, $query, $this->queryParameters->filter()); - - // collect the result. - $collection = $query->get(['accounts.*']); - // sort the data after the query, and return it right away. - $collection = $this->sortCollection(Account::class, $collection, $sort); - - // if the entire collection needs to be enriched and sorted, do so now: - $totalCount = $collection->count(); - Log::debug(sprintf('Total is %d', $totalCount)); - if ($needsAll) { - Log::debug('Needs the entire collection'); - // enrich the entire collection - $enrichment = new AccountEnrichment(); - $enrichment->setStart($otherParams['start'] ?? null); - $enrichment->setEnd($otherParams['end'] ?? null); - $collection = $enrichment->enrich($collection); - - // TODO sort the set based on post-query sort options: - $collection = $this->postQuerySort(Account::class, $collection, $sort); - - // take the current page from the enriched set. - $currentPage = $collection->skip(($pagination['number'] - 1) * $pagination['size'])->take($pagination['size']); - } - if (!$needsAll) { - Log::debug('Needs only partial collection'); - // take from the collection the filtered page + page number: - $currentPage = $collection->skip(($pagination['number'] - 1) * $pagination['size'])->take($pagination['size']); - - // enrich only the current page. - $enrichment = new AccountEnrichment(); - $enrichment->setStart($otherParams['start'] ?? null); - $enrichment->setEnd($otherParams['end'] ?? null); - $currentPage = $enrichment->enrich($currentPage); - } - // get current page? - Log::debug(sprintf('Skip %d, take %d', ($pagination['number'] - 1) * $pagination['size'], $pagination['size'])); - // $currentPage = $collection->skip(($pagination['number'] - 1) * $pagination['size'])->take($pagination['size']); - Log::debug(sprintf('New collection size: %d', $currentPage->count())); - - // TODO add filters after the query, if there are filters that cannot be applied to the database - // TODO same for sort things. - - return new LengthAwarePaginator($currentPage, $totalCount, $pagination['size'], $pagination['number']); - } - - #[\Override] - public function getOrPaginate(?array $page): iterable - { - exit('here weare'); - // TODO: Implement getOrPaginate() method. - } - - #[\Override] - public function paginate(array $page): Page - { - exit('here weare'); - // TODO: Implement paginate() method. - } -} diff --git a/app/JsonApi/V2/Accounts/Capabilities/CrudAccount.php b/app/JsonApi/V2/Accounts/Capabilities/CrudAccount.php deleted file mode 100644 index aec8e399dc..0000000000 --- a/app/JsonApi/V2/Accounts/Capabilities/CrudAccount.php +++ /dev/null @@ -1,61 +0,0 @@ -getOtherParams($this->request->query->all()); - - Log::debug(__METHOD__); - // enrich the collected data - $enrichment = new AccountEnrichment(); - - // set start and date, if present. - $enrichment->setStart($otherParams['start'] ?? null); - $enrichment->setEnd($otherParams['end'] ?? null); - - return $enrichment->enrichSingle($account); - } -} diff --git a/app/JsonApi/V2/Accounts/Capabilities/CrudAccountRelations.php b/app/JsonApi/V2/Accounts/Capabilities/CrudAccountRelations.php deleted file mode 100644 index 0386b9b62d..0000000000 --- a/app/JsonApi/V2/Accounts/Capabilities/CrudAccountRelations.php +++ /dev/null @@ -1,29 +0,0 @@ -detectUserGroup(); - $this->setUserGroup($res); - } - - /** - * Get the server's list of schemas. - */ - protected function allSchemas(): array - { - // Log::debug(__METHOD__); - - return [ - AccountSchema::class, - UserSchema::class, - // AccountBalanceSchema::class, - ]; - } -} diff --git a/app/JsonApi/V2/Users/UserResource.php b/app/JsonApi/V2/Users/UserResource.php deleted file mode 100644 index 137325e65d..0000000000 --- a/app/JsonApi/V2/Users/UserResource.php +++ /dev/null @@ -1,41 +0,0 @@ - $this->resource->created_at, - 'updated_at' => $this->resource->updated_at, - 'email' => $this->resource->email, - ]; - } - - /** - * Get the resource's relationships. - * - * @param null|Request $request - */ - public function relationships($request): iterable - { - return [ - // @TODO - ]; - } -} diff --git a/app/JsonApi/V2/Users/UserSchema.php b/app/JsonApi/V2/Users/UserSchema.php deleted file mode 100644 index 8a32b34676..0000000000 --- a/app/JsonApi/V2/Users/UserSchema.php +++ /dev/null @@ -1,55 +0,0 @@ -sortable()->readOnly(), - DateTime::make('updated_at')->sortable()->readOnly(), - Str::make('email'), - HasMany::make('accounts'), - ]; - } - - /** - * Get the resource filters. - */ - public function filters(): array - { - return [ - WhereIdIn::make($this), - ]; - } - - /** - * Get the resource paginator. - */ - public function pagination(): ?Paginator - { - return PagePagination::make(); - } -} diff --git a/app/Support/Http/Api/ParsesQueryFilters.php b/app/Support/Http/Api/ParsesQueryFilters.php deleted file mode 100644 index a3252eebee..0000000000 --- a/app/Support/Http/Api/ParsesQueryFilters.php +++ /dev/null @@ -1,75 +0,0 @@ -filter()?->value($field, []) ?? []; - - return is_string($array) ? [$array] : $array; - } - - private function dateOrToday(QueryParameters $parameters, string $field): Carbon - { - $date = today(); - - $value = $parameters->filter()?->value($field, date('Y-m-d')); - - if (is_array($value)) { - Log::error(sprintf('Multiple values for date field "%s". Using first value.', $field)); - $value = $value[0]; - } - - try { - $date = Carbon::createFromFormat('Y-m-d', $value, config('app.timezone')); - } catch (InvalidFormatException $e) { - Log::debug(sprintf('Invalid date format in request. Using today: %s', $e->getMessage())); - } - - return $date; - } - - private function integerFromQueryParams(QueryParameters $parameters, string $field, int $default): int - { - return (int) ($parameters->page()[$field] ?? $default); - } - - private function stringFromFilterParams(QueryParameters $parameters, string $field, string $default): string - { - return (string) $parameters->filter()?->value($field, $default) ?? $default; - } - - private function stringFromQueryParams(QueryParameters $parameters, string $field, string $default): string - { - return (string) ($parameters->page()[$field] ?? $default); - } -} diff --git a/app/Support/JsonApi/ExpandsQuery.php b/app/Support/JsonApi/ExpandsQuery.php index 5599efae5e..2062eb9e7d 100644 --- a/app/Support/JsonApi/ExpandsQuery.php +++ b/app/Support/JsonApi/ExpandsQuery.php @@ -28,8 +28,6 @@ use FireflyIII\Models\Account; use FireflyIII\Support\Http\Api\AccountFilter; use Illuminate\Contracts\Database\Eloquent\Builder; use Illuminate\Support\Facades\Log; -use LaravelJsonApi\Core\Query\FilterParameters; -use LaravelJsonApi\Core\Query\SortFields; trait ExpandsQuery { diff --git a/app/Support/JsonApi/SortsCollection.php b/app/Support/JsonApi/SortsCollection.php index 1a58c1a621..30f0d0315b 100644 --- a/app/Support/JsonApi/SortsCollection.php +++ b/app/Support/JsonApi/SortsCollection.php @@ -26,7 +26,6 @@ namespace FireflyIII\Support\JsonApi; use Illuminate\Support\Collection; use Illuminate\Support\Facades\Log; -use LaravelJsonApi\Core\Query\SortFields; trait SortsCollection { diff --git a/app/Support/JsonApi/SortsQueryResults.php b/app/Support/JsonApi/SortsQueryResults.php index 9c5539aa3b..17d8370405 100644 --- a/app/Support/JsonApi/SortsQueryResults.php +++ b/app/Support/JsonApi/SortsQueryResults.php @@ -27,8 +27,6 @@ namespace FireflyIII\Support\JsonApi; use FireflyIII\Models\Account; use Illuminate\Support\Collection; use Illuminate\Support\Facades\Log; -use LaravelJsonApi\Core\Query\SortField; -use LaravelJsonApi\Core\Query\SortFields; trait SortsQueryResults { diff --git a/app/Support/JsonApi/ValidateSortParameters.php b/app/Support/JsonApi/ValidateSortParameters.php index c2fda7ecf2..79ae9c461e 100644 --- a/app/Support/JsonApi/ValidateSortParameters.php +++ b/app/Support/JsonApi/ValidateSortParameters.php @@ -25,7 +25,6 @@ declare(strict_types=1); namespace FireflyIII\Support\JsonApi; use Illuminate\Support\Facades\Log; -use LaravelJsonApi\Core\Query\SortFields; trait ValidateSortParameters { diff --git a/changelog.md b/changelog.md index 2c01fec774..450bc5b765 100644 --- a/changelog.md +++ b/changelog.md @@ -7,7 +7,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Added -- Multi-currency support. If you set `ENABLE_EXCHANGE_RATES=true` and optionally `ENABLE_EXTERNAL_RATES=true` Firefly III will try to calculate all foreign currencies back to your native currency. This is a work in progress, not all fields and all places will support this yet. Please check out the [documentation](#). +- Multi-currency support. If you set `ENABLE_EXCHANGE_RATES=true` and optionally `ENABLE_EXTERNAL_RATES=true` Firefly III will try to calculate all foreign currencies back to your native currency. This is a work in progress, not all fields and all places will support this yet. Please check out the [documentation](https://docs.firefly-iii.org/explanation/financial-concepts/exchange-rates/). - Notifications support Nfty, Pushover, Slack and Discord. - Many new security related notifications. - #5523