From e0baddaec02118e201d48e48b74f1875bdffb718 Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Tue, 21 May 2013 13:46:11 -0700 Subject: [PATCH] Added queriesRemaining --- src/GeoIP2/Model/City.php | 3 +++ src/GeoIP2/Model/CityIspOrg.php | 3 +++ src/GeoIP2/Model/Country.php | 5 +++++ src/GeoIP2/Model/Omni.php | 3 +++ src/GeoIP2/Record/MaxMind.php | 19 +++++++++++++++++++ tests/GeoIP2/Test/Model/OmniTest.php | 9 +++++++++ tests/GeoIP2/Test/WebService/ClientTest.php | 8 ++++++++ 7 files changed, 50 insertions(+) create mode 100644 src/GeoIP2/Record/MaxMind.php diff --git a/src/GeoIP2/Model/City.php b/src/GeoIP2/Model/City.php index 642814b..f01fa4d 100644 --- a/src/GeoIP2/Model/City.php +++ b/src/GeoIP2/Model/City.php @@ -23,6 +23,9 @@ namespace GeoIP2\Model; * @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 in and may differ from the diff --git a/src/GeoIP2/Model/CityIspOrg.php b/src/GeoIP2/Model/CityIspOrg.php index c4c675d..834130d 100644 --- a/src/GeoIP2/Model/CityIspOrg.php +++ b/src/GeoIP2/Model/CityIspOrg.php @@ -23,6 +23,9 @@ namespace GeoIP2\Model; * @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 in and may differ from the diff --git a/src/GeoIP2/Model/Country.php b/src/GeoIP2/Model/Country.php index daf23c5..e4eda38 100644 --- a/src/GeoIP2/Model/Country.php +++ b/src/GeoIP2/Model/Country.php @@ -17,6 +17,9 @@ namespace GeoIP2\Model; * IP address. This object represents the country where MaxMind believes the * end user is located. * + * @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 in and may differ from the @@ -35,6 +38,7 @@ class Country private $continent; private $country; private $languages; + private $maxmind; private $registeredCountry; private $representedCountry; private $traits; @@ -55,6 +59,7 @@ class Country $this->get('country'), $languages ); + $this->maxmind = new \GeoIP2\Record\MaxMind($this->get('maxmind')); $this->registeredCountry = new \GeoIP2\Record\Country( $this->get('registered_country'), $languages diff --git a/src/GeoIP2/Model/Omni.php b/src/GeoIP2/Model/Omni.php index 1eddbbc..909b5f2 100644 --- a/src/GeoIP2/Model/Omni.php +++ b/src/GeoIP2/Model/Omni.php @@ -23,6 +23,9 @@ namespace GeoIP2\Model; * @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 in and may differ from the diff --git a/src/GeoIP2/Record/MaxMind.php b/src/GeoIP2/Record/MaxMind.php new file mode 100644 index 0000000..4ead892 --- /dev/null +++ b/src/GeoIP2/Record/MaxMind.php @@ -0,0 +1,19 @@ + 33, 'time_zone' => 'America/Chicago', ), + 'maxmind' => array( + 'queries_remaining' => 22, + ), 'registered_country' => array( 'geoname_id' => 2, 'iso_code' => 'CA', @@ -127,6 +130,12 @@ class OmniTest extends \PHPUnit_Framework_TestCase '$model->traits' ); + $this->assertEquals( + 22, + $model->maxmind->queriesRemaining, + 'queriesRemaining is correct' + ); + $this->assertEquals( $raw, $model->raw, diff --git a/tests/GeoIP2/Test/WebService/ClientTest.php b/tests/GeoIP2/Test/WebService/ClientTest.php index 0565604..8b0f4a9 100644 --- a/tests/GeoIP2/Test/WebService/ClientTest.php +++ b/tests/GeoIP2/Test/WebService/ClientTest.php @@ -22,6 +22,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase 'iso_code' => 'US', 'names' => array( 'en' => 'United States of America' ), ), + 'maxmind' => array('queries_remaining' => 11), 'traits' => array( 'ip_address' => '1.2.3.4', ), @@ -139,6 +140,13 @@ class ClientTest extends \PHPUnit_Framework_TestCase $country->country->name, 'country name is United States of America' ); + + $this->assertEquals( + 11, + $country->maxmind->queriesRemaining, + 'queriesRemaining is correct' + ); + }