john-mayer 0.0.5 → 0.0.6
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 +7 -1
- data/lib/foursquare.rb +12 -0
- metadata +3 -3
data/lib/foursquare/base.rb
CHANGED
@@ -21,7 +21,13 @@ module Foursquare
|
|
21
21
|
def get(path, params={})
|
22
22
|
params.merge!(:oauth_token => @access_token)
|
23
23
|
response = JSON.parse(Typhoeus::Request.get(API + path, :params => params).body)
|
24
|
-
response["meta"]["code"] == 200 ? response["response"] :
|
24
|
+
response["meta"]["code"] == 200 ? response["response"] : error(response)
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def error(response)
|
30
|
+
raise Foursquare::Error.new(Foursquare::ERRORS[response['meta']['errorType']])
|
25
31
|
end
|
26
32
|
end
|
27
33
|
end
|
data/lib/foursquare.rb
CHANGED
@@ -12,4 +12,16 @@ require "foursquare/venue_proxy"
|
|
12
12
|
require "foursquare/venue"
|
13
13
|
|
14
14
|
module Foursquare
|
15
|
+
class Error < StandardError ; end
|
16
|
+
|
17
|
+
ERRORS = {
|
18
|
+
"invalid_auth" => "OAuth token was not provided or was invalid."
|
19
|
+
"param_error" => "A required parameter was missing or a parameter was malformed. This is also used if the resource ID in the path is incorrect."
|
20
|
+
"endpoint_error" => "The requested path does not exist."
|
21
|
+
"not_authorized" => "Although authentication succeeded, the acting user is not allowed to see this information due to privacy restrictions."
|
22
|
+
"rate_limit_exceeded" => "Rate limit for this hour exceeded."
|
23
|
+
"deprecated" => "Something about this request is using deprecated functionality, or the response format may be about to change."
|
24
|
+
"server_error" => "Server is currently experiencing issues. Check status.foursquare.com for udpates."
|
25
|
+
"other" => "Some other type of error occurred."
|
26
|
+
}
|
15
27
|
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
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 6
|
10
|
+
version: 0.0.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Pat Nakajima
|