You are here

public static function WebServiceUtility::getUrl in Smart IP 8.3

Same name in this branch
  1. 8.3 modules/smart_ip_ipinfodb_web_service/src/WebServiceUtility.php \Drupal\smart_ip_ipinfodb_web_service\WebServiceUtility::getUrl()
  2. 8.3 modules/smart_ip_abstract_web_service/src/WebServiceUtility.php \Drupal\smart_ip_abstract_web_service\WebServiceUtility::getUrl()
  3. 8.3 modules/smart_ip_maxmind_geoip2_web_service/src/WebServiceUtility.php \Drupal\smart_ip_maxmind_geoip2_web_service\WebServiceUtility::getUrl()
Same name and namespace in other branches
  1. 8.4 modules/smart_ip_maxmind_geoip2_web_service/src/WebServiceUtility.php \Drupal\smart_ip_maxmind_geoip2_web_service\WebServiceUtility::getUrl()

Get Smart IP's data source module's web service URL.

Parameters

string $ipAddress: IP address to query for geolocation.

Return value

string Smart IP's data source module's web service URL.

Overrides WebServiceUtilityInterface::getUrl

1 call to WebServiceUtility::getUrl()
WebServiceUtility::getGeolocation in modules/smart_ip_maxmind_geoip2_web_service/src/WebServiceUtility.php
Perform HTTP request and decoding the raw Geolocation data returned by Smart IP's data source module web service.

File

modules/smart_ip_maxmind_geoip2_web_service/src/WebServiceUtility.php, line 26
Contains \Drupal\smart_ip_maxmind_geoip2_web_service\WebServiceUtility.

Class

WebServiceUtility
Utility methods class wrapper.

Namespace

Drupal\smart_ip_maxmind_geoip2_web_service

Code

public static function getUrl($ipAddress = NULL) {
  if (!empty($ipAddress)) {
    $config = \Drupal::config(SmartIpEventSubscriber::configName());
    $userId = $config
      ->get('user_id');
    $licenseKey = $config
      ->get('license_key');
    $serviceType = $config
      ->get('service_type');
    return "https://{$userId}:{$licenseKey}@" . MaxmindGeoip2WebService::BASE_URL . "/{$serviceType}/{$ipAddress}";
  }
  return '';
}