class WebServiceUtility in Smart IP 8.4
Same name in this branch
- 8.4 modules/smart_ip_ipinfodb_web_service/src/WebServiceUtility.php \Drupal\smart_ip_ipinfodb_web_service\WebServiceUtility
- 8.4 modules/smart_ip_abstract_web_service/src/WebServiceUtility.php \Drupal\smart_ip_abstract_web_service\WebServiceUtility
- 8.4 modules/smart_ip_maxmind_geoip2_web_service/src/WebServiceUtility.php \Drupal\smart_ip_maxmind_geoip2_web_service\WebServiceUtility
Same name and namespace in other branches
- 8.3 modules/smart_ip_abstract_web_service/src/WebServiceUtility.php \Drupal\smart_ip_abstract_web_service\WebServiceUtility
Utility methods class wrapper.
@package Drupal\smart_ip_abstract_web_service
Hierarchy
- class \Drupal\smart_ip\WebServiceUtilityBase implements WebServiceUtilityInterface
- class \Drupal\smart_ip_abstract_web_service\WebServiceUtility
Expanded class hierarchy of WebServiceUtility
1 file declares its use of WebServiceUtility
- SmartIpEventSubscriber.php in modules/
smart_ip_abstract_web_service/ src/ EventSubscriber/ SmartIpEventSubscriber.php - Contains \Drupal\smart_ip_abstract_web_service\EventSubscriber\SmartIpEventSubscriber.
File
- modules/
smart_ip_abstract_web_service/ src/ WebServiceUtility.php, line 20 - Contains \Drupal\smart_ip_abstract_web_service\WebServiceUtility.
Namespace
Drupal\smart_ip_abstract_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');
$version = $config
->get('version');
if ($version == 1) {
return AbstractWebService::V1_URL . "?api_key={$apiKey}&ip_address={$ipAddress}";
}
}
return '';
}
/**
* {@inheritdoc}
*/
public static function getGeolocation($ipAddress = NULL) {
$url = self::getUrl($ipAddress);
$json = self::sendRequest($url);
$data = 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 service. 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:: |