I\'m writing a client that consumes a non-REST API (i.e. GET site.com/gettreasurehunts), which requires that I specify all parameters (even the resource ID) in the request\'s HT
Simple answer, don't. I had a similar problem with ActiveResource, didn't like HTTParty's api (too many class methods), so I rolled my own. Try it out, it's called Wrest. It has partial support for Curl and deserialisation via REXML, LibXML, Nokogiri and JDom out of the box. You can trivially write your own deserialiser too.
Here's an example for the Delicious api:
class Delicious
def initialize(options)
@uri = "https://api.del.icio.us/v1/posts".to_uri(options)
end
def bookmarks(parameters = {})
@uri['/get'].get(parameters)
end
def recent(parameters = {})
@uri['/recent'].get(parameters)
end
def bookmark(parameters)
@uri['/add'].post_form(parameters)
end
def delete(parameters)
@uri['/delete'].delete(parameters)
end
end
account = Delicious.new :username => 'kaiwren', :password => 'fupupp1es'
account.bookmark(
:url => 'http://blog.sidu.in/search/label/ruby',
:description => 'The Ruby related posts on my blog!',
:extended => "All posts tagged with 'ruby'",
:tags => 'ruby hacking'
)