john-mayer 0.1.3 → 0.1.4
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/lib/foursquare/base.rb +9 -4
- data/lib/foursquare/venue_proxy.rb +32 -0
- metadata +3 -3
data/lib/foursquare/base.rb
CHANGED
@@ -23,6 +23,7 @@ module Foursquare
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def get(path, params={})
|
26
|
+
params = camelize(params)
|
26
27
|
Foursquare.log("GET #{API + path}")
|
27
28
|
Foursquare.log("PARAMS: #{params.inspect}")
|
28
29
|
params.merge!(:oauth_token => @access_token)
|
@@ -32,10 +33,7 @@ module Foursquare
|
|
32
33
|
end
|
33
34
|
|
34
35
|
def post(path, params={})
|
35
|
-
params = params
|
36
|
-
o[k.to_s.gsub(/(_[a-z])/) { |m| m[1..1].upcase }] = v
|
37
|
-
o
|
38
|
-
} # Camelize them params.
|
36
|
+
params = camelize(params)
|
39
37
|
Foursquare.log("POST #{API + path}")
|
40
38
|
params.merge!(:oauth_token => @access_token)
|
41
39
|
response = JSON.parse(Typhoeus::Request.post(API + path, :params => params).body)
|
@@ -45,6 +43,13 @@ module Foursquare
|
|
45
43
|
|
46
44
|
private
|
47
45
|
|
46
|
+
def camelize(params)
|
47
|
+
params.inject({}) { |o, (k, v)|
|
48
|
+
o[k.to_s.gsub(/(_[a-z])/) { |m| m[1..1].upcase }] = v
|
49
|
+
o
|
50
|
+
}
|
51
|
+
end
|
52
|
+
|
48
53
|
def error(response)
|
49
54
|
raise Foursquare::Error.new(Foursquare::ERRORS[response['meta']['errorType']])
|
50
55
|
end
|
@@ -7,5 +7,37 @@ module Foursquare
|
|
7
7
|
def find(id)
|
8
8
|
Foursquare::Venue.new(@foursquare, @foursquare.get("venues/#{id}")["venue"])
|
9
9
|
end
|
10
|
+
|
11
|
+
def search(options={})
|
12
|
+
raise ArgumentError, "You must include :ll" unless options[:ll]
|
13
|
+
response = @foursquare.get('venues/search', options)["groups"].inject({}) do |venues, group|
|
14
|
+
venues[group["type"]] ||= []
|
15
|
+
venues[group["type"]] << group["items"].map do |json|
|
16
|
+
Foursquare::Venue.new(@foursquare, json)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def trending(options={})
|
22
|
+
search_group("trending", options)
|
23
|
+
end
|
24
|
+
|
25
|
+
def favorites(options={})
|
26
|
+
search_group("favorites", options)
|
27
|
+
end
|
28
|
+
|
29
|
+
def nearby(options={})
|
30
|
+
search_group("nearby", options)
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def search_group(name, options)
|
36
|
+
raise ArgumentError, "You must include :ll" unless options[:ll]
|
37
|
+
response = @foursquare.get('venues/search', options)["groups"].detect { |group| group["type"] == name }
|
38
|
+
response ? response["items"].map do |json|
|
39
|
+
Foursquare::Venue.new(@foursquare, json)
|
40
|
+
end : []
|
41
|
+
end
|
10
42
|
end
|
11
43
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: john-mayer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 4
|
10
|
+
version: 0.1.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Pat Nakajima
|