Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/origin/v3.2' into 3.3
Browse files Browse the repository at this point in the history
# Conflicts:
#	composer.json
#	composer.lock
  • Loading branch information
john committed Apr 21, 2018
2 parents 62db30d + eb10af7 commit e07dc4f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 22 deletions.
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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
)
);
Expand Down Expand Up @@ -49,12 +56,10 @@ try {
echo 'Bad user key';
} catch (\GusApi\Exception\NotFoundException $e) {
echo 'No data found <br>';
echo 'For more information read server message belowe: <br>';
echo 'For more information read server message below: <br>';
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)

18 changes: 9 additions & 9 deletions src/GusApi/GusApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand Down Expand Up @@ -326,4 +326,4 @@ private function search($sid, array $searchData)

return $result;
}
}
}
14 changes: 12 additions & 2 deletions src/GusApi/SearchReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Class SearchReport
* @package GusApi
*/
class SearchReport
class SearchReport implements \JsonSerializable
{
const TYPE_JURIDICAL_PERSON = 'p';

Expand Down Expand Up @@ -212,4 +212,14 @@ private function makeType($type)
{
return trim(strtolower($type));
}
}

/**
* @return array
*/
public function jsonSerialize()
{
$vars = get_object_vars($this);

return $vars;
}
}
6 changes: 3 additions & 3 deletions tests/Client/RequestDecoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ 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);
}

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);
Expand Down

0 comments on commit e07dc4f

Please sign in to comment.