Skip to content

Commit

Permalink
Release v1.04.1
Browse files Browse the repository at this point in the history
* Updated release notes.
* Minor bug fix, booleans not being parsed correctly.
* Removed rendundant code.
  • Loading branch information
deanblackborough committed Oct 7, 2018
1 parent 2a8f162 commit 43d9fb3
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Full changelog for the costs to expect REST API.
* Added App\Http\Parameters\Get class to validate GET parameters, moved code from base controller.
* Added App\Http\Parameters\Route\Validate and child classes to validator route parameters.
* Updated controllers to use new App\Http\Parameters\* classes.
* Minor bug fix, booleans not being checked correctly.

## 2019-09-25 - v1.04.0

Expand Down
1 change: 0 additions & 1 deletion app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class Kernel extends HttpKernel
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
// \Illuminate\Session\Middleware\AuthenticateSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
Expand Down
22 changes: 12 additions & 10 deletions app/Http/Parameters/Get.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use App\Models\Category;
use App\Models\SubCategory;
use Illuminate\Http\Request;

/**
* Fetch any GET parameters attached to the end of the URI and validate
Expand Down Expand Up @@ -32,7 +31,17 @@ private static function fetch(array $parameter_names = [])
if (array_key_exists($parameter, $request_parameters) === true &&
$request_parameters[$parameter] !== null &&
$request_parameters[$parameter] !== 'nill') {
self::$parameters[$parameter] = $request_parameters[$parameter];

switch ($parameter) {
case 'include_resources';
case 'include_sub_categories';
self::$parameters[$parameter] = filter_var($request_parameters[$parameter], FILTER_VALIDATE_BOOLEAN);
break;

default:
self::$parameters[$parameter] = $request_parameters[$parameter];
break;
}
}
}
}
Expand All @@ -55,16 +64,9 @@ private static function validate()
break;

case 'include_sub_categories':
if (array_key_exists($key, self::$parameters) === true) {
if (boolval(self::$parameters['include_sub_categories']) === false) {
unset(self::$parameters[$key]);
}
}
break;

case 'include_resources':
if (array_key_exists($key, self::$parameters) === true) {
if (boolval(self::$parameters['include_resources']) === false) {
if (filter_var(self::$parameters[$key], FILTER_VALIDATE_BOOLEAN) === false) {
unset(self::$parameters[$key]);
}
}
Expand Down
3 changes: 2 additions & 1 deletion app/Transformers/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ public function toArray(): array

if (
isset($this->parameters['include_sub_categories']) &&
$this->parameters['include_sub_categories'] === true) {
$this->parameters['include_sub_categories'] === true
) {
$subCategoriesCollection = $this->category->sub_categories;

$subCategoriesCollection->map(
Expand Down
4 changes: 2 additions & 2 deletions config/api/version.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

return [
'version'=> '1.04.0',
'version'=> '1.04.1',
'prefix' => 'v1',
'release_date' => '2018-09-25',
'release_date' => '2018-10-08',
'changelog' => 'https://github.com/costs-to-expect/api/blob/master/CHANGELOG.md',
'readme' => 'https://github.com/costs-to-expect/api/blob/master/README.md'
];

0 comments on commit 43d9fb3

Please sign in to comment.