From e12052515672f461cff3307a30809701302945e0 Mon Sep 17 00:00:00 2001 From: john Date: Wed, 3 Jan 2018 15:40:26 +0100 Subject: [PATCH] Add implementation for method to search many NIP, KRS, REGON9 and REGON14 in one request --- src/GusApi/GusApi.php | 74 +++++++++++++++++++++++++- src/GusApi/RegonConstantsInterface.php | 5 ++ 2 files changed, 78 insertions(+), 1 deletion(-) diff --git a/src/GusApi/GusApi.php b/src/GusApi/GusApi.php index d70a1f9..f142621 100644 --- a/src/GusApi/GusApi.php +++ b/src/GusApi/GusApi.php @@ -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 @@ -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) diff --git a/src/GusApi/RegonConstantsInterface.php b/src/GusApi/RegonConstantsInterface.php index 6037847..195a7f2 100644 --- a/src/GusApi/RegonConstantsInterface.php +++ b/src/GusApi/RegonConstantsInterface.php @@ -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';