Webservice => WebService
This commit is contained in:
parent
06cb4df177
commit
58673466c0
10
README.md
10
README.md
|
@ -9,7 +9,7 @@ In the future, this distribution will also provide the same API for the
|
||||||
GeoIP2 downloadable databases. These databases have not yet been
|
GeoIP2 downloadable databases. These databases have not yet been
|
||||||
released as a downloadable product.
|
released as a downloadable product.
|
||||||
|
|
||||||
See GeoIP2\Webservice\Client for details on the web service client
|
See GeoIP2\WebService\Client for details on the web service client
|
||||||
API.
|
API.
|
||||||
|
|
||||||
## Installation ##
|
## Installation ##
|
||||||
|
@ -52,7 +52,7 @@ require 'vendor/autoload.php';
|
||||||
|
|
||||||
## Usage ##
|
## Usage ##
|
||||||
|
|
||||||
To use this API, you must create a new ``\GeoIP2\Webservice\Client``
|
To use this API, you must create a new ``\GeoIP2\WebService\Client``
|
||||||
object with your ``$userId`` and ``$licenseKey``, then you call the method
|
object with your ``$userId`` and ``$licenseKey``, then you call the method
|
||||||
corresponding to a specific end point, passing it the IP address you want to
|
corresponding to a specific end point, passing it the IP address you want to
|
||||||
look up.
|
look up.
|
||||||
|
@ -68,7 +68,7 @@ See the API documentation for more details.
|
||||||
```php
|
```php
|
||||||
<?php
|
<?php
|
||||||
require_once 'vendor/autoload.php';
|
require_once 'vendor/autoload.php';
|
||||||
use \GeoIP2\Webservice\Client;
|
use \GeoIP2\WebService\Client;
|
||||||
|
|
||||||
$client = new Client(42, 'abcdef123456');
|
$client = new Client(42, 'abcdef123456');
|
||||||
$omni = $client->omni('24.24.24.24');
|
$omni = $client->omni('24.24.24.24');
|
||||||
|
@ -82,9 +82,9 @@ http://dev.maxmind.com/geoip2/geoip/web-services for the GeoIP2 web service
|
||||||
docs.
|
docs.
|
||||||
|
|
||||||
If the web service returns an explicit error document, this is thrown as a
|
If the web service returns an explicit error document, this is thrown as a
|
||||||
```\GeoIP2\Exception\WebserviceException```. If some other sort of transport
|
```\GeoIP2\Exception\WebServiceException```. If some other sort of transport
|
||||||
error occurs, this is thrown as a ```\GeoIP2\Exception\HttpException```.
|
error occurs, this is thrown as a ```\GeoIP2\Exception\HttpException```.
|
||||||
The difference is that the webservice error includes an error message and
|
The difference is that the web service error includes an error message and
|
||||||
error code delivered by the web service. The latter is thrown when some sort
|
error code delivered by the web service. The latter is thrown when some sort
|
||||||
of unanticipated error occurs, such as the web service returning a 500 or an
|
of unanticipated error occurs, such as the web service returning a 500 or an
|
||||||
invalid error document.
|
invalid error document.
|
||||||
|
|
|
@ -6,7 +6,7 @@ namespace GeoIP2\Exception;
|
||||||
* This class represents an error returned by MaxMind's GeoIP2 Precision
|
* This class represents an error returned by MaxMind's GeoIP2 Precision
|
||||||
* web service.
|
* web service.
|
||||||
*/
|
*/
|
||||||
class WebserviceException extends HttpException
|
class WebServiceException extends HttpException
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The code returned by the MaxMind web service
|
* The code returned by the MaxMind web service
|
|
@ -1,10 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace GeoIP2\Webservice;
|
namespace GeoIP2\WebService;
|
||||||
|
|
||||||
use GeoIP2\Exception\GenericException;
|
use GeoIP2\Exception\GenericException;
|
||||||
use GeoIP2\Exception\HttpException;
|
use GeoIP2\Exception\HttpException;
|
||||||
use GeoIP2\Exception\WebserviceException;
|
use GeoIP2\Exception\WebServiceException;
|
||||||
use GeoIP2\Model\City;
|
use GeoIP2\Model\City;
|
||||||
use GeoIP2\Model\CityIspOrg;
|
use GeoIP2\Model\CityIspOrg;
|
||||||
use GeoIP2\Model\Country;
|
use GeoIP2\Model\Country;
|
||||||
|
@ -52,9 +52,9 @@ use Guzzle\Http\Exception\ServerErrorResponseException;
|
||||||
* service docs}.
|
* service docs}.
|
||||||
*
|
*
|
||||||
* If the web service returns an explicit error document, this is thrown as a
|
* If the web service returns an explicit error document, this is thrown as a
|
||||||
* {@link \GeoIP2\Exception\WebserviceException}. If some other sort of
|
* {@link \GeoIP2\Exception\WebServiceException}. If some other sort of
|
||||||
* transport error occurs, this is thrown as a {@link
|
* transport error occurs, this is thrown as a {@link
|
||||||
* \GeoIP2\Exception\HttpException}. The difference is that the webservice
|
* \GeoIP2\Exception\HttpException}. The difference is that the web service
|
||||||
* error includes an error message and error code delivered by the web
|
* error includes an error message and error code delivered by the web
|
||||||
* service. The latter is thrown when some sort of unanticipated error occurs,
|
* service. The latter is thrown when some sort of unanticipated error occurs,
|
||||||
* such as the web service returning a 500 or an invalid error document.
|
* such as the web service returning a 500 or an invalid error document.
|
||||||
|
@ -112,7 +112,7 @@ class Client
|
||||||
* error processing your request.
|
* error processing your request.
|
||||||
* @throws \GeoIP2\Exception\HttpException if there was an HTTP transport
|
* @throws \GeoIP2\Exception\HttpException if there was an HTTP transport
|
||||||
* error.
|
* error.
|
||||||
* @throws \GeoIP2\Exception\WebserviceException if an error was returned
|
* @throws \GeoIP2\Exception\WebServiceException if an error was returned
|
||||||
* by MaxMind's GeoIP2 web service.
|
* by MaxMind's GeoIP2 web service.
|
||||||
*/
|
*/
|
||||||
public function city($ipAddress = 'me')
|
public function city($ipAddress = 'me')
|
||||||
|
@ -133,7 +133,7 @@ class Client
|
||||||
* error processing your request.
|
* error processing your request.
|
||||||
* @throws \GeoIP2\Exception\HttpException if there was an HTTP transport
|
* @throws \GeoIP2\Exception\HttpException if there was an HTTP transport
|
||||||
* error.
|
* error.
|
||||||
* @throws \GeoIP2\Exception\WebserviceException if an error was returned
|
* @throws \GeoIP2\Exception\WebServiceException if an error was returned
|
||||||
* by MaxMind's GeoIP2 web service.
|
* by MaxMind's GeoIP2 web service.
|
||||||
*/
|
*/
|
||||||
public function country($ipAddress = 'me')
|
public function country($ipAddress = 'me')
|
||||||
|
@ -154,7 +154,7 @@ class Client
|
||||||
* error processing your request.
|
* error processing your request.
|
||||||
* @throws \GeoIP2\Exception\HttpException if there was an HTTP transport
|
* @throws \GeoIP2\Exception\HttpException if there was an HTTP transport
|
||||||
* error.
|
* error.
|
||||||
* @throws \GeoIP2\Exception\WebserviceException if an error was returned
|
* @throws \GeoIP2\Exception\WebServiceException if an error was returned
|
||||||
* by MaxMind's GeoIP2 web service.
|
* by MaxMind's GeoIP2 web service.
|
||||||
*/
|
*/
|
||||||
public function cityIspOrg($ipAddress = 'me')
|
public function cityIspOrg($ipAddress = 'me')
|
||||||
|
@ -175,7 +175,7 @@ class Client
|
||||||
* error processing your request.
|
* error processing your request.
|
||||||
* @throws \GeoIP2\Exception\HttpException if there was an HTTP transport
|
* @throws \GeoIP2\Exception\HttpException if there was an HTTP transport
|
||||||
* error.
|
* error.
|
||||||
* @throws \GeoIP2\Exception\WebserviceException if an error was returned
|
* @throws \GeoIP2\Exception\WebServiceException if an error was returned
|
||||||
* by MaxMind's GeoIP2 web service.
|
* by MaxMind's GeoIP2 web service.
|
||||||
*/
|
*/
|
||||||
public function omni($ipAddress = 'me')
|
public function omni($ipAddress = 'me')
|
||||||
|
@ -274,7 +274,7 @@ class Client
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new WebserviceException(
|
throw new WebServiceException(
|
||||||
$body['error'],
|
$body['error'],
|
||||||
$body['code'],
|
$body['code'],
|
||||||
$status,
|
$status,
|
|
@ -1,8 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace GeoIP2\Test\Webservice;
|
namespace GeoIP2\Test\WebService;
|
||||||
|
|
||||||
use GeoIP2\Webservice\Client;
|
use GeoIP2\WebService\Client;
|
||||||
use Guzzle\Http\Client as GuzzleClient;
|
use Guzzle\Http\Client as GuzzleClient;
|
||||||
use Guzzle\Http\Message\Response;
|
use Guzzle\Http\Message\Response;
|
||||||
use Guzzle\Plugin\Mock\MockPlugin;
|
use Guzzle\Plugin\Mock\MockPlugin;
|
||||||
|
@ -176,7 +176,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException GeoIP2\Exception\WebserviceException
|
* @expectedException GeoIP2\Exception\WebServiceException
|
||||||
* @expectedExceptionCode 400
|
* @expectedExceptionCode 400
|
||||||
* @expectedExceptionMessage The value "1.2.3" is not a valid ip address
|
* @expectedExceptionMessage The value "1.2.3" is not a valid ip address
|
||||||
*/
|
*/
|
Loading…
Reference in New Issue
Block a user