Class: GooglePlaces::Client
- Inherits:
-
Object
- Object
- GooglePlaces::Client
- Defined in:
- lib/google_places/client.rb
Overview
This class acts as a proxy to the working classes when requesting data from the API.
Instance Attribute Summary collapse
-
#api_key ⇒ String
readonly
The provided api key.
-
#options ⇒ Hash
readonly
The provided options hash.
Instance Method Summary collapse
-
#initialize(api_key = @api_key, options = {}) ⇒ Client
constructor
Creates a new Client instance which proxies the requests to the certain classes.
-
#predictions_by_input(input, options = {}) ⇒ Array<Prediction>
Query for Place Predictions.
-
#spot(place_id, options = {}) ⇒ Spot
Search for a Spot with a reference key.
-
#spots(lat, lng, options = {}) ⇒ Array<Spot>
Search for Spots at the provided location.
-
#spots_by_bounds(bounds, options = {}) ⇒ Array<Spot>
Search for Spots within a give SW|NE bounds with query.
-
#spots_by_pagetoken(pagetoken, options = {}) ⇒ Array<Spot>
Search for Spots with a pagetoken.
-
#spots_by_query(query, options = {}) ⇒ Array<Spot>
Search for Spots with a query.
-
#spots_by_radar(lat, lng, options = {}) ⇒ Array<Spot>
Radar Search Service allows you to search for up to 200 Places at once, but with less detail than is typically returned from a Text Search or Nearby Search request.
Constructor Details
#initialize(api_key = @api_key, options = {}) ⇒ Client
Creates a new Client instance which proxies the requests to the certain classes
44 45 46 47 |
# File 'lib/google_places/client.rb', line 44 def initialize(api_key = @api_key, = {}) api_key ? @api_key = api_key : @api_key = GooglePlaces.api_key @options = end |
Instance Attribute Details
#api_key ⇒ String (readonly)
Returns the provided api key.
5 6 7 |
# File 'lib/google_places/client.rb', line 5 def api_key @api_key end |
#options ⇒ Hash (readonly)
Returns the provided options hash.
7 8 9 |
# File 'lib/google_places/client.rb', line 7 def @options end |
Instance Method Details
#predictions_by_input(input, options = {}) ⇒ Array<Prediction>
Query for Place Predictions
297 298 299 |
# File 'lib/google_places/client.rb', line 297 def predictions_by_input(input, = {}) Prediction.list_by_input(input, @api_key, @options.merge()) end |
#spot(place_id, options = {}) ⇒ Spot
Search for a Spot with a reference key
116 117 118 |
# File 'lib/google_places/client.rb', line 116 def spot(place_id, = {}) Spot.find(place_id, @api_key, @options.merge()) end |
#spots(lat, lng, options = {}) ⇒ Array<Spot>
Search for Spots at the provided location
95 96 97 98 99 100 101 |
# File 'lib/google_places/client.rb', line 95 def spots(lat, lng, = {}) detail = @options.merge!().delete(:detail) collection_detail_level( Spot.list(lat, lng, @api_key, @options), detail ) end |
#spots_by_bounds(bounds, options = {}) ⇒ Array<Spot>
Search for Spots within a give SW|NE bounds with query
202 203 204 205 206 207 208 |
# File 'lib/google_places/client.rb', line 202 def spots_by_bounds(bounds, = {}) detail = @options.merge!().delete(:detail) collection_detail_level( Spot.list_by_bounds(bounds, @api_key, @options), detail ) end |
#spots_by_pagetoken(pagetoken, options = {}) ⇒ Array<Spot>
Search for Spots with a pagetoken
226 227 228 229 230 231 232 |
# File 'lib/google_places/client.rb', line 226 def spots_by_pagetoken(pagetoken, = {}) detail = @options.merge!().delete(:detail) collection_detail_level( Spot.list_by_pagetoken(pagetoken, @api_key, @options), detail ) end |
#spots_by_query(query, options = {}) ⇒ Array<Spot>
Search for Spots with a query
159 160 161 162 163 164 165 |
# File 'lib/google_places/client.rb', line 159 def spots_by_query(query, = {}) detail = @options.merge!().delete(:detail) collection_detail_level( Spot.list_by_query(query, @api_key, @options), detail ) end |
#spots_by_radar(lat, lng, options = {}) ⇒ Array<Spot>
Radar Search Service allows you to search for up to 200 Places at once, but with less detail than is typically returned from a Text Search or Nearby Search request. The search response will include up to 200 Places, identified only by their geographic coordinates and reference. You can send a Place Details request for more information about any of them.
270 271 272 273 274 275 276 |
# File 'lib/google_places/client.rb', line 270 def spots_by_radar(lat, lng, = {}) detail = @options.merge!().delete(:detail) collection_detail_level( Spot.list_by_radar(lat, lng, @api_key, @options), detail ) end |