Can load some basic business info from YELP
This commit is contained in:
29
src/modules/api/yelp.cr
Normal file
29
src/modules/api/yelp.cr
Normal file
@@ -0,0 +1,29 @@
|
||||
require "http/client"
|
||||
require "io"
|
||||
|
||||
module Wince::Yelp
|
||||
extend self
|
||||
|
||||
@@token : String = {{ read_file("./api_key") }}
|
||||
|
||||
def search_businesses(search : String, location : String)
|
||||
|
||||
params = URI::Params.encode({
|
||||
location: location,
|
||||
term: search,
|
||||
sort_by: "best_match"
|
||||
})
|
||||
uri = URI.new(
|
||||
scheme: "https",
|
||||
host: "api.yelp.com",
|
||||
path: "/v3/businesses/search",
|
||||
query: params
|
||||
)
|
||||
headers = HTTP::Headers{ "Authorization" => "Bearer " + @@token }
|
||||
response = HTTP::Client.get(uri, headers)
|
||||
end
|
||||
end
|
||||
|
||||
#response = Wince::Yelp.search_businesses("miss saigon", "94610")
|
||||
#puts response.status_code
|
||||
#puts response.body
|
||||
Reference in New Issue
Block a user