Project

carriage

0.01
No commit activity in last 3 years
No release in over 3 years
Gem helps add any number of items to customer's shopping cart and direct him to Amazon website to complete order.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0
 Project Readme

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)
  • Every item should be a hash, with ASIN or ID (short for OfferListingId) key provided. All keys are case insensitive.
  • By default quantity is 1, feel free to rewrite that.
  • Carriage.build also requires :tag attribute (short for AssociateTag)
  • Defaults to locale: :us, if no other locale was provided.

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.