google_places 0.24.0 → 0.26.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -0
- data/Gemfile.lock +1 -1
- data/README.rdoc +28 -2
- data/google_places.gemspec +1 -1
- data/lib/google_places.rb +1 -1
- data/lib/google_places/client.rb +33 -25
- data/lib/google_places/error.rb +0 -1
- data/lib/google_places/photo.rb +1 -7
- data/lib/google_places/prediction.rb +71 -0
- data/lib/google_places/request.rb +24 -24
- data/lib/google_places/spot.rb +20 -43
- data/spec/google_places/client_spec.rb +10 -5
- data/spec/google_places/location_spec.rb +0 -2
- data/spec/google_places/photo_spec.rb +4 -3
- data/spec/google_places/prediction_spec.rb +58 -0
- data/spec/google_places/request_spec.rb +0 -19
- data/spec/google_places/spot_spec.rb +14 -15
- data/spec/vcr_cassettes/list_predictions.yml +845 -0
- data/spec/vcr_cassettes/list_spots.yml +3364 -44
- data/spec/vcr_cassettes/list_spots_by_radar.yml +1070 -14
- data/spec/vcr_cassettes/list_spots_with_multiple_types.yml +1192 -10
- data/spec/vcr_cassettes/list_spots_with_name.yml +6 -6
- data/spec/vcr_cassettes/list_spots_with_name_and_types.yml +156 -6
- data/spec/vcr_cassettes/list_spots_with_single_type.yml +640 -6
- data/spec/vcr_cassettes/list_spots_with_types_and_exclusion.yml +1194 -10
- data/spec/vcr_cassettes/multiple_page_request.yml +4194 -8
- data/spec/vcr_cassettes/photo.yml +84 -2
- data/spec/vcr_cassettes/premium_list_spots_with_data.yml +3 -3
- data/spec/vcr_cassettes/single_spot.yml +1386 -16
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa3d60080776cfdf41db6e889d93a4a867cbb21c
|
4
|
+
data.tar.gz: d9bc8d18548afecb8a3cf811c605db6c005b0591
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11d260b9b3a91ed0866a85b20236fd2d8bd10957972e2a482c06bc2d42ea261792622eb167877add3ade9e4b7474db3a24799f6a76da47f195b5b18ca44f732c
|
7
|
+
data.tar.gz: f5f368bf9522fe018179a2c7c52bc3aa4ad512da3c4b3678c2e9bc432dc554623b0a2073b6228c40c4947341978941fd9dd152613ca6f1beed992278f5f2ab03
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/README.rdoc
CHANGED
@@ -83,7 +83,7 @@ Get results in specific language:
|
|
83
83
|
@client.spots(-33.8670522, 151.1957362, :language => 'en')
|
84
84
|
|
85
85
|
=== Retrieving spots based on query
|
86
|
-
|
86
|
+
|
87
87
|
@client.spots_by_query('Pizza near Miami Florida')
|
88
88
|
|
89
89
|
Search by multiple types and exclude multiple types
|
@@ -111,9 +111,35 @@ Then retrieve the spot:
|
|
111
111
|
@spot = @client.spot('CmRYAAA...upoTH3g')
|
112
112
|
|
113
113
|
Then request one of the photos url with a max width:
|
114
|
-
|
114
|
+
|
115
115
|
url = @spot.photos[0].fetch_url(800)
|
116
116
|
|
117
|
+
=== Places Autocomplete
|
118
|
+
|
119
|
+
https://developers.google.com/places/documentation/autocomplete
|
120
|
+
|
121
|
+
<em>Note:</em> Autocomplete is often used and better suited on client side (browser/javascript). The Autocomplete API is rate limited, so make sure you check the usage limits before deciding on whether to call the API server/client side.
|
122
|
+
|
123
|
+
https://developers.google.com/maps/documentation/business/articles/usage_limits
|
124
|
+
|
125
|
+
==== Example usage
|
126
|
+
|
127
|
+
Register a new Client:
|
128
|
+
|
129
|
+
@client = GooglePlaces::Client.new(API_KEY)
|
130
|
+
|
131
|
+
Then request a prediction based on partial match:
|
132
|
+
|
133
|
+
@client.predictions_by_input(
|
134
|
+
'San F',
|
135
|
+
lat: 0.0,
|
136
|
+
lng: 0.0,
|
137
|
+
radius: 20000000,
|
138
|
+
types: 'geocode',
|
139
|
+
language: I18n.locale,
|
140
|
+
)
|
141
|
+
|
142
|
+
The response will be an array of predictions.
|
117
143
|
|
118
144
|
== Development
|
119
145
|
|
data/google_places.gemspec
CHANGED
data/lib/google_places.rb
CHANGED
data/lib/google_places/client.rb
CHANGED
@@ -5,7 +5,6 @@ module GooglePlaces
|
|
5
5
|
attr_reader :api_key
|
6
6
|
# @return [Hash] the provided options hash
|
7
7
|
attr_reader :options
|
8
|
-
attr_reader :sensor
|
9
8
|
|
10
9
|
# Creates a new Client instance which proxies the requests to the certain classes
|
11
10
|
#
|
@@ -19,8 +18,6 @@ module GooglePlaces
|
|
19
18
|
# Defines the distance (in meters) within which to return Place results.
|
20
19
|
# The maximum allowed radius is 50,000 meters.
|
21
20
|
# Note that radius must not be included if <b>:rankby</b> is specified
|
22
|
-
# @option options [Boolean] :sensor
|
23
|
-
# Indicates whether or not the Place request came from a device using a location sensor (e.g. a GPS) to determine the location sent in this request.
|
24
21
|
# @option options [String,Array] :types
|
25
22
|
# Restricts the results to Spots matching at least one of the specified types
|
26
23
|
# @option options [String] :name
|
@@ -44,9 +41,8 @@ module GooglePlaces
|
|
44
41
|
# @see http://spreadsheets.google.com/pub?key=p9pdwsai2hDMsLkXsoM05KQ&gid=1 List of supported languages
|
45
42
|
# @see https://developers.google.com/maps/documentation/places/supported_types List of supported types
|
46
43
|
|
47
|
-
def initialize(api_key = @api_key,
|
44
|
+
def initialize(api_key = @api_key, options = {})
|
48
45
|
api_key ? @api_key = api_key : @api_key = GooglePlaces.api_key
|
49
|
-
@sensor = sensor
|
50
46
|
@options = options
|
51
47
|
end
|
52
48
|
|
@@ -70,10 +66,6 @@ module GooglePlaces
|
|
70
66
|
# - distance. This option sorts results in ascending order by their distance from the specified location.
|
71
67
|
# Ranking results by distance will set a fixed search radius of 50km.
|
72
68
|
# One or more of keyword, name, or types is required. distance. This option sorts results in ascending order by their distance from the specified location. Ranking results by distance will set a fixed search radius of 50km. One or more of keyword, name, or types is required.
|
73
|
-
# @option options [Boolean] :sensor (false)
|
74
|
-
# Indicates whether or not the Place request came from a device using a location sensor (e.g. a GPS)
|
75
|
-
# to determine the location sent in this request.
|
76
|
-
# <b>Note that this is a mandatory parameter</b>
|
77
69
|
# @option options [String,Array] :types
|
78
70
|
# Restricts the results to Spots matching at least one of the specified types
|
79
71
|
# @option options [String] :name
|
@@ -97,7 +89,7 @@ module GooglePlaces
|
|
97
89
|
# @see http://spreadsheets.google.com/pub?key=p9pdwsai2hDMsLkXsoM05KQ&gid=1 List of supported languages
|
98
90
|
# @see https://developers.google.com/maps/documentation/places/supported_types List of supported types
|
99
91
|
def spots(lat, lng, options = {})
|
100
|
-
Spot.list(lat, lng, @api_key, @
|
92
|
+
Spot.list(lat, lng, @api_key, @options.merge(options))
|
101
93
|
end
|
102
94
|
|
103
95
|
# Search for a Spot with a reference key
|
@@ -105,9 +97,6 @@ module GooglePlaces
|
|
105
97
|
# @return [Spot]
|
106
98
|
# @param [String] place_id the place_id of the spot
|
107
99
|
# @param [Hash] options
|
108
|
-
# @option options [Boolean] :sensor (false)
|
109
|
-
# Indicates whether or not the Place request came from a device using a location sensor (e.g. a GPS) to determine the location sent in this request.
|
110
|
-
# <b>Note that this is a mandatory parameter</b>
|
111
100
|
# @option options [String] :language
|
112
101
|
# The language code, indicating in which language the results should be returned, if possible.
|
113
102
|
#
|
@@ -117,7 +106,7 @@ module GooglePlaces
|
|
117
106
|
# @option options [Integer] :retry_options[:max] (0) the maximum retries
|
118
107
|
# @option options [Integer] :retry_options[:delay] (5) the delay between each retry in seconds
|
119
108
|
def spot(place_id, options = {})
|
120
|
-
Spot.find(place_id, @api_key, @
|
109
|
+
Spot.find(place_id, @api_key, @options.merge(options))
|
121
110
|
end
|
122
111
|
|
123
112
|
# Search for Spots with a query
|
@@ -141,9 +130,6 @@ module GooglePlaces
|
|
141
130
|
# - distance. This option sorts results in ascending order by their distance from the specified location.
|
142
131
|
# Ranking results by distance will set a fixed search radius of 50km.
|
143
132
|
# One or more of keyword, name, or types is required. distance. This option sorts results in ascending order by their distance from the specified location. Ranking results by distance will set a fixed search radius of 50km. One or more of keyword, name, or types is required.
|
144
|
-
# @option options [Boolean] :sensor (false)
|
145
|
-
# Indicates whether or not the Place request came from a device using a location sensor (e.g. a GPS) to determine the location sent in this request.
|
146
|
-
# <b>Note that this is a mandatory parameter</b>
|
147
133
|
# @option options [String,Array] :types
|
148
134
|
# Restricts the results to Spots matching at least one of the specified types
|
149
135
|
# @option options [String] :language
|
@@ -160,7 +146,7 @@ module GooglePlaces
|
|
160
146
|
# @see http://spreadsheets.google.com/pub?key=p9pdwsai2hDMsLkXsoM05KQ&gid=1 List of supported languages
|
161
147
|
# @see https://developers.google.com/maps/documentation/places/supported_types List of supported types
|
162
148
|
def spots_by_query(query, options = {})
|
163
|
-
Spot.list_by_query(query, @api_key, @
|
149
|
+
Spot.list_by_query(query, @api_key, @options.merge(options))
|
164
150
|
end
|
165
151
|
|
166
152
|
# Search for Spots with a pagetoken
|
@@ -178,11 +164,11 @@ module GooglePlaces
|
|
178
164
|
#
|
179
165
|
# @see https://developers.google.com/maps/documentation/places/supported_types List of supported types
|
180
166
|
def spots_by_pagetoken(pagetoken, options = {})
|
181
|
-
Spot.list_by_pagetoken(pagetoken, @api_key, @
|
167
|
+
Spot.list_by_pagetoken(pagetoken, @api_key, @options.merge(options))
|
182
168
|
end
|
183
169
|
|
184
170
|
# 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.
|
185
|
-
#
|
171
|
+
#
|
186
172
|
# @return [Array<Spot>]
|
187
173
|
# @param [String,Integer] lat the latitude for the search
|
188
174
|
# @param [String,Integer] lng the longitude for the search
|
@@ -205,18 +191,40 @@ module GooglePlaces
|
|
205
191
|
# @option options [Integer] :maxprice
|
206
192
|
# Restricts results to only those places within the specified price range. Valid values range between 0 (most affordable) to 4 (most expensive), inclusive.
|
207
193
|
# @option options [Boolean] :opennow
|
208
|
-
# Retricts results to those Places that are open for business at the time the query is sent.
|
209
|
-
# Places that do not specify opening hours in the Google Places database will not be returned if you include this parameter in your query.
|
194
|
+
# Retricts results to those Places that are open for business at the time the query is sent.
|
195
|
+
# Places that do not specify opening hours in the Google Places database will not be returned if you include this parameter in your query.
|
210
196
|
# Setting openNow to false has no effect.
|
211
197
|
# @option options [Boolean] :zagatselected
|
212
|
-
# Restrict your search to only those locations that are Zagat selected businesses.
|
213
|
-
# This parameter does not require a true or false value, simply including the parameter in the request is sufficient to restrict your search.
|
198
|
+
# Restrict your search to only those locations that are Zagat selected businesses.
|
199
|
+
# This parameter does not require a true or false value, simply including the parameter in the request is sufficient to restrict your search.
|
214
200
|
# The zagatselected parameter is experimental, and only available to Places API enterprise customers.
|
215
201
|
#
|
216
202
|
# @see https://developers.google.com/places/documentation/search#RadarSearchRequests
|
217
203
|
def spots_by_radar(lat, lng, options = {})
|
218
|
-
Spot.list_by_radar(lat, lng, @api_key, @
|
204
|
+
Spot.list_by_radar(lat, lng, @api_key, @options.merge(options))
|
219
205
|
end
|
220
206
|
|
207
|
+
# Query for Place Predictions
|
208
|
+
#
|
209
|
+
# @return [Array<Prediction>]
|
210
|
+
# @param [String] query the query to search for
|
211
|
+
# @param [Hash] options
|
212
|
+
# @option options [String,Integer] lat the latitude for the search
|
213
|
+
# @option options [String,Integer] lng the longitude for the search
|
214
|
+
# @option options [Integer] :radius (1000)
|
215
|
+
# Defines the distance (in meters) within which to return Place results.
|
216
|
+
# The maximum allowed radius is 50,000 meters.
|
217
|
+
# Note that radius must not be included if :rankby => 'distance' (described below) is specified.
|
218
|
+
# <b>Note that this is a mandatory parameter</b>
|
219
|
+
# @option options [String,Array] :types
|
220
|
+
# Restricts the results to Spots matching at least one of the specified types
|
221
|
+
# @option options [String] :language
|
222
|
+
# The language code, indicating in which language the results should be returned, if possible.
|
223
|
+
#
|
224
|
+
# @see http://spreadsheets.google.com/pub?key=p9pdwsai2hDMsLkXsoM05KQ&gid=1 List of supported languages
|
225
|
+
# @see https://developers.google.com/maps/documentation/places/supported_types List of supported types
|
226
|
+
def predictions_by_input(input, options = {})
|
227
|
+
Prediction.list_by_input(input, @api_key, @options.merge(options))
|
228
|
+
end
|
221
229
|
end
|
222
230
|
end
|
data/lib/google_places/error.rb
CHANGED
data/lib/google_places/photo.rb
CHANGED
@@ -2,23 +2,18 @@ module GooglePlaces
|
|
2
2
|
class Photo
|
3
3
|
attr_accessor :width, :height, :photo_reference, :html_attributions
|
4
4
|
|
5
|
-
def initialize(width, height, photo_reference, html_attributions, api_key
|
5
|
+
def initialize(width, height, photo_reference, html_attributions, api_key)
|
6
6
|
@width = width
|
7
7
|
@height = height
|
8
8
|
@photo_reference = photo_reference
|
9
9
|
@html_attributions = html_attributions
|
10
10
|
@api_key = api_key
|
11
|
-
@sensor = sensor
|
12
11
|
end
|
13
12
|
|
14
13
|
# Search for a Photo's url with its reference key
|
15
14
|
#
|
16
15
|
# @return [URL]
|
17
16
|
# @param [String] api_key the provided api key
|
18
|
-
# @param [Boolean] sensor
|
19
|
-
# Indicates whether or not the Place request came from a device using a location sensor (e.g. a GPS)
|
20
|
-
# to determine the location sent in this request.
|
21
|
-
# <b>Note that this is a mandatory parameter</b>
|
22
17
|
# @param [Hash] options
|
23
18
|
# @option options [Hash] :retry_options ({})
|
24
19
|
# A Hash containing parameters for search retries
|
@@ -33,7 +28,6 @@ module GooglePlaces
|
|
33
28
|
@fetched_url = Request.photo_url(
|
34
29
|
:maxwidth => maxwidth,
|
35
30
|
:photoreference => @photo_reference,
|
36
|
-
:sensor => @sensor,
|
37
31
|
:key => @api_key,
|
38
32
|
:retry_options => retry_options
|
39
33
|
)
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module GooglePlaces
|
2
|
+
class Prediction
|
3
|
+
|
4
|
+
attr_accessor(
|
5
|
+
:description,
|
6
|
+
:place_id,
|
7
|
+
)
|
8
|
+
|
9
|
+
def initialize(json_result_object)
|
10
|
+
@description = json_result_object['description']
|
11
|
+
@place_id = json_result_object['place_id']
|
12
|
+
end
|
13
|
+
|
14
|
+
# Query for Predictions (optionally at the provided location)
|
15
|
+
#
|
16
|
+
# @option [String,Integer] :lat the latitude for the search
|
17
|
+
# @option [String,Integer] :lng the longitude for the search
|
18
|
+
# @option options [Integer] :radius (1000)
|
19
|
+
# Defines the distance (in meters) within which to return Place results.
|
20
|
+
# The maximum allowed radius is 50,000 meters.
|
21
|
+
# Note that radius must not be included if :rankby => 'distance' (described below) is specified.
|
22
|
+
# @option options [String,Array] :types
|
23
|
+
# Restricts the results to Spots matching at least one of the specified types
|
24
|
+
# @option options [String] :language
|
25
|
+
# The language code, indicating in which language the results should be returned, if possible.
|
26
|
+
# @option options [Hash] :retry_options ({})
|
27
|
+
# A Hash containing parameters for search retries
|
28
|
+
# @option options [Object] :retry_options[:status] ([])
|
29
|
+
# @option options [Integer] :retry_options[:max] (0) the maximum retries
|
30
|
+
# @option options [Integer] :retry_options[:delay] (5) the delay between each retry in seconds
|
31
|
+
def self.list_by_input(input, api_key, options = {})
|
32
|
+
lat = options.delete(:lat)
|
33
|
+
lng = options.delete(:lng)
|
34
|
+
language = options.delete(:language)
|
35
|
+
radius = options.delete(:radius)
|
36
|
+
retry_options = options.delete(:retry_options) || {}
|
37
|
+
types = options.delete(:types)
|
38
|
+
|
39
|
+
options = {
|
40
|
+
:input => input,
|
41
|
+
:key => api_key,
|
42
|
+
:retry_options => retry_options
|
43
|
+
}
|
44
|
+
|
45
|
+
if lat && lng
|
46
|
+
options[:location] = Location.new(lat, lng).format
|
47
|
+
options[:radius] = radius if radius
|
48
|
+
end
|
49
|
+
|
50
|
+
# Accept Types as a string or array
|
51
|
+
if types
|
52
|
+
types = (types.is_a?(Array) ? types.join('|') : types)
|
53
|
+
options[:types] = types
|
54
|
+
end
|
55
|
+
|
56
|
+
if language
|
57
|
+
options[:language] = language
|
58
|
+
end
|
59
|
+
|
60
|
+
request(:predictions_by_input, options)
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.request(method, options)
|
64
|
+
response = Request.send(method, options)
|
65
|
+
|
66
|
+
response['predictions'].map do |result|
|
67
|
+
self.new(result)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -14,6 +14,7 @@ module GooglePlaces
|
|
14
14
|
TEXT_SEARCH_URL = 'https://maps.googleapis.com/maps/api/place/textsearch/json'
|
15
15
|
PAGETOKEN_URL = 'https://maps.googleapis.com/maps/api/place/search/json'
|
16
16
|
RADAR_SEARCH_URL = 'https://maps.googleapis.com/maps/api/place/radarsearch/json'
|
17
|
+
AUTOCOMPLETE_URL = 'https://maps.googleapis.com/maps/api/place/autocomplete/json'
|
17
18
|
|
18
19
|
# Search for Spots at the provided location
|
19
20
|
#
|
@@ -27,9 +28,6 @@ module GooglePlaces
|
|
27
28
|
# The maximum allowed radius is 50,000 meters.
|
28
29
|
# Note that radius must not be included if <b>:rankby</b> is specified
|
29
30
|
# <b>Note that this is a mandatory parameter</b>
|
30
|
-
# @option options [Boolean] :sensor
|
31
|
-
# Indicates whether or not the Place request came from a device using a location sensor (e.g. a GPS) to determine the location sent in this request.
|
32
|
-
# <b>Note that this is a mandatory parameter</b>
|
33
31
|
# @option options [(Integer,Integer),String] :location
|
34
32
|
# The latitude/longitude around which to retrieve Spot information. This must be specified as latitude,longitude
|
35
33
|
# <b>Note that this is a mandatory parameter</b>
|
@@ -72,9 +70,6 @@ module GooglePlaces
|
|
72
70
|
# in requests but is snake_cased in responses (place_id)
|
73
71
|
# @see: https://developers.google.com/places/documentation/details
|
74
72
|
# <b>Note that this is a mandatory parameter</b>
|
75
|
-
# @option options [Boolean] :sensor
|
76
|
-
# Indicates whether or not the Place request came from a device using a location sensor (e.g. a GPS) to determine the location sent in this request.
|
77
|
-
# <b>Note that this is a mandatory parameter</b>
|
78
73
|
# @option options [String] :language
|
79
74
|
# The language code, indicating in which language the results should be returned, if possible.
|
80
75
|
#
|
@@ -94,9 +89,6 @@ module GooglePlaces
|
|
94
89
|
# <b>Note that this is a mandatory parameter</b>
|
95
90
|
# @option options [String] :location
|
96
91
|
# the lat, lng for the search
|
97
|
-
# @option options [Boolean] :sensor
|
98
|
-
# Indicates whether or not the Place request came from a device using a location sensor (e.g. a GPS) to determine the location sent in this request.
|
99
|
-
# <b>Note that this is a mandatory parameter</b>
|
100
92
|
# @option options [Integer] :radius (1000)
|
101
93
|
# Defines the distance (in meters) within which to return Place results.
|
102
94
|
# The maximum allowed radius is 50,000 meters.
|
@@ -115,12 +107,12 @@ module GooglePlaces
|
|
115
107
|
# @option options [Integer] :maxprice
|
116
108
|
# Restricts results to only those places within the specified price range. Valid values range between 0 (most affordable) to 4 (most expensive), inclusive.
|
117
109
|
# @option options [Boolean] :opennow
|
118
|
-
# Retricts results to those Places that are open for business at the time the query is sent.
|
119
|
-
# Places that do not specify opening hours in the Google Places database will not be returned if you include this parameter in your query.
|
110
|
+
# Retricts results to those Places that are open for business at the time the query is sent.
|
111
|
+
# Places that do not specify opening hours in the Google Places database will not be returned if you include this parameter in your query.
|
120
112
|
# Setting openNow to false has no effect.
|
121
113
|
# @option options [Boolean] :zagatselected
|
122
|
-
# Restrict your search to only those locations that are Zagat selected businesses.
|
123
|
-
# This parameter does not require a true or false value, simply including the parameter in the request is sufficient to restrict your search.
|
114
|
+
# Restrict your search to only those locations that are Zagat selected businesses.
|
115
|
+
# This parameter does not require a true or false value, simply including the parameter in the request is sufficient to restrict your search.
|
124
116
|
# The zagatselected parameter is experimental, and only available to Places API enterprise customers.
|
125
117
|
# @option options [Hash] :retry_options ({})
|
126
118
|
# A Hash containing parameters for search retries
|
@@ -150,9 +142,6 @@ module GooglePlaces
|
|
150
142
|
# The maximum allowed radius is 50,000 meters.
|
151
143
|
# Note that radius must not be included if <b>:rankby</b> is specified
|
152
144
|
# <b>Note that this is a mandatory parameter</b>
|
153
|
-
# @option options [Boolean] :sensor
|
154
|
-
# Indicates whether or not the Place request came from a device using a location sensor (e.g. a GPS) to determine the location sent in this request.
|
155
|
-
# <b>Note that this is a mandatory parameter</b>
|
156
145
|
# @option options [String,Array] :types
|
157
146
|
# Restricts the results to Spots matching at least one of the specified types
|
158
147
|
# @option options [String] :language
|
@@ -193,6 +182,25 @@ module GooglePlaces
|
|
193
182
|
request.parsed_response
|
194
183
|
end
|
195
184
|
|
185
|
+
# Query for Place Predictions
|
186
|
+
#
|
187
|
+
# @return [Array<Prediction>]
|
188
|
+
# @param [String] api_key the provided api key
|
189
|
+
# @param [Hash] options
|
190
|
+
# @option options [String,Array<String>] :exclude ([])
|
191
|
+
# A String or an Array of <b>types</b> to exclude from results
|
192
|
+
# @option options [Hash] :retry_options ({})
|
193
|
+
# A Hash containing parameters for search retries
|
194
|
+
# @option options [Object] :retry_options[:status] ([])
|
195
|
+
# @option options [Integer] :retry_options[:max] (0) the maximum retries
|
196
|
+
# @option options [Integer] :retry_options[:delay] (5) the delay between each retry in seconds
|
197
|
+
#
|
198
|
+
# @see https://developers.google.com/maps/documentation/places/supported_types List of supported types
|
199
|
+
def self.predictions_by_input(options = {})
|
200
|
+
request = new(AUTOCOMPLETE_URL, options)
|
201
|
+
request.parsed_response
|
202
|
+
end
|
203
|
+
|
196
204
|
# Search for a Photo's URL with a reference key
|
197
205
|
#
|
198
206
|
# @return [URL]
|
@@ -206,10 +214,6 @@ module GooglePlaces
|
|
206
214
|
# @option options [String] :photoreference
|
207
215
|
# The reference of a already retrieved Photo
|
208
216
|
# <b>Note that this is a mandatory parameter</b>
|
209
|
-
# @option options [Boolean] :sensor
|
210
|
-
# Indicates whether or not the Place request came from a device using a location sensor (e.g. a GPS) to determine the location sent in this request.
|
211
|
-
# <b>Note that this is a mandatory parameter</b>
|
212
|
-
#
|
213
217
|
# @option options [Hash] :retry_options ({})
|
214
218
|
# A Hash containing parameters for search retries
|
215
219
|
# @option options [Object] :retry_options[:status] ([])
|
@@ -233,9 +237,6 @@ module GooglePlaces
|
|
233
237
|
# The maximum allowed radius is 50,000 meters.
|
234
238
|
# Note that radius must not be included if <b>:rankby</b> is specified
|
235
239
|
# <b>Note that this is a mandatory parameter</b>
|
236
|
-
# @option options [Boolean] :sensor
|
237
|
-
# Indicates whether or not the Place request came from a device using a location sensor (e.g. a GPS) to determine the location sent in this request.
|
238
|
-
# <b>Note that this is a mandatory parameter</b>
|
239
240
|
# @option options [(Integer,Integer),String] :location
|
240
241
|
# The latitude/longitude around which to retrieve Spot information. This must be specified as latitude,longitude
|
241
242
|
# <b>Note that this is a mandatory parameter</b>
|
@@ -271,7 +272,6 @@ module GooglePlaces
|
|
271
272
|
retry_options[:status] = [retry_options[:status]] unless retry_options[:status].is_a?(Array)
|
272
273
|
@response = self.class.get(url, :query => options, :follow_redirects => follow_redirects)
|
273
274
|
|
274
|
-
# puts "@response.request.last_uri.to_s"
|
275
275
|
# puts @response.request.last_uri.to_s
|
276
276
|
|
277
277
|
return unless retry_options[:max] > 0 && retry_options[:status].include?(@response.parsed_response['status'])
|