def self.ip_to_country(ip_address)
ipinfo = maxmind_database.lookup(ip_address) if Settings.key?(:maxmind_database)
- if ipinfo.found?
- country = ipinfo.country.iso_code
- else
- country = http_client.get("https://api.hostip.info/country.php?ip=#{ip_address}").body
- country = "GB" if country == "UK"
- end
+ return ipinfo.country.iso_code if ipinfo&.found?
- country
- rescue StandardError
nil
end