Class: HungryVegan::Api

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

Constant Summary collapse

API_HOST =
"https://api.yelp.com"
SEARCH_PATH =
"/v3/businesses/search"
BUSINESS_PATH =
"/v3/businesses/"
SEARCH_LIMIT =
15

Class Method Summary collapse

Class Method Details

.search(term, location) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/hungry_vegan/api.rb', line 10

def self.search(term, location)
    url = "#{API_HOST}#{SEARCH_PATH}"
    params = {
        term: term, 
        location: location, 
        limit: SEARCH_LIMIT,
        sort_by: "rating"
        }
    response = HTTP.auth("Bearer #{ENV['YELP_API_KEY']}").get(url, params: params)
    response.parse
end