class Tucano::ProductSearch
Public Class Methods
new(key, secret, associate_tag)
click to toggle source
# File lib/tucano.rb, line 9 def initialize(key, secret, associate_tag) Amazon::Ecs.options = { :associate_tag => associate_tag, :AWS_access_key_id => key, :AWS_secret_key => secret } end
Public Instance Methods
convert_to_product(item)
click to toggle source
# File lib/tucano.rb, line 17 def convert_to_product(item) i = Item.new i.name = item.get_hash("ItemAttributes")["Title"] i.category = item.get_hash("ItemAttributes")["ProductGroup"] i.price = item.get_hash("ItemAttributes/ListPrice")["Amount"] i.currency = item.get_hash("ItemAttributes/ListPrice")["CurrencyCode"] i.description = item.get_hash("EditorialReviews/EditorialReview")["Content"] i.image = item.get_hash("LargeImage")["URL"] return i end
parse_response()
click to toggle source
# File lib/tucano.rb, line 28 def parse_response products = [] @response.items.each do |item| product = convert_to_product(item) products << product end products end
search(query)
click to toggle source
# File lib/tucano.rb, line 37 def search(query) @response = Amazon::Ecs.item_search(query, :search_index => "All", :response_group => "Medium") products = [] products = parse_response products end