Class: Hexillion::Client
- Inherits:
-
Object
- Object
- Hexillion::Client
- Defined in:
- lib/hexillion.rb
Constant Summary collapse
- AUTH_ENDPOINT =
"https://hexillion.com/rf/xml/1.0/auth/".freeze
- DATA_ENDPOINT =
"http://hexillion.com/rf/xml/1.0/whois/".freeze
Instance Method Summary collapse
-
#initialize(options) ⇒ Client
constructor
A new instance of Client.
-
#whois(domain, extra_params = {}) ⇒ Object
Query the API for a given domain.
Constructor Details
#initialize(options) ⇒ Client
Returns a new instance of Client.
12 13 14 15 16 |
# File 'lib/hexillion.rb', line 12 def initialize() @session_key = fetch_session_key() rescue raise "Authentication failed" end |
Instance Method Details
#whois(domain, extra_params = {}) ⇒ Object
Query the API for a given domain
25 26 27 28 29 30 31 32 33 |
# File 'lib/hexillion.rb', line 25 def whois(domain, extra_params = {}) params = {sessionkey: @session_key, query: domain}.merge(extra_params) uri = URI(DATA_ENDPOINT) uri.query = URI.encode_www_form(params) response = Net::HTTP.get_response(uri) parse_xml(response.body) end |