portero 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/portero/providers/foursquare.rb +11 -4
- data/lib/portero/providers/google_places.rb +10 -3
- data/lib/portero/search_provider.rb +1 -0
- data/lib/portero/version.rb +1 -1
- data/spec/data/foursquare.json +621 -436
- data/spec/data/foursquare_without_query.json +2961 -0
- data/spec/data/google_places_without_query.json +358 -0
- data/spec/providers/foursquare_spec.rb +7 -0
- data/spec/providers/google_places_spec.rb +8 -0
- data/spec/support/fakeweb.rb +3 -1
- metadata +6 -2
@@ -7,8 +7,15 @@ module Portero
|
|
7
7
|
requires_option :client_secret
|
8
8
|
|
9
9
|
def search(conn, query, latitude, longitude, options = {})
|
10
|
-
|
11
|
-
|
10
|
+
params = {}
|
11
|
+
params[:query] = query if query
|
12
|
+
params[:client_id] = @provider_options[:client_id]
|
13
|
+
params[:client_secret] = @provider_options[:client_secret]
|
14
|
+
params[:ll] = [latitude, longitude].join(",")
|
15
|
+
params[:v] = "20120709"
|
16
|
+
params[:limit] = options[:limit] || 50
|
17
|
+
params[:radius] = options[:radius] || 10000
|
18
|
+
results = conn.get("https://api.foursquare.com/v2/venues/search", params)
|
12
19
|
parse_results(results)
|
13
20
|
end
|
14
21
|
|
@@ -27,8 +34,8 @@ module Portero
|
|
27
34
|
venue.state = found_venue["location"]["state"]
|
28
35
|
venue.postal_code = found_venue["location"]["postalCode"]
|
29
36
|
venue.country = found_venue["location"]["country"]
|
30
|
-
venue.category = found_venue["categories"].first["name"]
|
31
|
-
venue.icon = found_venue["categories"].first["icon"]["prefix"] + "64" + found_venue["categories"].first["icon"]["suffix"]
|
37
|
+
venue.category = found_venue["categories"].first["name"] if found_venue["categories"].first
|
38
|
+
venue.icon = found_venue["categories"].first["icon"]["prefix"] + "64" + found_venue["categories"].first["icon"]["suffix"] if found_venue["categories"].first
|
32
39
|
venue.extra = {categories: found_venue["categories"], url: found_venue["url"]}
|
33
40
|
|
34
41
|
results << venue
|
@@ -7,8 +7,15 @@ module Portero
|
|
7
7
|
requires_option :key
|
8
8
|
|
9
9
|
def search(conn, query, latitude, longitude, options = {})
|
10
|
-
|
11
|
-
|
10
|
+
params = {}
|
11
|
+
params[:query] = query if query
|
12
|
+
params[:key] = @provider_options[:key]
|
13
|
+
params[:radius] = options[:radius] || 10000
|
14
|
+
params[:location] = [latitude, longitude].join(",")
|
15
|
+
params[:sensor] = false
|
16
|
+
|
17
|
+
url = query.present? ? "https://maps.googleapis.com/maps/api/place/textsearch/json" : "https://maps.googleapis.com/maps/api/place/search/json"
|
18
|
+
results = conn.get(url, params)
|
12
19
|
parse_results(results)
|
13
20
|
end
|
14
21
|
|
@@ -20,7 +27,7 @@ module Portero
|
|
20
27
|
venue = Portero::SearchResult.new
|
21
28
|
venue.id = found_venue["id"]
|
22
29
|
venue.name = found_venue["name"]
|
23
|
-
venue.address = found_venue["formatted_address"]
|
30
|
+
venue.address = found_venue["formatted_address"] || found_venue["vicinity"]
|
24
31
|
venue.latitude = found_venue["geometry"]["location"]["lat"]
|
25
32
|
venue.longitude = found_venue["geometry"]["location"]["lng"]
|
26
33
|
venue.city = ""
|
data/lib/portero/version.rb
CHANGED