Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add POST support

  • Loading branch information...
commit ebada05034cd40366b8b3ad12368388e6427350d 1 parent a8568dd
@doucette doucette authored
View
12 lib/readability/client.rb
@@ -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
View
4 lib/readability/helpers/authentication.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.