Class: Kickfire::Company
- Inherits:
-
Object
- Object
- Kickfire::Company
- Defined in:
- lib/kickfire/company.rb
Constant Summary collapse
- BASE_URL =
"https://api.kickfire.com/v2/"- BASE_QUERY =
"company:(all)"
Instance Attribute Summary collapse
-
#category ⇒ Object
readonly
Returns the value of attribute category.
-
#category2 ⇒ Object
readonly
Returns the value of attribute category2.
-
#cid ⇒ Object
readonly
Returns the value of attribute cid.
-
#city ⇒ Object
readonly
Returns the value of attribute city.
-
#country ⇒ Object
readonly
Returns the value of attribute country.
-
#countryShort ⇒ Object
readonly
Returns the value of attribute countryShort.
-
#employees ⇒ Object
readonly
Returns the value of attribute employees.
-
#facebook ⇒ Object
readonly
Returns the value of attribute facebook.
-
#lattitude ⇒ Object
readonly
Returns the value of attribute lattitude.
-
#linedkin_id ⇒ Object
readonly
Returns the value of attribute linedkin_id.
-
#linkedin ⇒ Object
readonly
Returns the value of attribute linkedin.
-
#longitude ⇒ Object
readonly
Returns the value of attribute longitude.
-
#naics_code ⇒ Object
readonly
Returns the value of attribute naics_code.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#phone ⇒ Object
readonly
Returns the value of attribute phone.
-
#postal ⇒ Object
readonly
Returns the value of attribute postal.
-
#region ⇒ Object
readonly
Returns the value of attribute region.
-
#regionShort ⇒ Object
readonly
Returns the value of attribute regionShort.
-
#revenue ⇒ Object
readonly
Returns the value of attribute revenue.
-
#site_code ⇒ Object
readonly
Returns the value of attribute site_code.
-
#stock_symbol ⇒ Object
readonly
Returns the value of attribute stock_symbol.
-
#street ⇒ Object
readonly
Returns the value of attribute street.
-
#twitter ⇒ Object
readonly
Returns the value of attribute twitter.
-
#website ⇒ Object
readonly
Returns the value of attribute website.
Class Method Summary collapse
Instance Method Summary collapse
- #address ⇒ Object
-
#initialize(attributes = nil) ⇒ Company
constructor
A new instance of Company.
- #isp? ⇒ Boolean
- #to_json ⇒ Object
- #twitter_url ⇒ Object
Constructor Details
#initialize(attributes = nil) ⇒ Company
Returns a new instance of Company.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# 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 |
Instance Attribute Details
#category ⇒ Object (readonly)
Returns the value of attribute category.
57 58 59 |
# File 'lib/kickfire/company.rb', line 57 def category @category end |
#category2 ⇒ Object (readonly)
Returns the value of attribute category2.
59 60 61 |
# File 'lib/kickfire/company.rb', line 59 def category2 @category2 end |
#cid ⇒ Object (readonly)
Returns the value of attribute cid.
44 45 46 |
# File 'lib/kickfire/company.rb', line 44 def cid @cid end |
#city ⇒ Object (readonly)
Returns the value of attribute city.
48 49 50 |
# File 'lib/kickfire/company.rb', line 48 def city @city end |
#country ⇒ Object (readonly)
Returns the value of attribute country.
53 54 55 |
# File 'lib/kickfire/company.rb', line 53 def country @country end |
#countryShort ⇒ Object (readonly)
Returns the value of attribute countryShort.
52 53 54 |
# File 'lib/kickfire/company.rb', line 52 def countryShort @countryShort end |
#employees ⇒ Object (readonly)
Returns the value of attribute employees.
55 56 57 |
# File 'lib/kickfire/company.rb', line 55 def employees @employees end |
#facebook ⇒ Object (readonly)
Returns the value of attribute facebook.
64 65 66 |
# File 'lib/kickfire/company.rb', line 64 def facebook @facebook end |
#lattitude ⇒ Object (readonly)
Returns the value of attribute lattitude.
62 63 64 |
# File 'lib/kickfire/company.rb', line 62 def lattitude @lattitude end |
#linedkin_id ⇒ Object (readonly)
Returns the value of attribute linedkin_id.
67 68 69 |
# File 'lib/kickfire/company.rb', line 67 def linedkin_id @linedkin_id end |
#linkedin ⇒ Object (readonly)
Returns the value of attribute linkedin.
66 67 68 |
# File 'lib/kickfire/company.rb', line 66 def linkedin @linkedin end |
#longitude ⇒ Object (readonly)
Returns the value of attribute longitude.
61 62 63 |
# File 'lib/kickfire/company.rb', line 61 def longitude @longitude end |
#naics_code ⇒ Object (readonly)
Returns the value of attribute naics_code.
60 61 62 |
# File 'lib/kickfire/company.rb', line 60 def naics_code @naics_code end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
45 46 47 |
# File 'lib/kickfire/company.rb', line 45 def name @name end |
#phone ⇒ Object (readonly)
Returns the value of attribute phone.
54 55 56 |
# File 'lib/kickfire/company.rb', line 54 def phone @phone end |
#postal ⇒ Object (readonly)
Returns the value of attribute postal.
51 52 53 |
# File 'lib/kickfire/company.rb', line 51 def postal @postal end |
#region ⇒ Object (readonly)
Returns the value of attribute region.
50 51 52 |
# File 'lib/kickfire/company.rb', line 50 def region @region end |
#regionShort ⇒ Object (readonly)
Returns the value of attribute regionShort.
49 50 51 |
# File 'lib/kickfire/company.rb', line 49 def regionShort @regionShort end |
#revenue ⇒ Object (readonly)
Returns the value of attribute revenue.
56 57 58 |
# File 'lib/kickfire/company.rb', line 56 def revenue @revenue end |
#site_code ⇒ Object (readonly)
Returns the value of attribute site_code.
58 59 60 |
# File 'lib/kickfire/company.rb', line 58 def site_code @site_code end |
#stock_symbol ⇒ Object (readonly)
Returns the value of attribute stock_symbol.
63 64 65 |
# File 'lib/kickfire/company.rb', line 63 def stock_symbol @stock_symbol end |
#street ⇒ Object (readonly)
Returns the value of attribute street.
47 48 49 |
# File 'lib/kickfire/company.rb', line 47 def street @street end |
#twitter ⇒ Object (readonly)
Returns the value of attribute twitter.
65 66 67 |
# File 'lib/kickfire/company.rb', line 65 def twitter @twitter end |
#website ⇒ Object (readonly)
Returns the value of attribute website.
46 47 48 |
# File 'lib/kickfire/company.rb', line 46 def website @website end |
Class Method Details
.find(ip, api_key: nil) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# 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 |
Instance Method Details
#address ⇒ Object
77 78 79 |
# File 'lib/kickfire/company.rb', line 77 def address [street, city, regionShort, postal].compact.join ", " end |
#isp? ⇒ Boolean
69 70 71 |
# File 'lib/kickfire/company.rb', line 69 def isp? @is_isp == 1 end |
#to_json ⇒ Object
81 82 83 |
# File 'lib/kickfire/company.rb', line 81 def to_json @raw.to_json end |
#twitter_url ⇒ Object
73 74 75 |
# File 'lib/kickfire/company.rb', line 73 def twitter_url "http://twitter.com/" + twitter end |