Download the PHP package lendable/dvla-vehicle-enquiry-api-client without Composer
On this page you can find all versions of the php package lendable/dvla-vehicle-enquiry-api-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download lendable/dvla-vehicle-enquiry-api-client
More information about lendable/dvla-vehicle-enquiry-api-client
Files in lendable/dvla-vehicle-enquiry-api-client
Package dvla-vehicle-enquiry-api-client
Short Description API client for the DVLA's Vehicle Enquiry Service API
License proprietary
Homepage https://www.lendable.co.uk
Informations about the package dvla-vehicle-enquiry-api-client
DVLA Vehicle Enquiry API client
PHP client implementation for the DVLA Vehicle Enquiry API v1. This package provides:
- API client that supports PSR-18 HTTP clients
- token-based authentication
- value objects for the request building and for the response
Installation
You can install the library via Composer.
Usage
The Client class implements the DVLA's REST API and can return the vehicles scope which can be used to request the vehicle details.
For the instantiation of the Client class we need to inject the decorators which adds the API key authentication, and the PSR-18 compatibility layers. Also, we need to define the API's base URI to easily switch between UAT and live service.
Base URI
The API's specification contains the UAT and live URL.
The given URI should not end with slash (/
) and should contain the /v1
path too.
For example: https://uat.driver-vehicle-licensing.api.gov.uk/vehicle-enquiry/v1
The client accepts the URI in any PSR-7 UriInterface implementation.
Authentication
The ApiKeyAuthHttpClientDecorator adds the required API token authentication headers to the requests. The ApiKey value object keeps the token secret, avoiding accidental exposure.
HTTP client
With the Psr18ClientDecorator you can use any HTTP client which supports the PSR-18 standard to perform the prebuilt HTTP request.
If you prefer to use an HTTP client that doesn't support the PSR-18 standard, you can alternatively make a simple decorator that calls the HTTP client using the PSR-18 RequestInterface format request data and convert the HTTP client's response to a PSR-18 ResponseInterface format response.
For example in our integration test we are using GuzzleClient with a decorator which using this PSR-18 conversion.
Example request
This makes an API request with the AA19PPP
registration number and the $vehicleDetails
variable will contain an
EnquiryResponse object
which contains all the returned API response data in value objects.
This example is using the UAT API URL and a test registration number. Test registration numbers for mock responses of the different test cases are available in the DVLA Vehicle Enquiry Service API documentation.
All versions of dvla-vehicle-enquiry-api-client with dependencies
ext-json Version *
beberlei/assert Version ^3.2
nyholm/psr7 Version ^1.2
paragonie/hidden-string Version ^1.0 || ^2.0
psr/http-client Version ^1.0.1
psr/http-message Version ^1.0