Added queriesRemaining

This commit is contained in:
Gregory Oschwald 2013-05-21 13:46:11 -07:00
parent 89f1bbdb65
commit e0baddaec0
7 changed files with 50 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,19 @@
<?php
namespace GeoIP2\Record;
/**
* Contains data about your account.
*
* This record is returned by all the end points.
*
* @property int $queriesRemaining The number of remaining queries you have
* for the end point you are calling.
*/
class MaxMind extends AbstractRecord
{
/**
* @ignore
*/
protected $validAttributes = array('queriesRemaining');
}

View File

@ -36,6 +36,9 @@ class OmniTest extends \PHPUnit_Framework_TestCase
'postal_confidence' => 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,

View File

@ -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'
);
}