class RubyIpClient::IpCallbackHandler

Public Instance Methods

generate_error_result(message) click to toggle source
# File lib/ruby_ip_client/ip_callback_handler.rb, line 27
def generate_error_result(message)

  result = {:success => false, :fieldErrors => [], :globalErrors => ["#{message}"]}
  result.to_json

end
parse_callback(params) click to toggle source

Parses an asynchronous IP Lookup callback and returns a JSON string with the results. @param params @returns {*}

Params example: {“success”:true,“results”:[{“context”:{“id”:“3ac9069dc6e9”,“ip”:“85.10.208.227”,“state”:“COMPLETED”,“storage”:“ASYNC-API-2017-02”,“engine”:“IV1”,“interface”:“Async API”,“cost”:“0.01000”,“timeStamp”:“2017-02-09 22:57:33.80855+08”},“geolocation”:{“country”:“Germany”,“region”:“Bavaria”,“countryCode”:“DE”,“regionCode”:“BY”,“city”:“Nuremberg”,“zip”:“90455”,“latitude”:“49.44780”,“longitude”:“11.06830”,“radius”:200,“timeZone”:“Europe/Berlin”,“averageIncome”:null,“populationDensity”:null,“dmaCode”:null},“network”:{“connectionType”:“HOSTING”,“asn”:“24940”,“asnOrganization”:“Hetzner Online GmbH”,“isp”:“Hetzner Online GmbH”,“ispOrganization”:“Hetzner Online GmbH”,“domain”:“your-server.de”,“registeredCountry”:“Germany”,“registeredCountryCode”:“DE”,“isRoutable”:true},“threatIntelligence”:{“threatLevel”:“VERY_HIGH”,“threatIntelligenceScore”:“1.00000”,“genericBlacklistMatch”:false,“proxyBlacklistMatch”:false,“torBlacklistMatch”:false,“vpnBlacklistMatch”:false,“malwareBlacklistMatch”:false,“spywareBlacklistMatch”:false,“hijackBlacklistMatch”:false,“crawlerBlacklistMatch”:false,“botBlacklistMatch”:false,“spamBotBlacklistMatch”:false,“exploitBotBlacklistMatch”:false,“dshieldBlacklistMatch”:false}}]}

# File lib/ruby_ip_client/ip_callback_handler.rb, line 11
def parse_callback(params)

  unless params.has_key?('json')
    return generate_error_result('Invalid callback parameters. Missing json payload.')
  end

  params['json']

end
send_response() click to toggle source
# File lib/ruby_ip_client/ip_callback_handler.rb, line 21
def send_response

  'OK'

end