yelpster 1.2.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.rdoc +4 -1
- data/README.md +42 -6
- data/lib/yelpster/client.rb +0 -1
- data/lib/yelpster/v1/request.rb +2 -10
- data/lib/yelpster/v2/request.rb +2 -9
- data/lib/yelpster/version.rb +1 -1
- data/spec/business_search_spec.rb +8 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a75f537e21edaea19815d27e1916e6aa89997a4
|
4
|
+
data.tar.gz: 1f246a02f2a564b0e24748e70ea1f0ee1bb0493d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 09acfa27d785f39dc9cf7557e4e10e133d8497c77f891024e72ed63951182b5a1b232085aeb53de08ddfeed9d32699e77bc7e92732b7fe6a00acf9551c359132
|
7
|
+
data.tar.gz: d7db033f5ddfa508a3b5f959c675f1e004a36b6bb6282ef452f8f5df3581b299e55ac8b42a4a782a63ddbfdfed6b55e3f072ebf7d51b387de7b776f6f7df9c98
|
data/CHANGELOG.rdoc
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
-
|
1
|
+
=== YELPSTER_20141010_1_3_0
|
2
|
+
* [naveed] Deprecate and remove compress_response param from requests (Yelp has stopped compressing v1 responses)
|
3
|
+
|
4
|
+
= YELPSTER_20141010_1_2_1
|
2
5
|
* [Leslie Viljoen] Add cc (country_code) parameter to v1 phone search
|
3
6
|
|
4
7
|
* [naveed] Check encoding before uncompressing v1 responses
|
data/README.md
CHANGED
@@ -29,22 +29,28 @@ retrieved via their API, documented at http://www.yelp.com/developers/getting_st
|
|
29
29
|
For tests to execute successfully you must have the YWSID (for v1) or YELP_CONSUMER_KEY, YELP_CONSUMER_SECRET, YELP_TOKEN and YELP_TOKEN_SECRET(for v2) set in your environment via (shell-dependent, bash example provided):
|
30
30
|
|
31
31
|
```console
|
32
|
-
|
32
|
+
export YWSID='YOUR_ID_HERE'
|
33
33
|
```
|
34
34
|
|
35
35
|
or
|
36
36
|
|
37
37
|
```console
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
38
|
+
export YELP_CONSUMER_KEY='YOUR_CONSUMER_KEY_HERE'
|
39
|
+
export YELP_CONSUMER_SECRET='YOUR_CONSUMER_SECRET_HERE'
|
40
|
+
export YELP_TOKEN='YOUR_TOKEN_HERE'
|
41
|
+
export YELP_TOKEN_SECRET='YOUR_TOKEN_SECRET_HERE'
|
42
42
|
```
|
43
43
|
|
44
44
|
## Installing
|
45
45
|
|
46
46
|
```console
|
47
|
-
|
47
|
+
gem install yelpster
|
48
|
+
```
|
49
|
+
|
50
|
+
and in your gemfile:
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
gem 'yelpster'
|
48
54
|
```
|
49
55
|
|
50
56
|
## Usage
|
@@ -78,6 +84,8 @@ types.
|
|
78
84
|
To configure token/keys, add the following in a pre-loader file (eg: in initializers dir for Rails).
|
79
85
|
Although currently available, support for specifying keys in request object will be deprecated in the future.
|
80
86
|
|
87
|
+
For example, you might have a 'yelp.rb' file in your 'config/initializers' directory that looks like the following:
|
88
|
+
|
81
89
|
```ruby
|
82
90
|
Yelp.configure(:yws_id => 'YOUR_YWSID',
|
83
91
|
:consumer_key => 'YOUR_CONSUMER_KEY',
|
@@ -166,6 +174,34 @@ A few examples:
|
|
166
174
|
response = client.search(request)
|
167
175
|
```
|
168
176
|
|
177
|
+
Here is another example, let's say I wanted to make a call to the API in a controller action:
|
178
|
+
|
179
|
+
```ruby
|
180
|
+
class FoodsController < ApplicationController
|
181
|
+
include Yelp::V2::Search::Request
|
182
|
+
|
183
|
+
def search
|
184
|
+
client = Yelp::Client.new
|
185
|
+
|
186
|
+
request = GeoPoint.new(
|
187
|
+
:term => 'thai',
|
188
|
+
:category_filter => 'food,restaurants',
|
189
|
+
:limit => 20,
|
190
|
+
:radius_filter => 8047,
|
191
|
+
:latitude => params[:latitude],
|
192
|
+
:longitude => params[:longitude])
|
193
|
+
response = client.search(request)
|
194
|
+
|
195
|
+
# rest of your code
|
196
|
+
end
|
197
|
+
end
|
198
|
+
```
|
199
|
+
|
200
|
+
You can check out all the parameters you can pass in the Yelp API Documentation.
|
201
|
+
|
202
|
+
For V1 - http://www.yelp.com/developers/documentation/search_api.
|
203
|
+
For V2 - http://www.yelp.com/developers/documentation/v2/search_api
|
204
|
+
|
169
205
|
If you want to convert some addresses to latitude/longitude, or vice
|
170
206
|
versa, for testing or what have you -- try http://stevemorse.org/jcal/latlon.php.
|
171
207
|
|
data/lib/yelpster/client.rb
CHANGED
@@ -68,7 +68,6 @@ module Yelp
|
|
68
68
|
# submit the http request for the results
|
69
69
|
# http_request_params not used in v2 as OAuth (implemented in v2) only takes response params
|
70
70
|
http_params = { 'User-Agent' => @agent }
|
71
|
-
http_params['Accept-Encoding'] = 'gzip,deflate' if request.compress_response?
|
72
71
|
http_params[:proxy] = nil
|
73
72
|
content = request.pull_results(url, http_params)
|
74
73
|
|
data/lib/yelpster/v1/request.rb
CHANGED
@@ -5,10 +5,6 @@ require 'zlib'
|
|
5
5
|
module Yelp
|
6
6
|
module V1
|
7
7
|
class Request < Yelp::Record
|
8
|
-
# specifies whether the response content should be transmitted
|
9
|
-
# over the wire compressed, defaulting to true.
|
10
|
-
attr_reader :compress_response
|
11
|
-
|
12
8
|
# one of the Yelp::ResponseFormat format specifiers detailing the
|
13
9
|
# desired format of the search results, defaulting to
|
14
10
|
# Yelp::ResponseFormat::JSON_TO_RUBY.
|
@@ -19,11 +15,8 @@ module Yelp
|
|
19
15
|
# to get your own.
|
20
16
|
attr_reader :yws_id
|
21
17
|
|
22
|
-
alias :compress_response? :compress_response
|
23
|
-
|
24
18
|
def initialize (params)
|
25
19
|
default_params = {
|
26
|
-
:compress_response => true,
|
27
20
|
:response_format => Yelp::ResponseFormat::JSON_TO_RUBY
|
28
21
|
}
|
29
22
|
super(default_params.merge(params))
|
@@ -46,9 +39,8 @@ module Yelp
|
|
46
39
|
params
|
47
40
|
end
|
48
41
|
|
49
|
-
def pull_results
|
50
|
-
|
51
|
-
response.content_encoding.include?('gzip') ? Zlib::GzipReader.new(response).read : response.read
|
42
|
+
def pull_results(url, http_params)
|
43
|
+
open(url, http_params).read
|
52
44
|
end
|
53
45
|
end
|
54
46
|
end
|
data/lib/yelpster/v2/request.rb
CHANGED
@@ -4,10 +4,6 @@ require 'oauth'
|
|
4
4
|
module Yelp
|
5
5
|
module V2
|
6
6
|
class Request < Yelp::Record
|
7
|
-
# specifies whether the response content should be transmitted
|
8
|
-
# over the wire compressed, defaulting to true.
|
9
|
-
attr_reader :compress_response
|
10
|
-
|
11
7
|
# one of the Yelp::ResponseFormat format specifiers detailing the
|
12
8
|
# desired format of the search results, defaulting to
|
13
9
|
# Yelp::ResponseFormat::JSON_TO_RUBY.
|
@@ -21,11 +17,8 @@ module Yelp
|
|
21
17
|
attr_reader :token
|
22
18
|
attr_reader :token_secret
|
23
19
|
|
24
|
-
|
25
|
-
|
26
|
-
def initialize (params)
|
20
|
+
def initialize(params)
|
27
21
|
default_params = {
|
28
|
-
:compress_response => true,
|
29
22
|
:response_format => Yelp::ResponseFormat::JSON_TO_RUBY
|
30
23
|
}
|
31
24
|
super(default_params.merge(params))
|
@@ -46,7 +39,7 @@ module Yelp
|
|
46
39
|
params
|
47
40
|
end
|
48
41
|
|
49
|
-
def pull_results
|
42
|
+
def pull_results(url, _)
|
50
43
|
consumer = OAuth::Consumer.new(consumer_key, consumer_secret, {:site => "http://api.yelp.com"})
|
51
44
|
access_token = OAuth::AccessToken.new(consumer, token, token_secret)
|
52
45
|
access_token.get(url).body
|
data/lib/yelpster/version.rb
CHANGED
@@ -10,15 +10,15 @@ module Yelp::V2::Search::Request
|
|
10
10
|
let(:latitude) { 37.7821868 }
|
11
11
|
let(:longitude) { -122.4841149 }
|
12
12
|
let(:location) { {
|
13
|
-
"cross_streets"=>"21st Ave & 22nd Ave",
|
14
|
-
"city"=>"San Francisco",
|
13
|
+
"cross_streets"=>"21st Ave & 22nd Ave",
|
14
|
+
"city"=>"San Francisco",
|
15
15
|
"coordinate" => {"latitude"=>37.78221, "longitude"=>-122.480624},
|
16
|
-
"display_address"=>["2001 Clement St", "(b/t 21st Ave & 22nd Ave)", "Outer Richmond", "San Francisco, CA 94121"],
|
17
16
|
"geo_accuracy" => 9,
|
18
|
-
"
|
19
|
-
"
|
20
|
-
"
|
21
|
-
"
|
17
|
+
"display_address" => ["2001 Clement St", "Outer Richmond", "San Francisco, CA 94121"],
|
18
|
+
"neighborhoods"=>["Outer Richmond"],
|
19
|
+
"postal_code"=>"94121",
|
20
|
+
"country_code"=>"US",
|
21
|
+
"address"=>["2001 Clement St"],
|
22
22
|
"state_code"=>"CA"
|
23
23
|
} }
|
24
24
|
|
@@ -40,7 +40,7 @@ module Yelp::V2::Search::Request
|
|
40
40
|
:longitude => longitude)
|
41
41
|
response = client.search(request)
|
42
42
|
expect(response).to be_valid_response_hash
|
43
|
-
expect(response['businesses'].first['location']).to
|
43
|
+
expect(response['businesses'].first['location']).to include(location)
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yelpster
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naveed Siddiqui
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|