Search a browse node by BrowseNodeId
# File lib/amazon/ecs.rb, line 111 def self.browse_node_lookup(browse_node_id, opts = {}) opts[:operation] = 'BrowseNodeLookup' opts[:browse_node_id] = browse_node_id self.send_request(opts) end
# File lib/amazon/ecs.rb, line 81 def self.configure(&proc) raise ArgumentError, "Block is required." unless block_given? yield @@options end
Get debug flag.
# File lib/amazon/ecs.rb, line 72 def self.debug @@debug end
Set debug flag to true or false.
# File lib/amazon/ecs.rb, line 77 def self.debug=(dbg) @@debug = dbg end
Search an item by ASIN no.
# File lib/amazon/ecs.rb, line 103 def self.item_lookup(item_id, opts = {}) opts[:operation] = 'ItemLookup' opts[:item_id] = item_id self.send_request(opts) end
Search amazon items with search terms. Default search index option is 'Books'. For other search type other than keywords, please specify :type => [search type param name].
# File lib/amazon/ecs.rb, line 88 def self.item_search(terms, opts = {}) opts[:operation] = 'ItemSearch' opts[:search_index] = opts[:search_index] || 'Books' type = opts.delete(:type) if type opts[type.to_sym] = terms else opts[:keywords] = terms end self.send_request(opts) end
Default search options
# File lib/amazon/ecs.rb, line 62 def self.options @@options end
Set default search options
# File lib/amazon/ecs.rb, line 67 def self.options=(opts) @@options = opts end
Generic send request to ECS REST service. You have to specify the :operation parameter.
# File lib/amazon/ecs.rb, line 119 def self.send_request(opts) opts = self.options.merge(opts) if self.options # Include other required options opts[:timestamp] = Time.now.utc.strftime("%Y-%m-%dT%H:%M:%SZ") request_url = prepare_url(opts) log "Request URL: #{request_url}" res = Net::HTTP.get_response(URI::parse(request_url)) unless res.kind_of? Net::HTTPSuccess raise Amazon::RequestError, "HTTP Response: #{res.code} #{res.message}" end Response.new(res.body) end
Generated with the Darkfish Rdoc Generator 2.