Class: Quova::REST

Inherits:
Object
  • Object
show all
Defined in:
lib/quova/rest.rb

Overview

Interface to the standard Quova REST API.

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ REST

Initialize the REST client with the Quova credentials.

Examples:

Quova::REST.new(:api_key => 'your-key', :secret => 'your-secret')

Parameters:

  • options (Hash)

    Hash containing :api_key and :secret for Quova



19
20
21
22
# File 'lib/quova/rest.rb', line 19

def initialize(options)
  @options  = options.dup
  @resource = RestClient::Resource.new("http://api.quova.com/v1/ipinfo")
end

Instance Method Details

#info(ip) ⇒ Quova::Result<Virtus> Also known as: []

Query the API for a given IP address

Examples:

rest.info("4.2.2.2") # => { ... }

Parameters:

  • ip (String, IPAddr, #to_s)

    The IP address to look up

Returns:

  • (Quova::Result<Virtus>)

    A Hash-like object containing a key for each element. Provided fields:

    :ip_address :ip_type :domain_tld :domain_sld :organization :carrier :asn :connection_type :line_speed :ip_routing_type :continent_name :country_code :country_name :country_confidence :region_name :state_code :state_name :state_confidence :city_name :city_confidence :postal_code :time_zone :area_code :longitude :latitude :dma_id :msa_id



64
65
66
# File 'lib/quova/rest.rb', line 64

def info(ip)
  parse_xml(@resource[ip].get(:params => params_for_ip(ip)).body)
end