lib/tumblr/request.rb in tumblr_client-0.6.7 vs lib/tumblr/request.rb in tumblr_client-0.6.8
- old
+ new
@@ -7,20 +7,29 @@
def get(path, params={})
response = connection.get do |req|
req.url path
req.params = params
end
- #check for errors and encapsulate
- response.body['response']
+ #Check for errors and encapsulate
+ respond(response)
end
#Performs post request
def post(path, params={})
response = connection.post do |req|
req.url path
req.body = params unless params.empty?
end
#Check for errors and encapsulate
- response.body['response']
+ respond(response)
end
+
+ def respond(response)
+ if [201, 200].include?(response.status)
+ response.body['response']
+ else
+ response.body['meta']
+ end
+ end
+
end
end