romato 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/#Gemfile# +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +88 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +661 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/romato.rb +255 -0
- data/lib/romato/version.rb +3 -0
- data/romato.gemspec +41 -0
- metadata +173 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: e56e0be07e20c75547441183ab19f7a19dc13bc6
|
|
4
|
+
data.tar.gz: 44741fe930dd130556e5f98cfcc525ef62a6df94
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 27c621d407c6fb5f63d537b9f7ecba8fbdcaea669d751cfe7f6f109f3ed790e0d011b389c284bd4d26845e72a07a583550a4ed4a47684b4bd478101e959c5fee
|
|
7
|
+
data.tar.gz: c99073a0b37412d0e2f87c48d5bce173ea165f42549e8fb93934b2fb501f12d00ffc5b0a53ca7ec1d6e19f42e83cdb00c444fc2e5b0bdd8c3fb0b46ccc245fb4
|
data/#Gemfile#
ADDED
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
|
2
|
+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
|
3
|
+
**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
|
|
4
|
+
|
|
5
|
+
- [Contributor Covenant Code of Conduct](#contributor-covenant-code-of-conduct)
|
|
6
|
+
- [Our Pledge](#our-pledge)
|
|
7
|
+
- [Our Standards](#our-standards)
|
|
8
|
+
- [Our Responsibilities](#our-responsibilities)
|
|
9
|
+
- [Scope](#scope)
|
|
10
|
+
- [Enforcement](#enforcement)
|
|
11
|
+
- [Attribution](#attribution)
|
|
12
|
+
|
|
13
|
+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
|
14
|
+
|
|
15
|
+
# Contributor Covenant Code of Conduct
|
|
16
|
+
|
|
17
|
+
## Our Pledge
|
|
18
|
+
|
|
19
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
20
|
+
contributors and maintainers pledge to making participation in our project and
|
|
21
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
|
22
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
23
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
|
24
|
+
orientation.
|
|
25
|
+
|
|
26
|
+
## Our Standards
|
|
27
|
+
|
|
28
|
+
Examples of behavior that contributes to creating a positive environment
|
|
29
|
+
include:
|
|
30
|
+
|
|
31
|
+
* Using welcoming and inclusive language
|
|
32
|
+
* Being respectful of differing viewpoints and experiences
|
|
33
|
+
* Gracefully accepting constructive criticism
|
|
34
|
+
* Focusing on what is best for the community
|
|
35
|
+
* Showing empathy towards other community members
|
|
36
|
+
|
|
37
|
+
Examples of unacceptable behavior by participants include:
|
|
38
|
+
|
|
39
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
40
|
+
advances
|
|
41
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
42
|
+
* Public or private harassment
|
|
43
|
+
* Publishing others' private information, such as a physical or electronic
|
|
44
|
+
address, without explicit permission
|
|
45
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
46
|
+
professional setting
|
|
47
|
+
|
|
48
|
+
## Our Responsibilities
|
|
49
|
+
|
|
50
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
|
51
|
+
behavior and are expected to take appropriate and fair corrective action in
|
|
52
|
+
response to any instances of unacceptable behavior.
|
|
53
|
+
|
|
54
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
55
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
56
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
57
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
58
|
+
threatening, offensive, or harmful.
|
|
59
|
+
|
|
60
|
+
## Scope
|
|
61
|
+
|
|
62
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
|
63
|
+
when an individual is representing the project or its community. Examples of
|
|
64
|
+
representing a project or community include using an official project e-mail
|
|
65
|
+
address, posting via an official social media account, or acting as an appointed
|
|
66
|
+
representative at an online or offline event. Representation of a project may be
|
|
67
|
+
further defined and clarified by project maintainers.
|
|
68
|
+
|
|
69
|
+
## Enforcement
|
|
70
|
+
|
|
71
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
72
|
+
reported by contacting the project team at kyleannen@gmail.com. All
|
|
73
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
74
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
|
75
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
76
|
+
Further details of specific enforcement policies may be posted separately.
|
|
77
|
+
|
|
78
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
79
|
+
faith may face temporary or permanent repercussions as determined by other
|
|
80
|
+
members of the project's leadership.
|
|
81
|
+
|
|
82
|
+
## Attribution
|
|
83
|
+
|
|
84
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
85
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
|
86
|
+
|
|
87
|
+
[homepage]: http://contributor-covenant.org
|
|
88
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016 Kyle Annen
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,661 @@
|
|
|
1
|
+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
|
2
|
+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
|
3
|
+
**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
|
|
4
|
+
|
|
5
|
+
- [Romato - Zomato API Wrapper for Ruby](#romato---zomato-api-wrapper-for-ruby)
|
|
6
|
+
- [Installation](#installation)
|
|
7
|
+
- [Usage](#usage)
|
|
8
|
+
- [Initialization](#initialization)
|
|
9
|
+
- [Romato::Zomato.new()](#romatozomatonew)
|
|
10
|
+
- [Methods](#methods)
|
|
11
|
+
- [Common Methods (as defined by Zomato API)](#common-methods-as-defined-by-zomato-api)
|
|
12
|
+
- [Romato::Zomato.get_categories()](#romatozomatoget_categories)
|
|
13
|
+
- [Romato::Zomato.get_cities(options)](#romatozomatoget_citiesoptions)
|
|
14
|
+
- [Romato::Zomato.get_collections(options)](#romatozomatoget_collectionsoptions)
|
|
15
|
+
- [Romato::Zomato.get_cuisines()](#romatozomatoget_cuisines)
|
|
16
|
+
- [Development](#development)
|
|
17
|
+
- [Contributing](#contributing)
|
|
18
|
+
- [License](#license)
|
|
19
|
+
|
|
20
|
+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
|
21
|
+
|
|
22
|
+
# Romato - Zomato API Wrapper for Ruby
|
|
23
|
+
|
|
24
|
+
A simple api wrapper for Zomato API, all methods coorelate to the API definitions in the Zomato API documentation: https://developers.zomato.com/documentation.
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
Add this line to your application's Gemfile:
|
|
29
|
+
|
|
30
|
+
```ruby
|
|
31
|
+
gem 'romato'
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
And then execute:
|
|
35
|
+
|
|
36
|
+
$ bundle
|
|
37
|
+
|
|
38
|
+
Or install it yourself as:
|
|
39
|
+
|
|
40
|
+
$ gem install romato
|
|
41
|
+
|
|
42
|
+
## Usage
|
|
43
|
+
|
|
44
|
+
All api methods accept an options hash if the API call accepts parameters, and directly mirror the API parameters defined by the Zomato API v2.1.
|
|
45
|
+
|
|
46
|
+
## Initialization
|
|
47
|
+
___
|
|
48
|
+
|
|
49
|
+
##### Romato::Zomato.new()
|
|
50
|
+
|
|
51
|
+
The initialization of the class accetps an options parameter as a hash. Provide the API key here as a hash.
|
|
52
|
+
|
|
53
|
+
`zomato_instance = Romato::Zomato.new("APIKEY")`
|
|
54
|
+
|
|
55
|
+
## Methods
|
|
56
|
+
|
|
57
|
+
### Common Methods (as defined by Zomato API)
|
|
58
|
+
___
|
|
59
|
+
#### Romato::Zomato.get_categories()
|
|
60
|
+
|
|
61
|
+
Get the categories of venues defined by Zomato, accepts no parameters.
|
|
62
|
+
|
|
63
|
+
`zomato_instance.get_categories()`
|
|
64
|
+
|
|
65
|
+
Response:
|
|
66
|
+
|
|
67
|
+
```ruby
|
|
68
|
+
{
|
|
69
|
+
"categories"=>
|
|
70
|
+
[
|
|
71
|
+
{"categories"=>{"id"=>1, "name"=>"Delivery"}},
|
|
72
|
+
{"categories"=>{"id"=>2, "name"=>"Dine-out"}},
|
|
73
|
+
{"categories"=>{"id"=>3, "name"=>"Nightlife"}},
|
|
74
|
+
{"categories"=>{"id"=>4, "name"=>"Catching-up"}},
|
|
75
|
+
{"categories"=>{"id"=>5, "name"=>"Takeaway"}},
|
|
76
|
+
{"categories"=>{"id"=>6, "name"=>"Cafes"}},
|
|
77
|
+
{"categories"=>{"id"=>7, "name"=>"Daily Menus"}},
|
|
78
|
+
{"categories"=>{"id"=>8, "name"=>"Breakfast"}},
|
|
79
|
+
{"categories"=>{"id"=>9, "name"=>"Lunch"}},
|
|
80
|
+
{"categories"=>{"id"=>10, "name"=>"Dinner"}},
|
|
81
|
+
{"categories"=>{"id"=>11, "name"=>"Pubs & Bars"}},
|
|
82
|
+
{"categories"=>{"id"=>12, "name"=>"Premium Delivery"}},
|
|
83
|
+
{"categories"=>{"id"=>13, "name"=>"Pocket Friendly Delivery"}},
|
|
84
|
+
{"categories"=>{"id"=>14, "name"=>"Clubs & Lounges"}}
|
|
85
|
+
]
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Categories will be accessible through the class variable `categories`
|
|
90
|
+
|
|
91
|
+
`zomato_instance.categories`
|
|
92
|
+
|
|
93
|
+
#### Romato::Zomato.get_cities(options)
|
|
94
|
+
|
|
95
|
+
View API documentation here: https://developers.zomato.com/documentation#!/common/cities
|
|
96
|
+
|
|
97
|
+
Accepts `options` hash with the following values:
|
|
98
|
+
* `q` query by city name
|
|
99
|
+
* `count` max results to return (optional)
|
|
100
|
+
|
|
101
|
+
or
|
|
102
|
+
|
|
103
|
+
* `lat` query in conjunction with lon
|
|
104
|
+
* `lon` query in conjunction with lat
|
|
105
|
+
* `count` max results to return (optional)
|
|
106
|
+
|
|
107
|
+
or
|
|
108
|
+
|
|
109
|
+
* `city_ids` comma seperated city ids string
|
|
110
|
+
* `count` max results to return (optional)
|
|
111
|
+
|
|
112
|
+
Example Options Hash `{ q: "seattle", count: 30 }`
|
|
113
|
+
|
|
114
|
+
Usage `zomato_instance.get_cities( {q: "seattle", count: 30} )`
|
|
115
|
+
|
|
116
|
+
Access through class variable `cities`
|
|
117
|
+
|
|
118
|
+
`zomato_instance.cities`
|
|
119
|
+
|
|
120
|
+
```ruby
|
|
121
|
+
{
|
|
122
|
+
"location_suggestions"=>
|
|
123
|
+
[
|
|
124
|
+
{
|
|
125
|
+
"id"=>279,
|
|
126
|
+
"name"=>"Seattle, WA",
|
|
127
|
+
"country_id"=>216,
|
|
128
|
+
"country_name"=>"United States",
|
|
129
|
+
"discovery_enabled"=>1,
|
|
130
|
+
"has_new_ad_format"=>0,
|
|
131
|
+
"is_state"=>0,
|
|
132
|
+
"state_id"=>115,
|
|
133
|
+
"state_name"=>"Washington State",
|
|
134
|
+
"state_code"=>"WA"}
|
|
135
|
+
],
|
|
136
|
+
"status"=>"success",
|
|
137
|
+
"has_more"=>0,
|
|
138
|
+
"has_total"=>0
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
#### Romato::Zomato.get_collections(options)
|
|
143
|
+
|
|
144
|
+
View API documentation here: https://developers.zomato.com/documentation#!/common/collections
|
|
145
|
+
|
|
146
|
+
Accepts `options` hash with the following values:
|
|
147
|
+
* `city_id` query collections by city id
|
|
148
|
+
* `count` max results (optional)
|
|
149
|
+
|
|
150
|
+
or
|
|
151
|
+
|
|
152
|
+
* `lat` query in conjunction with lon
|
|
153
|
+
* `lon` query in conjunction with lat
|
|
154
|
+
* `count` max results (optional)
|
|
155
|
+
|
|
156
|
+
Usage `zomato_instance.get_collections( { city_id: 279, count: 1000 })`
|
|
157
|
+
|
|
158
|
+
Access through class variable `collections`
|
|
159
|
+
|
|
160
|
+
`zomato_instance.collections`
|
|
161
|
+
|
|
162
|
+
```ruby
|
|
163
|
+
{
|
|
164
|
+
"collections" => [
|
|
165
|
+
[ 0] {
|
|
166
|
+
"collection" => {
|
|
167
|
+
"collection_id" => 1,
|
|
168
|
+
"res_count" => 30,
|
|
169
|
+
"image_url" => "https://b.zmtcdn.com/data/collections/e140962ec7eecbb851155fe0bb0cd28c_1463395649.jpg",
|
|
170
|
+
"url" => "https://www.zomato.com/moscow-id/top-restaurants?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1",
|
|
171
|
+
"title" => "Trending this Week",
|
|
172
|
+
"description" => "The most popular restaurants in town this week",
|
|
173
|
+
"share_url" => "http://www.zoma.to/c-279/1"
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
[ 1] {
|
|
177
|
+
"collection" => {
|
|
178
|
+
"collection_id" => 29,
|
|
179
|
+
"res_count" => 31,
|
|
180
|
+
"image_url" => "https://b.zmtcdn.com/data/collections/4661c54a624d8a055119af2d0ccde724_1463399059.jpg",
|
|
181
|
+
"url" => "https://www.zomato.com/moscow-id/best-new-restaurants?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1",
|
|
182
|
+
"title" => "Newly Opened",
|
|
183
|
+
"description" => "The best new places in town",
|
|
184
|
+
"share_url" => "http://www.zoma.to/c-279/29"
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
........
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
#### Romato::Zomato.get_cuisines()
|
|
191
|
+
|
|
192
|
+
View API documentation here: https://developers.zomato.com/documentation#!/common/cuisines
|
|
193
|
+
|
|
194
|
+
Accepts `options` hash with the following values:
|
|
195
|
+
* `city_id` query collections by city id
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
or
|
|
199
|
+
|
|
200
|
+
* `lat` query in conjunction with lon
|
|
201
|
+
* `lon` query in conjunction with lat
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
Usage `zomato_instance.get_cuisines( { city_id: 279 })`
|
|
205
|
+
|
|
206
|
+
Access through class variable `cuisines`
|
|
207
|
+
|
|
208
|
+
`zomato_instance.cuisines`
|
|
209
|
+
|
|
210
|
+
```ruby
|
|
211
|
+
{
|
|
212
|
+
"cuisines" => [
|
|
213
|
+
[ 0] {
|
|
214
|
+
"cuisine" => {
|
|
215
|
+
"cuisine_id" => 6,
|
|
216
|
+
"cuisine_name" => "Afghani"
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
[ 1] {
|
|
220
|
+
"cuisine" => {
|
|
221
|
+
"cuisine_id" => 152,
|
|
222
|
+
"cuisine_name" => "African"
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
[ 2] {
|
|
226
|
+
"cuisine" => {
|
|
227
|
+
"cuisine_id" => 1,
|
|
228
|
+
"cuisine_name" => "American"
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
...
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
#### Romato::Zomato.get_establishments()
|
|
235
|
+
|
|
236
|
+
View API documentation here: https://developers.zomato.com/documentation#!/common/establishments
|
|
237
|
+
|
|
238
|
+
*Note: Establishments returns categories of establishments, rather than a list of establishments*
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
Accepts `options` hash with the following values:
|
|
242
|
+
* `city_id` query collections by city id
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
or
|
|
246
|
+
|
|
247
|
+
* `lat` query in conjunction with lon
|
|
248
|
+
* `lon` query in conjunction with lat
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
Usage `zomato_instance.get_establishments( { city_id: 279 })`
|
|
252
|
+
|
|
253
|
+
Access through class variable `establishments`
|
|
254
|
+
|
|
255
|
+
`zomato_instance.establishments`
|
|
256
|
+
|
|
257
|
+
```ruby
|
|
258
|
+
{
|
|
259
|
+
"establishments" => [
|
|
260
|
+
[ 0] {
|
|
261
|
+
"establishment" => {
|
|
262
|
+
"id" => 275,
|
|
263
|
+
"name" => "Pizzeria"
|
|
264
|
+
}
|
|
265
|
+
},
|
|
266
|
+
[ 1] {
|
|
267
|
+
"establishment" => {
|
|
268
|
+
"id" => 21,
|
|
269
|
+
"name" => "Quick Bites"
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
[ 2] {
|
|
273
|
+
"establishment" => {
|
|
274
|
+
"id" => 281,
|
|
275
|
+
"name" => "Fast Food"
|
|
276
|
+
}
|
|
277
|
+
},
|
|
278
|
+
...
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
#### Romato::Zomato.get_geocode()
|
|
283
|
+
|
|
284
|
+
View API documentation here: https://developers.zomato.com/documentation#!/common/geocode
|
|
285
|
+
|
|
286
|
+
*Note: geocode is used to return the location name of a given lat/lon, including locality name and nearby restaurants. In depth information is provided, examine the response for more details.*
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
Accepts `options` hash with the following values:
|
|
290
|
+
|
|
291
|
+
* `lat` query in conjunction with lon
|
|
292
|
+
* `lon` query in conjunction with lat
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
Usage `zomato_instance.get_geocode( { lat: "40.742051", lon: "-74.004821" } )`
|
|
296
|
+
|
|
297
|
+
Access through class variable `geocode`
|
|
298
|
+
|
|
299
|
+
`zomato_instance.geocode`
|
|
300
|
+
|
|
301
|
+
```ruby
|
|
302
|
+
{
|
|
303
|
+
"location" => {
|
|
304
|
+
"entity_type" => "",
|
|
305
|
+
"entity_id" => 0,
|
|
306
|
+
"title" => "Chelsea",
|
|
307
|
+
"latitude" => "40.7445500495",
|
|
308
|
+
"longitude" => "-73.9971540829",
|
|
309
|
+
"city_id" => 280,
|
|
310
|
+
"city_name" => "New York City",
|
|
311
|
+
"country_id" => 216,
|
|
312
|
+
"country_name" => "United States"
|
|
313
|
+
},
|
|
314
|
+
"popularity" => {
|
|
315
|
+
"popularity" => "5.00",
|
|
316
|
+
"nightlife_index" => "4.94",
|
|
317
|
+
"nearby_res" => [
|
|
318
|
+
[0] "16765367",
|
|
319
|
+
[1] "16761344",
|
|
320
|
+
[2] "16767139",
|
|
321
|
+
[3] "16777934",
|
|
322
|
+
[4] "16777961",
|
|
323
|
+
[5] "16777384",
|
|
324
|
+
[6] "16761868",
|
|
325
|
+
[7] "16771928",
|
|
326
|
+
[8] "16760901"
|
|
327
|
+
],
|
|
328
|
+
...
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
### Location Methods (as defined by Zomato API)
|
|
332
|
+
|
|
333
|
+
#### Romato::Zomato.get_location_details()
|
|
334
|
+
|
|
335
|
+
View API documentation here: https://developers.zomato.com/documentation#!/location/location_details
|
|
336
|
+
|
|
337
|
+
*Note: The amount of information returned is quite large, examine the response for more detail.*
|
|
338
|
+
|
|
339
|
+
Accepts `options` hash with the following values:
|
|
340
|
+
|
|
341
|
+
* `entity_id` the id of the location entity
|
|
342
|
+
* `entity_type` the type i.e. city, locality
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
Usage `zomato_instance.get_location_details( { entity_id: 279, entity_type: "city" } )`
|
|
346
|
+
|
|
347
|
+
Access through class variable `location_details`
|
|
348
|
+
|
|
349
|
+
`zomato_instance.location_details`
|
|
350
|
+
|
|
351
|
+
```ruby
|
|
352
|
+
{
|
|
353
|
+
"popularity" => "4.88",
|
|
354
|
+
"nightlife_index" => "4.84",
|
|
355
|
+
"nearby_res" => [
|
|
356
|
+
[0] "16718075",
|
|
357
|
+
[1] "16718098",
|
|
358
|
+
[2] "16720781",
|
|
359
|
+
[3] "16717315",
|
|
360
|
+
[4] "16720700",
|
|
361
|
+
[5] "16718128",
|
|
362
|
+
[6] "16718982",
|
|
363
|
+
[7] "16718725",
|
|
364
|
+
[8] "16727949"
|
|
365
|
+
],
|
|
366
|
+
"top_cuisines" => [
|
|
367
|
+
[0] "Cafe",
|
|
368
|
+
[1] "Sandwich",
|
|
369
|
+
[2] "American",
|
|
370
|
+
[3] "Bar Food",
|
|
371
|
+
[4] "Pacific Northwest"
|
|
372
|
+
],
|
|
373
|
+
"popularity_res" => "100",
|
|
374
|
+
"nightlife_res" => "10",
|
|
375
|
+
"subzone" => "Downtown",
|
|
376
|
+
"subzone_id" => 113179,
|
|
377
|
+
"city" => "Seattle",
|
|
378
|
+
"location" => {
|
|
379
|
+
"entity_type" => "city",
|
|
380
|
+
"entity_id" => "279",
|
|
381
|
+
"title" => "Seattle, Washington State",
|
|
382
|
+
"latitude" => 47.60577,
|
|
383
|
+
"longitude" => -122.329437,
|
|
384
|
+
"city_id" => 279,
|
|
385
|
+
"city_name" => "Seattle",
|
|
386
|
+
"country_id" => 216,
|
|
387
|
+
"country_name" => "United States"
|
|
388
|
+
},
|
|
389
|
+
...
|
|
390
|
+
```
|
|
391
|
+
#### Romato::Zomato.get_locations()
|
|
392
|
+
|
|
393
|
+
View API documentation here: https://developers.zomato.com/documentation#!/location/locations
|
|
394
|
+
|
|
395
|
+
Accepts `options` hash with the following values:
|
|
396
|
+
|
|
397
|
+
* `query` use a string to query the location name
|
|
398
|
+
* `count` max results to return (optional)
|
|
399
|
+
|
|
400
|
+
or
|
|
401
|
+
|
|
402
|
+
* `lat` query in conjunction with lon
|
|
403
|
+
* `lon` query in conjunction with lat
|
|
404
|
+
* `count` max results to return (optional)
|
|
405
|
+
|
|
406
|
+
Usage `zomato_instance.get_locations( { lat: "40.742051", lon: "-74.004821" } )`
|
|
407
|
+
|
|
408
|
+
Access through class variable `locations`
|
|
409
|
+
|
|
410
|
+
`zomato_instance.locations`
|
|
411
|
+
|
|
412
|
+
```ruby
|
|
413
|
+
{
|
|
414
|
+
"location_suggestions" => [
|
|
415
|
+
[0] {
|
|
416
|
+
"entity_type" => "group",
|
|
417
|
+
"entity_id" => 36932,
|
|
418
|
+
"title" => "Chelsea Market, Chelsea, New York City",
|
|
419
|
+
"latitude" => 40.742051,
|
|
420
|
+
"longitude" => -74.004821,
|
|
421
|
+
"city_id" => 280,
|
|
422
|
+
"city_name" => "New York City",
|
|
423
|
+
"country_id" => 216,
|
|
424
|
+
"country_name" => "United States"
|
|
425
|
+
}
|
|
426
|
+
],
|
|
427
|
+
"status" => "success",
|
|
428
|
+
"has_more" => 0,
|
|
429
|
+
"has_total" => 0
|
|
430
|
+
}
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
## Restaurant Methods (as defined by Zomato API)
|
|
434
|
+
|
|
435
|
+
#### Romato::Zomato.get_daily_menu()
|
|
436
|
+
|
|
437
|
+
View API documentation here: https://developers.zomato.com/documentation#!/restaurant/restaurant
|
|
438
|
+
|
|
439
|
+
Accepts `options` hash with the following values:
|
|
440
|
+
|
|
441
|
+
* `res_id` restaurant id
|
|
442
|
+
|
|
443
|
+
Usage `zomato_instance.get_daily_menu( { res_id: "16717368" } )`
|
|
444
|
+
|
|
445
|
+
Access through class variable `daily_menu`
|
|
446
|
+
|
|
447
|
+
`zomato_instance.daily_menu`
|
|
448
|
+
|
|
449
|
+
```ruby
|
|
450
|
+
{
|
|
451
|
+
"R" => {
|
|
452
|
+
"res_id" => 16717368
|
|
453
|
+
},
|
|
454
|
+
"apikey" => "f47a72ab00afe64aab78b9919ee3d427",
|
|
455
|
+
"id" => "16717368",
|
|
456
|
+
"name" => "Canlis",
|
|
457
|
+
"url" => "https://www.zomato.com/seattle/canlis-westlake?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1",
|
|
458
|
+
"location" => {
|
|
459
|
+
"address" => "2576 Aurora Avenue North, WA 98109",
|
|
460
|
+
"locality" => "Westlake",
|
|
461
|
+
"city" => "Seattle",
|
|
462
|
+
"city_id" => 279,
|
|
463
|
+
"latitude" => "47.6429138889",
|
|
464
|
+
"longitude" => "-122.3468250000",
|
|
465
|
+
"zipcode" => "98109",
|
|
466
|
+
"country_id" => 216
|
|
467
|
+
},
|
|
468
|
+
"cuisines" => "Pacific Northwest, Seafood",
|
|
469
|
+
"average_cost_for_two" => 150,
|
|
470
|
+
"price_range" => 4,
|
|
471
|
+
"currency" => "$",
|
|
472
|
+
"offers" => [],
|
|
473
|
+
"thumb" => "https://b.zmtcdn.com/data/pictures/8/16717368/840eb8f385b06e0408e6ab9e533533da_featured_v2.jpg",
|
|
474
|
+
"user_rating" => {
|
|
475
|
+
"aggregate_rating" => "3.7",
|
|
476
|
+
"rating_text" => "Good",
|
|
477
|
+
"rating_color" => "9ACD32",
|
|
478
|
+
"votes" => "1431"
|
|
479
|
+
},
|
|
480
|
+
"photos_url" => "https://www.zomato.com/seattle/canlis-westlake/photos#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1",
|
|
481
|
+
"menu_url" => "https://www.zomato.com/seattle/canlis-westlake/menu#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1",
|
|
482
|
+
"featured_image" => "https://b.zmtcdn.com/data/pictures/8/16717368/840eb8f385b06e0408e6ab9e533533da_featured_v2.jpg",
|
|
483
|
+
"has_online_delivery" => 0,
|
|
484
|
+
"is_delivering_now" => 0,
|
|
485
|
+
"deeplink" => "zomato://r/16717368",
|
|
486
|
+
"has_table_booking" => 0,
|
|
487
|
+
"events_url" => "https://www.zomato.com/seattle/canlis-westlake/events#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1"
|
|
488
|
+
}
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
#### Romato::Zomato.get_restaurant()
|
|
492
|
+
|
|
493
|
+
View API documentation here: https://developers.zomato.com/documentation#!/restaurant/restaurant_0
|
|
494
|
+
|
|
495
|
+
Accepts `options` hash with the following values:
|
|
496
|
+
|
|
497
|
+
* `res_id` restaurant id
|
|
498
|
+
|
|
499
|
+
Usage `zomato_instance.get_restaurant( { res_id: "16717368" } )`
|
|
500
|
+
|
|
501
|
+
Access through class variable `restaurant`
|
|
502
|
+
|
|
503
|
+
`zomato_instance.restaurant`
|
|
504
|
+
|
|
505
|
+
```ruby
|
|
506
|
+
{
|
|
507
|
+
"R" => {
|
|
508
|
+
"res_id" => 16717368
|
|
509
|
+
},
|
|
510
|
+
"apikey" => "f47a72ab00afe64aab78b9919ee3d427",
|
|
511
|
+
"id" => "16717368",
|
|
512
|
+
"name" => "Canlis",
|
|
513
|
+
"url" => "https://www.zomato.com/seattle/canlis-westlake?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1",
|
|
514
|
+
"location" => {
|
|
515
|
+
"address" => "2576 Aurora Avenue North, WA 98109",
|
|
516
|
+
"locality" => "Westlake",
|
|
517
|
+
"city" => "Seattle",
|
|
518
|
+
"city_id" => 279,
|
|
519
|
+
"latitude" => "47.6429138889",
|
|
520
|
+
"longitude" => "-122.3468250000",
|
|
521
|
+
"zipcode" => "98109",
|
|
522
|
+
"country_id" => 216
|
|
523
|
+
},
|
|
524
|
+
"cuisines" => "Pacific Northwest, Seafood",
|
|
525
|
+
"average_cost_for_two" => 150,
|
|
526
|
+
"price_range" => 4,
|
|
527
|
+
"currency" => "$",
|
|
528
|
+
"offers" => [],
|
|
529
|
+
"thumb" => "https://b.zmtcdn.com/data/pictures/8/16717368/840eb8f385b06e0408e6ab9e533533da_featured_v2.jpg",
|
|
530
|
+
"user_rating" => {
|
|
531
|
+
"aggregate_rating" => "3.7",
|
|
532
|
+
"rating_text" => "Good",
|
|
533
|
+
"rating_color" => "9ACD32",
|
|
534
|
+
"votes" => "1431"
|
|
535
|
+
},
|
|
536
|
+
"photos_url" => "https://www.zomato.com/seattle/canlis-westlake/photos#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1",
|
|
537
|
+
"menu_url" => "https://www.zomato.com/seattle/canlis-westlake/menu#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1",
|
|
538
|
+
"featured_image" => "https://b.zmtcdn.com/data/pictures/8/16717368/840eb8f385b06e0408e6ab9e533533da_featured_v2.jpg",
|
|
539
|
+
"has_online_delivery" => 0,
|
|
540
|
+
"is_delivering_now" => 0,
|
|
541
|
+
"deeplink" => "zomato://r/16717368",
|
|
542
|
+
"has_table_booking" => 0,
|
|
543
|
+
"events_url" => "https://www.zomato.com/seattle/canlis-westlake/events#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1"
|
|
544
|
+
}
|
|
545
|
+
```
|
|
546
|
+
|
|
547
|
+
#### Romato::Zomato.get_reviews()
|
|
548
|
+
|
|
549
|
+
View API documentation here: https://developers.zomato.com/documentation#!/restaurant/reviews
|
|
550
|
+
|
|
551
|
+
Accepts `options` hash with the following values:
|
|
552
|
+
|
|
553
|
+
* `res_id` restaurant id
|
|
554
|
+
* `start` which review to begin query
|
|
555
|
+
* `count` max number of results
|
|
556
|
+
|
|
557
|
+
Usage `zomato_instance.get_reviews( { res_id: "16717368" } )`
|
|
558
|
+
|
|
559
|
+
Access through class variable `reviews`
|
|
560
|
+
|
|
561
|
+
`zomato_instance.reviews`
|
|
562
|
+
|
|
563
|
+
```ruby
|
|
564
|
+
{
|
|
565
|
+
"reviews_count" => 58,
|
|
566
|
+
"reviews_start" => 0,
|
|
567
|
+
"reviews_shown" => 5,
|
|
568
|
+
"user_reviews" => [
|
|
569
|
+
[0] {
|
|
570
|
+
"review" => {
|
|
571
|
+
"rating" => 4.5,
|
|
572
|
+
"review_text" => "Canlis July 28, 2016 Seattle, Washington Generation Owner Brian Canlis Executive Chef Brady Williams Executive Sous Chef Baruch Ellsworth Wine & Spirits Director Nelson Daquip Sommelier & Vice Director Jackson Rohrbaugh Accolades: -4 Stars, Seattle Times -Relais & Chateaux -Wine Spectator Grand Award -James Beard Outstanding Wine Service Nomination -James Beard Outstanding Service Nomination -James Beard Best Chef Northwest Nomination -Highest Overall Rating, Zagat -Top 50 Restaurants in Ame...",
|
|
573
|
+
"id" => "27856458",
|
|
574
|
+
"rating_color" => "3F7E00",
|
|
575
|
+
"review_time_friendly" => "one month ago",
|
|
576
|
+
"rating_text" => "Loved it!",
|
|
577
|
+
"timestamp" => 1470513585,
|
|
578
|
+
"likes" => 0,
|
|
579
|
+
"user" => {
|
|
580
|
+
"name" => "Lee Pitofsky",
|
|
581
|
+
"zomato_handle" => "Lpit8",
|
|
582
|
+
"foodie_level" => "Super Foodie",
|
|
583
|
+
"foodie_level_num" => 8,
|
|
584
|
+
"foodie_color" => "f58552",
|
|
585
|
+
"profile_url" => "https://www.zomato.com/Lpit8?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1",
|
|
586
|
+
"profile_image" => "https://b.zmtcdn.com/data/user_profile_pictures/249/d795854560c55d98e622b91881695249.jpg?fit=around%7C100%3A100&crop=100%3A100%3B%2A%2C%2A",
|
|
587
|
+
"profile_deeplink" => "zomato://u/23178569"
|
|
588
|
+
},
|
|
589
|
+
"comments_count" => 0
|
|
590
|
+
}
|
|
591
|
+
},
|
|
592
|
+
...
|
|
593
|
+
```
|
|
594
|
+
|
|
595
|
+
#### Romato::Zomato.search()
|
|
596
|
+
|
|
597
|
+
View API documentation here: https://developers.zomato.com/documentation#!/restaurant/search
|
|
598
|
+
|
|
599
|
+
*Note: To use the search method it is highly recommended to read the documentation and will require some exploration.*
|
|
600
|
+
|
|
601
|
+
Accepts `options` hash with the following values:
|
|
602
|
+
|
|
603
|
+
* `entity_id`
|
|
604
|
+
* `entity_type`
|
|
605
|
+
* `q`
|
|
606
|
+
* `start`
|
|
607
|
+
* `count`
|
|
608
|
+
* `lat`
|
|
609
|
+
* `lon`
|
|
610
|
+
* `radius`
|
|
611
|
+
* `cuisines`
|
|
612
|
+
* `establishment_type`
|
|
613
|
+
* `collection_id`
|
|
614
|
+
* `category`
|
|
615
|
+
* `sort`
|
|
616
|
+
* `order`
|
|
617
|
+
|
|
618
|
+
Usage `zomato_instance.get_search( { entity_id: "279", cuisines: "997" } )`
|
|
619
|
+
|
|
620
|
+
Access through class variable `search`
|
|
621
|
+
|
|
622
|
+
`zomato_instance.search`
|
|
623
|
+
{
|
|
624
|
+
"results_found": 1232547,
|
|
625
|
+
"results_start": 0,
|
|
626
|
+
"results_shown": 20,
|
|
627
|
+
"restaurants": [
|
|
628
|
+
{
|
|
629
|
+
"restaurant": {
|
|
630
|
+
"R": {
|
|
631
|
+
"res_id": 50474
|
|
632
|
+
},
|
|
633
|
+
"apikey": "f47a72ab00afe64aab78b9919ee3d427",
|
|
634
|
+
"id": "50474",
|
|
635
|
+
"name": "Empire Restaurant",
|
|
636
|
+
"url": "https://www.zomato.com/bangalore/empire-restaurant-koramangala-5th-block?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1",
|
|
637
|
+
"location": {
|
|
638
|
+
"address": "103, Industrial Area, 5th Block, Near Jyothi Nivas College, Koramangala 5th Block, Bangalore",
|
|
639
|
+
"locality": "Koramangala 5th Block",
|
|
640
|
+
"city": "Bangalore",
|
|
641
|
+
"city_id": 4,
|
|
642
|
+
"latitude": "12.9348880271",
|
|
643
|
+
"longitude": "77.6160025969",
|
|
644
|
+
...
|
|
645
|
+
```ruby
|
|
646
|
+
|
|
647
|
+
## Development
|
|
648
|
+
|
|
649
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
650
|
+
|
|
651
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
652
|
+
|
|
653
|
+
## Contributing
|
|
654
|
+
|
|
655
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/kyle-annen/romato. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
656
|
+
|
|
657
|
+
|
|
658
|
+
## License
|
|
659
|
+
|
|
660
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
|
661
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "romato"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/lib/romato.rb
ADDED
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
require "romato/version"
|
|
2
|
+
module Romato
|
|
3
|
+
#use HTTParty for simple http calls
|
|
4
|
+
require 'httparty'
|
|
5
|
+
|
|
6
|
+
class Zomato
|
|
7
|
+
#assign the variable to be accessed through dot notation
|
|
8
|
+
attr_accessor :locations, :location_details, :categories, :cities,
|
|
9
|
+
:collections, :cuisines, :establishments, :geocode, :daily_menu,
|
|
10
|
+
:reviews, :search, :restaurant
|
|
11
|
+
|
|
12
|
+
#initializes provided api_key
|
|
13
|
+
#headers and base uri should not change
|
|
14
|
+
def initialize(api_key)
|
|
15
|
+
@api_key = api_key
|
|
16
|
+
@headers = {"Accept" => "application/JSON", "user-key" => @api_key}
|
|
17
|
+
@base_uri = "https://developers.zomato.com/api/v2.1/"
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# COMMON Category
|
|
21
|
+
# returns a list of categories (food categories)
|
|
22
|
+
# https://developers.zomato.com/documentation#!/common/categories
|
|
23
|
+
def get_categories()
|
|
24
|
+
zomoato_categories_url = @base_uri + "categories"
|
|
25
|
+
response = HTTParty.get(zomoato_categories_url, headers: @headers)
|
|
26
|
+
if response.success?
|
|
27
|
+
@categories = response.parsed_response
|
|
28
|
+
else
|
|
29
|
+
raise response.response
|
|
30
|
+
end
|
|
31
|
+
return @categories
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# pass hash to get cities, valid key / value pairs below
|
|
35
|
+
# q = ""seattle, lat = "", lon = "" , city_ids ="", count=50
|
|
36
|
+
# {q: "seattle", lat: "", lon: "", city_ids: "", count=50 }
|
|
37
|
+
def get_cities(options)
|
|
38
|
+
url_base = @base_uri + "cities?"
|
|
39
|
+
a = options.key?(:q) ? "&q=#{options[:q]}" : ""
|
|
40
|
+
b = options.key?(:lat) ? "&lat=#{options[:lat]}" : ""
|
|
41
|
+
c = options.key?(:lon) ? "&lon=#{options[:lon]}" : ""
|
|
42
|
+
d = options.key?(:city_ids) ? "&city_ids=#{options[:city_ids]}" : ""
|
|
43
|
+
e = options.key?(:count) ? "&count=#{options[:count]}" : ""
|
|
44
|
+
zomato_cities_url = url_base + a + b + c + d + e
|
|
45
|
+
|
|
46
|
+
response = HTTParty.get(zomato_cities_url, headers: @headers)
|
|
47
|
+
if response.success?
|
|
48
|
+
@cities = response.parsed_response
|
|
49
|
+
else
|
|
50
|
+
raise response.response
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def get_collections(options)
|
|
55
|
+
url_base = @base_uri + "collections?"
|
|
56
|
+
a = options.key?(:city_id) ? "&city_id=#{options[:city_id]}" : ""
|
|
57
|
+
b = options.key?(:lat) ? "&lat=#{options[:lat]}" : ""
|
|
58
|
+
c = options.key?(:lon) ? "&lon=#{options[:lon]}" : ""
|
|
59
|
+
d = options.key?(:count) ? "&count=#{options[:count]}" : ""
|
|
60
|
+
zomato_collections_url = url_base + a + b + c + d
|
|
61
|
+
|
|
62
|
+
response = HTTParty.get(zomato_collections_url, headers: @headers)
|
|
63
|
+
if response.success?
|
|
64
|
+
@collections = response.parsed_response
|
|
65
|
+
else
|
|
66
|
+
raise response.response
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# returns a hash of cuisines in a particular city or geographic location
|
|
71
|
+
# accepts a hash: options. Required values either
|
|
72
|
+
# {city_id: "279"}
|
|
73
|
+
# or
|
|
74
|
+
# {lat: 32.342, lon: 12.234}
|
|
75
|
+
# utilizes string interpolation, any value will be interpolated to string and passed to the api endpoint
|
|
76
|
+
# as an html argument
|
|
77
|
+
def get_cuisines(options)
|
|
78
|
+
url_base = @base_uri + "cuisines?"
|
|
79
|
+
a = options.key?(:city_id) ? "&city_id=#{options[:city_id]}" : ""
|
|
80
|
+
b = options.key?(:lat) ? "&lat=#{options[:lat]}" : ""
|
|
81
|
+
c = options.key?(:lon) ? "&lon=#{options[:lon]}" : ""
|
|
82
|
+
zomato_cuisines_url = url_base + a + b + c
|
|
83
|
+
|
|
84
|
+
response = HTTParty.get(zomato_cuisines_url, headers: @headers)
|
|
85
|
+
if response.success?
|
|
86
|
+
@cuisines = response.parsed_response
|
|
87
|
+
else
|
|
88
|
+
raise response.response
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
# returns a hash of establishment categories in a particular city or geographic location
|
|
94
|
+
# accepts a hash: options. Required values either
|
|
95
|
+
# {city_id: "279"}
|
|
96
|
+
# or
|
|
97
|
+
# {lat: 32.342, lon: 12.234}
|
|
98
|
+
# utilizes string interpolation, any value will be interpolated to string and passed to the api endpoint
|
|
99
|
+
# as an html argument
|
|
100
|
+
def get_establishments(options)
|
|
101
|
+
url_base = @base_uri + "establishments?"
|
|
102
|
+
a = options.key?(:city_id) ? "&city_id=#{options[:city_id]}" : ""
|
|
103
|
+
b = options.key?(:lat) ? "&lat=#{options[:lat]}" : ""
|
|
104
|
+
c = options.key?(:lon) ? "&lon=#{options[:lon]}" : ""
|
|
105
|
+
zomato_establishments_url = url_base + a + b + c
|
|
106
|
+
|
|
107
|
+
response = HTTParty.get(zomato_establishments_url, headers: @headers)
|
|
108
|
+
if response.success?
|
|
109
|
+
@establishments = response.parsed_response
|
|
110
|
+
else
|
|
111
|
+
raise response.response
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
#returns the information to a cooresponding geographical coordinate
|
|
116
|
+
#accepts options hash
|
|
117
|
+
#hash example
|
|
118
|
+
#options: {lat: 24.5344, lon: -12.3423}
|
|
119
|
+
def get_geocode(options)
|
|
120
|
+
url_base = @base_uri + "geocode?"
|
|
121
|
+
a = options.key?(:lat) ? "&lat=#{options[:lat]}" : ""
|
|
122
|
+
b = options.key?(:lon) ? "&lon=#{options[:lon]}" : ""
|
|
123
|
+
zomato_geocode_url = url_base + a + b
|
|
124
|
+
|
|
125
|
+
response = HTTParty.get(zomato_geocode_url, headers: @headers)
|
|
126
|
+
if response.success?
|
|
127
|
+
@geocode = response.parsed_response
|
|
128
|
+
else
|
|
129
|
+
raise response.response
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
#LOCATION
|
|
134
|
+
|
|
135
|
+
# Sets the locations details to @location_details
|
|
136
|
+
# https://developers.zomato.com/documentation#!/location/location_details
|
|
137
|
+
# options passed as hash, both entity_id and entity_type are required
|
|
138
|
+
# options hash example: {entity_id: "279", entity_type: "seattle"}
|
|
139
|
+
def get_location_details(options)
|
|
140
|
+
zomato_location_details_url = @base_uri +
|
|
141
|
+
"/location_details?entity_id=#{options[:entity_id]}&entity_type=#{options[:entity_type]}"
|
|
142
|
+
response = HTTParty.get(zomato_location_details_url, headers: @headers)
|
|
143
|
+
if response.success?
|
|
144
|
+
@location_details = response.parsed_response
|
|
145
|
+
else
|
|
146
|
+
raise response.response
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
#sets location guesses based on the query to @locations
|
|
151
|
+
#query and latitude/longitude are required
|
|
152
|
+
#hash returned can be viewed in Zomato documentation
|
|
153
|
+
#https://developers.zomato.com/documentation#!/location/locations
|
|
154
|
+
#options passed as a hash
|
|
155
|
+
#options hash example: {query: "seattle", lat: "47.6906021", lon}
|
|
156
|
+
def get_locations(options)
|
|
157
|
+
url_base = @base_uri + "locations?"
|
|
158
|
+
a = options.has_key?(:query) ? "&query=#{options[:query]}" : ""
|
|
159
|
+
b = options.has_key?(:lat) ? "&lat=#{options[:lat]}" : ""
|
|
160
|
+
c = options.has_key?(:lon) ? "&lon=#{options[:lon]}" : ""
|
|
161
|
+
d = options.has_key?(:count) ? "&count=#{options[:count]}" : ""
|
|
162
|
+
zomato_locations_url = url_base + a + b + c + d
|
|
163
|
+
|
|
164
|
+
response = HTTParty.get(zomato_locations_url, headers: @headers)
|
|
165
|
+
if response.success?
|
|
166
|
+
@locations = []
|
|
167
|
+
#for result in response.parsed_response.location_suggestions
|
|
168
|
+
@locations = response.parsed_response
|
|
169
|
+
#end
|
|
170
|
+
else
|
|
171
|
+
raise response.response
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
#RESTAURANT
|
|
179
|
+
# accepts options hash as parameters
|
|
180
|
+
# options example: {res_id: "279"}
|
|
181
|
+
def get_daily_menu(options)
|
|
182
|
+
zomato_daily_menu_url = @base_uri +
|
|
183
|
+
"restaurant?res_id=#{options[:res_id]}"
|
|
184
|
+
response = HTTParty.get(zomato_daily_menu_url, headers: @headers)
|
|
185
|
+
if response.success?
|
|
186
|
+
@daily_menu = response.parsed_response
|
|
187
|
+
else
|
|
188
|
+
raise response.response
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
# get the details from the restaurant
|
|
194
|
+
# https://developers.zomato.com/documentation#!/restaurant/restaurant_0
|
|
195
|
+
# # accepts options hash as parameters
|
|
196
|
+
# options example: {res_id: "279"}
|
|
197
|
+
def get_restaurant(options)
|
|
198
|
+
|
|
199
|
+
zomato_restaurant_details_url = @base_uri +
|
|
200
|
+
"restaurant?res_id=#{options[:res_id]}"
|
|
201
|
+
response = HTTParty.get(zomato_restaurant_details_url, headers: @headers)
|
|
202
|
+
if response.success?
|
|
203
|
+
@restaurant = response.parsed_response
|
|
204
|
+
else
|
|
205
|
+
raise response.response
|
|
206
|
+
end
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
def get_reviews(options)
|
|
212
|
+
url_base = @base_uri + "reviews?"
|
|
213
|
+
a = options.key?(:res_id) ? "&res_id=#{options[:res_id]}" : ""
|
|
214
|
+
b = options.key?(:start) ? "&start=#{options[:start]}" : ""
|
|
215
|
+
c = options.key?(:count) ? "&count=#{options[:count]}" : ""
|
|
216
|
+
zomato_reviews_url = url_base + a + b + c
|
|
217
|
+
|
|
218
|
+
response = HTTParty.get(zomato_reviews_url, headers: @headers)
|
|
219
|
+
|
|
220
|
+
if response.success?
|
|
221
|
+
@reviews = response.parsed_response
|
|
222
|
+
else
|
|
223
|
+
raise response.response
|
|
224
|
+
end
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
def get_search(options)
|
|
229
|
+
url_base = @base_uri + "search?"
|
|
230
|
+
a = options.key?(:entity_id) ? "&entity_id=#{options[:entity_id]}" : ""
|
|
231
|
+
b = options.key?(:entity_type) ? "&entity_type=#{options[:entity_type]}" : ""
|
|
232
|
+
c = options.key?(:q) ? "&q=#{options[:q]}" : ""
|
|
233
|
+
d = options.key?(:start) ? "&start=#{options[:start]}" : ""
|
|
234
|
+
e = options.key?(:count) ? "&count=#{options[:count]}" : ""
|
|
235
|
+
f = options.key?(:lat) ? "&lat=#{options[:lat]}" : ""
|
|
236
|
+
g = options.key?(:lon) ? "&lon=#{options[:lon]}" : ""
|
|
237
|
+
h = options.key?(:radius) ? "&radius=#{options[:radius]}" : ""
|
|
238
|
+
i = options.key?(:cuisines) ? "&cuisines=#{options[:cuisines]}" : ""
|
|
239
|
+
j = options.key?(:establishment_type) ? "&establishment_type=#{options[:establishment_type]}" : ""
|
|
240
|
+
k = options.key?(:collection_id) ? "&collection_id=#{options[:collection_id]}" : ""
|
|
241
|
+
l = options.key?(:category) ? "&category=#{options[:category]}" : ""
|
|
242
|
+
m = options.key?(:sort) ? "&sort=#{options[:sort]}" : ""
|
|
243
|
+
n = options.key?(:order) ? "&order=#{options[:order]}" : ""
|
|
244
|
+
zomato_search_url = a + b + c + d + e + f + g + h + i + j + k + l + m + n
|
|
245
|
+
|
|
246
|
+
response = HTTParty.get(zomato_search_url, headers: @headers)
|
|
247
|
+
|
|
248
|
+
if response.success?
|
|
249
|
+
@search = response.parsed_response
|
|
250
|
+
else
|
|
251
|
+
raise response.response
|
|
252
|
+
end
|
|
253
|
+
end
|
|
254
|
+
end
|
|
255
|
+
end
|
data/romato.gemspec
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'romato/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "romato"
|
|
8
|
+
spec.version = Romato::VERSION
|
|
9
|
+
spec.authors = ["Kyle Annen"]
|
|
10
|
+
spec.email = ["kyleannen@gmail.com"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{Romato is an API wrapper for Zomato API v2.1.}
|
|
13
|
+
spec.description = %q{Romato provides a class, Zomato, which has methods cooresponding to each API class provided under the Zomato API documentation. Please read through the Zomato API terms of use: https://www.zomato.com/api_policy}
|
|
14
|
+
spec.homepage = "http://www.github.com/kyle-annen/romato"
|
|
15
|
+
spec.license = "MIT"
|
|
16
|
+
|
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
|
19
|
+
if spec.respond_to?(:metadata)
|
|
20
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org/"
|
|
21
|
+
else
|
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
|
23
|
+
"public gem pushes."
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
27
|
+
f.match(%r{^(test|spec|features)/})
|
|
28
|
+
end
|
|
29
|
+
spec.bindir = "exe"
|
|
30
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
31
|
+
spec.require_paths = ["lib"]
|
|
32
|
+
spec.add_runtime_dependency "httparty"
|
|
33
|
+
spec.add_runtime_dependency "bundler", "~> 1.13"
|
|
34
|
+
spec.add_runtime_dependency "rake", "~> 10.0"
|
|
35
|
+
spec.add_runtime_dependency "rspec", "~> 3.0"
|
|
36
|
+
|
|
37
|
+
spec.add_development_dependency "httparty"
|
|
38
|
+
spec.add_development_dependency "bundler", "~> 1.13"
|
|
39
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
40
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
|
41
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: romato
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Kyle Annen
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2016-09-15 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: httparty
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: bundler
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '1.13'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '1.13'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rake
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '10.0'
|
|
48
|
+
type: :runtime
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '10.0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rspec
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '3.0'
|
|
62
|
+
type: :runtime
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '3.0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: httparty
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: bundler
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - "~>"
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '1.13'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - "~>"
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '1.13'
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: rake
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - "~>"
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '10.0'
|
|
104
|
+
type: :development
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - "~>"
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '10.0'
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: rspec
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - "~>"
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: '3.0'
|
|
118
|
+
type: :development
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - "~>"
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: '3.0'
|
|
125
|
+
description: 'Romato provides a class, Zomato, which has methods cooresponding to
|
|
126
|
+
each API class provided under the Zomato API documentation. Please read through
|
|
127
|
+
the Zomato API terms of use: https://www.zomato.com/api_policy'
|
|
128
|
+
email:
|
|
129
|
+
- kyleannen@gmail.com
|
|
130
|
+
executables: []
|
|
131
|
+
extensions: []
|
|
132
|
+
extra_rdoc_files: []
|
|
133
|
+
files:
|
|
134
|
+
- "#Gemfile#"
|
|
135
|
+
- ".gitignore"
|
|
136
|
+
- ".rspec"
|
|
137
|
+
- ".travis.yml"
|
|
138
|
+
- CODE_OF_CONDUCT.md
|
|
139
|
+
- Gemfile
|
|
140
|
+
- LICENSE.txt
|
|
141
|
+
- README.md
|
|
142
|
+
- Rakefile
|
|
143
|
+
- bin/console
|
|
144
|
+
- bin/setup
|
|
145
|
+
- lib/romato.rb
|
|
146
|
+
- lib/romato/version.rb
|
|
147
|
+
- romato.gemspec
|
|
148
|
+
homepage: http://www.github.com/kyle-annen/romato
|
|
149
|
+
licenses:
|
|
150
|
+
- MIT
|
|
151
|
+
metadata:
|
|
152
|
+
allowed_push_host: https://rubygems.org/
|
|
153
|
+
post_install_message:
|
|
154
|
+
rdoc_options: []
|
|
155
|
+
require_paths:
|
|
156
|
+
- lib
|
|
157
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
158
|
+
requirements:
|
|
159
|
+
- - ">="
|
|
160
|
+
- !ruby/object:Gem::Version
|
|
161
|
+
version: '0'
|
|
162
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
163
|
+
requirements:
|
|
164
|
+
- - ">="
|
|
165
|
+
- !ruby/object:Gem::Version
|
|
166
|
+
version: '0'
|
|
167
|
+
requirements: []
|
|
168
|
+
rubyforge_project:
|
|
169
|
+
rubygems_version: 2.5.1
|
|
170
|
+
signing_key:
|
|
171
|
+
specification_version: 4
|
|
172
|
+
summary: Romato is an API wrapper for Zomato API v2.1.
|
|
173
|
+
test_files: []
|