Class: Ip2whoisRuby::Api

Inherits:
Object
  • Object
show all
Defined in:
lib/ip2whois_ruby/api.rb

Class Method Summary collapse

Class Method Details

.get_normal_text(params = {}) ⇒ Object

Get Normal text.



35
36
37
# File 'lib/ip2whois_ruby/api.rb', line 35

def self.get_normal_text(params = {})
    return SimpleIDN.to_ascii(params[:domain])
end

.get_punycode(params = {}) ⇒ Object

Get Punycode.



30
31
32
# File 'lib/ip2whois_ruby/api.rb', line 30

def self.get_punycode(params = {})
    return SimpleIDN.to_unicode(params[:domain])
end

.lookup(params = {}) ⇒ Object

Lookup domain WHOIS information.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/ip2whois_ruby/api.rb', line 10

def self.lookup(params = {})
  if params[:format] == nil
    params[:format] = 'json'
  end

  uri = URI.parse("https://api.ip2whois.com/v2?key=" + Ip2whoisRuby::Configuration.api_key + "&format=" + params[:format] + "&domain=" + params[:domain])
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true
  request = Net::HTTP::Get.new(uri.request_uri)

  response = http.request(request)

  if response == nil
    return false
  else
    return response
  end
end