Is there a more user friendly alternative to Net::HTTP for interacting with REST APIs?
If you only have to deal with REST, the rest-client library is fantastic.
If the APIs you're using aren't completely RESTful - or even if they are - HTTParty is really worth checking out. It simplifies using REST APIs, as well as non-RESTful web APIs. Check out this code (copied from the above link):
require 'rubygems'require 'httparty'class Representative include HTTParty format :xml def self.find_by_zip(zip) get('http://whoismyrepresentative.com/whoismyrep.php', :query => {:zip => zip}) endendputs Representative.find_by_zip(46544).inspect# {"result"=>{"n"=>"1", "rep"=>{"name"=>"Joe Donnelly", "district"=>"2", "office"=>"1218 Longworth", "phone"=>"(202) 225-3915", "link"=>"http://donnelly.house.gov/", "state"=>"IN"}}}
rest-open-uri is the one that is used heavily throughout the RESTful Web Services book.
gem install rest-open-uri
Example usage:
response = open('https://wherever/foo', :method => :put, :http_basic_authentication => ['my-user', 'my-passwd'], :body => 'payload')puts response.read
I'm a big fan of rest-client, which does just enough to be useful without getting in the way of your implementation. It handles exceptions intelligently, and supports logging and auth, out of the box.