Laravel API wrapper for PCA Predict formerly Postcode Anywhere

Build Status

This wrapper simplifies process of making API calls to PostcodeAnywhere web services. Single line of code within your Laravel application that's all it takes.

Dependency

PHP cURL required

Installation

To install in console issue following command

composer require alexpechkarev/postcode-anywhere:dev-master

Alternatively edit composer.json by adding following line and issue composer update command in console.

"alexpechkarev/postcode-anywhere": "dev-master"

Configuration

Once installed, register Laravel service provider, in your config/app.php:

'providers' => [
    ...
    'PostcodeAnywhere\PAServiceProvider',
]

'aliases' => [
    ...
    'PA' => 'PostcodeAnywhere\PAFacade' ,
]

In console issue following command to publish configuration file php artisan vendor:publish . To access the services do not forget to update the service key in configuration file.

Configuration file have multidimensional array 'services' that defines web services by type 'find' and 'retrieve' and store each services request path. Feel free to add / remove any other PCA Predict services.

Usage

Here is an example of making call to find address records for the given postcode. See API documentation PostcodeAnywhere Interactive FindByPostcode (v1.00) for required parameters and response.

Within your application call \PA::getResponse() with array of parameters.

Where:

$response = \PA::getRespose(['find'=>'FindByPostcode', 'param'=>['postcode'=>'SW1A 1AA', 'endpoint'=>'json'] ]);

Here is another example of retrieving full address details based on the id. See API documentation PostcodeAnywhere Interactive RetrieveById (v1.30) for required parameters and response.

Where:

$response = \PA::getRespose(['retrieve'=>'RetrieveById', 'param'=>['id'=>'23747212.00'] ]);

Support

Found errors or to suggest improvements please open an issue on GitHub

License

Laravel API wrapper for PCA Predict formerly Postcode Anywhere is released under the MIT License. See the bundled LICENSE file for details.