itk-dev / datafordeler-php-client
PHP client for datafordeler.dk
1.0.0
2023-02-18 10:23 UTC
Requires
- php: ^7.4 || ^8.0
- guzzlehttp/guzzle: ^7.3
Requires (Dev)
This package is auto-updated.
Last update: 2024-11-18 14:16:59 UTC
README
Installation
composer require itk-dev/datafordeler-php-client
Usage
use ItkDev\Datafordeler\Client; use ItkDev\Datafordeler\Service\CVR\HentCVRData\V1 as HentCVRDataV1; use ItkDev\Datafordeler\Service\BBR\BBRPublic\V1 as BBRPublicV1; $certPath = «path to pem certificate»; $client = Client::createFromCertPath($certPath); $service = new HentCVRDataV1($client); // Get data from just a CVR. $data = $hentCVRData->hentVirksomhedMedCVRNummer(12345678); … // Get data using more parameters. $data = $hentCVRData->hentVirksomhedMedCVRNummer([ 'pCVRNummer' => 12345678, 'pInkluderBeskaeftigelse' => true, 'pInkluderProduktionsenhedsnumre' => false, ]); $username = '…'; $password = '…' $client = Client::createFromUsernameAndPassword($username, $password); $service = new BBRPublicV1($client); $service->bbrsag([]);
Helper script
For testing you can run vendor/bin/datafordeler
to perform a data lookup, e.g.
with certificate (in PEM format):
vendor/bin/datafordeler «pem path» 'ItkDev\Datafordeler\Service\CVR\V1\HentCVRData' hentVirksomhedMedCVRNummer 55133018
or with username and password:
vendor/bin/datafordeler «username» «password» 'ItkDev\Datafordeler\Service\BBR\V1\BBRPublic' enhed '{"AdresseIdentificerer": "bb64a029-ba99-404a-85fd-cad0ecf203b7"}'
An address identifier can be fetched via https://api.dataforsyningen.dk/datavask/adresser, e.g. https://api.dataforsyningen.dk/datavask/adresser?betegnelse=Hack%20Kampmanns%20Plads%202%208000%20Aarhus%20C:
curl --silent 'https://api.dataforsyningen.dk/datavask/adresser?betegnelse=Hack%20Kampmanns%20Plads%202%208000%20Aarhus%20C' | jq --raw-output '.resultater[0].adresse.id'
Development
Coding standards
composer check-coding-standards yarn check-coding-standards
API documentation
Run
docker run --rm -v $(pwd):/data phpdoc/phpdoc:3 --config=phpdoc.dist.xml
to update the API documentation.