Code Monkey home page Code Monkey logo

asin's Introduction

asin's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

asin's Issues

Maybe it's a good idea to change XML serialization library?

I've ran into an issue that data returned from amazon had different property names ('TinyImage' vs 'tiny_image') -- that caused me to write a lot of hacks and wordarounds to deal with. While i expected asin library and code seemed reasonable, i was really puzzled why would amazon do such a thing with me (or us) :D

But I think that this weirdness is explained by one of dependencies used in this project, it has a code like this:

https://github.com/jnunemaker/crack/blob/master/lib/crack/util.rb

I don't think that altering objects is a good idea for any Xml serialization library. So maybe it's a good opportunity to change dependency to something like multiXml ( https://github.com/sferik/multi_xml ) ?

NoMethodError: undefined method `each_pair' error when searching for an ISBN

When doing a search_keywords for an ISBN number (e.g. for 0471317519) I receive the following error:

NoMethodError: undefined method `each_pair' for ["ASIN", "0471317519"]:Array

After a bit of investigation here is what I've found:

when TotalResults > 1 then response['ItemSearchResponse']['Items'] is a an array of hashes

when totalResults == 1 then response['ItemSearchResponse']['Items'] is a single hash

ASIN::Configuration clashing with a Configuration model already in my app

Hi there,

My app has a Configuration.rb model. Short of renaming it, how can avoid the clash with ASIN::Configuration?

When I comment out the contents of asin.rb (to allow the app to start), enter the rails console, and type ASIN:Configuration, I see:

Configuration(id: integer, name: string, cached_slug: string, model_id: integer, configured_ram: float, requires: string, created_at: datetime, updated_at: datetime)

These are the attributes of my app's existing Configuration model, not ASIN:Configuration.

Many thanks,

Steven.

How to get list of products for a particular store only

I am using product advertising api for fetching amazon products. API returns product from different store.
I want to fetch products from my store only.

Let say "ABC" is my amazon store and I want to fetch all products belongs to "ABC" only.

Please help me.

Example are broken ...

In your doco you say this:

lookup an item with the amazon standard identification number (asin)

items = client.lookup '1430218150'

have a look at the title of the item

items.first.item_attributes.title
=> Learn Objective-C on the Mac (Learn Series)

BUT if you execute that it fails saying 'item_attributes' method undefined.

What is the set of methods you can call on a returned item given they are not defined on the SimpleItem class?

Push version to RubyGems with updated HTTPI dependency

Hi !

The version of asin found on RubyGems still depends on

HTTPI ~> 0.9

which breaks other Gems such as savon (soap client) which requires

HTTPI ~> 1.0

Can you please push an updated version (its already changed in master I think) ?

Thx

undefined method `options' for nil:NilClass

I'm having a weird issue.

I have the following file in the lib folder of my Rails App:

require 'asin'

module YoofersAsin
  # set up a client to talk to the AWS REST API
  @client = ASIN::Client.instance

  def self.search keywords, index = :All, response_group = :Large
    begin
      @client.search(:Keywords => keywords, :SearchIndex => index, :ResponseGroup => response_group)
    rescue HTTPClient::ConnectTimeoutError
      []
    end
  end

  def self.format_result_for_dropdown results
    results.map { |item| { title: item.title, price: item.formatted_amount, image_url: item.image_url, url: item.details_url } }
  end

  # as long as the max is less than the min, it can be ignored
  def self.limit_price_range results, min = 100, max = 200
    if max <= min
      results.select { |each| each.amount >= min }
    else
      results.select { |each| each.amount >= min && each.amount <= max }
    end
  end

  def self.autocomplete keywords, index = :All, response_group = :Large
    results = self.search(keywords, index, response_group)
    results = self.limit_price_range results
    self.format_result_for_dropdown results
  end
end

require 'hashie'
module ASIN
  class SimpleItem
    def formatted_amount
      @raw.ItemAttributes!.ListPrice!.FormattedPrice
    end
  end
end

I'm calling it from a controller like this:

class AmazonSearchController < ApplicationController
  respond_to :json

  def index
     @response = YoofersAsin.autocomplete(params[:term])
     respond_with(@response)
  end
end

When I call the index action of the controller I get the following error:

undefined method `options' for nil:NilClass

lib/yoofers_asin.rb:9:in `search'
lib/yoofers_asin.rb:29:in `autocomplete'
app/controllers/amazon_search_controller.rb:5:in `index'

the full trace is:

confiture (0.1.2) lib/confiture/configuration.rb:152:in `method_missing'
confiture (0.1.2) lib/confiture/configuration.rb:123:in `blank?'
confiture (0.1.2) lib/confiture/configuration.rb:103:in `block in valid?'
confiture (0.1.2) lib/confiture/configuration.rb:103:in `each'
confiture (0.1.2) lib/confiture/configuration.rb:103:in `none?'
confiture (0.1.2) lib/confiture/configuration.rb:103:in `valid?'
confiture (0.1.2) lib/confiture/configuration.rb:95:in `validate!'
asin (1.1.0) lib/asin/client.rb:360:in `call'
asin (1.1.0) lib/asin/client.rb:196:in `search'
lib/yoofers_asin.rb:9:in `search'
lib/yoofers_asin.rb:29:in `autocomplete'
app/controllers/amazon_search_controller.rb:5:in `index'
actionpack (3.2.8) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.2.8) lib/abstract_controller/base.rb:167:in `process_action'
actionpack (3.2.8) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (3.2.8) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (3.2.8) lib/active_support/callbacks.rb:447:in `_run__2410238790327027604__process_action__3423452464221231008__callbacks'
activesupport (3.2.8) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.8) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
activesupport (3.2.8) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.8) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.2.8) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (3.2.8) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.2.8) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.8) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.8) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.8) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.2.8) lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
newrelic_rpm (3.5.0.1) lib/new_relic/agent/instrumentation/rails3/action_controller.rb:34:in `block in process_action'
newrelic_rpm (3.5.0.1) lib/new_relic/agent/instrumentation/controller_instrumentation.rb:268:in `block in perform_action_with_newrelic_trace'
newrelic_rpm (3.5.0.1) lib/new_relic/agent/method_tracer.rb:242:in `trace_execution_scoped'
newrelic_rpm (3.5.0.1) lib/new_relic/agent/instrumentation/controller_instrumentation.rb:263:in `perform_action_with_newrelic_trace'
newrelic_rpm (3.5.0.1) lib/new_relic/agent/instrumentation/rails3/action_controller.rb:33:in `process_action'
actionpack (3.2.8) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.2.8) lib/abstract_controller/rendering.rb:45:in `process'
actionpack (3.2.8) lib/action_controller/metal.rb:203:in `dispatch'
actionpack (3.2.8) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.2.8) lib/action_controller/metal.rb:246:in `block in action'
actionpack (3.2.8) lib/action_dispatch/routing/route_set.rb:73:in `call'
actionpack (3.2.8) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
actionpack (3.2.8) lib/action_dispatch/routing/route_set.rb:36:in `call'
journey (1.0.4) lib/journey/router.rb:68:in `block in call'
journey (1.0.4) lib/journey/router.rb:56:in `each'
journey (1.0.4) lib/journey/router.rb:56:in `call'
actionpack (3.2.8) lib/action_dispatch/routing/route_set.rb:600:in `call'
omnicontacts (0.2.2) lib/omnicontacts/middleware/base_oauth.rb:41:in `call'
omnicontacts (0.2.2) lib/omnicontacts/middleware/base_oauth.rb:41:in `call'
omnicontacts (0.2.2) lib/omnicontacts/middleware/base_oauth.rb:41:in `call'
omnicontacts (0.2.2) lib/omnicontacts/builder.rb:27:in `call'
rack-timeout (0.0.3) lib/rack/timeout.rb:16:in `block in call'
/Users/ychaker/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/timeout.rb:68:in `timeout'
rack-timeout (0.0.3) lib/rack/timeout.rb:16:in `call'
newrelic_rpm (3.5.0.1) lib/new_relic/rack/error_collector.rb:8:in `call'
newrelic_rpm (3.5.0.1) lib/new_relic/rack/browser_monitoring.rb:12:in `call'
newrelic_rpm (3.5.0.1) lib/new_relic/rack/developer_mode.rb:24:in `call'
mongoid (3.0.10) lib/rack/mongoid/middleware/identity_map.rb:34:in `call'
client_side_validations (3.2.1) lib/client_side_validations/middleware.rb:21:in `call'
warden (1.2.1) lib/warden/manager.rb:35:in `block in call'
warden (1.2.1) lib/warden/manager.rb:34:in `catch'
warden (1.2.1) lib/warden/manager.rb:34:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.4.1) lib/rack/etag.rb:23:in `call'
rack (1.4.1) lib/rack/conditionalget.rb:25:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/flash.rb:242:in `call'
rack (1.4.1) lib/rack/session/abstract/id.rb:205:in `context'
rack (1.4.1) lib/rack/session/abstract/id.rb:200:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/cookies.rb:339:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (3.2.8) lib/active_support/callbacks.rb:405:in `_run__705490732763847319__call__2964165817004619242__callbacks'
activesupport (3.2.8) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.8) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
activesupport (3.2.8) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.8) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/reloader.rb:65:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.8) lib/rails/rack/logger.rb:26:in `call_app'
railties (3.2.8) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.1) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.1) lib/rack/runtime.rb:17:in `call'
activesupport (3.2.8) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.4.1) lib/rack/lock.rb:15:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/static.rb:62:in `call'
railties (3.2.8) lib/rails/engine.rb:479:in `call'
railties (3.2.8) lib/rails/application.rb:223:in `call'
rack (1.4.1) lib/rack/content_length.rb:14:in `call'
railties (3.2.8) lib/rails/rack/log_tailer.rb:17:in `call'
rack (1.4.1) lib/rack/handler/webrick.rb:59:in `service'
/Users/ychaker/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
/Users/ychaker/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
/Users/ychaker/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'

The weird part is that if I go to the rails console and call the same method as I do in the index action, I get the results just fine.

My initializer looks like this:

ASIN::Configuration.configure do |config|
  config.secret         = "***********"
  config.key            = "************"
  config.associate_tag  = "*********"
end

require 'httpi'
HTTPI.adapter = :httpclient
HTTPI.logger  = Rails.logger

I'm running ruby '1.9.3' and rails '3.2.8'

So, 'rails c' works, 'rails s' does not! very odd!

Any ideas?

check compatibility with new AWS certificates

Dear Associate,

We have an important update for you regarding the Amazon Product Advertising API.

Certificate Authorities (CAs) and companies such as Google and Microsoft are retiring support for SHA1 as a hashing algorithm used to sign SSL/TLS certificates (for more information, please read the CA/Browser Forum post). Because of this, the Amazon Product Advertising API will also be retiring use of SHA1 for digital signatures in SSL/TLS certificates and will be upgrading to SHA256 by October 09, 2015. This means that customers accessing the Product Advertising API via HTTPS will need to make sure they’re using the latest certificate bundles on their client machines.

The questions below should help you ensure you’re ready when we switch to SHA256:

  1. What action do I need to take?

You need to verify if your applications are compatible with our new certificate. Simply run an API request to one of the following testing endpoints:

US https://sha256.webservices.amazon.com/onca/xml

If you are able to run the request successfully, your software is compatible with our new certificates.

  1. I was able to get a successful response using the testing endpoint. What do I do now?

Nothing! If your application was able to get a successful response using the testing endpoint, then you will be able to access the API even after the SHA256 migration.

  1. I was unable to get a response using the testing endpoint. What do I do now?

If you were unable to get a response using the testing endpoint, then you will have to ensure you are using more recent libraries of the programming/scripting language to access the API. For compatibility, the client libraries will require the following:
Java: Requires JDK 1.6.0_19 or later.
PHP: Requires OpenSSL 0.9.8o or later.
C#: No change.

You can update the certificate bundle in your browser simply by updating your browser. Instructions for the most common browsers can be found on the browsers’ websites: Chrome, FireFox, and Safari. Certificate bundles for Internet Explorer are managed by the Windows OS, so ensure that you update the OS as well.

If you need development support beyond the above suggestions, please post your questions to the Product Advertising API forum under the Advisory: Product Advertising API to switch to SHA256 Hash Algorithm thread. Many experienced members of the Amazon Associates program regularly participate in the forums.

  1. Do I need to update the endpoint for accessing Product Advertising API to the above listed endpoints?

No, the listed endpoints are only for testing purposes and will be discontinued post migration.

  1. By when do I need to make the change/ update?

You can do this change at any time on or before October 09, 2015. Any changes you make will be compatible with our existing URL(s).

Thank you for your understanding and cooperation.

The Amazon Product Advertising API team.

Find only books w/images

Using code like the following, I'm pulling down a list of books.

t = tags.collect {|x| x.name}
client = ASIN::Client.instance
books = (client.search_keywords t)

Works great, except that sometimes it grabs a book like this one: http://www.amazon.com/Lasers-Lynn-Myring/dp/0613769902%3FSubscriptionId%3DAKIAINAJKLF3WOPY77OA%26tag%3Dwha07-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D0613769902

which doesn't have an image, so it displays poorly on my page. I could set a 'default' image, but overall, I'd just rather not retrieve ones without an image. Is this possible, or does the Amazon API (or the gem) not allow that?

different languages

Hi!

Is it possible to change the language dynamically for the amazon results? I only get US-results at the moment and I also like to receive german results.
How could I change your gem to provide this feature also? Any suggestions?
Best regards.

Matthias

How can I pull image url(s) ?

Hey, thanks for making this gem. newbie here.

I was able to get up and running with the gem and able to fetch the Item details. But "item_attributes" does not seem to have images to it. Is there a way I can pull images ?

Thanks again.

Response not contain image product

require 'asin'
    ASIN::Configuration.configure do |config|
      config.secret        = 'SG7Z6LG8SxLk4vTC*********+s/hqOThFhOb'
      config.key           = 'AKIAI********RMMKU5NGQ'
      config.associate_tag = 'books'
    end
    client = ASIN::Client.instance
    book = client.search(:Keywords => 'William W. Purkey', :SearchIndex => :Books).first

result call back is book "From Conflict to Conciliation: How to Defuse Difficult Situations by William W. Purkey, John J. Schmidt and John M. Novak".
I can get title, details_url, but image_url is nil. IN result I see "LargeImage=#Hashie::Mash>>", BUT in website search I see it have image

http://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Dstripbooks&field-keywords=William%20W.%20Purkey

ASIN + Unicorn?

I just migrated from Thin to Unicorn, everything's working except ASIN. I'm getting the following error, do I need to configure an "after_fork" method or something in order for ASIN to work with Unicorn?

Here's a portion of the error message:

<div id="Framework-Trace" style="display: none;">
      <pre><code>confiture (0.1.2) lib/confiture/configuration.rb:152:in `method_missing'
