sigrun / ceidg-api
PHP CEIDG API library
Installs: 8 927
Dependents: 1
Suggesters: 0
Security: 0
Stars: 8
Watchers: 2
Forks: 5
Open Issues: 4
Requires
- php: >=7.2
- ext-simplexml: ^7.2
- ext-soap: ^7.2
Requires (Dev)
- php-coveralls/php-coveralls: 2.1.x-dev
- phpunit/php-code-coverage: ^7.0@dev
- phpunit/phpcov: ^6.0@dev
- phpunit/phpunit: ^8.4@dev
- vlucas/phpdotenv: ^3.4@dev
This package is auto-updated.
Last update: 2025-01-08 14:09:06 UTC
README
PHP CEIDG API library
We proudly present a PHP library to connect with CEIDG (Polish registry on businesses) API, using SOAP protocol.
Our library is capable of parsing querying result into well-formatted object or array of objects, validating inputted data (such as VAT number). Build atop the SOLID, DRY, and KISS principles, it provides a comprehensive tool to communicate with CEIDG API.
Please refer to the official API documentation, available at the CEIDG system website at https://datastore.ceidg.gov.pl (you should be logged in to view documentation files). Our library reflects their idea wholly.
Usage
Installation
As simple as it can be:
composer require sigrun/ceidg-api
Declaring API client
To declare API client, create new client class, with authorization token and (optionally) sandbox flag as arguments:
use CeidgApi\CeidgApi; $authToken = 'secret'; // To connect with the production environment $ceidgProductionApi = new CeidgApi($authToken); // To connect with the sandbox environment $ceidgSandboxApi = new CeidgApi($authToken, true);
Declaring requested function
CEIDG API provides two SOAP functions - GetId and GetMigrationData201901. The first returns only companies' unique IDs, whereas the second one - full data on the companies.
$getId = $ceidgProductionApi->getId(); $getMigrationData = $ceidgProductionApi->getMigrationData(); // or $getMigrationData = $ceidgProductionApi->getMigrationData201901();
Setting query parameters with a simple chain of responsibility pattern
We've implemented a simple chain of responsibility pattern, enabling easy setting up querying params.
// To get IDs of all companies modified or created on August 5th, 2019 $result = $getId->setMigrationDateFrom('2019-08-05')->setMigrationDateTo('2019-08-05')->send(); // To get IDs of all companies having postcode '02-662' $result = $getId->setPostcode('02-662')->send();
Parsing of response
You can demand on-the-fly parsing of the result. Depending on the number of retrieved entries, you will receive either a single object or an array of them. send()
method has a $parse
argument, default set to true
.
An example (abbreviated) of parsed response looks as following:
{ "IdentyfikatorWpisu": "ff83fff2fc2ab947f78fb6069f1767df", "DanePodstawowe": { "Imie": "Ryszard", "Nazwisko": "Petru", "NIP": "8991999655", "REGON": "147022306", "Firma": "Ryszard Petru Consulting" } }
Single line of code
You can do everything mentioned above, within a single line of code:
$result = (new CeidgApi($authToken))->getId()->setMigrationDateFrom('2019-08-05')->setMigrationDateTo('2019-08-05')->send();
Available params
Available query params are compliant with those described in the official API documentation. A 'UniqueId' param can be set using the 'setUniqueId' method, a 'NIP' param - using the 'setNIP' method, etc.
Removing param from query
To remove a param from query params array, you can call a method with 'null' as its only argument, like 'SetUniqueId(null)'. There's no difference between method names starting with a capital letter or not.
GetMigrationData
When a SOAP request envelope is sent, all previously set params are cleared.