Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SF4 support #7

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
language: php

php:
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
- 7.2

branches:
only:
Expand Down
22 changes: 22 additions & 0 deletions Api/ApiClient.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
namespace BoxUk\PostcodesIoBundle\Api;

use GuzzleHttp\Command\Guzzle\GuzzleClient;

/**
* Class ApiClient
* @package BoxUk\PostcodesIoBundle\Api
* Skeleton class for autowiring
* @method array lookup(array $parameters = ['postcode' => ''])
* @method array bulkLookup(array $parameters = ['postcodes' => []])
* @method array reverseGeocode(array $parameters = ['longitude' => '', 'latitude' => '', 'limit' => '', 'radius' => ''])
* @method array bulkReverseGeocode(array $parameters = [])
* @method array matching(array $parameters = ['query' => '', 'limit' => ''])
* @method array validate(array $parameters = ['postcode' => ''])
* @method array autocomplete(array $parameters = ['postcode' => '', 'limit' => ''])
* @method array random()
* @method array outwardCodeLookup(array $parameters = ['postcode' => ''])
*/
class ApiClient extends GuzzleClient
{
}
6 changes: 3 additions & 3 deletions Api/ClientFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ClientFactory
*/
public function create($baseUrl = self::DEFAULT_BASE_URL)
{
return new GuzzleClient(new Client(), $this->getServiceDescription($baseUrl));
return new ApiClient(new Client(), $this->getServiceDescription($baseUrl));
}

/**
Expand Down Expand Up @@ -59,7 +59,7 @@ protected function getServiceDescription($baseUrl)
'responseModel' => 'getResponse',
'parameters' => array(
'postcodes' => array(
'location' => 'postField',
'location' => 'formParam',
'description' => 'The postcodes to look up (max 100).',
'required' => true
)
Expand Down Expand Up @@ -98,7 +98,7 @@ protected function getServiceDescription($baseUrl)
'responseModel' => 'getResponse',
'parameters' => array(
'geolocations' => array(
'location' => 'postField',
'location' => 'formParam',
'description' => 'The latitude and longitude coordinates to look up.',
'required' => true
)
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ A bundle for querying the [postcodes.io](http://postcodes.io) web service.

[License](LICENSE)

Note from DailyInfo - SF4 work in progress
====

This is a fork of the excellent [Symfony 2 bundle by Chris Collins of Box UK](https://github.com/boxuk/postcodes-io-bundle) that has been updated to support Symfony 3/4. The tests are failing due to the updated version of Guzzle being used in this fork, use it at your own risk. The version of Guzzle has been updated to v6, which means that the mocking of clients must be changed - if you find yourself using this fork and have Guzzle testing experience, please feel free to submit a pull request.

Installation
------------
Expand Down
10 changes: 3 additions & 7 deletions Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

<parameters>
<parameter key="box_uk_postcodes_io.client_factory.class">BoxUk\PostcodesIoBundle\Api\ClientFactory</parameter>
<parameter key="box_uk_postcodes_io.client.class">GuzzleHttp\Command\Guzzle\GuzzleClient</parameter>
</parameters>

<services>
<service id="box_uk_postcodes_io.client_factory" class="%box_uk_postcodes_io.client_factory.class%" />
<service id="box_uk_postcodes_io.client" class="%box_uk_postcodes_io.client.class%" factory-service="box_uk_postcodes_io.client_factory" factory-method="create">
<service id="BoxUk\PostcodesIoBundle\Api\ClientFactory" class="BoxUk\PostcodesIoBundle\Api\ClientFactory" />
<service id="BoxUk\PostcodesIoBundle\Api\ApiClient" class="BoxUk\PostcodesIoBundle\Api\ApiClient">
<factory service="BoxUk\PostcodesIoBundle\Api\ClientFactory" method="create"/>
<argument>%box_uk_postcodes_io.base_url%</argument>
</service>
</services>
Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "boxuk/postcodes-io-bundle",
"type": "library",
"description": "A Symfony2 bundle for interaction with the postcodes.io service.",
"description": "A Symfony 3/4 bundle for interaction with the postcodes.io service.",
"keywords": ["postcode", "postcodes.io", "guzzle"],
"license": "MIT",
"authors": [
Expand All @@ -11,12 +11,12 @@
}
],
"require": {
"php": ">=5.4.0",
"symfony/framework-bundle": "2.*",
"guzzlehttp/guzzle-services": "~0.1"
"php": "^7.0",
"symfony/framework-bundle": "^3.0|^4.0",
"guzzlehttp/guzzle-services": "^1.0"
},
"require-dev": {
"symfony/browser-kit": "~2.5",
"symfony/browser-kit": "^3.0|^4.0",
"phpunit/phpunit": "~4.7",
"squizlabs/php_codesniffer": "~1.5",
"phpmd/phpmd": "~2.0",
Expand Down