Skip to content

RacyMind/GusApi

This branch is 199 commits behind johnzuk/GusApi:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

author
john
Feb 5, 2018
eb10af7 · Feb 5, 2018

History

85 Commits
Sep 30, 2017
Jan 23, 2018
Feb 5, 2018
Sep 30, 2017
Feb 15, 2015
Jan 19, 2018
Jan 28, 2018
Jan 28, 2018
Feb 16, 2015
Feb 16, 2015

Repository files navigation

PHP GUS API library

PHP GUS API is an object-oriented library to get information from REGON site based on official REGON SOAP API. Official GUS docs here.

Installation

This library uses Composer, just type in: composer require gusapi/gusapi

Example

See file examples/getFromNip.php.

require_once '../vendor/autoload.php';

use GusApi\GusApi;
use GusApi\RegonConstantsInterface;
use GusApi\Exception\InvalidUserKeyException;
use GusApi\ReportTypes;
use GusApi\ReportTypeMapper;

$gus = new GusApi(
    '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 server use RegonConstantsInterface::BASE_WSDL_ADDRESS_TEST
        //w przypadku serwera testowego użyj: RegonConstantsInterface::BASE_WSDL_ADDRESS_TEST
    )
);

$mapper = new ReportTypeMapper();

try {
    $nipToCheck = 'xxxxxxxxxx'; //change to valid nip value
    $sessionId = $gus->login();
    
    $gusReports = $gus->getByNip($sessionId, $nipToCheck);
    
    foreach ($gusReports as $gusReport) {
        $reportType = $mapper->getReportType($gusReport);

        var_dump($gus->getFullReport(
            $sessionId,
            $gusReport,
            $reportType
        ));

        echo $gusReport->getName();
    }
    
} catch (InvalidUserKeyException $e) {
    echo 'Bad user key';
} catch (\GusApi\Exception\NotFoundException $e) {
    echo 'No data found <br>';
    echo 'For more information read server message below: <br>';
    echo $gus->getResultSearchMessage($sessionId);
}

About

PHP GUS API library based on official REGON SOAP api.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%