confiture (0.1.2) lib/confiture/configuration.rb:123:in `blank?'
confiture (0.1.2) lib/confiture/configuration.rb:103:in `block in valid?'
confiture (0.1.2) lib/confiture/configuration.rb:103:in `each'
confiture (0.1.2) lib/confiture/configuration.rb:103:in `none?'
confiture (0.1.2) lib/confiture/configuration.rb:103:in `valid?'
confiture (0.1.2) lib/confiture/configuration.rb:95:in `validate!'
asin (1.1.0) lib/asin/client.rb:360:in `call'
asin (1.1.0) lib/asin/client.rb:196:in `search'
actionpack (3.2.6) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.2.6) lib/abstract_controller/base.rb:167:in `process_action'

Care required with dependent module versioning when using excon with httpi

By default, httpi uses excon, but there can be version-related issues between these two libraries, causing Amazon to report that the Signature does not match. By changing to curb, this problem disappears. It may be the case that the correct combination of versions works, but I was not able to determine the correct combination. This can be done by adding 'require "curb"' prior to the 'require "asin"' command.

SearchBins Response Group does not return any Search Bins

Adding SearchBins Response Group return only ASINS and PARENT_ASINS but not Search Bins.

For example
request:
@search = @client.search SearchIndex: :Baby, Keywords: 'pants', ResponseGroup: :SearchBins

Response:
[{"asin":"B016YZGI5K","parent_asin":"B00UZRKZTE"},{"asin":"B00XZ19MS2","parent_asin":"B00YFD0SGE"},{"asin":"B0133JD07Y","parent_asin":"B0133JAE8W"},{"asin":"B017NT1UFY","parent_asin":"B017NT1F4A"},{"asin":"B00PZVDFDI","parent_asin":"B00PZVCI8Q"},{"asin":"B012TV6920","parent_asin":"B00JABR8KA"},{"asin":"B017NT234G","parent_asin":"B017NT1HH0"},{"asin":"B017NT1U6S","parent_asin":"B017NT1FCC"},{"asin":"B0133JEGO0","parent_asin":"B00LAYTVJQ"},{"asin":"B012U6XCV0","parent_asin":"B00JABR8LO"}]

Prevent stdout logging

As asin uses httpi, I presumed one could disable the default stdout logging using:

HTTPI.log = false

However this does not suppress the lookup response output. Is there some other setting one could use to suppress this output? It is of course useful for debugging but otherwise unnecessary.

Jason

Latest Ruby/Rails issue...

Ruby 1.9.3p392, Rails 3.2.13, I get the following error on some products:

uninitialized constant REXML::Text::Document

The line that causes it is this:
@Items = client.lookup @item.asin

client is client = ASIN::Client.instance

Latest Amazon changes to product API seemed to result in errors

I'm using the asin gem (https://github.com/phoet/asin) to make requests to Amazon Product API.

It has been working well for a whole year but a few days ago without making any changes I started noticing the same product API requests now return the following error:

<ItemLookupErrorResponse xmlns="http://ecs.amazonaws.com/doc/2011-08-01/"><Error><Code>SignatureDoesNotMatch</Code><Message>The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.</Message></Error><RequestId>314b6504-8845-43a1-bdf6-53b02bbc974b</RequestId></ItemLookupErrorResponse>'
RuntimeError: request failed with response-code='403'
    from /usr/local/rvm/gems/ruby-1.9.3-p484/gems/asin-2.0.1/lib/asin/client.rb:264:in `call'
    from /usr/local/rvm/gems/ruby-1.9.3-p484/gems/asin-2.0.1/lib/asin/client.rb:55:in `lookup'
    from (irb):5
    from /usr/local/rvm/gems/ruby-1.9.3-p484/gems/railties-3.2.8/lib/rails/commands/console.rb:47:in `start'
    from /usr/local/rvm/gems/ruby-1.9.3-p484/gems/railties-3.2.8/lib/rails/commands/console.rb:8:in `start'
    from /usr/local/rvm/gems/ruby-1.9.3-p484/gems/railties-3.2.8/lib/rails/commands.rb:41:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

The original request still works, so I'm assuming that some changes on Amazon product API made the asin gem incompatible:

http://webservices.amazon.com/onca/xml?AWSAccessKeyId=<my-key>&AssociateTag=<my-tag>&Keywords=apple&Operation=ItemSearch&ResponseGroup=ItemAttributes&SearchIndex=UnboxVideo&Service=AWSECommerceService&Timestamp=2014-07-25T23%3A57%3A23Z&Version=2011-08-01&Signature=<hash>

Getting an error from within the Asin gem...

Hey, many thanks for this gem. I've been able to use it to query the Amazon API by manually loading it into IRB. When I tried to load it into my rails application I ran into some problems though.

Not sure if I'm doing it wrong or not. Here is what I have:

config/initializers/asin.rb:
require 'asin'
include ASIN
configure :secret => '', :key => ''

and when I start the rails app (rails s or rails c) I get a stackdump starting with:
/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/asin-0.0.8/lib/asin.rb:91:in `merge!': can't convert Class into Hash (TypeError)

