Class: ClearbitApi::Company

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

Class Method Summary collapse

Class Method Details

.search(company) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/clearbit_api.rb', line 6

def self.search(company)
  # get call on REST API
  base_url = "https://autocomplete.clearbit.com/v1/companies/suggest?query="
  response = HTTParty.get(base_url + company)

  # parse data
  begin
    data = JSON.parse(response.body, {symbolize_names: true})
  rescue JSON::ParserError
    data = {error: "Clearbit Error"}
  end
end