yelp 2.0.7 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/lib/yelp/client.rb +1 -2
- data/lib/yelp/endpoint/business.rb +3 -1
- data/lib/yelp/endpoint/phone_search.rb +4 -1
- data/lib/yelp/endpoint/search.rb +5 -3
- data/lib/yelp/responses/base.rb +21 -0
- data/lib/yelp/responses/business.rb +14 -0
- data/lib/yelp/responses/models/business.rb +26 -0
- data/lib/yelp/responses/models/coordinate.rb +11 -0
- data/lib/yelp/responses/models/deal.rb +20 -0
- data/lib/yelp/responses/models/deal_option.rb +12 -0
- data/lib/yelp/responses/models/gift_certificate.rb +18 -0
- data/lib/yelp/responses/models/gift_certificate_option.rb +11 -0
- data/lib/yelp/responses/models/location.rb +19 -0
- data/lib/yelp/responses/models/rating.rb +11 -0
- data/lib/yelp/responses/models/region.rb +20 -0
- data/lib/yelp/responses/models/region_center.rb +11 -0
- data/lib/yelp/responses/models/region_span.rb +11 -0
- data/lib/yelp/responses/models/review.rb +12 -0
- data/lib/yelp/responses/models/user.rb +11 -0
- data/lib/yelp/responses/phone_search.rb +18 -0
- data/lib/yelp/responses/search.rb +18 -0
- data/lib/yelp/version.rb +1 -1
- data/spec/fixtures/vcr_cassettes/business.yml +52 -41
- data/spec/fixtures/vcr_cassettes/phone_search.yml +35 -28
- data/spec/fixtures/vcr_cassettes/search.yml +360 -332
- data/spec/fixtures/vcr_cassettes/search_bounding_box.yml +349 -327
- data/spec/fixtures/vcr_cassettes/search_by_coordinates.yml +361 -355
- data/spec/yelp/endpoint/business_spec.rb +2 -2
- data/spec/yelp/endpoint/phone_search_spec.rb +1 -1
- data/spec/yelp/endpoint/search_spec.rb +1 -1
- data/spec/yelp/responses/base_spec.rb +22 -0
- data/tasks/console.rake +2 -2
- data/yelp.gemspec +1 -1
- metadata +24 -7
- data/lib/yelp/burst_struct.rb +0 -63
- data/spec/yelp/burst_struct_spec.rb +0 -155
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 076604a5f23f287ad4412e17d9c25e8666d67914
|
4
|
+
data.tar.gz: 4cb7f7bb5f62861006664204307a325a4d600771
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 524acb6c644fb10ac46fafa4d30fffd07f307bb618a4c82eef1b3057b7f58549d9fabeab6cd99e716b1bf2b534361dc408562d81d160a7fe60e517e7a903da8e
|
7
|
+
data.tar.gz: 1153dc00ce890a7006a148f8496b72bd206ee29d2ae7bd152985fbf837fa7e8b4b66e2b0119e0ddf9f069d9a612065826ddf61731773070d28fd3b67f6715461
|
data/README.md
CHANGED
@@ -143,14 +143,14 @@ response.businesses[0].rating
|
|
143
143
|
## business
|
144
144
|
response = client.business('yelp-san-francisco')
|
145
145
|
|
146
|
-
response.name
|
146
|
+
response.business.name
|
147
147
|
# Yelp
|
148
148
|
|
149
|
-
response.categories
|
149
|
+
response.business.categories
|
150
150
|
# [["Local Flavor", "localflavor"], ["Mass Media", "massmedia"]]
|
151
151
|
```
|
152
152
|
|
153
|
-
For specific response values check out the docs for the [
|
153
|
+
For specific response values check out the docs for the [Search API](http://www.yelp.com/developers/documentation/v2/search_api#rValue) and the [Business API](http://www.yelp.com/developers/documentation/v2/business#rValue). You can also look at the responses and models inside of `lib/yelp/responses` and `lib/yelp/responses/models` to see the methods available.
|
154
154
|
|
155
155
|
## Contributing
|
156
156
|
|
data/lib/yelp/client.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'faraday'
|
2
2
|
require 'faraday_middleware'
|
3
3
|
|
4
|
-
require 'yelp/burst_struct'
|
5
4
|
require 'yelp/configuration'
|
6
5
|
require 'yelp/error'
|
7
6
|
require 'yelp/endpoint/business'
|
@@ -10,7 +9,7 @@ require 'yelp/endpoint/search'
|
|
10
9
|
|
11
10
|
module Yelp
|
12
11
|
class Client
|
13
|
-
API_HOST = '
|
12
|
+
API_HOST = 'https://api.yelp.com'
|
14
13
|
REQUEST_CLASSES = [ Yelp::Endpoint::Search,
|
15
14
|
Yelp::Endpoint::Business,
|
16
15
|
Yelp::Endpoint::PhoneSearch]
|
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'json'
|
2
2
|
|
3
|
+
require 'yelp/responses/business'
|
4
|
+
|
3
5
|
module Yelp
|
4
6
|
module Endpoint
|
5
7
|
class Business
|
@@ -19,7 +21,7 @@ module Yelp
|
|
19
21
|
# business.name # => 'Yelp'
|
20
22
|
# buinesss.url # => 'http://www.yelp.com/biz/yelp-san-francisco'
|
21
23
|
def business(id)
|
22
|
-
|
24
|
+
Response::Business.new(JSON.parse(business_request(id).body))
|
23
25
|
end
|
24
26
|
|
25
27
|
private
|
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'json'
|
2
2
|
|
3
|
+
require 'yelp/responses/phone_search'
|
4
|
+
|
3
5
|
module Yelp
|
4
6
|
module Endpoint
|
5
7
|
class PhoneSearch
|
@@ -27,7 +29,8 @@ module Yelp
|
|
27
29
|
def phone_search(phone, options={})
|
28
30
|
params = {phone: phone}
|
29
31
|
params.merge!(options)
|
30
|
-
|
32
|
+
|
33
|
+
Response::PhoneSearch.new(JSON.parse(phone_search_request(params).body))
|
31
34
|
end
|
32
35
|
|
33
36
|
private
|
data/lib/yelp/endpoint/search.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'json'
|
2
2
|
|
3
|
+
require 'yelp/responses/search'
|
4
|
+
|
3
5
|
module Yelp
|
4
6
|
module Endpoint
|
5
7
|
class Search
|
@@ -44,7 +46,7 @@ module Yelp
|
|
44
46
|
params.merge!(locale)
|
45
47
|
params.merge!({location: location})
|
46
48
|
|
47
|
-
|
49
|
+
Response::Search.new(JSON.parse(search_request(params).body))
|
48
50
|
end
|
49
51
|
|
50
52
|
# Search by a bounding box: specify a south west lat/long and a ne lat/long
|
@@ -90,7 +92,7 @@ module Yelp
|
|
90
92
|
options.merge!(params)
|
91
93
|
options.merge!(locale)
|
92
94
|
|
93
|
-
|
95
|
+
Response::Search.new(JSON.parse(search_request(options).body))
|
94
96
|
end
|
95
97
|
|
96
98
|
# Search by coordinates: give it a latitude and longitude along with
|
@@ -136,7 +138,7 @@ module Yelp
|
|
136
138
|
options.merge!(params)
|
137
139
|
options.merge!(locale)
|
138
140
|
|
139
|
-
|
141
|
+
Response::Search.new(JSON.parse(search_request(options).body))
|
140
142
|
end
|
141
143
|
|
142
144
|
private
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Yelp
|
2
|
+
module Response
|
3
|
+
class Base
|
4
|
+
def initialize(json)
|
5
|
+
return if json.nil?
|
6
|
+
|
7
|
+
json.each do |key, value|
|
8
|
+
instance_variable_set("@#{key}", value)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def parse(json, klass)
|
15
|
+
return json.collect { |j| klass.new(j) } if json.is_a?(Array)
|
16
|
+
return klass.new(json) if json
|
17
|
+
nil
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'yelp/responses/base'
|
2
|
+
require 'yelp/responses/models/deal'
|
3
|
+
require 'yelp/responses/models/gift_certificate'
|
4
|
+
require 'yelp/responses/models/location'
|
5
|
+
require 'yelp/responses/models/review'
|
6
|
+
|
7
|
+
module Yelp
|
8
|
+
module Response
|
9
|
+
module Model
|
10
|
+
class Business < Response::Base
|
11
|
+
attr_reader :categories, :deals, :display_phone, :distance, :eat24_url, :gift_certificates, :id, :image_url,
|
12
|
+
:is_claimed, :is_closed, :location, :menu_provider, :menu_date_updated, :mobile_url, :name, :phone,
|
13
|
+
:rating, :reviews, :reservation_url, :review_count, :snippet_image_url, :snippet_text, :url
|
14
|
+
|
15
|
+
def initialize(json)
|
16
|
+
super(json)
|
17
|
+
|
18
|
+
@deals = parse(@deals, Deal)
|
19
|
+
@gift_certificates = parse(@gift_certificates, GiftCertificate)
|
20
|
+
@location = parse(@location, Location)
|
21
|
+
@reviews = parse(@reviews, Review)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'yelp/responses/base'
|
2
|
+
require 'yelp/responses/models/deal_option'
|
3
|
+
|
4
|
+
module Yelp
|
5
|
+
module Response
|
6
|
+
module Model
|
7
|
+
class Deal < Response::Base
|
8
|
+
attr_reader :additional_restrictions, :currency_code, :image_url, :important_restriction, :is_popular,
|
9
|
+
:id, :options, :time_end, :time_start, :title, :url, :what_you_get
|
10
|
+
|
11
|
+
def initialize(json)
|
12
|
+
super(json)
|
13
|
+
|
14
|
+
@options = parse(@options, DealOption)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'yelp/responses/base'
|
2
|
+
|
3
|
+
module Yelp
|
4
|
+
module Response
|
5
|
+
module Model
|
6
|
+
class DealOption < Response::Base
|
7
|
+
attr_reader :formatted_original_price, :formatted_price, :is_quantity_limited, :original_price,
|
8
|
+
:price, :purchase_url, :remaining_count, :title
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'yelp/responses/base'
|
2
|
+
require 'yelp/responses/models/gift_certificate_option'
|
3
|
+
|
4
|
+
module Yelp
|
5
|
+
module Response
|
6
|
+
module Model
|
7
|
+
class GiftCertificate < Response::Base
|
8
|
+
attr_reader :currency_code, :id, :image_url, :options, :unused_balances, :url
|
9
|
+
|
10
|
+
def initialize(json)
|
11
|
+
super(json)
|
12
|
+
|
13
|
+
@options = parse(@options, GiftCertificateOption)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'yelp/responses/base'
|
2
|
+
require 'yelp/responses/models/coordinate'
|
3
|
+
|
4
|
+
module Yelp
|
5
|
+
module Response
|
6
|
+
module Model
|
7
|
+
class Location < Response::Base
|
8
|
+
attr_reader :address, :city, :coordinate, :country_code, :cross_streets, :display_address, :geo_accuracy,
|
9
|
+
:neighborhoods, :postal_code, :state_code
|
10
|
+
|
11
|
+
def initialize(json)
|
12
|
+
super(json)
|
13
|
+
|
14
|
+
@coordinate = parse(@coordinate, Coordinate)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'yelp/responses/base'
|
2
|
+
require 'yelp/responses/models/region_center'
|
3
|
+
require 'yelp/responses/models/region_span'
|
4
|
+
|
5
|
+
module Yelp
|
6
|
+
module Response
|
7
|
+
module Model
|
8
|
+
class Region < Response::Base
|
9
|
+
attr_reader :center, :span
|
10
|
+
|
11
|
+
def initialize(json)
|
12
|
+
super(json)
|
13
|
+
|
14
|
+
@center = parse(@center, RegionCenter)
|
15
|
+
@span = parse(@span, RegionSpan)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'yelp/responses/base'
|
2
|
+
require 'yelp/responses/models/business'
|
3
|
+
require 'yelp/responses/models/region'
|
4
|
+
|
5
|
+
module Yelp
|
6
|
+
module Response
|
7
|
+
class PhoneSearch < Base
|
8
|
+
attr_reader :businesses, :region, :total
|
9
|
+
|
10
|
+
def initialize(json)
|
11
|
+
super(json)
|
12
|
+
|
13
|
+
@businesses = parse(@businesses, Model::Business)
|
14
|
+
@region = parse(@region, Model::Region)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'yelp/responses/base'
|
2
|
+
require 'yelp/responses/models/business'
|
3
|
+
require 'yelp/responses/models/region'
|
4
|
+
|
5
|
+
module Yelp
|
6
|
+
module Response
|
7
|
+
class Search < Base
|
8
|
+
attr_reader :businesses, :region, :total
|
9
|
+
|
10
|
+
def initialize(json)
|
11
|
+
super(json)
|
12
|
+
|
13
|
+
@businesses = parse(@businesses, Model::Business)
|
14
|
+
@region = parse(@region, Model::Region)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/yelp/version.rb
CHANGED
@@ -2,17 +2,17 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: get
|
5
|
-
uri:
|
5
|
+
uri: https://api.yelp.com/v2/business/yelp-san-francisco
|
6
6
|
body:
|
7
7
|
encoding: US-ASCII
|
8
8
|
string: ''
|
9
9
|
headers:
|
10
10
|
User-Agent:
|
11
|
-
- Faraday v0.
|
11
|
+
- Faraday v0.9.2
|
12
12
|
Authorization:
|
13
|
-
- OAuth oauth_consumer_key="<YELP_CONSUMER_KEY>", oauth_nonce="
|
14
|
-
oauth_signature="
|
15
|
-
oauth_timestamp="
|
13
|
+
- OAuth oauth_consumer_key="<YELP_CONSUMER_KEY>", oauth_nonce="bf04bd00e56b2a626a911991aac75201",
|
14
|
+
oauth_signature="a48uevnfXQaPvPlZMqCJHAxO3uI%3D", oauth_signature_method="HMAC-SHA1",
|
15
|
+
oauth_timestamp="1445634930", oauth_token="<YELP_TOKEN>", oauth_version="1.0"
|
16
16
|
Accept-Encoding:
|
17
17
|
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
18
18
|
Accept:
|
@@ -22,52 +22,63 @@ http_interactions:
|
|
22
22
|
code: 200
|
23
23
|
message: OK
|
24
24
|
headers:
|
25
|
-
Date:
|
26
|
-
- Mon, 28 Apr 2014 16:16:40 GMT
|
27
25
|
Server:
|
28
|
-
-
|
26
|
+
- nginx
|
27
|
+
Date:
|
28
|
+
- Fri, 23 Oct 2015 21:15:31 GMT
|
29
|
+
Content-Type:
|
30
|
+
- application/json; charset=UTF-8
|
31
|
+
Transfer-Encoding:
|
32
|
+
- chunked
|
33
|
+
Connection:
|
34
|
+
- keep-alive
|
29
35
|
X-Node:
|
30
|
-
-
|
36
|
+
- 10-64-75-62-uswest1aprod
|
37
|
+
- api_com
|
31
38
|
Cache-Control:
|
32
|
-
- private
|
39
|
+
- max-age=0, must-revalidate, no-cache, no-store, private
|
40
|
+
Expires:
|
41
|
+
- Fri, 23 Oct 2015 21:15:30 GMT
|
42
|
+
Pragma:
|
43
|
+
- no-cache
|
33
44
|
Set-Cookie:
|
34
|
-
- bse=
|
35
|
-
|
36
|
-
|
45
|
+
- bse=a4d16c41d4edd2d4d07d7e74cbc80651; Domain=.yelp.com; Path=/; HttpOnly
|
46
|
+
- yuv=vsukueZSeZE-fIOZGHia4PxFRYNgLhbppBfZiB3gOVcA61zINwm64_hWk6xt5mC6d99F16jmQKaI3F5AbI6Bs9sWyHQF2h31;
|
47
|
+
Domain=.yelp.com; Max-Age=630720000; Path=/; expires=Thu, 18-Oct-2035 21:15:30
|
48
|
+
GMT
|
37
49
|
Vary:
|
38
|
-
- User-Agent
|
39
|
-
Content-Type:
|
40
|
-
- application/json; charset=UTF-8
|
50
|
+
- Accept-Encoding,User-Agent
|
41
51
|
X-Mode:
|
42
|
-
-
|
52
|
+
- ro
|
43
53
|
X-Proxied:
|
44
|
-
-
|
54
|
+
- 10-64-0-167-uswest1aprod
|
45
55
|
body:
|
46
56
|
encoding: UTF-8
|
47
57
|
string: '{"is_claimed": true, "rating": 2.5, "mobile_url": "http://m.yelp.com/biz/yelp-san-francisco",
|
48
|
-
"rating_img_url": "http://s3-media4.
|
49
|
-
"review_count":
|
50
|
-
"
|
51
|
-
"
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
"rating_image_small_url": "http://s3-media1.
|
56
|
-
"user": {"image_url": "http://s3-
|
57
|
-
"id": "
|
58
|
-
"http://s3-media3.
|
59
|
-
"id": "
|
60
|
-
|
61
|
-
|
62
|
-
"image_url": "http://s3-media3.
|
63
|
-
"
|
64
|
-
"display_phone": "+1-415-908-3801", "rating_img_url_large": "http://s3-media2.
|
58
|
+
"rating_img_url": "http://s3-media4.fl.yelpcdn.com/assets/2/www/img/c7fb9aff59f9/ico/stars/v1/stars_2_half.png",
|
59
|
+
"review_count": 7534, "name": "Yelp", "rating_img_url_small": "http://s3-media4.fl.yelpcdn.com/assets/2/www/img/8e8633e5f8f0/ico/stars/v1/stars_small_2_half.png",
|
60
|
+
"url": "http://www.yelp.com/biz/yelp-san-francisco", "categories": [["Local
|
61
|
+
Flavor", "localflavor"], ["Mass Media", "massmedia"]], "reviews": [{"rating":
|
62
|
+
5, "excerpt": "My 200th review! For this milestone I have decided to review
|
63
|
+
Yelp. I wrote my first Yelp review back in 2013, I never thought that one
|
64
|
+
review would turn...", "time_created": 1445434241, "rating_image_url": "http://s3-media1.fl.yelpcdn.com/assets/2/www/img/f1def11e4e79/ico/stars/v1/stars_5.png",
|
65
|
+
"rating_image_small_url": "http://s3-media1.fl.yelpcdn.com/assets/2/www/img/c7623205d5cd/ico/stars/v1/stars_small_5.png",
|
66
|
+
"user": {"image_url": "http://s3-media1.fl.yelpcdn.com/photo/RCmPU2uqGkm0A_NEcRJm0g/ms.jpg",
|
67
|
+
"id": "E8RgeQeEF3xD6CcopTNjhA", "name": "Britt Z."}, "rating_image_large_url":
|
68
|
+
"http://s3-media3.fl.yelpcdn.com/assets/2/www/img/22affc4e6c38/ico/stars/v1/stars_large_5.png",
|
69
|
+
"id": "AIL0eKK3vFNsR_n9BaJI5Q"}], "phone": "4159083801", "snippet_text": "My
|
70
|
+
200th review! For this milestone I have decided to review Yelp. I wrote my
|
71
|
+
first Yelp review back in 2013, I never thought that one review would turn...",
|
72
|
+
"image_url": "http://s3-media3.fl.yelpcdn.com/bphoto/nQK-6_vZMt5n88zsAS94ew/ms.jpg",
|
73
|
+
"snippet_image_url": "http://s3-media1.fl.yelpcdn.com/photo/RCmPU2uqGkm0A_NEcRJm0g/ms.jpg",
|
74
|
+
"display_phone": "+1-415-908-3801", "rating_img_url_large": "http://s3-media2.fl.yelpcdn.com/assets/2/www/img/d63e3add9901/ico/stars/v1/stars_large_2_half.png",
|
65
75
|
"id": "yelp-san-francisco", "is_closed": false, "location": {"cross_streets":
|
66
76
|
"Natoma St \u0026 Minna St", "city": "San Francisco", "display_address": ["140
|
67
|
-
New Montgomery St", "
|
68
|
-
|
69
|
-
"
|
70
|
-
|
77
|
+
New Montgomery St", "Financial District", "San Francisco, CA 94105"], "geo_accuracy":
|
78
|
+
9.5, "neighborhoods": ["Financial District", "SoMa"], "postal_code": "94105",
|
79
|
+
"country_code": "US", "address": ["140 New Montgomery St"], "coordinate":
|
80
|
+
{"latitude": 37.7867703362929, "longitude": -122.399958372115}, "state_code":
|
81
|
+
"CA"}}'
|
71
82
|
http_version:
|
72
|
-
recorded_at:
|
73
|
-
recorded_with: VCR 2.
|
83
|
+
recorded_at: Fri, 23 Oct 2015 21:15:31 GMT
|
84
|
+
recorded_with: VCR 2.9.3
|