Net::Amazon::RemoteCart

Net::Amazon::RemoteCart is a Perl extension for dealing with Amazon.com's remote shopping cart API.
Download

Net::Amazon::RemoteCart Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • David Emery
  • Publisher web site:
  • http://search.cpan.org/~demery/Net-Amazon-RemoteCart-0.03/lib/Net/Amazon/RemoteCart.pm

Net::Amazon::RemoteCart Tags


Net::Amazon::RemoteCart Description

Net::Amazon::RemoteCart is a Perl extension for dealing with Amazon.com's remote shopping cart API. Net::Amazon::RemoteCart is a Perl extension for dealing with Amazon.com's remote shopping cart API.SYNOPSIS use Net::Amazon::RemoteCart; # Start a new cart my $cart = Net::Amazon::RemoteCart->new ( token =>'my_amazon_developer_token' , affiliate_id =>'my_amazon_assoc_id', ); # Add some stuff my $res = $cart->add( 'myasin' =>1, 'myotherasin'=>4 ); # See if our request succeeded unless ($res->status == 1){ print "Problem with Amazon request: ", $res->message, "n"; } # Get data for all cart items my $arrayref_of_item_data = $cart->get_items(); # Get info for a single item based on its ASIN my $item = $cart->get_item('myasin'); # Get the total cost of the items in the cart my $total = $cart->total_cost(); # Maybe save the cart in a session object like CGI::Session $session->param("cart", $cart); # A later request... # Recreate the cart from the one saved in session rt_params = %{ $session->param("cart") }; my $cart = Net::Amazon::RemoteCart->new(rt_params); # Or instead... my $cart = Net::Amazon::RemoteCart->new ( token =>my_amazon_developer_token , affiliate_id =>my_amazon_assoc_id, cart_id =>mycart_id, hmac =>mycart_hmac, ); # update local cart instance by fetching from Amazon $res = $cart->sync(); # Modify quantities my $res = $cart->modify('myasin' =>2, 'myotherasin'=>1 ); # Remove items $res = $cart->remove('myasin1', 'myasin2'); # Get a list similar products (ASINS) $arrayref_of_asins = $cart->similar_products(); # Get the URL for transferring the user and cart # over to Amazon for checkout $url_string = $cart->purchase_url();RemoteCart is an interface to Amazon Web Services Remote Cart API, built on Mike Schilli's Net::Amazon package.RemoteCart attempts to be a consistent and easy to use interface to the Amazon remote cart API. I've tried to make it work as closely as is practical to how someone (Ok, by someone I mean ME) would expect a shopping cart to work. It has methods to add, remove, fetch items, and modify their quantities based on the product's ASIN.Each time a request goes to Amazon's remote cart (i.e. for adding, modifying, removing items, or running sync(), etc.), AWS returns the data for the whole cart. So the RemoteCart module will update it's own representation of the cart each time this happens. Then when you access methods like get_items() or purchase_url(), the data is retrieved from the local instance of the cart rather than accessing Amazon's server every time.One thing it doesn't do for you is maintain state between requests. This can be done either by saving the cart object in a session and passing that to new() on the next request, or by saving just the cart_id and hmac (returned from Amazon) and passing those to new() and then running sync() or get_items_online() to refetch the cart data.I've also added a couple of convenience methods like total_cost(), and formatted versions of the prices that I think are useful but not provided from Amazon's end. Requirements: · Perl


Net::Amazon::RemoteCart Related Software