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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ea5f96fd6a51f4571eb7f1db0f3aba2f9ec74097
4
- data.tar.gz: 1e8ae7365887cba09c1e5eebc66cdaefe672264c
3
+ metadata.gz: 8a75f537e21edaea19815d27e1916e6aa89997a4
4
+ data.tar.gz: 1f246a02f2a564b0e24748e70ea1f0ee1bb0493d
5
5
  SHA512:
6
- metadata.gz: 7f53b513568ba71f13f43eb17f012d3cd904dd6c3dd12e5d775fca756e2b181a517c4df2516142d8b5f05563d8eb875d0b928eb502b8b07f44c07321bcc58956
7
- data.tar.gz: 1102dd29d49374dce029cdff0d085ad76f6178569baba4ebaac123bf11112e6f06d7b0f63c58b6b6c19e402e2242fb84b1c55f4211d28663c2431c6adf5ad6ef
6
+ metadata.gz: 09acfa27d785f39dc9cf7557e4e10e133d8497c77f891024e72ed63951182b5a1b232085aeb53de08ddfeed9d32699e77bc7e92732b7fe6a00acf9551c359132
7
+ data.tar.gz: d7db033f5ddfa508a3b5f959c675f1e004a36b6bb6282ef452f8f5df3581b299e55ac8b42a4a782a63ddbfdfed6b55e3f072ebf7d51b387de7b776f6f7df9c98
@@ -1,4 +1,7 @@
1
- == YELPSTER_20141010_1_2_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
- % export YWSID='YOUR_ID_HERE'
32
+ export YWSID='YOUR_ID_HERE'
33
33
  ```
34
34
 
35
35
  or
36
36
 
37
37
  ```console
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'
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
- % gem install yelpster
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
 
@@ -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
 
@@ -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 (url, http_params)
50
- response = open(url, http_params)
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
@@ -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
- alias :compress_response? :compress_response
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 (url, http_params)
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
@@ -1,3 +1,3 @@
1
1
  module Yelp
2
- VERSION = '1.2.1'.freeze
2
+ VERSION = '1.3.0'.freeze
3
3
  end
@@ -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
- "neighborhoods"=>["Outer Richmond"],
19
- "postal_code"=>"94121",
20
- "country_code"=>"US",
21
- "address"=>["2001 Clement St"],
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 eq(location)
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.2.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-10 00:00:00.000000000 Z
11
+ date: 2014-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json