1

我正在使用a2z gem来处理亚马逊的产品广告 API,当我尝试在 item_lookup 请求中指定多个 product_id 时,我遇到了 gem 的这个问题。这是我可以解决的问题,还是我必须联系 gem 作者?

can't convert String into Integer

这是我的代码:

def product_lookup
    # Check which Retailer this is for
    case params[:retailer] 
        when "amazon"
            client = A2z::Client.new(key: ENV["AMAZON_PAAPI_KEY"], secret: ENV["AMAZON_PAAPI_SECRET"], tag: ENV["AMAZON_PAAPI_TAG"])
            product_ids = []
            product_ids << product_one_id = params[:product_one_id]
            product_ids << product_two_id = "B00D43QGPS"
            product_ids = product_ids.join(",")

            @products = client.item_lookup do
                 id product_ids
                 response_group 'Small, Images, OfferListings'
            end

            render :json => @products

    end
end
4

1 回答 1

1

Gem creator here. :) Thanks for the question and for adding the issue on Github.

I'm wondering if something changed either in a gem dependency or in the Amazon response structure, unless I just inadvertently broke it through another change since the gem is lacking tests at the moment.

I see what the problem is: the response is an array of hashes (i.e.: multiple products), and I'm just treating it as a hash (i.e.: a single product). I'll need to change the response parsing to account for arrays, which shouldn't be too hard. Let me see if I can get a fix together.

于 2013-08-19T00:45:38.973 回答