Add Support for POST Requests #3

Merged
merged 1 commit into from Jul 10, 2011
@@ -9,11 +9,16 @@ def initialize(token)
@token = token.dup
# get available resource types
- @resources = get
+ @resources = request
end
- def get(resource="", args={})
- response = @token.get(format_query(resource, args))
+ def request(resource="", args={}, body={})
+ if body == {}
+ response = @token.get(format_query(resource, args))
+ else
+ response = @token.post(format_query(resource, args), parameterize(body),
+ { 'Content-Type' => 'application/x-www-form-urlencoded' })
+ end
case response
when Net::HTTPSuccess
data = JSON.parse(response.body)
@@ -23,6 +28,7 @@ def get(resource="", args={})
raise StandardError, "Could not get data for those params."
end
end
+ alias :get :request
def format_query(resource, args)
options = args.dup
@@ -9,8 +9,8 @@ def readability_access
session[:readability][:readability_access] if session[:readability]
end
- def readability(resource, args = {})
- readability_client.get(resource, args)
+ def readability(resource, args = {}, body = {})
+ readability_client.request(resource, args, body)
end
def dereadabilify