deutschepost / sdk-api-addressfactory
PostDirekt Addressfactory API
Installs: 239 967
Dependents: 2
Suggesters: 0
Security: 0
Stars: 3
Watchers: 9
Forks: 3
Open Issues: 0
Requires (Dev)
- ext-simplexml: *
- fig/log-test: ^1.1
- phpstan/phpstan: ^1.0
- phpunit/phpunit: ^9.5
- rector/rector: ^0.15.21
- squizlabs/php_codesniffer: ^3.4
This package is auto-updated.
Last update: 2024-10-27 12:41:46 UTC
README
The Postdirekt Addressfactory API SDK package offers an interface to the ADDRESSFACTORY DIRECT web service which allows to correct and enrich address datasets.
Requirements
System Requirements
- PHP 8.1+ with SOAP extension
Package Requirements
psr/log
: PSR-3 logger interfaces
Development Package Requirements
phpstan/phpstan
: Static analysis toolphpunit/phpunit
: Testing frameworksquizlabs/php_codesniffer
: Static analysis toolrector/rector
: Refactoring toolfig/log-test
: Test utilities forpsr/log
Installation
composer require deutschepost/sdk-api-addressfactory
Uninstallation
composer remove deutschepost/sdk-api-addressfactory
Testing
composer run test
Features
The Postdirekt Addressfactory API SDK supports the following features:
- Get address record by flat address data
- Get address record(s) by complex address data
Get Record By Address
Verify a single address record by passing name and street address.
Public API
The library's components suitable for consumption comprise of
- service:
- service factory
- address verification service
- data transfer objects:
- response record with corrections and status codes indicating issues with the input data
Usage
$logger = new \Psr\Log\NullLogger(); $configName = 'default'; $serviceFactory = new \PostDirekt\Sdk\AddressfactoryDirect\Service\ServiceFactory(); $service = $serviceFactory->createAddressVerificationService('user', 'pass', $logger); $record = $service->getRecordByAddress('53114', 'Bonn', 'Sträßchenweg', '10', 'Mustermann', 'Hans', null, $configName); echo $record->getAddress()->getPostalCode(); // "53113" echo $record->getAddress()->getStreetName(); // "Sträßchensweg" echo $record->getStatusCodes(); // ['BAC100103', 'FNC400501', 'PDC030105', '…']
Get Records By Complex Address
Verify address records by passing in a complex request objects.
Public API
The library's components suitable for consumption comprise of
- service:
- service factory
- address verification service
- data transfer object builder
- data transfer objects:
- response record with corrections and status codes indicating issues with the input data
Usage
$logger = new \Psr\Log\NullLogger(); $configName = 'default'; $serviceFactory = new \PostDirekt\Sdk\AddressfactoryDirect\Service\ServiceFactory(); $service = $serviceFactory->createAddressVerificationService('user', 'pass', $logger); $requestBuilder = new \PostDirekt\Sdk\AddressfactoryDirect\RequestBuilder\RequestBuilder(); $requestBuilder->setMetadata($recordId = 1); $requestBuilder->setAddress('Deutschland', '53114', 'Bonn', 'Sträßchenweg', '10'); $request = $requestBuilder->create(); $records = $service->getRecords([$request], null, $configName); foreach ($records as $record) { echo $record->getRecordId(); // 1 echo $record->getAddress()->getPostalCode(); // "53113" echo $record->getAddress()->getStreetName(); // "Sträßchensweg" echo $record->getStatusCodes(); // ['BAC100103', 'FNC400501', 'PDC030105', '…'] }