Skip to content
This repository has been archived by the owner on Mar 17, 2020. It is now read-only.

Add Support for POST Requests #3

Merged
merged 1 commit into from
Jul 10, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions lib/readability/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/readability/helpers/authentication.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down