Project

hapi

0.0
No commit activity in last 3 years
No release in over 3 years
Generic HTTP API wrapper for Ruby
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

HAPI

HAPI provides a generic abstraction layer for dealing with simple HTTP APIs that return XML content.

Installing

gem install hapi

Using

Making an API call is a simple matter.

  1. Create the HAPI::APICall object
  2. Set the parameters you want to send
  3. Fire the post() or get() methods

The XML content result is parsed by xml-object and returned at a Ruby object for simplicity.

require 'hapi'
h = HAPI::APICall.new "https://path.to/my/api"
h.params = {'user' => 'rodjek, 'foo' => 'bar'}
response = h.post

i.e.

<response>
    <result>
        <command>foo</command>
        <code>0</code>
    </result>
</response>

Can be accessed as follows

response.result.command
=> "foo"
response.result.code
=> "0"

Copyright

Copyright (c) 2010 Tim Sharpe. See LICENSE for details.