class Kickfire::Company
Constants
- BASE_QUERY
- BASE_URL
Attributes
category[R]
category2[R]
cid[R]
city[R]
country[R]
countryShort[R]
employees[R]
facebook[R]
lattitude[R]
linedkin_id[R]
linkedin[R]
longitude[R]
naics_code[R]
name[R]
phone[R]
postal[R]
region[R]
regionShort[R]
revenue[R]
site_code[R]
stock_symbol[R]
street[R]
twitter[R]
website[R]
Public Class Methods
find(ip, api_key: nil)
click to toggle source
# File lib/kickfire/company.rb, line 21 def self.find(ip, api_key: nil) if !api_key if defined? Kickfire::API_KEY api_key = Kickfire::API_KEY end end uri = URI("#{BASE_URL}#{BASE_QUERY}") params = { ip: ip, key: api_key } uri.query = URI.encode_www_form(params) response = ::HTTParty.get(uri) if !response raise Kickfire::Error.new('No data returned from Kickfire') elsif response['status'] == 'error' Kickfire::Error.find(response['code'],response['message']) elsif response['status'] == 'not found' nil else new(response['data']) end end
new(attributes = nil)
click to toggle source
# File lib/kickfire/company.rb, line 6 def initialize(attributes = nil) if attributes.kind_of?(Array) && attributes.first attributes = attributes.first end if attributes.kind_of?(Hash) @raw = attributes attributes.each do |k,v| instance_variable_set("@#{k.to_s.underscore}", v) end elsif attributes.kind_of? String Kickfire::Company.find(attributes) end end
Public Instance Methods
address()
click to toggle source
# File lib/kickfire/company.rb, line 77 def address [street, city, regionShort, postal].compact.join ", " end
isp?()
click to toggle source
# File lib/kickfire/company.rb, line 69 def isp? @is_isp == 1 end
to_json()
click to toggle source
# File lib/kickfire/company.rb, line 81 def to_json @raw.to_json end
twitter_url()
click to toggle source
# File lib/kickfire/company.rb, line 73 def twitter_url "http://twitter.com/" + twitter end