I'm done working for the night, but tomorrow I'll probably crack open the gem and see what I can find.

Readme correction for properly finding the Formatted Price

I was checking this out and I see that the example is incorrect.
access the internal data representation (Hashie::Mash)
item.raw.ItemAttributes.ListPrice.FormattedPrice
=> $39.99

If you are following along with the previous examples (VERY helpful for noobs), the proper syntax is:
items.first.raw.ItemAttributes.ListPrice.FormattedPrice

empty price for some asin

when i look some asins like B00X4WSLS4 it does not return me price anywhere how i can lookup its price and all colors?

Question: Getting lowest new price including shipping

Currently I can get the list price or the lowest new price but the lowest new price doesn't include shipping. Does anyone have any idea as to how I can get the lowest new price including shipping?

Edit: Apparently, due to a recent change, Amazon no longer offers the ability to grab the lowest price via their API. I just wanted to update this comment in case anyone is running into the same problem as I was. I solved it by using Nokogiri to scrape the product details page for the price.

ItemAttributes Missing?

This code:
https://gist.github.com/880611

Produces the below output. It seems like I'm not getting back the expected ItemAttributes.


D, [2011-03-21T21:55:33.830684 #11869] DEBUG -- : calling with params={:Operation=>:ItemLookup, :ItemId=>"020161622X"}
I, [2011-03-21T21:55:33.830975 #11869]  INFO -- : performing rest call to url='http://webservices.amazon.com/onca/xml?AWSAccessKeyId=...'
D, [2011-03-21T21:55:33.831260 #11869] DEBUG -- : HTTPI executes HTTP GET using the httpclient adapter
D, [2011-03-21T21:55:34.073197 #11869] DEBUG -- : got response='<?xml version="1.0" ?><ItemLookupResponse xmlns="http://webservices.amazon.com/AWSECommerceService/2005-10-05"><OperationRequest><RequestId>3454bf50-6233-4bd8-9c9b-120fd6ddc8e6</RequestId><Arguments><Argument Name="Operation" Value="ItemLookup"></Argument><Argument Name="Service" Value="AWSECommerceService"></Argument><Argument Name="ItemId" Value="020161622X"></Argument><Argument Name="AWSAccessKeyId" Value="KEY"></Argument><Argument Name="Timestamp" Value="2011-03-22T01:55:33Z"></Argument><Argument Name="Signature" Value="SIGNATURE"></Argument></Arguments><RequestProcessingTime>0.0078060000000000</RequestProcessingTime></OperationRequest><Items><Request><IsValid>True</IsValid><ItemLookupRequest><Condition>New</Condition><DeliveryMethod>Ship</DeliveryMethod><IdType>ASIN</IdType><MerchantId>Amazon</MerchantId><OfferPage>1</OfferPage><ItemId>020161622X</ItemId><ResponseGroup>Small</ResponseGroup><ReviewPage>1</ReviewPage></ItemLookupRequest></Request><Item><ASIN>020161622X</ASIN><DetailPageURL>http://www.amazon.com/Pragmatic-Programmer-Journeyman-Master/dp/020161622X%3FSubscriptionId%3DAKIAIJ7ILTHT3NAFDDPQ%26tag%3Dws%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D020161622X</DetailPageURL><ItemAttributes><Author>Andrew Hunt</Author><Author>David Thomas</Author><Manufacturer>Addison-Wesley Professional</Manufacturer><ProductGroup>Book</ProductGroup><Title>The Pragmatic Programmer: From Journeyman to Master</Title></ItemAttributes></Item></Items></ItemLookupResponse>'

{"Author"=>["Andrew Hunt", "David Thomas"],
 "Manufacturer"=>"Addison-Wesley Professional",
 "ProductGroup"=>"Book",
 "Title"=>"The Pragmatic Programmer: From Journeyman to Master"}

SignatureDoesNotMatch

Hi,

I've been using the asin gem for months without any problems but now all of a sudden I get these errors on all my api calls:

SignatureDoesNotMatchThe request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.eb0458ea-0d4c-42ea-bd0b-4ba3b8eddc79'

These are the params I'm sending:

D, [2017-08-01T13:34:02.116024 #9058] DEBUG -- : calling with params={:Keywords=>"pampers baby dry 2 22", :SearchIndex=>"Baby", :Operation=>:ItemSearch}
I, [2017-08-01T13:34:02.116742 #9058] INFO -- : performing rest call to url='http://webservices.amazon.de/onca/xml?AWSAccessKeyId=AKIAJMVM7ENHSE65I23Q&AssociateTag=i0616-21&Keywords=pampers%20baby%20dry%202%2022&Operation=ItemSearch&SearchIndex=Baby&Service=AWSECommerceService&Timestamp=2017-08-01T11%3A34%3A02Z&Version=2011-08-01&Signature=9zSE%2BHIFFqYR5PUnOHf%2Fpwmb3NtShIB5y8zevGhtccw%3D'

I didn't change anything (I think) and I've made several new access key id's and they all give the same error.

I think it has to do with the %2B (+) and %3D (=) in the signature which must be some kind of character encoding thingy going wrong...

Thnx!

Reinier

Search returning REXML::ParseException error

I found that the search function for some queries frequently returns REXML::ParseException error. The issue is especially severe on Heroku Cedar stack (for unknown reason). And it only happens for some queries. I'm suspecting that there are some issues with parsing the XML response.

The following is my code:

client = ASIN::Client.instance

client.search(:Keywords => "Shark Tale", :SearchIndex => :UnboxVideo, :ResponseGroup => :ItemAttributes)

And the following is the error I'm seeing. It rarely fails on my local machine, but it shows up frequently on heroku:

REXML::ParseException: #<NoMethodError: undefined method `[]' for nil:NilClass>
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/rexml/parsers/baseparser.rb:340:in `pull_event'
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/rexml/parsers/baseparser.rb:183:in `pull'
/app/vendor/bundle/ruby/2.0.0/gems/crack-0.4.0/lib/crack/xml.rb:203:in `parse'
/app/vendor/bundle/ruby/2.0.0/gems/crack-0.4.0/lib/crack/xml.rb:235:in `parse'
/app/vendor/bundle/ruby/2.0.0/gems/asin-1.1.2/lib/asin/client.rb:375:in `call'
/app/vendor/bundle/ruby/2.0.0/gems/asin-1.1.2/lib/asin/client.rb:197:in `search'
(irb):223:in `irb_binding'
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/irb/workspace.rb:86:in `eval'
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/irb/workspace.rb:86:in `evaluate'
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/irb/context.rb:380:in `evaluate'
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/irb.rb:492:in `block (2 levels) in eval_input'
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/irb.rb:624:in `signal_status'
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/irb.rb:489:in `block in eval_input'
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/irb/ruby-lex.rb:247:in `block (2 levels) in each_top_level_statement'
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/irb/ruby-lex.rb:233:in `loop'
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/irb/ruby-lex.rb:233:in `block in each_top_level_statement'
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/irb/ruby-lex.rb:232:in `catch'
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/irb/ruby-lex.rb:232:in `each_top_level_statement'
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/irb.rb:488:in `eval_input'
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/irb.rb:397:in `block in start'
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/irb.rb:396:in `catch'
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/irb.rb:396:in `start'
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.8/lib/rails/commands/console.rb:47:in `start'
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.8/lib/rails/commands/console.rb:8:in `start'
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.8/lib/rails/commands.rb:41:in `<top (required)>'
script/rails:6:in `require'
script/rails:6:in `<main>'
...
Exception parsing
Line: 1
Position: 30315
Last 80 unconsumed characters:
Actor><Actor>Matthew Broderick</Actor><Actor>Patrick Warburton</Actor><Actor>J
from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/rexml/parsers/baseparser.rb:439:in `rescue in pull_event'
from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/rexml/parsers/baseparser.rb:331:in `pull_event'
from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/rexml/parsers/baseparser.rb:183:in `pull'
from /app/vendor/bundle/ruby/2.0.0/gems/crack-0.4.0/lib/crack/xml.rb:203:in `parse'
from /app/vendor/bundle/ruby/2.0.0/gems/crack-0.4.0/lib/crack/xml.rb:235:in `parse'
from /app/vendor/bundle/ruby/2.0.0/gems/asin-1.1.2/lib/asin/client.rb:375:in `call'
from /app/vendor/bundle/ruby/2.0.0/gems/asin-1.1.2/lib/asin/client.rb:197:in `search'
from (irb):223
from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.8/lib/rails/commands/console.rb:47:in `start'
from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.8/lib/rails/commands/console.rb:8:in `start'
from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.8/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'

An example where this issue doesn't occur is with a slightly different query

client.search(:Keywords => "Shark Tales", :SearchIndex => :UnboxVideo, :ResponseGroup => :ItemAttributes)

Add a way to find similar products

The amazon product API appears to support similar products but I don't see support for it in ASIN. Is this something you are intending to add support for?

Aligning ASIN's terminology with Amazon's

ASIN's read me talks about:

config.secret = 'your-secret'
config.key = 'your-key'
config.associate_tag = 'your-tag'

Amazon's Product API website talks about:

Secret Key
Access Key ID
Associate ID

Are these the same thing? (I can't test this myself due to the other issue I just reported via your GitHub page.)

If they are the same, I'll fork the gem, edit the 'read me' to what follows, then submit a pull request:

config.secret = 'your Secret Key'
config.key = 'your Access Key ID'
config.associate_tag = 'your Associate ID'

Hashie::Rash namespace collision in newer versions of Hashie & Rash gems

Hi.

In the current version of Hashie, Rash is used for a regular expression-based hash, and the Rash gem's definitions of Rash gets overridden by the Hashie Gem's own. wzcolon has forked the gem to use a new namespace for the class. (Hashie::Hash::Rash, see https://github.com/wzcolon/rash.)

Would you accept a pull request to point at the new version of Rash? The tests currently pass but moving forward to the current version of Hashie is required for some other products.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.