sandal (owner)

Fork Of

Revisions

gist: 163855 Download_button fork
public
Public Clone URL: git://gist.github.com/163855.git
Embed All Files: show embed
Ruby #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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")