Skip to content

Instantly share code, notes, and snippets.

@charly
Created August 7, 2009 12:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save charly/163872 to your computer and use it in GitHub Desktop.
Save charly/163872 to your computer and use it in GitHub Desktop.
module RAAWS
ONE_NECESSARY_SEARCH_PARAM =%w<
Actor Artist AudienceRating Author
Brand BrowseNode Composer Conductor CityDirector
Keywords Manufacturer MusicLabel Neighborhood
Orchestra Power Publisher TextStream Title>
class ItemOperation < Operation
def self.lookup(item_id, index=nil, &block)
new.tap do |obj|
obj.operation = "Lookup"
obj.search_index = index if index
if block_given?
yield(obj.search_index)
obj.request = obj.search_index.to_params
end
obj.request = {:item_id => item_id}
obj.response = "Large"
end
end
def self.search(index, opt={}, &block)
new.tap do |obj|
obj.operation = "Search"
obj.search_index = index
if block_given?
yield(obj.search_index)
end
obj.request = obj.search_index.to_params
obj.response = "Small"
end
end
end
end
# getting info on an amazon product
RAAWS::ItemOperation.lookup("678bk456hb654")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment