Skip to content

Commit

Permalink
Merge pull request #176 from deanblackborough/v2.10.0
Browse files Browse the repository at this point in the history
v2.10.0
  • Loading branch information
deanblackborough authored Apr 1, 2020
2 parents 00ca3e7 + cb98d1c commit e745df5
Show file tree
Hide file tree
Showing 53 changed files with 1,643 additions and 250 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ APP_HASH_SALT_RESOURCE_TYPE=
APP_HASH_SALT_RESOURCE=
APP_HASH_SALT_ITEM=
APP_HASH_SALT_ITEM_CATEGORY=
APP_HASH_SALT_ITEM_PARTIAL_TRANSFER=
APP_HASH_SALT_ITEM_SUBCATEGORY=
APP_HASH_SALT_ITEM_TRANSFER=
APP_HASH_SALT_ITEM_TYPE=
APP_HASH_SALT_PERMITTED_USER=
APP_HASH_SALT_USER=

LOG_CHANNEL=stack

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

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

## [v2.10.0] - 2020-04-01
### Added
- We have added a new route, `/resource_types/[id]/resources/[id]/items/[id]/partial-transfer`; A partial transfer allows you to transfer a percentage of the `total` for an item from one resource to another.
- We have added an `item_transfer` table; the table will log which items were transferred and by whom.
- We have added a partial transfers collection; the route is `/resource_types/[id]/partial-transfers`.
- We have added a partial transfers item view; the route is `/resource_types/[id]/partial-transfers/[id]`.
- We have added a transfers collection; the route is `/resource_types/[id]/transfers`.
- We have added a transfers item view; the route is `/resource_types/[id]/transfers/[id]`.
- We have added a delete endpoint for partial transfers.

### Changed
- We have reformatted the validation rules in the configuration files; easier to read and simpler to add additional rules.
- We have switched the HTTP status code for a "Constraint error" from 500 to 409.
- We have tweaked the description for the resource field in the `/resource_types/[id]/resources/[id]/items/[id]/transfer` OPTIONS request.
- We have renamed the third parameter of the route validation methods; we changed the name from `$manage` to `$write`.
- We have renamed a response helper method; it was not clear from the name that the method is used for updates and delete.

### Fixed
- It is possible to set the quantity for a `simple-item` item as zero.
- It is possible to clear optional values in a PATCH request.

## [v2.09.4] - 2020-03-25
### Changed
- When a response includes additional data via the include parameters, we include the URI fragment for that data.
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ additionally, the same is true if you are assigned to a resource type.
| DELETE | v2/resource-types/{resource_type_id}/categories/{category_id}/subcategories/{subcategory_id} |
| GET/HEAD | v2/resource-types/{resource_type_id}/items |
| OPTIONS | v2/resource-types/{resource_type_id}/items |
| GET/HEAD | v2/resource-types/{resource_type_id}/partial-transfers |
| OPTIONS | v2/resource-types/{resource_type_id}/partial-transfers |
| GET/HEAD | v2/resource-types/{resource_type_id}/partial-transfers/{item_partial_transfer_id} |
| OPTIONS | v2/resource-types/{resource_type_id}/partial-transfers/{item_partial_transfer_id} |
| DELETE | v2/resource-types/{resource_type_id}/partial-transfers/{item_partial_transfer_id} |
| GET/HEAD | v2/resource-types/{resource_type_id}/permitted-users |
| OPTIONS | v2/resource-types/{resource_type_id}/permitted-users |
| GET/HEAD | v2/resource-types/{resource_type_id}/resources |
| OPTIONS | v2/resource-types/{resource_type_id}/resources |
Expand Down Expand Up @@ -153,8 +159,14 @@ additionally, the same is true if you are assigned to a resource type.
| GET/HEAD | v2/resource-types/{resource_type_id}/resources/{resource_id}/items/{item_id}/category/{item_category_id}/subcategory/{item_subcategory_id} |
| OPTIONS | v2/resource-types/{resource_type_id}/resources/{resource_id}/items/{item_id}/category/{item_category_id}/subcategory/{item_subcategory_id} |
| DELETE | v2/resource-types/{resource_type_id}/resources/{resource_id}/items/{item_id}/category/{item_category_id}/sub_category/{item_subcategory_id} |
| OPTIONS | v2/resource-types/{resource_type_id}/resources/{resource_id}/items/{item_id}/partial-transfer |
| POST | v2/resource-types/{resource_type_id}/resources/{resource_id}/items/{item_id}/partial-transfer |
| OPTIONS | v2/resource-types/{resource_type_id}/resources/{resource_id}/items/{item_id}/transfer |
| POST | v2/resource-types/{resource_type_id}/resources/{resource_id}/items/{item_id}/transfer |
| GET/HEAD | v2/resource-types/{resource_type_id}/transfers |
| OPTIONS | v2/resource-types/{resource_type_id}/transfers |
| GET/HEAD | v2/resource-types/{resource_type_id}/transfers/{item_transfer_id} |
| OPTIONS | v2/resource-types/{resource_type_id}/transfers/{item_transfer_id} |
| GET/HEAD | v2/request/error-log |
| OPTIONS | v2/request/error-log |
| POST | v2/request/error-log |
Expand Down
10 changes: 5 additions & 5 deletions app/Http/Controllers/CategoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,16 +269,16 @@ public function create($resource_type_id): JsonResponse
]);
UtilityRequest::validateAndReturnErrors($validator);

//try {
try {
$category = new Category([
'name' => request()->input('name'),
'description' => request()->input('description'),
'resource_type_id' => $resource_type_id
]);
$category->save();
//} catch (Exception $e) {
// UtilityResponse::failedToSaveModelForCreate();
//}
} catch (Exception $e) {
UtilityResponse::failedToSaveModelForCreate();
}

return response()->json(
(new CategoryTransformer((new Category)->instanceToArray($category)))->toArray(),
Expand Down Expand Up @@ -337,7 +337,7 @@ public function update($resource_type_id, $category_id): JsonResponse
$category = (new Category())->instance($category_id);

if ($category === null) {
UtilityResponse::failedToSelectModelForUpdate();
UtilityResponse::failedToSelectModelForUpdateOrDelete();
}

UtilityRequest::checkForEmptyPatch();
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/ItemController.php
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ public function update(
$item_type = $item_interface->instance((int) $item_id);

if ($item === null || $item_type === null) {
UtilityResponse::failedToSelectModelForUpdate();
UtilityResponse::failedToSelectModelForUpdateOrDelete();
}

try {
Expand All @@ -415,7 +415,7 @@ public function update(
UtilityResponse::failedToSaveModelForUpdate();
}

UtilityResponse::successNoContent();
return UtilityResponse::successNoContent();
}

/**
Expand Down
Loading

0 comments on commit e745df5

Please sign in to comment.