lib/coop.rb in coop-1.1.0 vs lib/coop.rb in coop-1.1.1
- old
+ new
@@ -6,11 +6,11 @@
module Coop
include HTTParty
base_uri 'http://coopapp.com'
headers "Accept" => "application/json", "User-Agent" => "coop-gem"
-
+
class << self
# Public: Shortcut for creating a new Coop::Session for API stuff
#
# email - (String) the user's email
# password - (String) the user's password
@@ -20,14 +20,14 @@
# Coop.new("test@example.com", "password123")
# # => #<Coop::Session @email="test@example.com">
#
# Returns an authenticated Coop::Session object
def new(email, password)
- basic_auth email, password
+ basic_auth email, password
Coop::Session.new(email, password)
end
-
+
# Public: Parse an HTTParty response into APIObjects
#
# *args - any valid arguments for HTTParty.get
#
# Examples
@@ -37,20 +37,17 @@
#
# Returns Array of APIObjects or APIObject, depending on response argument
def get_parsed(*args)
begin
request = self.get(*args)
-
+
raise BadRequest if request.response.code == "400"
raise Unauthorized if request.response.code == "401"
raise NotFound if request.response.code == "404"
raise InternalServerError if request.response.code == "500"
raise ServiceUnavailable if request.response.code == "503"
-
+
APIObject.parse_response(request)
-
- rescue MultiJson::DecodeError
- nil
end
end
end
-end
\ No newline at end of file
+end