-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial work of Postcode Anywhere integration
- Loading branch information
Jordan Hall
committed
Jun 22, 2017
1 parent
3ea7854
commit 1694ce8
Showing
7 changed files
with
70 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
require_once 'vendor/autoload.php'; | ||
|
||
use RapidWeb\Postcodes\Objects\PostcodeAnywhere; | ||
|
||
$postcodeAnywhere = new PostcodeAnywhere('API_KEY'); | ||
|
||
$postcodeAnywhere->getAddressesByPostcode('st163jr'); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
namespace RapidWeb\Postcodes\Interfaces; | ||
|
||
interface PostcodeServiceInterface | ||
{ | ||
public function __construct($apiKey); | ||
public function getAddressesByPostcode($postcode); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
namespace RapidWeb\Postcodes\Objects; | ||
|
||
use GuzzleHttp\Client; | ||
use GuzzleHttp\Psr7\Response; | ||
use RapidWeb\Postcodes\Interfaces\PostcodeServiceInterface; | ||
use Exception; | ||
use SoapClient; | ||
|
||
class PostcodeAnywhere implements PostcodeServiceInterface | ||
{ | ||
private $apiKey = null; | ||
private $findSOAPClient = null; | ||
|
||
public function __construct($apiKey) | ||
{ | ||
if (!$apiKey) { | ||
throw new Exception('No Postcode Anywhere API key specified.'); | ||
} | ||
|
||
$this->apiKey = $apiKey; | ||
|
||
$this->findSOAPClient = new SoapClient('https://services.postcodeanywhere.co.uk/PostcodeAnywhere/Interactive/Find/v1.10/wsdlnew.ws'); | ||
|
||
} | ||
|
||
public function getAddressesByPostcode($postcode) | ||
{ | ||
$findResponse = $this->findSOAPClient->PostcodeAnywhere_Interactive_Find_v1_10( | ||
[ | ||
'Key' => $this->apiKey, | ||
'SearchTerm' => $postcode | ||
] | ||
); | ||
|
||
$findResponseAddresses = $findResponse->PostcodeAnywhere_Interactive_Find_v1_10_Result->PostcodeAnywhere_Interactive_Find_v1_10_Results; | ||
|
||
return $result; | ||
} | ||
|
||
} |