Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Generic HTTP API wrapper

branch: master

Sigh

latest commit 3aaa30913a
Tim Sharpe authored January 10, 2010
Octocat-spinner-32 lib 0.0.1 release January 10, 2010
Octocat-spinner-32 test Initial commit to hapi. January 09, 2010
Octocat-spinner-32 .document Initial commit to hapi. January 09, 2010
Octocat-spinner-32 .gitignore Initial commit to hapi. January 09, 2010
Octocat-spinner-32 LICENSE Initial commit to hapi. January 09, 2010
Octocat-spinner-32 README.markdown
Octocat-spinner-32 Rakefile Fixed gem description January 10, 2010
Octocat-spinner-32 VERSION Version bump to 0.0.2 January 10, 2010
README.markdown

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.

Something went wrong with that request. Please try again.