/**
  * @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;
 }
예제 #2
0
 /**
  * @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
  * @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;
 }
예제 #4
0
 /**
  * @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;
 }
 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');
 }
 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');
 }
 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');
 }
예제 #8
0
 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');
 }
예제 #9
0
 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');
 }