yelpster 1.1.1

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.
data/README.rdoc ADDED
@@ -0,0 +1,199 @@
1
+ This is an expansion of the yelp api ruby gem written by Walter Korman. The gem has been extended to support version 2 of the yelp api. V2 supports business details retrieval via yelp id as well as searches for businesses using geo-point, bounding box or address/location. It also uses OAuth for authorization of requests.
2
+
3
+ NOTE: Use of this code will break legacy code. You need to update all existing references to Yelp::Request::.. with Yelp::V1::Request::... Check out sample usage section for more information.
4
+
5
+ The source for the original gem can be found here: http://github.com/shaper/yelp
6
+ Following is the updated extract of the readme file.
7
+
8
+ --------------------------------------------------------------------------------
9
+
10
+ == yelp
11
+
12
+ A Ruby object-oriented interface to the local business content available
13
+ on Yelp at http://www.yelp.com. Functionality is provided to perform
14
+ all searches available via the developer API including:
15
+
16
+ * search for business reviews by geo-bounding-box, geo-point, or address/location.
17
+ * search for a business review by business phone number.
18
+ * search for a neighborhood by geo-point or address/location.
19
+ * search for business details by geo-bounding-box, geo-point, or address/location.
20
+ * retrieval of business details by specifying yelp id of business
21
+
22
+ More detailed information on the underlying Yelp API, error response codes, and so forth is available at http://www.yelp.com/developers/getting_started.
23
+
24
+ The RubyForge project is hosted at http://rubyforge.org/projects/yelpster. This documentation is available at http://yelpster.rubyforge.org.
25
+
26
+ The latest source code is at http://github.com/nvd/yelpster.
27
+
28
+ == About
29
+
30
+ Everybody loves Yelp! For those seeking burritos in the Mission District of
31
+ San Francisco, it's easy to feel awash in a sea of taquerias with little to go
32
+ on for decision-making other than whether the rice has peas in it (generally a
33
+ negatory data point) or how long the line happens to be around lunchtime.
34
+
35
+ Worry no longer! Yelp is here.
36
+
37
+ Why should you use this library rather than writing directly to their API, or rolling your own? A few reasons that come to mind:
38
+
39
+ * we've done a variety of mini-legwork from which you, Yelp and our fellow netizens will benefit, such as making sure we inform the Yelp server that we support gzipped data over the wire to save on bandwidth.
40
+ * we have rudimentary tests, whereas your implementation doesn't (since you haven't even written it yet).
41
+ * we return responses (by default, configurable) as JSON data converted into a Ruby hash and appropriate data types where applicable.
42
+ * (subjective but we know we're right) -- we think our API is a nicer layer for Ruby developers to work with than the bare-bones REST API that Yelp provides.
43
+
44
+ == Requirements
45
+
46
+ You must have a Yelp Web Service ID (YWSID) if you're using v1 of the api or Consumer Key, Consumer Secret, Token and a Token Secret for version 2. These are available at http://www.yelp.com/developers/getting_started/api_access.
47
+
48
+ You must conform to the Yelp Branding Requirements when making use of content
49
+ retrieved via their API, documented at http://www.yelp.com/developers/getting_started/api_branding.
50
+
51
+ For tests to execute successfully you must have the YWSID (for v1) or CONSUMER_KEY, CONSUMER_SECRET, TOKEN and TOKEN_SECRET(for v2) set in your environment via (shell-dependent, bash example provided):
52
+
53
+ % export YWSID='YOUR_ID_HERE'
54
+
55
+ or
56
+
57
+ % export CONSUMER_KEY='YOUR_CONSUMER_KEY_HERE'
58
+ % export CONSUMER_SECRET='YOUR_CONSUMER_SECRET_HERE'
59
+ % export TOKEN='YOUR_TOKEN_HERE'
60
+ % export TOKEN_SECRET='YOUR_TOKEN_SECRET_HERE'
61
+
62
+ == Installing
63
+
64
+ NOTE: At the moment, this source (and support for yelp api v2) has not been incorporated into the original gem. You can install the original gem following the instructions below
65
+
66
+ Install +rubygems+ if you don't already have it. See http://rubyforge.org/projects/rubygems/.
67
+
68
+ Then install the +yelp+ gem by executing:
69
+
70
+ % gem install yelp
71
+
72
+ == Usage
73
+
74
+ Instantiate a Yelp::Client and use its +search+ method to make requests of
75
+ the Yelp server.
76
+
77
+ The available search request types are:
78
+
79
+ * Yelp::V1::Review::Request::BoundingBox
80
+ * Yelp::V1::Review::Request::GeoPoint
81
+ * Yelp::V1::Review::Request::Location
82
+ * Yelp::V1::Phone::Request::Number
83
+ * Yelp::V1::Neighborhood::Request::GeoPoint
84
+ * Yelp::V1::Neighborhood::Request::Location
85
+ * Yelp::V2::Business::Request::Id
86
+ * Yelp::V2::Search::Request::BoundingBox
87
+ * Yelp::V2::Search::Request::GeoPoint
88
+ * Yelp::V2::Search::Request::Location
89
+
90
+ By default, response content is formatted as a Ruby hash converted from Yelp's
91
+ source JSON response content. Alternate response formats (including the
92
+ original pure JSON) can be specified on request record construction via the
93
+ Yelp::[V1/V2]::Request +response_format+ parameter, available in all request record
94
+ types.
95
+
96
+ A few examples:
97
+
98
+ # construct a client instance
99
+ client = Yelp::Client.new
100
+
101
+ # perform an address/location-based search for cream puffs nearby
102
+ request = Yelp::V1::Review::Request::Location.new(
103
+ :address => '650 Mission St',
104
+ :city => 'San Francisco',
105
+ :state => 'CA',
106
+ :radius => 2,
107
+ :term => 'cream puffs',
108
+ :yws_id => 'YOUR_YWSID_HERE')
109
+ response = client.search(request)
110
+
111
+ # perform a location-based category search for either ice cream or donut shops in SF
112
+ request = Yelp::V1::Review::Request::Location.new(
113
+ :city => 'San Francisco',
114
+ :state => 'CA',
115
+ :category => [ 'donuts', 'icecream' ],
116
+ :yws_id => 'YOUR_YWSID_HERE')
117
+ response = client.search(request)
118
+
119
+ # perform a neighborhood name lookup for a specific geo-location point
120
+ request = Yelp::V1::Neighborhood::Request::GeoPoint.new(
121
+ :latitude => 37.782093,
122
+ :longitude => -122.483230,
123
+ :yws_id => 'YOUR_YWSID_HERE')
124
+ response = client.search(request)
125
+
126
+ # perform a business review search based on a business phone number
127
+ request = Yelp::V1::Phone::Request::Number.new(
128
+ :phone_number => '4155551212',
129
+ :yws_id => 'YOUR_YWSID_HERE')
130
+ response = client.search(request)
131
+
132
+ # retrieve details of business vi yelp business id
133
+ request = Yelp::V2::Business::Request::Id.new(
134
+ :yelp_business_id => "pjb2WMwa0AfK3L-dWimO8w",
135
+ :consumer_key => ‘YOUR_CONSUMER_KEY’,
136
+ :consumer_secret => ‘YOUR_CONSUMER_SECRET’,
137
+ :token => ‘YOUR_TOKEN’,
138
+ :token_secret => ‘YOUR_TOKEN_SECRET’)
139
+ response = client.search(request)
140
+
141
+ # search for businesses via bounding box geo coords'
142
+ request = Yelp::V2::Search::Request::BoundingBox.new(
143
+ :term => "cream puffs",
144
+ :sw_latitude => 37.900000,
145
+ :sw_longitude => -122.500000,
146
+ :ne_latitude => 37.788022,
147
+ :ne_longitude => -122.399797,
148
+ :limit => 3,
149
+ :consumer_key => ‘YOUR_CONSUMER_KEY’,
150
+ :consumer_secret => ‘YOUR_CONSUMER_SECRET’,
151
+ :token => ‘YOUR_TOKEN’,
152
+ :token_secret => ‘YOUR_TOKEN_SECRET’)
153
+ response = client.search(request)
154
+
155
+ # search for businesses via lat/long geo point'
156
+ request = Yelp::V2::Search::Request::GeoPoint.new(
157
+ :term => "cream puffs",
158
+ :latitude => 37.788022,
159
+ :longitude => -122.399797,
160
+ :consumer_key => ‘YOUR_CONSUMER_KEY’,
161
+ :consumer_secret => ‘YOUR_CONSUMER_SECRET’,
162
+ :token => ‘YOUR_TOKEN’,
163
+ :token_secret => ‘YOUR_TOKEN_SECRET’)
164
+ response = client.search(request)
165
+
166
+ # search for businesses via location (address, neighbourhood, city, state, zip, country, latitude, longitude)'
167
+ request = Yelp::V2::Search::Request::Location.new(
168
+ :term => "cream puffs",
169
+ :city => "San Francisco",
170
+ :consumer_key => ‘YOUR_CONSUMER_KEY’,
171
+ :consumer_secret => ‘YOUR_CONSUMER_SECRET’,
172
+ :token => ‘YOUR_TOKEN’,
173
+ :token_secret => ‘YOUR_TOKEN_SECRET’)
174
+ response = client.search(request)
175
+
176
+ request = Yelp::V2::Search::Request::Location.new(
177
+ :term => "german food",
178
+ :address => "Hayes",
179
+ :latitude => 37.77493,
180
+ :longitude => -122.419415,
181
+ :consumer_key => ‘YOUR_CONSUMER_KEY’,
182
+ :consumer_secret => ‘YOUR_CONSUMER_SECRET’,
183
+ :token => ‘YOUR_TOKEN’,
184
+ :token_secret => ‘YOUR_TOKEN_SECRET’)
185
+ response = client.search(request)
186
+
187
+ If you want to convert some addresses to latitude/longitude, or vice
188
+ versa, for testing or what have you -- try http://stevemorse.org/jcal/latlon.php.
189
+
190
+ == License
191
+
192
+ This library is provided via the GNU LGPL license at http://www.gnu.org/licenses/lgpl.html.
193
+
194
+ == Authors
195
+
196
+ Copyright 2007 - 2009, Walter Korman <shaper@fatgoose.com>, http://lemurware.blogspot.com
197
+
198
+ 2011 – Yelp V2 Additions by Naveed Siddiqui <naveed@10eighteen.com>
199
+
data/Rakefile ADDED
@@ -0,0 +1,19 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'echoe'
4
+ $:.unshift(File.dirname(__FILE__) + "/lib")
5
+ require 'yelpster'
6
+
7
+ Echoe.new('yelpster', Yelp::VERSION) do |p|
8
+ p.author = 'Naveed Siddiqui'
9
+ p.email = 'naveed@10eighteen.com'
10
+ p.url = 'https://github.com/nvd/yelpster'
11
+ p.summary = 'An object-oriented interface to the Yelp Developer API.'
12
+ p.description = <<EDOC
13
+ Extension of Korman's Ruby wrapper to interface with Yelp's REST API described in detail at:
14
+
15
+ http://www.yelp.com/developers/getting_started
16
+ EDOC
17
+ p.ignore_pattern = ["tmp/*", "script/*"]
18
+ p.runtime_dependencies = [ 'json >=1.1.1', 'oauth >=0.4.5' ]
19
+ end
data/TODO.txt ADDED
@@ -0,0 +1,6 @@
1
+ * look into rails partials inability to properly enumerate the response
2
+ business records with the :collection param.
3
+ * think about how to gracefully report errors
4
+ * should we use "require 'json/add/rails'" for json for rails happiness?
5
+ * use SAX-based XML parsing rather than DOM
6
+ * consider supporting keep-alive for high volume requests
@@ -0,0 +1,105 @@
1
+ require 'cgi'
2
+ require 'logger'
3
+ require 'rubygems'
4
+ require 'json'
5
+ require 'yaml'
6
+
7
+ class Yelp
8
+ # Provides access to the Yelp search facilities as documented at:
9
+ #
10
+ # http://www.yelp.com/developers/documentation
11
+ #
12
+ # Example usage:
13
+ #
14
+ # client = Yelp::Client.new
15
+ # request = Yelp::V1::Review::Request::Location.new(
16
+ # :address => '650 Mission St',
17
+ # :city => 'San Francisco',
18
+ # :state => 'CA',
19
+ # :radius => 2,
20
+ # :term => 'cream puffs',
21
+ # :yws_id => 'YOUR_YWSID_HERE')
22
+ # response = client.search(request)
23
+ #
24
+ # By default, response content is formatted as a Ruby hash converted from
25
+ # Yelp's source JSON response content. Alternate response formats can be
26
+ # specified on request record construction via the Yelp::Request
27
+ # +response_format+ parameter, available in all request record types.
28
+ #
29
+ class Client
30
+ # allows specifying the user agent string to submit with search requests
31
+ attr_accessor :agent
32
+
33
+ # whether debug mode is enabled for logging purposes, defaulting to false
34
+ attr_accessor :debug
35
+
36
+ # the Logger compatible object with which log messages are outputted,
37
+ # defaulting to output to STDOUT
38
+ attr_accessor :logger
39
+
40
+ # the default user agent submitted with search requests
41
+ DEFAULT_AGENT = 'yelp for Ruby (http://www.rubyforge.org/projects/yelp/)'
42
+
43
+ # Constructs a new client that uses the supplied YWSID for submitting
44
+ # search requests.
45
+ #
46
+ def initialize
47
+ @agent = DEFAULT_AGENT
48
+ @debug = false
49
+ @logger = nil
50
+ end
51
+
52
+ # Submits the supplied search request to Yelp and returns the response in
53
+ # the format specified by the request.
54
+ #
55
+ def search (request)
56
+ # build the full set of hash params with which the url is constructed
57
+ params = request.to_yelp_params
58
+
59
+ # construct the url with which we obtain results
60
+ url = build_url(request.base_url, params)
61
+ debug_msg "submitting search [url=#{url}, request=#{request.to_yaml}]."
62
+
63
+ # submit the http request for the results
64
+ # http_request_params not used in v2 as OAuth (implemented in v2) only takes response params
65
+ http_params = { 'User-Agent' => @agent }
66
+ http_params['Accept-Encoding'] = 'gzip,deflate' if request.compress_response?
67
+ content = request.pull_results(url, http_params)
68
+
69
+ # read the response content
70
+ debug_msg((request.response_format.serialized?) ? "received response [content_length=#{content.length}]." : "received response [content_length=#{content.length}, content=#{content}].")
71
+
72
+ # format the output as specified in the request
73
+ format_content(request.response_format, content)
74
+ end
75
+
76
+ protected
77
+
78
+ def format_content (response_format, content)
79
+ (response_format == Yelp::ResponseFormat::JSON_TO_RUBY) ? JSON.parse(content) : content
80
+ end
81
+
82
+ def debug_msg (message)
83
+ return if !@debug
84
+ @logger = Logger.new(STDOUT) if (!@logger)
85
+ @logger.debug message
86
+ end
87
+
88
+ def build_url (base_url, params)
89
+ url = base_url.clone
90
+ unless params.nil?
91
+ url << '?'
92
+ param_count = 0
93
+ params.each do |key, value|
94
+ next if value.nil?
95
+ url << '&' if (param_count > 0)
96
+ key_str = (params[key].kind_of?(Array)) ?
97
+ params[key].map { |k| CGI.escape(k.to_s) }.join("+") : CGI.escape(params[key].to_s)
98
+ url << "#{CGI.escape(key.to_s)}=#{key_str}"
99
+ param_count += 1
100
+ end
101
+ end
102
+ url
103
+ end
104
+ end
105
+ end
@@ -0,0 +1,16 @@
1
+ class Yelp
2
+ # General-purpose record that allows passing a hash with parameters
3
+ # to populate object attributes defined via methods like
4
+ # +attr_reader+ or +attr_accessor+.
5
+ #
6
+ class Record
7
+ def initialize (params)
8
+ if !params.nil?
9
+ params.each do |key, value|
10
+ name = key.to_s
11
+ instance_variable_set("@#{name}", value) if respond_to?(name)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,36 @@
1
+ require 'yelpster/record'
2
+
3
+ class Yelp
4
+ # Describes the available response formats when querying the Yelp web
5
+ # service for results.
6
+ #
7
+ class ResponseFormat < Record
8
+ # the name of the response format
9
+ attr_reader :name
10
+
11
+ # whether this response format returns serialized data (and, so, data that
12
+ # we probably don't want to print to a log file and suchlike)
13
+ attr_reader :serialized
14
+
15
+ # the format specifier to retrieve results as straight JSON content
16
+ JSON = Yelp::ResponseFormat.new(:name => 'json')
17
+
18
+ # the format specifier to retrieve results as Ruby objects converted
19
+ # from the returned JSON content via the +json+ rubygem.
20
+ JSON_TO_RUBY = Yelp::ResponseFormat.new(:name => 'json_to_ruby')
21
+
22
+ # the format specifier to retrieve results as a serialized Python
23
+ # response. We're not quite sure why you'd want to use this if
24
+ # you're calling it from Ruby code, but we like to see completeness
25
+ # in an API.
26
+ PICKLE = Yelp::ResponseFormat.new(:name => 'pickle', :serialized => true)
27
+
28
+ # the format specifier to retrieve results as a serialized PHP
29
+ # response. We're not quite sure why you'd want to use this if
30
+ # you're calling it from Ruby code, but we like to see completeness
31
+ # in an API.
32
+ PHP = Yelp::ResponseFormat.new(:name => 'php', :serialized => true)
33
+
34
+ alias :serialized? :serialized
35
+ end
36
+ end
@@ -0,0 +1,15 @@
1
+ require 'yelpster/v1/request'
2
+
3
+ class Yelp
4
+ module V1
5
+ module Neighborhood
6
+ module Request
7
+ class Base < Yelp::V1::Request
8
+ def base_url
9
+ 'http://api.yelp.com/neighborhood_search'
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,25 @@
1
+ require 'yelpster/v1/neighborhood/request/base'
2
+
3
+ class Yelp
4
+ module V1
5
+ module Neighborhood
6
+ module Request
7
+ # Describes a request to search for the name of a neighborhood at a
8
+ # specific geo-point location.
9
+ #
10
+ class GeoPoint < Yelp::V1::Neighborhood::Request::Base
11
+ # latitude of geo-point for which a neighborhood name is desired
12
+ attr_reader :latitude
13
+
14
+ # longitude of geo-point for which a neighborhood name is desired
15
+ attr_reader :longitude
16
+
17
+ def to_yelp_params
18
+ super.merge(:lat => latitude,
19
+ :long => longitude)
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,55 @@
1
+ require 'yelpster/v1/neighborhood/request/base'
2
+
3
+ class Yelp
4
+ module V1
5
+ module Neighborhood
6
+ module Request
7
+ # Describes a request to search for a neighborhood name for a specific
8
+ # address/location. You do not need to specify all of the address
9
+ # attributes -- some subset of the core +address+, +city+,
10
+ # +state+ and +zipcode+ will suffice.
11
+ #
12
+ class Location < Yelp::V1::Neighborhood::Request::Base
13
+ # the street address of the location sought
14
+ attr_reader :address
15
+
16
+ # the city of the location sought
17
+ attr_reader :city
18
+
19
+ # the state of the location sought
20
+ attr_reader :state
21
+
22
+ # the zipcode of the location sought
23
+ attr_reader :zipcode
24
+
25
+ def initialize (params)
26
+ # we explicitly initialize the location fields since we reference
27
+ # them later when building a full location string and we want
28
+ # to know they were initialized properly (and avoid warnings)
29
+ super({
30
+ :address => nil,
31
+ :city => nil,
32
+ :state => nil,
33
+ :zipcode => nil
34
+ }.merge(params))
35
+ end
36
+
37
+ def to_yelp_params
38
+ super.merge(:location => build_location_string)
39
+ end
40
+
41
+ protected
42
+
43
+ # Returns the Yelp-compatible concatenated string with the various
44
+ # possible bits of an address-oriented location.
45
+ #
46
+ def build_location_string
47
+ # per the Yelp documentation, the location string is to be built
48
+ # as some combination of "address, city, state, or zip".
49
+ [ @address, @city, @state, @zipcode ].compact.join(" ")
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,26 @@
1
+ require 'yelpster/v1/request'
2
+
3
+ class Yelp
4
+ module V1
5
+ module Phone
6
+ module Request
7
+ # Describes a request to search for a business review for the business
8
+ # associated with a specific phone number.
9
+ #
10
+ class Number < Yelp::V1::Request
11
+ # the phone number of the business to search for, formatted as
12
+ # '1112223333'. Make sure you don't have any hyphens or parentheses.
13
+ attr_reader :phone_number
14
+
15
+ def base_url
16
+ 'http://api.yelp.com/phone_search'
17
+ end
18
+
19
+ def to_yelp_params
20
+ super.merge(:phone => phone_number)
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,55 @@
1
+ require 'yelpster/record'
2
+ require 'open-uri'
3
+ require 'zlib'
4
+
5
+ class Yelp
6
+ module V1
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
+ # one of the Yelp::ResponseFormat format specifiers detailing the
13
+ # desired format of the search results, defaulting to
14
+ # Yelp::ResponseFormat::JSON_TO_RUBY.
15
+ attr_reader :response_format
16
+
17
+ # the Yelp Web Services ID to be passed with the request for
18
+ # authentication purposes. See http://www.yelp.com/developers/getting_started/api_access
19
+ # to get your own.
20
+ attr_reader :yws_id
21
+
22
+ alias :compress_response? :compress_response
23
+
24
+ def initialize (params)
25
+ default_params = {
26
+ :compress_response => true,
27
+ :response_format => Yelp::ResponseFormat::JSON_TO_RUBY
28
+ }
29
+ super(default_params.merge(params))
30
+ end
31
+
32
+ def to_yelp_params
33
+ params = {
34
+ :ywsid => yws_id
35
+ }
36
+
37
+ # if they specified anything other than a json variant, we
38
+ # need to tell yelp what we're looking for
39
+ case @response_format
40
+ when Yelp::ResponseFormat::PICKLE
41
+ params[:output] = 'pickle'
42
+ when Yelp::ResponseFormat::PHP
43
+ params[:output] = 'php'
44
+ end
45
+
46
+ params
47
+ end
48
+
49
+ def pull_results (url, http_params)
50
+ source = open(url, http_params)
51
+ content = (compress_response?) ? Zlib::GzipReader.new(source).read : source.read
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,33 @@
1
+ require 'yelpster/v1/request'
2
+
3
+ class Yelp
4
+ module V1
5
+ module Review
6
+ module Request
7
+ class Base < Yelp::V1::Request
8
+ # specifies the number of businesses to return in the result set.
9
+ # default is 10. minimum value is 1 and maximum value is 20.
10
+ attr_reader :business_count
11
+
12
+ # string representing the name of business or search term being
13
+ # requested.
14
+ attr_reader :term
15
+
16
+ # optionally narrow the results by one or more categories.
17
+ # may be a single string value, or an Array of multiple values.
18
+ attr_reader :category
19
+
20
+ def base_url
21
+ 'http://api.yelp.com/business_review_search'
22
+ end
23
+
24
+ def to_yelp_params
25
+ super.merge(:term => term,
26
+ :num_biz_requested => business_count,
27
+ :category => category)
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,39 @@
1
+ require 'yelpster/v1/review/request/base'
2
+
3
+ class Yelp
4
+ module V1
5
+ module Review
6
+ module Request
7
+ # Describes a request to search for business reviews for businesses
8
+ # within a geo-point-specific bounding box and radius around
9
+ # that box.
10
+ #
11
+ class BoundingBox < Yelp::V1::Review::Request::Base
12
+ # bottom right latitude of bounding box
13
+ attr_reader :bottom_right_latitude
14
+
15
+ # bottom right longitude of bounding box
16
+ attr_reader :bottom_right_longitude
17
+
18
+ # radius to use while searching around specified geo-point.
19
+ # default value is 1, maximum value is 25.
20
+ attr_reader :radius
21
+
22
+ # top left latitude of bounding box
23
+ attr_reader :top_left_latitude
24
+
25
+ # top left longitude of bounding box
26
+ attr_reader :top_left_longitude
27
+
28
+ def to_yelp_params
29
+ super.merge(:tl_lat => top_left_latitude,
30
+ :tl_long => top_left_longitude,
31
+ :br_lat => bottom_right_latitude,
32
+ :br_long => bottom_right_longitude,
33
+ :radius => radius)
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,30 @@
1
+ require 'yelpster/v1/review/request/base'
2
+
3
+ class Yelp
4
+ module V1
5
+ module Review
6
+ module Request
7
+ # Describes a request to search for business reviews for businesses near
8
+ # a specific geo-point and radius around that point.
9
+ #
10
+ class GeoPoint < Yelp::V1::Review::Request::Base
11
+ # latitude of geo-point to search near
12
+ attr_reader :latitude
13
+
14
+ # longitude of geo-point to search near
15
+ attr_reader :longitude
16
+
17
+ # radius to use while searching around specified geo-point.
18
+ # default value is 1, maximum value is 25.
19
+ attr_reader :radius
20
+
21
+ def to_yelp_params
22
+ super.merge(:lat => latitude,
23
+ :long => longitude,
24
+ :radius => radius)
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end