Class: RubyIpClient::IpCallbackHandler
- Inherits:
-
Object
- Object
- RubyIpClient::IpCallbackHandler
- Defined in:
- lib/ruby_ip_client/ip_callback_handler.rb
Instance Method Summary collapse
- #generate_error_result(message) ⇒ Object
-
#parse_callback(params) ⇒ Object
Parses an asynchronous IP Lookup callback and returns a JSON string with the results.
- #send_response ⇒ Object
Instance Method Details
#generate_error_result(message) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/ruby_ip_client/ip_callback_handler.rb', line 27 def generate_error_result() result = {:success => false, :fieldErrors => [], :globalErrors => ["#{}"]} result.to_json end |
#parse_callback(params) ⇒ Object
Parses an asynchronous IP Lookup callback and returns a JSON string with the results. Params example: 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”: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}]}
11 12 13 14 15 16 17 18 19 |
# 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 ⇒ Object
21 22 23 24 25 |
# File 'lib/ruby_ip_client/ip_callback_handler.rb', line 21 def send_response 'OK' end |