carriage

Carriage is a Ruby wrapper to Amazon's Cart Form functionality

View the Project on GitHub skatkov/carriage

Gem Version Maintainability Build Status

Carriage

Carriage project logo

Carriage is a Ruby wrapper to Amazon’s Cart Form functionality. Gem helps add any number of items to customer’s shopping cart and direct him to Amazon website to complete order.

To use this gem, you will eventually require Amazon’s AssociateTag, so consider to register first with Amazon Associate program and become more familiar with it.

Programmatic access to product data is out of scope for this gem, but I recommend to use vacuum gem if there is such a need.

Battle tested at aShop

Installation

Add this line to your application’s Gemfile:

gem 'carriage'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install carriage

Usage

A lot of examples could be found in tests

There are basically two ways to use this gem bare metal and with builder. Let’s start off with baremetal:

Bare metal

Carriage.call(:us, {
  AssociateTag:'tag', 
  "OfferListingId.1": "B00WR23X5I", 
  "Quantity.1": 1 
 }
)

The only thing it will validate, is a presence of locale. All other parameters will be converted by URI.encode_www_form without any verification. Be carefull!

Builder

Library also offers a simpler interface that tries to valide data with convinince methods on top.

items = [
 {Id: '123123'}.
 {ASIN: '1231234', quantity: 2}
]

Carriage.build(items, tag: 'my_attribution_tag', locale: :uk)

Locale

All locale are based on a two letter country codes - ISO 3166-1 alpha-2. Here is an exact mapping:

https://github.com/skatkov/carriage/blob/master/lib/carriage/locale.rb#L7-L23

Getting help

Credits

Logo was done by Max Kazmin

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Carriage project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.