Skip to content

Commit

Permalink
Add implementation for method to search many NIP, KRS, REGON9 and REG…
Browse files Browse the repository at this point in the history
…ON14 in one request
  • Loading branch information
john committed Jan 3, 2018
1 parent f0cdc79 commit e120525
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 1 deletion.
74 changes: 73 additions & 1 deletion src/GusApi/GusApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,78 @@ public function getByKrs($sid, $krs)
]);
}

/**
* @param $sid
* @param array $nips
* @return SearchReport[]
* @throws NotFoundException
*/
public function getByNips($sid, array $nips)
{
if (count($nips) > 20) {
throw new \InvalidArgumentException("To few NIP numbers. Maximum quantity is 20");
}
$nips = implode(',', $nips);

return $this->search($sid, [
RegonConstantsInterface::SEARCH_TYPE_NIPS => $nips
]);
}

/**
* @param $sid
* @param array $krses
* @return SearchReport[]
* @throws NotFoundException
*/
public function getByKrses($sid, array $krses)
{
if (count($krses) > 20) {
throw new \InvalidArgumentException("To few KRS numbers. Maximum quantity is 20");
}
$krses = implode(',', $krses);

return $this->search($sid, [
RegonConstantsInterface::SEARCH_TYPE_KRSES => $krses
]);
}

/**
* @param $sid
* @param array $regons
* @return SearchReport[]
* @throws NotFoundException
*/
public function getByRegons9($sid, array $regons)
{
if (count($regons) > 20) {
throw new \InvalidArgumentException("To few REGONS numbers. Maximum quantity is 20");
}
$regons = implode(',', $regons);

return $this->search($sid, [
RegonConstantsInterface::SEARCH_TYPE_REGONS_9 => $regons
]);
}

/**
* @param $sid
* @param array $regons
* @return SearchReport[]
* @throws NotFoundException
*/
public function getByregons14($sid, array $regons)
{
if (count($regons) > 20) {
throw new \InvalidArgumentException("To few REGONS numbers. Maximum quantity is 20");
}
$regons = implode(',', $regons);

return $this->search($sid, [
RegonConstantsInterface::SEARCH_TYPE_REGONS_14 => $regons
]);
}

/**
* @param $sid
* @param SearchReport $searchReport
Expand All @@ -193,7 +265,7 @@ public function getFullReport($sid, SearchReport $searchReport, $reportType)
/**
* Get get message about search if you don't get data
*
* @param sid
* @param $sid
* @return string
*/
public function getResultSearchMessage($sid)
Expand Down
5 changes: 5 additions & 0 deletions src/GusApi/RegonConstantsInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ interface RegonConstantsInterface
const SEARCH_TYPE_KRS = 'Krs';
const SEARCH_TYPE_REGON = 'Regon';

const SEARCH_TYPE_NIPS = 'Nipy';
const SEARCH_TYPE_KRSES = 'Krsy';
const SEARCH_TYPE_REGONS_9 = 'Regony9zn';
const SEARCH_TYPE_REGONS_14 = 'Regony14zn';

const PARAM_STATUS_DATE_STATE = 'StanDanych';
const PARAM_MESSAGE_CODE = 'KomunikatKod';
const PARAM_MESSAGE = 'KomunikatTresc';
Expand Down

0 comments on commit e120525

Please sign in to comment.