Download the PHP package hyraiq/ie-companies-registration-office-lookup without Composer
On this page you can find all versions of the php package hyraiq/ie-companies-registration-office-lookup. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hyraiq/ie-companies-registration-office-lookup
More information about hyraiq/ie-companies-registration-office-lookup
Files in hyraiq/ie-companies-registration-office-lookup
Package ie-companies-registration-office-lookup
Short Description Irish business number validation and verification using the Irish Companies Registration Office (CRO) web services API
License MIT
Informations about the package ie-companies-registration-office-lookup
hyraiq/ie-companies-registration-office-lookup
A PHP SDK to validate Irish Business Numbers and verify them with the Irish Companies Registration Office (CRO) Public Data API.
The difference between validation and verification can be outlined as follows:
- Validation uses a regular expression to check that a given number is a valid Irish business number. This does not contact the API to ensure that the given number is assigned to a business
- Verification contacts the Companies Registration Office through their API to retrieve information registered against the entity number. It will tell you if the number actually belongs to a business.
In order to use the API (only necessary for verification), you'll need to register an account to receive an API key.
Type safety
The SDK utilises the Symfony Serializer and the Symfony Validator to deserialize and validate data returned from the API in order to provide a valid IeCompanyResponse model. This means that if you receive a response from the SDK, it is guaranteed to be valid.
Invalid responses from the API fall into three categories, which are handled with exceptions:
ConnectionException.php
: Unable to connect to the API, or the API returned an unexpected responseNumberInvalidException.php
: The entity number is invalid (i.e. validation failed)NumberNotFoundException.php
: The entity number is valid, however it is not assigned to a business (i.e. verification failed)
Usage
Installation
Configuration with Symfony
In services.yaml
, you need to pass your CRO API key and associated email address to the ApiClient
and register the ApiClient
with the
ApiClientInterface
:
You can then inject the ApiClientInterface
directly into your controllers/services.
You also need to add the custom address denormalizer to the services.yaml
:
Configuration outside Symfony
If you're not using Symfony, you'll need to instantiate the API client yourself, which can be registered in your service
container or just used directly. We have provided some helpers in the Dependencies
class in order to create the
Symfony Serializer and Validator with minimal options.
Looking up a business number
Once you have configured your ApiClient
you can look up an individual business numbers. Note, this will validate the number before
calling the API in order to prevent unnecessary API requests.
Testing
In automated tests, you can replace the ApiClient
with the StubApiClient
in order to mock responses from the API.
There is also the BusinessNumberFaker
which you can use during tests to get both valid and invalid business numbers.
Contributing
All contributions are welcome! You'll need docker installed in order to run tests and CI processes locally. These will also be run against your pull request with any failures added as GitHub annotations in the Files view.
In order for you PR to be accepted, it will need to be covered by tests and be accepted by:
All versions of ie-companies-registration-office-lookup with dependencies
ext-json Version *
doctrine/annotations Version ^2.0
phpdocumentor/reflection-docblock Version ^5.3
phpstan/phpdoc-parser Version ^1.2
pmigut/gtin-validator Version ^1.2
symfony/cache Version ^6.0 | ^7.0
symfony/http-client Version ^6.0 | ^7.0
symfony/property-access Version ^6.0 | ^7.0
symfony/property-info Version ^6.0 | ^7.0
symfony/serializer Version ^6.0 | ^7.0
symfony/validator Version ^6.0 | ^7.0