This Ruby code performs the following steps:

  1. Sets the FraudGuard.io API credentials (username and password).
  2. Defines the IP address to query.
  3. Constructs the API endpoint URL.
  4. Creates a URI object with the API URL.
  5. Creates an HTTP object and enables SSL for secure communication.
  6. Creates a GET request object.
  7. Sets the basic authentication header using Base64 encoding.
  8. Sends the HTTP request to the API endpoint.
  9. Checks the response code and prints the response body if the request was successful.
require 'net/http'
require 'base64'

# FraudGuard.io API credentials
username = 'username'
password = 'password'

# IP address to query
ip_address = '8.8.8.8'

# API endpoint
api_url = "https://api.fraudguard.io/ip/#{ip_address}"

# Create URI object
uri = URI(api_url)

# Create HTTP object
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

# Create request
request = Net::HTTP::Get.new(uri)

# Set basic authentication header
auth_string = "#{username}:#{password}"
encoded_auth_string = Base64.strict_encode64(auth_string)
request['Authorization'] = "Basic #{encoded_auth_string}"

# Send request
response = http.request(request)

# Check response
if response.code == '200'
  puts response.body
else
  puts "Error: #{response.code} - #{response.message}"
end

Make sure to replace ‘username’ and ‘password’ with your actual API credentials.