Skip to content
/ vacuum Public
forked from hakanensari/vacuum

A Ruby wrapper to the Amazon Product Advertising API

License

Notifications You must be signed in to change notification settings

donmb1/vacuum

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vacuum

Build Status

Vacuum is a Ruby wrapper to the Amazon Product Advertising API.

vacuum

Usage

Set up a request:

req = Vacuum.new
  .configure(
    aws_access_key_id:     'foo',
    aws_secret_access_key: 'secret',
    associate_tag:         'biz-val'
  )

The locale defaults to the US. If you wish to use another locale, specify its ISO-3166 two-letter code when instantiating the request:

Vacuum.new('GB')

Make a request:

params = { 'Operation'   => 'ItemSearch',
           'SearchIndex' => 'Books',
           'Keywords'    => 'Architecture' }

res = req.get(query: params)

Once you have a response, parse it with your favourite XML parser and parsing method.

If you don't mind the performance hit, here is a simplistic solution based on MultiXml:

require 'forwardable'
require 'multi_xml'

class Response
  extend Forwardable

  def_delegators :@response, :code, :body

  def initialize(response)
    @response = response
  end

  def to_h
    MultiXml.parse(body)
  end
end

Response.new(res).to_h

About

A Ruby wrapper to the Amazon Product Advertising API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 100.0%