Patronage
Patronage is a small and generic library for accessing and interacting with web-services. It is built on top of another Ruby library named Patron, which uses libcurl.
Usage Example
Supposing there's an API in the address http://example.com/api and you want to perform a query to /users.xml.
# Creates an API instance with a default parameter that should be sent in all requests
api = Patronage::API.new("http://example.com/api", :params => {:token => "79173109187231827312"})
# Will perform a GET request to http://example.com/api/users.xml?token=79173109187231827312&id=1
resp = api.service(:users, :format => 'xml').get(:id => "1")
# To access the response, already parsed.
resp.payload
# To access the raw response
resp.body
# Get the response status code
resp.status
Note on Patches/Pull Requests
- Fork the project.
- Make your feature addition or bug fix.
- Add tests for it. This is important so I don't break it in a future version unintentionally.
- Commit, do not mess with rakefile, version, or history (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull).
- Send me a pull request. Bonus points for topic branches.
Copyright
Copyright (c) 2009 Rodrigo Kochenburger. See LICENSE for details.