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
272 273 274 |
# File 'lib/google_places/client.rb', line 272 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
119 120 121 |
# File 'lib/google_places/client.rb', line 119 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 102 103 104 |
# File 'lib/google_places/client.rb', line 95 def spots(lat, lng, = {}) detail_spot = .delete(:detail) spots = Spot.list(lat, lng, @api_key, @options.merge()) if detail_spot spots.map {|spot| Spot.find(spot.place_id, @api_key, @options.merge())} else spots end end |
#spots_by_bounds(bounds, options = {}) ⇒ Array<Spot>
Search for Spots within a give SW|NE bounds with query
195 196 197 |
# File 'lib/google_places/client.rb', line 195 def spots_by_bounds(bounds, = {}) Spot.list_by_bounds(bounds, @api_key, @options.merge()) end |
#spots_by_pagetoken(pagetoken, options = {}) ⇒ Array<Spot>
Search for Spots with a pagetoken
212 213 214 |
# File 'lib/google_places/client.rb', line 212 def spots_by_pagetoken(pagetoken, = {}) Spot.list_by_pagetoken(pagetoken, @api_key, @options.merge()) end |
#spots_by_query(query, options = {}) ⇒ Array<Spot>
Search for Spots with a query
159 160 161 |
# File 'lib/google_places/client.rb', line 159 def spots_by_query(query, = {}) Spot.list_by_query(query, @api_key, @options.merge()) 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.
249 250 251 |
# File 'lib/google_places/client.rb', line 249 def spots_by_radar(lat, lng, = {}) Spot.list_by_radar(lat, lng, @api_key, @options.merge()) end |