Last active
September 15, 2020 14:46
-
-
Save sosedoff/2504683 to your computer and use it in GitHub Desktop.
OpenTable API Client - Visit http://opentable.herokuapp.com for details
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "faraday" | |
require "faraday_middleware" | |
module OpenTable | |
class Error < StandardError ; end | |
module Request | |
API_BASE = "http://opentable.herokuapp.com" | |
def connection | |
connection = Faraday.new(API_BASE) do |c| | |
c.use(Faraday::Request::UrlEncoded) | |
c.use(Faraday::Response::ParseJson) | |
c.adapter(Faraday.default_adapter) | |
end | |
end | |
def request(method, path, params={}, raw=false) | |
headers = {'Accept' => 'application/json'} | |
path = "/api#{path}" | |
response = connection.send(method, path, params) do |request| | |
request.url(path, params) | |
end | |
if [404, 403, 400].include?(response.status) | |
raise OpenTable::Error, response.body["error"] | |
end | |
raw ? response : response.body | |
end | |
def get(path, params={}) | |
request(:get, path, params) | |
end | |
end | |
class Client | |
include Request | |
def countries | |
get("/countries") | |
end | |
def cities(country=nil) | |
get("/cities") | |
end | |
def restaurants(options={}) | |
get("/restaurants", options) | |
end | |
def restaurant(id) | |
get("/restaurants/#{id}") | |
end | |
end | |
end |
Is there any API to get the customer details who have done a reservation or book a table of particular a restaurant.
Hey for all restaurants the image url are not working....
Hi, the restaurants images (image_url) are not working, it shows the same image for all.
Want to query restaurants within a GEO Square, FROM/TO Lat/Long
1 - Restaurant image is always the same. Can this be fixed?
2 - Cuisine Type filter doesn't seem available. Is this something that can be added?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is there any search available?
Why does the opentable link show only reservations until 9.30?
I have ref_id and I need to pass datetime and party size parameter into the request so that i can get same results on openTable.Please respond on this soon. .Thanks