Skip to content

Commit

Permalink
Merge pull request #1 from Cyber-Duck/release/v2.0
Browse files Browse the repository at this point in the history
Adds the company field to the address details class. New getter and s…
  • Loading branch information
Tiago Tavares authored Dec 1, 2020
2 parents 02b3389 + 0cc8fe5 commit d9865f3
Show file tree
Hide file tree
Showing 3 changed files with 225 additions and 47 deletions.
24 changes: 24 additions & 0 deletions src/Details.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ class Details
*/
private $city;

/**
* @var string
*/
private $company;

/**
* @var string
*/
Expand Down Expand Up @@ -80,6 +85,24 @@ public function setCity($city): Details
return $this;
}

/**
* @return mixed
*/
public function getCompany()
{
return $this->company;
}

/**
* @param mixed $company
* @return Details
*/
public function setCompany($company): Details
{
$this->company = $company;
return $this;
}

/**
* @return mixed
*/
Expand Down Expand Up @@ -182,6 +205,7 @@ public function get()
'postal_code' => $this->getPostalCode(),
'province_code' => $this->getProvinceCode() ?? '',
'state' => $this->getState() ?? '',
'company' => $this->getCompany(),
'city' => $this->getCity(),
'address_line_1' => $this->getLine1(),
'address_line_2' => $this->getLine2(),
Expand Down
7 changes: 5 additions & 2 deletions src/Drivers/LoqateDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

use CyberDuck\AddressFinder\Details;
use CyberDuck\AddressFinder\Suggestions;
use Http;
use Illuminate\Http\Client\PendingRequest;

/**
* Class LoqateDriver
Expand All @@ -23,7 +25,7 @@ class LoqateDriver implements DriverContract
private $detailsEndpoint;

/**
* @var \Illuminate\Http\Client\PendingRequest
* @var PendingRequest
*/
private $client;

Expand All @@ -35,7 +37,7 @@ public function __construct()
$config = config('laravel-address-finder.loqate');
$this->suggestionsEndpoint = $config['api']['endpoints']['suggestions'];
$this->detailsEndpoint = $config['api']['endpoints']['details'];
$this->client = \Http::withOptions([
$this->client = Http::withOptions([
'base_uri' => $config['api']['base_uri'],
'query' => [
'Key' => $config['api']['key'],
Expand Down Expand Up @@ -119,6 +121,7 @@ public function parseDetails($response)

return $details->setPostalCode($addressDetails['PostalCode'] ?? '')
->setProvinceCode($addressDetails['ProvinceCode'] ?? '')
->setCompany($addressDetails['Company'])
->setCity($addressDetails['City'])
->setLine1($addressDetails['Line1'])
->setLine2($addressDetails['Line2'])
Expand Down
Loading

0 comments on commit d9865f3

Please sign in to comment.