1 | <?php |
||
14 | abstract class AbstractNetAcuityDatabase implements NetAcuityDatabaseInterface |
||
15 | { |
||
16 | /** |
||
17 | * @var ClientInterface The GuzzleHttp Client. |
||
18 | */ |
||
19 | protected $client; |
||
20 | |||
21 | /** |
||
22 | * @var array The translations array for the data set. |
||
23 | */ |
||
24 | protected $translations; |
||
25 | |||
26 | /** |
||
27 | * @var string The API User Token. |
||
28 | */ |
||
29 | protected $apiUserToken; |
||
30 | |||
31 | /** |
||
32 | * @var int The Net Acuity Database ID. |
||
33 | */ |
||
34 | protected $databaseIdentifier; |
||
35 | |||
36 | /** |
||
37 | * AbstractNetAcuityDatabase constructor. |
||
38 | * |
||
39 | * @param ClientInterface $client The injected GuzzleHttp Client. |
||
40 | * @param string $apiUserToken The Net Acuity API User Token. |
||
41 | */ |
||
42 | public function __construct( |
||
49 | |||
50 | /** |
||
51 | * @param string $ip The IP to fetch the result data set for. |
||
52 | * |
||
53 | * @return array The formatted data set. |
||
54 | * |
||
55 | * @throws Exception On failure to send a Guzzle request. |
||
56 | */ |
||
57 | public function fetch(string $ip) |
||
72 | |||
73 | /** |
||
74 | * @param ClientException $e The thrown exception for handling. |
||
75 | * |
||
76 | * @throws Exception A formatted exception masking the API User Token in the event that it becomes invalid. |
||
77 | * |
||
78 | * @return void |
||
79 | */ |
||
80 | protected function handleGuzzleException(ClientException $e) |
||
94 | |||
95 | /** |
||
96 | * Parses the response into an array using the field definition. |
||
97 | * |
||
98 | * @param array $response The response from NetAcuity. |
||
99 | * |
||
100 | * @return array The response where the keys are from $fields and the values are from the $response. |
||
101 | */ |
||
102 | protected function parseBody(array $response) |
||
111 | |||
112 | /** |
||
113 | * @param string $userToken Net Acuity API User Token. |
||
114 | * @param string $ip The IP to be referenced in the lookup. |
||
115 | * |
||
116 | * @return string The formatted url query string. |
||
117 | */ |
||
118 | protected function buildQuery(string $userToken, string $ip) : string |
||
123 | } |
||
124 |