diff --git a/README.md b/README.md index 6097f5d..97d60c3 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,17 @@ PHP GUS API library =================== -PHP GUS API library based on **official** REGON SOAP api. -Official GUS docs [here](http://bip.stat.gov.pl/dzialalnosc-statystyki-publicznej/rejestr-regon/interfejsyapi/jak-skorzystac-informacja-dla-podmiotow-komercyjnych/) + +PHP GUS API is an object-oriented library to get information from [REGON site](https://wyszukiwarkaregon.stat.gov.pl/wsBIR/UslugaBIRzewnPubl.svc) based on **official** REGON SOAP API. +Official GUS docs [here](http://bip.stat.gov.pl/dzialalnosc-statystyki-publicznej/rejestr-regon/interfejsyapi/jak-skorzystac-informacja-dla-podmiotow-komercyjnych/). + +Installation +====================== +This library uses [Composer](https://packagist.org/packages/gusapi/gusapi), just type in: +```composer require gusapi/gusapi``` Example ====================== +See file [examples/getFromNip.php](examples/getFromNip.php). ```php require_once '../vendor/autoload.php'; @@ -16,11 +23,11 @@ use GusApi\ReportTypes; use GusApi\ReportTypeMapper; $gus = new GusApi( - 'abcde12345abcde12345', // <--- your user key / twój klucz użytkownika + 'abcde12345abcde12345', // your user key / twój klucz użytkownika new \GusApi\Adapter\Soap\SoapAdapter( RegonConstantsInterface::BASE_WSDL_URL, - RegonConstantsInterface::BASE_WSDL_ADDRESS //<--- production server / serwer produkcyjny - //for test serwer use RegonConstantsInterface::BASE_WSDL_ADDRESS_TEST + RegonConstantsInterface::BASE_WSDL_ADDRESS // production server / serwer produkcyjny + //for test server use RegonConstantsInterface::BASE_WSDL_ADDRESS_TEST //w przypadku serwera testowego użyj: RegonConstantsInterface::BASE_WSDL_ADDRESS_TEST ) ); @@ -49,12 +56,10 @@ try { echo 'Bad user key'; } catch (\GusApi\Exception\NotFoundException $e) { echo 'No data found
'; - echo 'For more information read server message belowe:
'; + echo 'For more information read server message below:
'; echo $gus->getResultSearchMessage($sessionId); } ``` -or see file: getFromNip.php in examples directory. -PHP GUS API is an object-oriented library to get information from [Regon site](https://wyszukiwarkaregon.stat.gov.pl/wsBIR/UslugaBIRzewnPubl.svc) diff --git a/src/GusApi/GusApi.php b/src/GusApi/GusApi.php index f142621..647244f 100644 --- a/src/GusApi/GusApi.php +++ b/src/GusApi/GusApi.php @@ -179,14 +179,14 @@ public function getByKrs($sid, $krs) /** * @param $sid - * @param array $nips + * @param array $nips Maxium quantity is 20. * @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"); + throw new \InvalidArgumentException("Too many NIP numbers. Maximum quantity is 20."); } $nips = implode(',', $nips); @@ -197,14 +197,14 @@ public function getByNips($sid, array $nips) /** * @param $sid - * @param array $krses + * @param array $krses Maxium quantity is 20. * @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"); + throw new \InvalidArgumentException("Too many KRS numbers. Maximum quantity is 20."); } $krses = implode(',', $krses); @@ -215,14 +215,14 @@ public function getByKrses($sid, array $krses) /** * @param $sid - * @param array $regons + * @param array $regons Maxium quantity is 20. * @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"); + throw new \InvalidArgumentException("Too many REGON numbers. Maximum quantity is 20."); } $regons = implode(',', $regons); @@ -233,14 +233,14 @@ public function getByRegons9($sid, array $regons) /** * @param $sid - * @param array $regons + * @param array $regons Maxium quantity is 20. * @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"); + throw new \InvalidArgumentException("Too many REGON numbers. Maximum quantity is 20."); } $regons = implode(',', $regons); @@ -326,4 +326,4 @@ private function search($sid, array $searchData) return $result; } -} \ No newline at end of file +} diff --git a/src/GusApi/SearchReport.php b/src/GusApi/SearchReport.php index 94800f5..c1ad2b1 100644 --- a/src/GusApi/SearchReport.php +++ b/src/GusApi/SearchReport.php @@ -5,7 +5,7 @@ * Class SearchReport * @package GusApi */ -class SearchReport +class SearchReport implements \JsonSerializable { const TYPE_JURIDICAL_PERSON = 'p'; @@ -212,4 +212,14 @@ private function makeType($type) { return trim(strtolower($type)); } -} \ No newline at end of file + + /** + * @return array + */ + public function jsonSerialize() + { + $vars = get_object_vars($this); + + return $vars; + } +} diff --git a/tests/Client/RequestDecoderTest.php b/tests/Client/RequestDecoderTest.php index 7ca68d4..b92693a 100644 --- a/tests/Client/RequestDecoderTest.php +++ b/tests/Client/RequestDecoderTest.php @@ -11,7 +11,7 @@ public function testDecodeRawRandomString() public function testDecodeValidSOAPResponse() { - $content = file_get_contents('../resources/validSOAPResponse.xsd'); + $content = file_get_contents(__DIR__.'/../resources/validSOAPResponse.xsd'); $result = RequestDecoder::decode($content); $this->assertEquals(trim($content), $result); @@ -19,8 +19,8 @@ public function testDecodeValidSOAPResponse() public function testDecodeRawSOAPResponse() { - $content = file_get_contents('../resources/rawSOAPResponse.xsd'); - $valid = file_get_contents('../resources/validSOAPResponse.xsd'); + $content = file_get_contents(__DIR__.'/../resources/rawSOAPResponse.xsd'); + $valid = file_get_contents(__DIR__.'/../resources/validSOAPResponse.xsd'); $result = RequestDecoder::decode($content); $this->assertEquals(trim($valid), $result);