Update for GeoIP2 web services v2.1

This commit is contained in:
Gregory Oschwald
2014-07-15 14:19:30 -07:00
parent 6b919b4cba
commit a5fe44c3d3
17 changed files with 134 additions and 130 deletions
+10 -6
View File
@@ -92,37 +92,41 @@ class Reader implements ProviderInterface
}
/**
* This method returns a GeoIP2 City/ISP/Org model.
* This method returns a GeoIP2 City model.
*
* @param string $ipAddress IPv4 or IPv6 address as a string.
*
* @return \GeoIp2\Model\CityIspOrg
* @return \GeoIp2\Model\City
*
* @throws \GeoIp2\Exception\AddressNotFoundException if the address is
* not in the database.
* @throws \MaxMind\Db\Reader\InvalidDatabaseException if the database
* is corrupt or invalid
*
* @deprecated deprecated since version 0.7.0
*/
public function cityIspOrg($ipAddress)
{
return $this->modelFor('CityIspOrg', $ipAddress);
return $this->modelFor('City', $ipAddress);
}
/**
* This method returns a GeoIP2 Omni model.
* This method returns a GeoIP2 Insights model.
*
* @param string $ipAddress IPv4 or IPv6 address as a string.
*
* @return \GeoIp2\Model\Omni
* @return \GeoIp2\Model\Insights
*
* @throws \GeoIp2\Exception\AddressNotFoundException if the address is
* not in the database.
* @throws \MaxMind\Db\Reader\InvalidDatabaseException if the database
* is corrupt or invalid
*
* @deprecated deprecated since version 0.7.0
*/
public function omni($ipAddress)
{
return $this->modelFor('Omni', $ipAddress);
return $this->modelFor('Insights', $ipAddress);
}
public function connectionType($ipAddress)
+3 -4
View File
@@ -3,11 +3,10 @@
namespace GeoIp2\Model;
/**
* This class provides a model for the data returned by the GeoIP2
* City end point.
* Model class for the data returned by GeoIP2 City web service and database.
*
* The only difference between the City, City/ISP/Org, and Omni model
* classes is which fields in each record may be populated. See
* The only difference between the City and Insights model classes is which
* fields in each record may be populated. See
* http://dev.maxmind.com/geoip/geoip2/web-services more details.
*
* @property \GeoIp2\Record\City $city City data for the requested IP
-57
View File
@@ -1,57 +0,0 @@
<?php
namespace GeoIp2\Model;
/**
* This class provides a model for the data returned by the GeoIP2
* City/ISP/Org end point.
*
* The only difference between the City, City/ISP/Org, and Omni model
* classes is which fields in each record may be populated. See
* http://dev.maxmind.com/geoip/geoip2/web-services more details.
*
* @property \GeoIp2\Record\City $city City data for the requested IP
* address.
*
* @property \GeoIp2\Record\Continent $continent Continent data for the
* requested IP address.
*
* @property \GeoIp2\Record\Country $country Country data for the requested
* IP address. This object represents the country where MaxMind believes the
* end user is located.
*
* @property \GeoIp2\Record\Location $location Location data for the
* requested IP address.
*
* @property \GeoIp2\Record\MaxMind $maxmind Data related to your MaxMind
* account.
*
* @property \GeoIp2\Record\Country $registeredCountry Registered country
* data for the requested IP address. This record represents the country
* where the ISP has registered a given IP block and may differ from the
* user's country.
*
* @property \GeoIp2\Record\RepresentedCountry $representedCountry
* Represented country data for the requested IP address. The represented
* country is used for things like military bases or embassies. It is only
* present when the represented country differs from the country.
*
* @property array $subdivisions An array of {@link \GeoIp2\Record\Subdivision}
* objects representing the country subdivisions for the requested IP
* address. The number and type of subdivisions varies by country, but a
* subdivision is typically a state, province, county, etc. Subdivisions
* are ordered from most general (largest) to most specific (smallest).
* If the response did not contain any subdivisions, this method returns
* an empty array.
*
* @property \GeoIp2\Record\Subdivision $mostSpecificSubdivision An object
* representing the most specific subdivision returned. If the response
* did not contain any subdivisions, this method returns an empty
* {@link \GeoIp2\Record\Subdivision} object.
*
* @property \GeoIp2\Record\Traits $traits Data for the traits of the
* requested IP address.
*/
class CityIspOrg extends City
{
}
+3 -3
View File
@@ -3,10 +3,10 @@
namespace GeoIp2\Model;
/**
* This class provides a model for the data returned by the GeoIP2 Country.
* Model class for the data returned by GeoIP2 Country web service and database.
*
* The only difference between the City, City/ISP/Org, and Omni model
* classes is which fields in each record may be populated. See
* The only difference between the City and Insights model classes is which
* fields in each record may be populated. See
* http://dev.maxmind.com/geoip/geoip2/web-services more details.
*
* @property \GeoIp2\Record\Continent $continent Continent data for the
@@ -3,11 +3,10 @@
namespace GeoIp2\Model;
/**
* This class provides a model for the data returned by the GeoIP2
* Omni end point.
* Model class for the data returned by GeoIP2 Precision: Insights web service.
*
* The only difference between the City, City/ISP/Org, and Omni model
* classes is which fields in each record may be populated. See
* The only difference between the City and Insights model classes is which
* fields in each record may be populated. See
* http://dev.maxmind.com/geoip/geoip2/web-services more details.
*
* @property \GeoIp2\Record\City $city City data for the requested IP
@@ -52,6 +51,6 @@ namespace GeoIp2\Model;
* @property \GeoIp2\Record\Traits $traits Data for the traits of the
* requested IP address.
*/
class Omni extends CityIspOrg
class Insights extends City
{
}
+6 -2
View File
@@ -21,14 +21,18 @@ interface ProviderInterface
/**
* @param ipAddress
* IPv4 or IPv6 address to lookup.
* @return \GeoIp2\Model\CityIspOrg A CityIspOrg model for the requested IP address.
* @return \GeoIp2\Model\City A City model for the requested IP address.
*
* @deprecated deprecated since version 0.7.0
*/
public function cityIspOrg($ipAddress);
/**
* @param ipAddress
* IPv4 or IPv6 address to lookup.
* @return \GeoIp2\Model\Omni An Omni model for the requested IP address.
* @return \GeoIp2\Model\Insights An Insights model for the requested IP address.
*
* @deprecated deprecated since version 0.7.0
*/
public function omni($ipAddress);
}
+1 -1
View File
@@ -9,7 +9,7 @@ namespace GeoIp2\Record;
*
* @property int $confidence A value from 0-100 indicating MaxMind's
* confidence that the city is correct. This attribute is only available
* from the Omni end point.
* from the Insights end point.
*
* @property int $geonameId The GeoName ID for the city. This attribute
* is returned by all end points.
+1 -1
View File
@@ -9,7 +9,7 @@ namespace GeoIp2\Record;
*
* @property int $accuracyRadius The radius in kilometers around the
* specified location where the IP address is likely to be. This attribute
* is only available from the Omni end point.
* is only available from the Insights end point.
*
* @property float $latitude The latitude of the location as a floating
* point number. This attribute is returned by all end points except the
+1 -1
View File
@@ -14,7 +14,7 @@ namespace GeoIp2\Record;
*
* @property int $confidence A value from 0-100 indicating MaxMind's
* confidence that the postal code is correct. This attribute is only
* available from the Omni end point.
* available from the Insights end point.
*/
class Postal extends AbstractRecord
{
+1 -1
View File
@@ -13,7 +13,7 @@ namespace GeoIp2\Record;
*
* @property int $confidence A value from 0-100 indicating MaxMind's
* confidence that the country is correct. This attribute is only available
* from the Omni end point.
* from the Insights end point.
*
* @property int $geonameId The GeoName ID for the country. This attribute is
* returned by all end points.
+1 -1
View File
@@ -10,7 +10,7 @@ namespace GeoIp2\Record;
*
* @property int $confidence This is a value from 0-100 indicating MaxMind's
* confidence that the subdivision is correct. This attribute is only
* available from the Omni end point.
* available from the Insights end point.
*
* @property int $geonameId This is a GeoName ID for the subdivision. This
* attribute is returned by all end points except Country.
+10 -7
View File
@@ -11,18 +11,18 @@ namespace GeoIp2\Record;
* @property int $autonomousSystemNumber The {@link
* http://en.wikipedia.org/wiki/Autonomous_system_(Internet) autonomous
* system number} associated with the IP address. This attribute is only
* available from the City/ISP/Org and Omni end points.
* available from the City and Insights web service end points.
*
* @property string $autonomousSystemOrganization The organization
* associated with the registered {@link
* http://en.wikipedia.org/wiki/Autonomous_system_(Internet) autonomous
* system number} for the IP address. This attribute is only available from
* the City/ISP/Org and Omni end points.
* the City and Insights web service end points.
*
* @property string $domain The second level domain associated with the
* IP address. This will be something like "example.com" or "example.co.uk",
* not "foo.example.com". This attribute is only available from the
* City/ISP/Org and Omni end points.
* City and Insights web service end points.
*
* @property string $ipAddress The IP address that the data in the model
* is for. If you performed a "me" lookup against the web service, this
@@ -40,12 +40,12 @@ namespace GeoIp2\Record;
* end points.
*
* @property string $isp The name of the ISP associated with the IP address.
* This attribute is only available from the City/ISP/Org and Omni end
* This attribute is only available from the City and Insights web service end
* points.
*
* @property string $organization The name of the organization associated
* with the IP address. This attribute is only available from the City/ISP/Org
* and Omni end points.
* with the IP address. This attribute is only available from the City and
* Insights web service end points.
*
* @property string $userType <p>The user type associated with the IP
* address. This can be one of the following values:</p>
@@ -66,7 +66,10 @@ namespace GeoIp2\Record;
* <li>search_engine_spider
* <li>traveler
* </ul>
* <p>This attribute is only available from the Omni end point.</p>
* <p>
* This attribute is only available from the Insight web service end
* point.
* </p>
*/
class Traits extends AbstractRecord
{
+52 -14
View File
@@ -15,10 +15,10 @@ use Guzzle\Http\Exception\ClientErrorResponseException;
use Guzzle\Http\Exception\ServerErrorResponseException;
/**
* This class provides a client API for all the GeoIP2 web service's
* end points. The end points are Country, City, City/ISP/Org, and Omni. Each
* end point returns a different set of data about an IP address, with Country
* returning the least data and Omni the most.
* This class provides a client API for all the GeoIP2 Precision web service
* end points. The end points are Country, City, and Insights. Each end point
* returns a different set of data about an IP address, with Country returning
* the least data and Insights the most.
*
* Each web service end point is represented by a different model class, and
* these model classes in turn contain multiple Record classes. The record
@@ -80,7 +80,7 @@ class Client implements ProviderInterface
}
/**
* This method calls the GeoIP2 City endpoint.
* This method calls the GeoIP2 Precision: City endpoint.
*
* @param string $ipAddress IPv4 or IPv6 address as a string. If no
* address is provided, the address that the web service is called
@@ -112,7 +112,41 @@ class Client implements ProviderInterface
}
/**
* This method calls the GeoIP2 Country endpoint.
* This method calls the GeoIP2 Precision: City endpoint.
*
* @param string $ipAddress IPv4 or IPv6 address as a string. If no
* address is provided, the address that the web service is called
* from will be used.
*
* @return \GeoIp2\Model\City
*
* @throws \GeoIp2\Exception\AddressNotFoundException if the address you
* provided is not in our database (e.g., a private address).
* @throws \GeoIp2\Exception\AuthenticationException if there is a problem
* with the user ID or license key that you provided.
* @throws \GeoIp2\Exception\OutOfQueriesException if your account is out
* of queries.
* @throws \GeoIp2\Exception\InvalidRequestException} if your request was
* received by the web service but is invalid for some other reason.
* This may indicate an issue with this API. Please report the error to
* MaxMind.
* @throws \GeoIp2\Exception\HttpException if an unexpected HTTP error
* code or message was returned. This could indicate a problem with the
* connection between your server and the web service or that the web
* service returned an invalid document or 500 error code.
* @throws \GeoIp2\Exception\GeoIp2Exception This serves as the parent
* class to the above exceptions. It will be thrown directly if a 200
* status code is returned but the body is invalid.
*
* @deprecated deprecated since version 0.7.0
*/
public function cityIspOrg($ipAddress = 'me')
{
return $this->city($ipAddress);
}
/**
* This method calls the GeoIP2 Precision: Country endpoint.
*
* @param string $ipAddress IPv4 or IPv6 address as a string. If no
* address is provided, the address that the web service is called
@@ -144,13 +178,13 @@ class Client implements ProviderInterface
}
/**
* This method calls the GeoIP2 City/ISP/Org endpoint.
* This method calls the GeoIP2 Precision: Insights endpoint.
*
* @param string $ipAddress IPv4 or IPv6 address as a string. If no
* address is provided, the address that the web service is called
* from will be used.
*
* @return \GeoIp2\Model\CityIspOrg
* @return \GeoIp2\Model\Insights
*
* @throws \GeoIp2\Exception\AddressNotFoundException if the address you
* provided is not in our database (e.g., a private address).
@@ -169,20 +203,22 @@ class Client implements ProviderInterface
* @throws \GeoIp2\Exception\GeoIp2Exception This serves as the parent
* class to the above exceptions. It will be thrown directly if a 200
* status code is returned but the body is invalid.
*
* @deprecated deprecated since version 0.7.0
*/
public function cityIspOrg($ipAddress = 'me')
public function insights($ipAddress = 'me')
{
return $this->responseFor('city_isp_org', 'CityIspOrg', $ipAddress);
return $this->responseFor('insights', 'Insights', $ipAddress);
}
/**
* This method calls the GeoIP2 Omni endpoint.
* This method calls the GeoIP2 Precision: Insights (prev. Omni) endpoint.
*
* @param string $ipAddress IPv4 or IPv6 address as a string. If no
* address is provided, the address that the web service is called
* from will be used.
*
* @return \GeoIp2\Model\Omni
* @return \GeoIp2\Model\Insights
*
* @throws \GeoIp2\Exception\AddressNotFoundException if the address you
* provided is not in our database (e.g., a private address).
@@ -201,10 +237,12 @@ class Client implements ProviderInterface
* @throws \GeoIp2\Exception\GeoIp2Exception This serves as the parent
* class to the above exceptions. It will be thrown directly if a 200
* status code is returned but the body is invalid.
*
* @deprecated deprecated since version 0.7.0
*/
public function omni($ipAddress = 'me')
{
return $this->responseFor('omni', 'Omni', $ipAddress);
return $this->insights($ipAddress);
}
private function responseFor($endpoint, $class, $ipAddress)
@@ -354,6 +392,6 @@ class Client implements ProviderInterface
private function baseUri()
{
return 'https://' . $this->host . '/geoip/v2.0';
return 'https://' . $this->host . '/geoip/v2.1';
}
}