/**
  * @param $postCode
  * @return Address
  */
 public function find($postCode)
 {
     $this->setRequestUrl(sprintf($this->getRequestUrl(), $postCode));
     $response = $this->request();
     $address = new Address();
     $address->setLatitude($response['wgs84']['lat'])->setLongitude($response['wgs84']['lon']);
     return $address;
 }
 /**
  * @param $postCode
  * @return Address
  */
 public function find($postCode)
 {
     $this->setRequestUrl(sprintf($this->getRequestUrl(), $postCode, $this->getApiKey()));
     $response = $this->request();
     $address = new Address();
     $address->setLatitude($response['Latitude'])->setLongitude($response['Longitude'])->setStreet($response['Addresses'][0]);
     return $address;
 }
 public function testCanReadFindAddressResponse()
 {
     $json = file_get_contents(__DIR__ . '\\UkPostcodes.json');
     $response = new Response(200, [], Stream::factory($json));
     $json = json_decode($response->getBody(), true);
     $address = new Address();
     $address->setLatitude($json['geo']['lat'])->setLongitude($json['geo']['lng']);
     $this->assertEquals($address->getLatitude(), '51.501009174414');
     $this->assertEquals($address->getLongitude(), '-0.14157319687256');
 }
 public function testCanReadFindAddressResponse()
 {
     $json = file_get_contents(__DIR__ . '\\GeoPostcodeOrgUk.json');
     $response = new Response(200, [], Stream::factory($json));
     $json = json_decode($response->getBody(), true);
     $address = new Address();
     $address->setLatitude($json['wgs84']['lat'])->setLongitude($json['wgs84']['lon']);
     $this->assertEquals($address->getLatitude(), '51.501009');
     $this->assertEquals($address->getLongitude(), '-0.141588');
 }
 public function testCanReadFindAddressResponse()
 {
     $json = file_get_contents(__DIR__ . '\\GetAddressIO.json');
     $response = new Response(200, [], Stream::factory($json));
     $json = $response->json();
     $address = new Address();
     $address->setLatitude($json['Latitude'])->setLongitude($json['Longitude'])->setStreet($json['Addresses'][0]);
     $this->assertEquals($address->getLatitude(), '51.503038');
     $this->assertEquals($address->getLongitude(), '-0.128371');
     $this->assertEquals($address->getStreet(), 'Prime Minister & First Lord of the Treasury, 10 Downing Street, , , , London, Greater London');
 }
 public function testCanReadFindAddressResponse()
 {
     $json = file_get_contents(__DIR__ . '\\GetAddressIO.json');
     $response = new Response(200, [], Stream::factory($json));
     $json = json_decode($response->getBody(), true);
     $address = new Address();
     $address->setLatitude($json['Latitude'])->setLongitude($json['Longitude'])->setStreet($json['Addresses'][0]);
     $this->assertEquals($address->getLatitude(), '51.500571');
     $this->assertEquals($address->getLongitude(), '-0.142881');
     $this->assertEquals($address->getStreet(), 'Buckingham Palace, , , , , London, Greater London');
 }