Skip to content

Commit

Permalink
Updated Database Id value to get the zip code back
Browse files Browse the repository at this point in the history
It returns more values by changing database value.
  • Loading branch information
krishnaramya committed Nov 11, 2015
1 parent 6f8f5a7 commit 7395144
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 deletions.
26 changes: 19 additions & 7 deletions src/NetAcuity.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,42 +41,54 @@ public function __construct(Socket $socket, $apiId)
* @type string $region
* @type string $city
* @type string $conn-speed
* @type string $country-conf
* @type string $region-conf
* @type string $city-conf
* @type string $metro-code
* @type string $latitude
* @type string $longitude
* @type string $postal-code
* @type string $country-code
* @type string $region-code
* @type string $city-code
* @type string $continent-code
* @type string $two-letter-country
* @type string $internal-code
* @type string $area-code
* @type string $country-conf
* @type string $region-conf
* @type string $city-conf
* @type string $postal-conf
* @type string $gmt-offset
* @type string $in-dist
* }
*/
public function getGeo($ip)
{
Util::throwIfNotType(['string' => $ip], true);

$response = $this->_query($this->_buildQuery(3, $ip));
$response = $this->_query($this->_buildQuery(4, $ip));
return $this->_parseResponse(
$response,
[
'country',
'region',
'city',
'conn-speed',
'country-conf',
'region-conf',
'city-conf',
'metro-code',
'latitude',
'longitude',
'zip-code',
'country-code',
'region-code',
'city-code',
'continent-code',
'two-letter-country',
'internal-code',
'area-code',
'country-conf',
'region-conf',
'city-conf',
'postal-conf',
'gmt-offset',
'in-dist',
]
);
}
Expand Down
16 changes: 11 additions & 5 deletions tests/NetAcuityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ public function createNonIntApiId()
public function getGeo()
{
$socket = $this->getMockBuilder('\Socket\Raw\Socket')->disableOriginalConstructor()->setMethods(['write', 'read'])->getMock();
$socket->expects($this->once())->method('write')->with("3;1;1.2.3.4\r\n")->will($this->returnValue(13));
$socket->expects($this->once())->method('write')->with("4;1;1.2.3.4\r\n")->will($this->returnValue(13));
$socket->expects($this->once())->method('read')->with(1024)->will(
$this->returnValue('xxxxUSA;something;reserved;broadband;5;4;3;2;123.456;789.101;112;1314;1516;1;USxxx')
$this->returnValue('xxxxUSA;something;reserved;broadband;2;123.456;789.101;12345;112;1314;1516;1;US;1;123;2;3;4;5;6;7xxx')
);

$client = new NetAcuity($socket, 1);
Expand All @@ -47,17 +47,23 @@ public function getGeo()
'region' => 'something',
'city' => 'reserved',
'conn-speed' => 'broadband',
'country-conf' => '5',
'region-conf' => '4',
'city-conf' => '3',
'metro-code' => '2',
'latitude' => '123.456',
'longitude' => '789.101',
'zip-code' => '12345',
'country-code' => '112',
'region-code' => '1314',
'city-code' => '1516',
'continent-code' => '1',
'two-letter-country' => 'US',
'internal-code' => '1',
'area-code' => '123',
'country-conf' => '2',
'region-conf' => '3',
'city-conf' => '4',
'postal-conf' => '5',
'gmt-offset' => '6',
'in-dist' => '7',
],
$client->getGeo('1.2.3.4')
);
Expand Down

0 comments on commit 7395144

Please sign in to comment.