class WebServiceUtility in Smart IP 8.2
Same name and namespace in other branches
- 8.4 modules/smart_ip_ipinfodb_web_service/src/WebServiceUtility.php \Drupal\smart_ip_ipinfodb_web_service\WebServiceUtility
- 8.3 modules/smart_ip_ipinfodb_web_service/src/WebServiceUtility.php \Drupal\smart_ip_ipinfodb_web_service\WebServiceUtility
Utility methods class wrapper.
@package Drupal\smart_ip_ipinfodb_web_service
Hierarchy
- class \Drupal\smart_ip\WebServiceUtilityBase implements WebServiceUtilityInterface
- class \Drupal\smart_ip_ipinfodb_web_service\WebServiceUtility
Expanded class hierarchy of WebServiceUtility
1 file declares its use of WebServiceUtility
- SmartIpEventSubscriber.php in modules/
smart_ip_ipinfodb_web_service/ src/ EventSubscriber/ SmartIpEventSubscriber.php - Contains \Drupal\smart_ip_ipinfodb_web_service\EventSubscriber\SmartIpEventSubscriber.
File
- modules/
smart_ip_ipinfodb_web_service/ src/ WebServiceUtility.php, line 19 - Contains \Drupal\smart_ip_ipinfodb_web_service\WebServiceUtility.
Namespace
Drupal\smart_ip_ipinfodb_web_serviceView source
class WebServiceUtility extends WebServiceUtilityBase {
/**
* {@inheritdoc}
*/
public static function getUrl($ipAddress = NULL) {
if (!empty($ipAddress)) {
$config = \Drupal::config(SmartIpEventSubscriber::configName());
$apiKey = $config
->get('api_key');
if ($config
->get('version') == 2) {
return SmartIpEventSubscriber::V2_URL . "?key={$apiKey}&ip={$ipAddress}&output=json&timezone=false";
}
elseif ($config
->get('version') == 3) {
return SmartIpEventSubscriber::V3_URL . "?key={$apiKey}&ip={$ipAddress}&format=json";
}
}
return '';
}
/**
* {@inheritdoc}
*/
public static function getGeolocation($ipAddress = NULL) {
$url = self::getUrl($ipAddress);
$json = self::sendRequest($url);
$data = (object) Json::decode($json);
return $data;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
WebServiceUtility:: |
public static | function |
Perform HTTP request and decoding the raw Geolocation data returned by
Smart IP's data source module web. Overrides WebServiceUtilityInterface:: |
|
WebServiceUtility:: |
public static | function |
Get Smart IP's data source module's web service URL. Overrides WebServiceUtilityInterface:: |
|
WebServiceUtilityBase:: |
public static | function |
Perform HTTP request to the Smart IP's data source module web service. Overrides WebServiceUtilityInterface:: |