/** * @param $postCode * @return Address */ public function find($postCode) { $this->setRequestUrl(sprintf($this->getRequestUrl(), $postCode)); $response = $this->request(); $address = new Address(); $address->setTown($response[0]['name'])->setMunicipality($response[0]['state']['name'])->setLatitude($response[0]['latitude'])->setLongitude($response[0]['longitude']); 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; }
/** * @param $postCode * @return Address */ public function find($postCode) { $this->setRequestUrl(sprintf($this->getRequestUrl(), $postCode, $this->getApiKey())); $response = $this->request(); $address = new Address(); $address->setMunicipality($response['results'][0]['address_components']['state'])->setStreet($response['results'][0]['address_components']['formatted_street'])->setTown($response['results'][0]['address_components']['city'])->setLatitude($response['results'][0]['location']['lat'])->setLongitude($response['results'][0]['location']['lng']); return $address; }
/** * @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(), $this->getApiKey(), $postCode)); $response = $this->request(); $address = new Address(); $address->setTown($response['results'][0]['city'])->setMunicipality($response['results'][0]['municipality'])->setProvince($response['results'][0]['province'])->setLatitude($response['results'][0]['lat'])->setLongitude($response['results'][0]['lng']); return $address; }
/** * @param $postCode * @param $houseNumber * @return Address */ public function findByPostcodeAndHouseNumber($postCode, $houseNumber) { $this->setRequestUrl(sprintf($this->getRequestUrl(), $postCode, $houseNumber)); $response = $this->request(); $address = new Address(); $address->setStreet($response['street'])->setTown($response['city'])->setHouseNo($response['houseNumber'])->setMunicipality($response['municipality'])->setProvince($response['province'])->setLatitude($response['latitude'])->setLongitude($response['longitude']); return $address; }
/** * @param $postCode * @return Address */ public function find($postCode) { $this->setRequestUrl(sprintf($this->getRequestUrl(), $postCode)); $response = $this->request(); $address = new Address(); $address->setTown($response['result'][0]['admin_county'])->setLatitude($response['result'][0]['latitude'])->setLongitude($response['result'][0]['longitude']); 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->setTown($response['result'][0]['post_town'])->setStreet($response['result'][0]['line_1'])->setLatitude($response['result'][0]['latitude'])->setLongitude($response['result'][0]['longitude']); return $address; }
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__ . '\\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__ . '\\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'); }
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__ . '\\PostcodesIO.json'); $response = new Response(200, [], Stream::factory($json)); $json = json_decode($response->getBody(), true); $address = new Address(); $address->setTown($json['result'][0]['region'])->setLatitude($json['result'][0]['latitude'])->setLongitude($json['result'][0]['longitude']); $this->assertEquals($address->getTown(), 'London'); $this->assertEquals($address->getLatitude(), '51.50100915646'); $this->assertEquals($address->getLongitude(), '-0.14158759787698'); }
/** * @param $postCode * @param $houseNumber * @return Address */ public function findByPostcodeAndHouseNumber($postCode, $houseNumber) { $postCode = strtoupper(preg_replace('/\\s+/', '', $postCode)); // P6 format (1234AB) $houseNumber = preg_replace('/[^0-9.]/', '', $houseNumber); // Should be an integer $this->setRequestUrl(sprintf($this->getRequestUrl(), $postCode, $houseNumber)); $response = $this->request(); $address = new Address(); $address->setHouseNo($response['_embedded']['addresses'][0]['number'])->setStreet($response['_embedded']['addresses'][0]['street'])->setTown($response['_embedded']['addresses'][0]['city']['label'])->setMunicipality($response['_embedded']['addresses'][0]['municipality']['label'])->setProvince($response['_embedded']['addresses'][0]['province']['label'])->setLatitude($response['_embedded']['addresses'][0]['geo']['center']['wgs84']['coordinates'][0])->setLongitude($response['_embedded']['addresses'][0]['geo']['center']['wgs84']['coordinates'][1]); return $address; }
public function testCanReadFindAddressResponse() { $json = file_get_contents(__DIR__ . '\\PostcodeData.json'); $response = new Response(200, [], Stream::factory($json)); $json = $response->json(); $address = new Address(); $address->setStreet($json['details'][0]['street'])->setTown($json['details'][0]['city'])->setMunicipality($json['details'][0]['municipality'])->setProvince($json['details'][0]['province'])->setLatitude($json['details'][0]['lat'])->setLongitude($json['details'][0]['lon']); $this->assertEquals($address->getStreet(), 'Evert van de Beekstraat'); $this->assertEquals($address->getTown(), 'Schiphol'); $this->assertEquals($address->getMunicipality(), 'Haarlemmermeer'); $this->assertEquals($address->getProvince(), 'Noord-Holland'); $this->assertEquals($address->getLatitude(), '52.3035437835548'); $this->assertEquals($address->getLongitude(), '4.7474064734608'); }
public function testCanReadFindAddressResponse() { $json = file_get_contents(__DIR__ . '\\PostcodeApiNu.json'); $response = new Response(200, [], Stream::factory($json)); $json = json_decode($response->getBody(), true); $address = new Address(); $address->setStreet($json['_embedded']['addresses'][0]['street'])->setTown($json['_embedded']['addresses'][0]['city']['label'])->setMunicipality($json['_embedded']['addresses'][0]['municipality']['label'])->setProvince($json['_embedded']['addresses'][0]['province']['label'])->setLatitude($json['_embedded']['addresses'][0]['geo']['center']['wgs84']['coordinates'][1])->setLongitude($json['_embedded']['addresses'][0]['geo']['center']['wgs84']['coordinates'][0]); $this->assertEquals($address->getStreet(), 'Evert van de Beekstraat'); $this->assertEquals($address->getTown(), 'Schiphol'); $this->assertEquals($address->getMunicipality(), 'Haarlemmermeer'); $this->assertEquals($address->getProvince(), 'Noord-Holland'); $this->assertEquals($address->getLatitude(), '52.3052531'); $this->assertEquals($address->getLongitude(), '4.7517051'); }
public function testCanReadFindAddressResponse() { $json = file_get_contents(__DIR__ . '\\Pro6PP_NL.json'); $response = new Response(200, [], Stream::factory($json)); $json = json_decode($response->getBody(), true); $address = new Address(); $address->setTown($json['results'][0]['city'])->setMunicipality($json['results'][0]['municipality'])->setProvince($json['results'][0]['province'])->setLatitude($json['results'][0]['lat'])->setLongitude($json['results'][0]['lng']); $this->assertEquals($address->getTown(), 'Schiphol'); $this->assertEquals($address->getMunicipality(), 'Haarlemmermeer'); $this->assertEquals($address->getProvince(), 'Noord-Holland'); $this->assertEquals($address->getLatitude(), '52.30389'); $this->assertEquals($address->getLongitude(), '4.7479'); }
public function testCanReadFindAddressResponse() { $json = file_get_contents(__DIR__ . '\\Geocodio.json'); $response = new Response(200, [], Stream::factory($json)); $json = json_decode($response->getBody(), true); $address = new Address(); $address->setMunicipality($json['results'][0]['address_components']['state'])->setStreet($json['results'][0]['address_components']['formatted_street'])->setTown($json['results'][0]['address_components']['city'])->setLatitude($json['results'][0]['location']['lat'])->setLongitude($json['results'][0]['location']['lng']); $this->assertEquals($address->getMunicipality(), 'CA'); $this->assertEquals($address->getStreet(), 'Bob Hope Dr'); $this->assertEquals($address->getTown(), 'Rancho Mirage'); $this->assertEquals($address->getLatitude(), '33.739464'); $this->assertEquals($address->getLongitude(), '-116.40803'); }
public function testCanReadFindAddressResponse() { $json = file_get_contents(__DIR__ . '\\Pro6PP_BE.json'); $response = new Response(200, [], Stream::factory($json)); $json = json_decode($response->getBody(), true); $address = new Address(); $address->setTown($json['results'][0]['city'])->setMunicipality($json['results'][0]['municipality'])->setProvince($json['results'][0]['province'])->setLatitude($json['results'][0]['lat'])->setLongitude($json['results'][0]['lng']); $this->assertEquals($address->getTown(), 'Brussel'); $this->assertEquals($address->getMunicipality(), 'Brussel'); $this->assertEquals($address->getProvince(), 'Brussel'); $this->assertEquals($address->getLatitude(), '50.84515'); $this->assertEquals($address->getLongitude(), '4.35842'); }
public function testCanReadFindAddressResponse() { $json = file_get_contents(__DIR__ . '\\PostcodeApiComAu.json'); $response = new Response(200, [], Stream::factory($json)); $json = json_decode($response->getBody(), true); $address = new Address(); $address->setTown($json['name'])->setMunicipality($json['state']['name'])->setLatitude($json['latitude'])->setLongitude($json['longitude']); $this->assertEquals($address->getTown(), 'Collingwood'); $this->assertEquals($address->getMunicipality(), 'Victoria'); $this->assertEquals($address->getLatitude(), '-37.8'); $this->assertEquals($address->getLongitude(), '144.9833'); }
public function testCanReadFindAddressResponse() { $json = file_get_contents(__DIR__ . '\\IdealPostcodes.json'); $response = new Response(200, [], Stream::factory($json)); $json = json_decode($response->getBody(), true); $address = new Address(); $address->setTown($json['result'][0]['post_town'])->setStreet($json['result'][0]['line_1'])->setLatitude($json['result'][0]['latitude'])->setLongitude($json['result'][0]['longitude']); $this->assertEquals($address->getTown(), 'LONDON'); $this->assertEquals($address->getStreet(), 'Buckingham Palace'); $this->assertEquals($address->getLatitude(), '51.50100915646'); $this->assertEquals($address->getLongitude(), '-0.14158759787698'); }