Class: Quova::QOD

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

Overview

Interface to the Quova QOD (Quova On Demand) service

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ QOD

Initialize the QOD client with Quova API credentials

Examples:

Quova::QOD.new(:id => "account-id", :password => "account-password")

Parameters:

  • options (Hash)

    Hash containing :id and :password for Quova



17
18
19
20
# File 'lib/quova/qod.rb', line 17

def initialize(options)
  base = "https://%s:%[email protected]/ipinfo"
  @resource = RestClient::Resource.new(base % [options[:id], options[:password]])
end

Instance Method Details

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

Query the API for a given IP address

Examples:

qod.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
    :anonymizer_status
    :domain_tld
    :domain_sld
    :aol
    :organization
    :carrier
    :asn
    :connection_type
    :line_speed
    :ip_routing_type
    :continent_name
    :country_code
    :country_confidence
    :region_name
    :state_name
    :state_confidence
    :city_name
    :city_confidence
    :postal_code
    :time_zone
    :area_code
    :longitude
    :latitude
    :dma_id
    :msa_id
    


62
63
64
# File 'lib/quova/qod.rb', line 62

def info(ip)
  parse_xml(@resource[ip.to_s].get.body)
end