Giter Club home page Giter Club logo

gusapi's Introduction

PHP GUS API library

Packagist Build Status Codecov Packagist Packagist StyleCI Scrutinizer Code Quality

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

Supported Versions

Version PHP version BIR service version Support Doc
5.x >= 7.1 BIR1.1 (available since May 2019) Support ends on December 1, 2020 Doc
4.x >= 7.1 BIR1 Support ends on December 1, 2019 Doc
3.3.x >= 5.6 BIR1 Support ends on December 1, 2018 Doc
3.2.x >= 5.4 BIR1 Support ended on April 1, 2018 Doc

If you still use PHP <= 7.0 see documentation for 3.3.x version HERE

New in 5.x (this version support BIR1.1)

  • New properties in SearchReport:

    • nip

    • nipStatus

    • propertyNumber

    • apartmentNumber

    • activityEndDate

      Till version 5.x you dont need to get full report to find property number and apartment number

  • Method getFullReport throws InvalidReportTypeException for invalid report name

  • Method dataStatus now return DateTimeImmutable instead of DateTime and throws InvalidServerResponseException

  • New method getBulkReport - new search type in BIR1.1 (mode documentation here) with BulkReportTypes

  • New supported report types for getBulkReport method (based on BIR1.1 documentation):

        public const REPORT_NEW_LEGAL_ENTITY_AND_NATURAL_PERSON = 'BIR11NowePodmiotyPrawneOrazDzialalnosciOsFizycznych';
        public const REPORT_UPDATED_LEGAL_ENTITY_AND_NATURAL_PERSON = 'BIR11AktualizowanePodmiotyPrawneOrazDzialalnosciOsFizycznych';
        public const REPORT_DELETED_LEGAL_ENTITY_AND_NATURAL_PERSON = 'BIR11SkreslonePodmiotyPrawneOrazDzialalnosciOsFizycznych';
        public const REPORT_NEW_LOCAL_UNITS = 'BIR11NoweJednostkiLokalne';
        public const REPORT_UPDATED_LOCAL_UNITS = 'BIR11AktualizowaneJednostkiLokalne';
        public const REPORT_DELETED_LOCAL_UNITS = 'BIR11SkresloneJednostkiLokalne';
  • Remove ReportTypeMapper

Upgrade from 4.x to 5.x

For more information see UPGRADE.md.

Example for 5.x

See file examples/readmeExample.php.

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

use GusApi\Exception\InvalidUserKeyException;
use GusApi\Exception\NotFoundException;
use GusApi\GusApi;
use GusApi\ReportTypes;
use GusApi\BulkReportTypes;

$gus = new GusApi('your api key here');
//for development server use:
//$gus = new GusApi('abcde12345abcde12345', 'dev');

try {
    $nipToCheck = 'xxxxxxxxxx'; //change to valid nip value
    $gus->login();

    $gusReports = $gus->getByNip($nipToCheck);

    var_dump($gus->dataStatus());
    var_dump($gus->getBulkReport(
        new DateTimeImmutable('2019-05-31'),
        BulkReportTypes::REPORT_DELETED_LOCAL_UNITS));

    foreach ($gusReports as $gusReport) {
        //you can change report type to other one
        $reportType = ReportTypes::REPORT_ACTIVITY_PHYSIC_PERSON;
        echo $gusReport->getName();
        echo 'Address: '. $gusReport->getStreet(). ' ' . $gusReport->getPropertyNumber() . '/' . $gusReport->getApartmentNumber();
        
        $fullReport = $gus->getFullReport($gusReport, $reportType);
        var_dump($fullReport);
    }
} catch (InvalidUserKeyException $e) {
    echo 'Bad user key';
} catch (NotFoundException $e) {
    echo 'No data found <br>';
    echo 'For more information read server message below: <br>';
    echo $gus->getResultSearchMessage();
}

Donation

If this project help you reduce time to develop, you can give me a cup of coffee ;)
PayPal Donate

gusapi's People

Contributors

ionbazan avatar simivar avatar johnzuk avatar bitdeli-chef avatar kapiwko avatar cureoeu avatar pszeptynski avatar robertpustulka avatar timitao avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.