WebServiceUtility.php in Smart IP 8.4
Same filename in this branch
Same filename and directory in other branches
Namespace
Drupal\smart_ip_abstract_web_serviceFile
modules/smart_ip_abstract_web_service/src/WebServiceUtility.phpView source
<?php
/**
* @file
* Contains \Drupal\smart_ip_abstract_web_service\WebServiceUtility.
*/
namespace Drupal\smart_ip_abstract_web_service;
use Drupal\smart_ip_abstract_web_service\EventSubscriber\SmartIpEventSubscriber;
use Drupal\smart_ip_abstract_web_service\AbstractWebService;
use Drupal\smart_ip\WebServiceUtilityBase;
use Drupal\Component\Serialization\Json;
/**
* Utility methods class wrapper.
*
* @package Drupal\smart_ip_abstract_web_service
*/
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;
}
}
Classes
Name | Description |
---|---|
WebServiceUtility | Utility methods class wrapper. |