Skip to content

Commit

Permalink
Add more settlement search parameters.
Browse files Browse the repository at this point in the history
  • Loading branch information
l-you committed Mar 7, 2024
1 parent 2088095 commit 5c85f00
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions src/Services/SettlementService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
*/
Expand All @@ -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,
Expand Down

0 comments on commit 5c85f00

Please sign in to comment.