Created
August 7, 2009 11:35
-
-
Save practicingruby/163855 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 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 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