Carriage is a Ruby wrapper to Amazon's Cart Form functionality
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.
Add this line to your application’s Gemfile:
gem 'carriage'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install carriage
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:
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!
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)
ASIN
or ID
(short for OfferListingId
) key provided. All keys are case insensitive.Carriage.build
also requires :tag
attribute (short for AssociateTag
)locale: :us
, if no other locale was provided.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
Logo was done by Max Kazmin
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the Carriage project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.