Skip to content

Instantly share code, notes, and snippets.

@guilhermesilveira
Created June 9, 2010 00:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guilhermesilveira/430873 to your computer and use it in GitHub Desktop.
Save guilhermesilveira/430873 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'restfulie'
# retrieves the list
resource = Restfulie.at("http://localhost:3000/items").accepts("application/xml").get
# picks the first item
basket = {"basket" => {"items" => [{"id" => resource.items.item.first["id"]}]}}
# creates the basket
resource = resource.items.links.basket.post! basket
# prepares the payment
payment = {"payment" => {"cardnumber" => "4850000000000001", "cardholder" => "guilherme silveira", :amount => resource.basket.price}}
# creates the payment
resource = resource.basket.links.payment.post! payment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment