Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A Gem for accessing the American Express Open Forum API
Ruby
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
spec
.gitignore
Gemfile
Gemfile.lock
README.textile
amex_open_forum.gemspec

README.textile

This originated at eastmedia/amex_open_forum. in pace requiescat

American Express Open Forum Gem

Open Forum is a site that offers content about Small Business.
It is associated with American Express’s OPEN CARD – a credit card used by Small Business Owners.

The Gem

This is gem uses httparty to wrap calls to open forum.
It then uses hashery’s OpenCascade class to turn the API’s hash response into callable methods.

Usage

Adding AmexOpenForum Into Your Class

require 'amex_open_forum'
class MyAmexAPI
  include AmexOpenForum
  open_forum_api_key "YOURKEYHERE"
end

Making Requests to the API

api = MyAmexAPI.new
api.most_recent
#=> {:Success=>"true", :ReturnItems=>{"Content"=>[{"Title"=>"Why LEDs Are a Vital Business Upgrade", "TeaserText"=>"How...}

Making Arbitrary Requests

Since the gem mixes HTTParty into your class for you – you can call HTTParty methods like
bc. MyAmexAPI.get(“/arbitrary/path”)

XML maketh Ugly Method Names

The beauty of HTTParty’s parser is – it translates XML responses into a nice hash.
The beauty of OpenCascade is – it translates that hash into methods.
Open Forum’s API responds with (surprise!) XML with leading-capitalized nodes – so out-of-the-box, you’re methods
would look like api.most_recent.ReturnItems.Content…urf!

AmexOpenForum (ab)uses method_missing, allowing you to call underscorized versions of those node names.
so you could respect the XML’s capitalization and call api.most_recent.ReturnItems.Content OR
give your eyes a break and call api.most_recent.return_items.content

Additional Resources

Something went wrong with that request. Please try again.