mhuggins / a2z

Simple Ruby DSL for searching & retrieving items from the Amazon Product Advertising API
MIT License
41 stars 9 forks source link

Item is nil. Beginner question, maybe? #12

Closed jmalley closed 9 years ago

jmalley commented 9 years ago

I believe I have set it up correctly. I am getting a response that has an 'item' method in it, but the item is always nil when I do a product lookup. I have tried multiple product IDs, and different response groups.

The object I'm interacting with is A2z::Responses::ItemLookup. Is that correct?

Thanks.

mhuggins commented 9 years ago

Can you paste some sample code for me to look at? Thanks!

jmalley commented 9 years ago

In my model:

def self.amazon_item_lookup(item_id)
    product_id = item_id.to_i

    client = A2z::Client.new(key: ENV["AMZN_KEY_ID"], secret: ENV["AMZN_SECRET"], tag: ENV["AMZN_TAG"])
    response = client.item_lookup do
      id product_id
      response_group('Large')
    end
    return response
end

In my controller: @amazon_item_search = Gift.amazon_item_lookup(@gift.link_code)

Thank you!

jmalley commented 9 years ago

I figured out my issue. Was passing item ID (ASIN) as an integer instead of a string. My bad!

mhuggins commented 9 years ago

Ahh awesome, sorry for not getting back to you quicker! Glad you were able to figure it out. :)