Skip to content

Commit

Permalink
Merge pull request #153 from deanblackborough/v2.02.0
Browse files Browse the repository at this point in the history
v2.02.0
  • Loading branch information
deanblackborough authored Oct 7, 2019
2 parents 79be963 + 30d82b0 commit 58380f0
Show file tree
Hide file tree
Showing 68 changed files with 3,661 additions and 491 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ APP_HASH_SALT_RESOURCE=
APP_HASH_SALT_ITEM=
APP_HASH_SALT_ITEM_CATEGORY=
APP_HASH_SALT_ITEM_SUBCATEGORY=
APP_HASH_SALT_ITEM_TYPE=

LOG_CHANNEL=stack

Expand Down
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@

The complete changelog for the Costs to Expect REST API, follows the format defined at https://keepachangelog.com/en/1.0.0/

## [v2.02.0] - 2019-10-07
### Added
- We have updated the create resource type route. It is now possible to set the item type that you want to use. There are two expense types, "allocated expense" and "simple expense". An allocated expense allows you to allocated a percentage of the total cost; a simple expense only has a total, no allocation rate.
- The supported item types exposed in the resource types OPTIONS request, additional item types will be added over time.
- We have added an item type hasher to hash the ids for item types.
- We have added support for simple expenses, create a simple expense resource type and off you go, "simple expenses" instead of "allocated expenses".

### Changed
- We have added an interface to use when interacting with items; it works out the item type by looking at the resource and then returns the relevant models and configuration data.
- We have updated numerous sections of the API to dynamically expose the relevant fields, sort parameters and search parameters etc. based on the current item type.
- We have moved several `item` based configuration files into the relevant item type folder.

### Fixed
- Localisation missing for allocated expense name.

## [v2.01.2] - 2019-09-25
### Added
- We have added an `X-Parameters` header; it contains the validated parameters for the request.
Expand Down
1 change: 0 additions & 1 deletion app/Http/Controllers/CategoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use App\Validators\Request\Parameters;
use App\Validators\Request\Route;
use App\Models\Category;
use App\Models\ResourceType;
use App\Models\Transformers\Category as CategoryTransformer;
use App\Utilities\Request as UtilityRequest;
use App\Utilities\Response as UtilityResponse;
Expand Down
24 changes: 23 additions & 1 deletion app/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@

namespace App\Http\Controllers;

use App\Item\AbstractItem;
use App\Item\ItemFactory;
use App\Models\PermittedUser;
use App\Utilities\Hash;
use Exception;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Http\JsonResponse;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Support\Facades\Auth;

class Controller extends BaseController
{
Expand Down Expand Up @@ -40,6 +42,11 @@ class Controller extends BaseController
*/
protected $allow_entire_collection = false;

/**
* @var AbstractItem
*/
protected $item_interface = null;

public function __construct()
{
$this->hash = new Hash();
Expand Down Expand Up @@ -93,4 +100,19 @@ protected function optionsResponse(array $verbs, $http_status_code = 200): JsonR
)->send();
exit;
}

/**
* Make a call to the item interface factory and set the relevant item
* interface
*
* @param integer $resource_type_id
*/
protected function setItemInterface(int $resource_type_id)
{
try {
$this->item_interface = ItemFactory::getItemInterface($resource_type_id);
} catch (Exception $e) {
abort(500, $e->getMessage());
}
}
}
Loading

0 comments on commit 58380f0

Please sign in to comment.