1 | <?php |
||
11 | class IpstackClient implements IpstackClientInterface { |
||
12 | |||
13 | use LoggerAwareTrait; |
||
14 | |||
15 | /** |
||
16 | * @var ClientInterface |
||
17 | */ |
||
18 | public $guzzle_client; |
||
19 | |||
20 | /** |
||
21 | * @var string |
||
22 | */ |
||
23 | public $http_method = "GET"; |
||
24 | |||
25 | /** |
||
26 | * The ipstack API endpoint |
||
27 | * @var string |
||
28 | */ |
||
29 | public $ipstack_endpoint; |
||
30 | |||
31 | /** |
||
32 | * The ipstack API Key |
||
33 | * @var string |
||
34 | */ |
||
35 | public $ipstack_api_key; |
||
36 | |||
37 | |||
38 | |||
39 | /** |
||
40 | * @var array |
||
41 | */ |
||
42 | public $ipstack_query_defaults = array( |
||
43 | "output" => "json", |
||
44 | #"fields" => "kkol,ip,country_code,country_name,latitude,longitude,region_name", #hostname |
||
45 | ); |
||
46 | |||
47 | |||
48 | /** |
||
49 | * @param string $ipstack_endpoint |
||
50 | * @param string $ipstack_api_key |
||
51 | * @param ClientInterface $guzzle_client Optional: Custom Guzzle Client |
||
52 | * @param LoggerInterface|null $logger Optional: PSR-3 Logger |
||
53 | */ |
||
54 | 56 | public function __construct( string $ipstack_endpoint, string $ipstack_api_key, ClientInterface $guzzle_client = null, LoggerInterface $logger = null ) |
|
66 | |||
67 | |||
68 | /** |
||
69 | * @param string $client_ip [description] |
||
70 | * @param array $custom_query [description] |
||
71 | * @return array |
||
72 | * |
||
73 | * @throws IpstackExceptionInterface |
||
74 | */ |
||
75 | 48 | public function get( string $client_ip, array $custom_query = array() ) : array |
|
120 | |||
121 | |||
122 | /** |
||
123 | * @param string $body Reponse body string |
||
124 | * @return array |
||
125 | * |
||
126 | * @throws IpstackResponseException |
||
127 | */ |
||
128 | 40 | public function decode( string $body ): array |
|
152 | |||
153 | |||
154 | } |