From fdc94628290553094b33b6fb60be5f88162cee12 Mon Sep 17 00:00:00 2001 From: Oliver Vollborn Date: Mon, 16 Sep 2024 14:38:15 +0200 Subject: [PATCH] Add query warehouses & storage locations --- src/Enums/Permission.php | 6 +++ .../StorageLocationDto.php | 35 ++++++++++++++ .../DataTransferObjects/WarehouseDto.php | 33 +++++++++++++ .../Requests/QueryStorageLocationsRequest.php | 12 +++++ .../Requests/QueryWarehousesRequest.php | 12 +++++ .../QueryStorageLocationsResponse.php | 17 +++++++ .../Responses/QueryWarehousesResponse.php | 17 +++++++ .../Warehouse/StorageLocationRepository.php | 46 ++++++++++++++++++ src/Modules/Warehouse/WarehouseRepository.php | 47 +++++++++++++++++++ src/Services/DataTransferObjectService.php | 2 +- 10 files changed, 226 insertions(+), 1 deletion(-) create mode 100644 src/Modules/Warehouse/DataTransferObjects/StorageLocationDto.php create mode 100644 src/Modules/Warehouse/DataTransferObjects/WarehouseDto.php create mode 100644 src/Modules/Warehouse/Requests/QueryStorageLocationsRequest.php create mode 100644 src/Modules/Warehouse/Requests/QueryWarehousesRequest.php create mode 100644 src/Modules/Warehouse/Responses/QueryStorageLocationsResponse.php create mode 100644 src/Modules/Warehouse/Responses/QueryWarehousesResponse.php create mode 100644 src/Modules/Warehouse/StorageLocationRepository.php create mode 100644 src/Modules/Warehouse/WarehouseRepository.php diff --git a/src/Enums/Permission.php b/src/Enums/Permission.php index dcd9c42..dce2943 100644 --- a/src/Enums/Permission.php +++ b/src/Enums/Permission.php @@ -14,6 +14,12 @@ enum Permission: string // Shipping Methods case QueryShippingMethods = 'shippingmethod.queryshippingmethods'; + // Warehouses + case QueryWarehouses = 'warehouse.querywarehouses'; + + // Storage Locations + case QueryStorageLocations = 'warehouse.querystoragelocations'; + // Suppliers case QuerySuppliers = 'supplier.querysuppliers'; diff --git a/src/Modules/Warehouse/DataTransferObjects/StorageLocationDto.php b/src/Modules/Warehouse/DataTransferObjects/StorageLocationDto.php new file mode 100644 index 0000000..4f0d39f --- /dev/null +++ b/src/Modules/Warehouse/DataTransferObjects/StorageLocationDto.php @@ -0,0 +1,35 @@ +getArrayValue($data, 'SortNumber'), + $service->getArrayValue($data, 'Priority'), + $service->getArrayValue($data, 'LockForShipment'), + $service->getArrayValue($data, 'LockForAvailability'), + $service->getArrayValue($data, 'Comment'), + ); + } +} diff --git a/src/Modules/Warehouse/DataTransferObjects/WarehouseDto.php b/src/Modules/Warehouse/DataTransferObjects/WarehouseDto.php new file mode 100644 index 0000000..7cb8efa --- /dev/null +++ b/src/Modules/Warehouse/DataTransferObjects/WarehouseDto.php @@ -0,0 +1,33 @@ +json['Items'])); + } +} diff --git a/src/Modules/Warehouse/Responses/QueryWarehousesResponse.php b/src/Modules/Warehouse/Responses/QueryWarehousesResponse.php new file mode 100644 index 0000000..c38e6a5 --- /dev/null +++ b/src/Modules/Warehouse/Responses/QueryWarehousesResponse.php @@ -0,0 +1,17 @@ +json['Items'])); + } +} diff --git a/src/Modules/Warehouse/StorageLocationRepository.php b/src/Modules/Warehouse/StorageLocationRepository.php new file mode 100644 index 0000000..6000762 --- /dev/null +++ b/src/Modules/Warehouse/StorageLocationRepository.php @@ -0,0 +1,46 @@ +get('/v1/warehouses/' . $request->warehouseId . '/storagelocations', [ + 'pageNumber' => $request->pageNumber, + 'pageSize' => $request->pageSize, + ]); + + if ($response->wasSuccessful) { + return new QueryStorageLocationsResponse($response); + } + + $this->throwExceptionsIfPossible($response); + throw new UnhandledResponseException($response); + } +} diff --git a/src/Modules/Warehouse/WarehouseRepository.php b/src/Modules/Warehouse/WarehouseRepository.php new file mode 100644 index 0000000..c5ff8dc --- /dev/null +++ b/src/Modules/Warehouse/WarehouseRepository.php @@ -0,0 +1,47 @@ +get('/v1/warehouses', [ + 'isActive' => $request->isActive, + 'pageNumber' => $request->pageNumber, + 'pageSize' => $request->pageSize, + ]); + + if ($response->wasSuccessful) { + return new QueryWarehousesResponse($response); + } + + $this->throwExceptionsIfPossible($response); + throw new UnhandledResponseException($response); + } +} diff --git a/src/Services/DataTransferObjectService.php b/src/Services/DataTransferObjectService.php index 100387d..8f45b37 100644 --- a/src/Services/DataTransferObjectService.php +++ b/src/Services/DataTransferObjectService.php @@ -12,7 +12,7 @@ public function getArrayValue(array $array, string $key): mixed $value = $array[$key]; - if (is_array($value)) { + if (is_array($value) || is_bool($value)) { return $value; }