diff --git a/src/Services/SettlementService.php b/src/Services/SettlementService.php index c835067..5d49a10 100644 --- a/src/Services/SettlementService.php +++ b/src/Services/SettlementService.php @@ -6,9 +6,9 @@ use Grisaia\NovaPoshta\DataAdapters\Result\SearchSettlementResult; use Grisaia\NovaPoshta\DataAdapters\Result\SettlementAreaListResult; +use Grisaia\NovaPoshta\DataAdapters\Result\SettlementListItem; use Grisaia\NovaPoshta\DataAdapters\Result\SettlementRegionListResult; use Grisaia\NovaPoshta\DataAdapters\Result\SettlementSearchResult; -use Grisaia\NovaPoshta\DataAdapters\Result\SettlementListItem; use Grisaia\NovaPoshta\Exception\QueryFailed\QueryFailedException; use Grisaia\NovaPoshta\MethodProperties\Address\SettlementAreaListProperties; use Grisaia\NovaPoshta\MethodProperties\Address\SettlementRegionListProperties; @@ -19,15 +19,26 @@ /** * @throws QueryFailedException */ - public function getSettlementList(int $page, int $limit): SettlementListItem + public function getSettlementList(int $page, int $limit, string $regionRef = null, string $areaRef = null, bool $hasWarehouse = null): SettlementListItem { + $data = [ + 'Page' => $page, + 'Limit' => $limit, + ]; + if ($regionRef !== null) { + $data['RegionRef'] = $regionRef; + } + if ($areaRef) { + $data['AreRef'] = $areaRef; + } + if ($hasWarehouse !== null) { + $data['Warehouse'] = $hasWarehouse; + } return new SettlementListItem( - $this->api->fetch('AddressGeneral', 'getSettlements', [ - 'Page' => $page, - 'Limit' => $limit, - ]) + $this->api->fetch('AddressGeneral', 'getSettlements', $data) ); } + /** * @throws QueryFailedException */ @@ -36,7 +47,8 @@ public function searchSettlementStreets( string $settlementRef, int $limit, int $page = 1 - ): SearchSettlementResult { + ): SearchSettlementResult + { return new SearchSettlementResult($this->api->fetch('Address', 'searchSettlementStreets', [ 'StreetName' => $streetName, 'SettlementRef' => $settlementRef,