Class: Amazon::Ecs
- Inherits:
-
Object
- Object
- Amazon::Ecs
- Defined in:
- lib/amazon/ecs.rb,
lib/amazon/version.rb
Defined Under Namespace
Classes: Response
Constant Summary collapse
- SERVICE_URLS =
{ :us => 'http://ecs.amazonaws.com/onca/xml', :uk => 'http://ecs.amazonaws.co.uk/onca/xml', :ca => 'http://ecs.amazonaws.ca/onca/xml', :de => 'http://ecs.amazonaws.de/onca/xml', :jp => 'http://ecs.amazonaws.jp/onca/xml', :fr => 'http://ecs.amazonaws.fr/onca/xml', :it => 'http://webservices.amazon.it/onca/xml', :cn => 'http://webservices.amazon.cn/onca/xml', :es => 'http://webservices.amazon.es/onca/xml' }
- OPENSSL_DIGEST_SUPPORT =
OpenSSL::Digest.constants.include?( 'SHA256' ) || OpenSSL::Digest.constants.include?( :SHA256 )
- OPENSSL_DIGEST =
OpenSSL::Digest::Digest.new( 'sha256' )
- VERSION =
'2.2.5'
- @@options =
{ :version => "2011-08-01", :service => "AWSECommerceService" }
- @@debug =
false
Class Method Summary collapse
-
.browse_node_lookup(browse_node_id, opts = {}) ⇒ Object
Search a browse node by BrowseNodeId.
-
.browse_node_lookup_multi(browse_node_ids, opts = {}) ⇒ Object
Search a browse node by BrowseNodeId.
- .configure {|@@options| ... } ⇒ Object
-
.debug ⇒ Object
Get debug flag.
-
.debug=(dbg) ⇒ Object
Set debug flag to true or false.
-
.item_lookup(item_ids, opts = {}) ⇒ Object
Search an item by ASIN no.
-
.item_search(terms, opts = {}) ⇒ Object
Search amazon items with search terms.
-
.options ⇒ Object
Default search options.
-
.options=(opts) ⇒ Object
Set default search options.
-
.send_request(opts) ⇒ Object
Generic send request to ECS REST service.
- .validate_request(opts) ⇒ Object
Class Method Details
.browse_node_lookup(browse_node_id, opts = {}) ⇒ Object
Search a browse node by BrowseNodeId
111 112 113 114 115 116 |
# 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 |
.browse_node_lookup_multi(browse_node_ids, opts = {}) ⇒ Object
Search a browse node by BrowseNodeId
119 120 121 122 123 124 125 126 |
# File 'lib/amazon/ecs.rb', line 119 def self.browse_node_lookup_multi(browse_node_ids, opts = {}) opts[:operation] = 'BrowseNodeLookup' browse_node_ids.each_with_index do |id, index| opts[:"browse_node_id.#{index + 1}"] = id end raise "Response parsing not implemented!" self.send_request(opts) end |
.configure {|@@options| ... } ⇒ Object
80 81 82 83 |
# File 'lib/amazon/ecs.rb', line 80 def self.configure(&proc) raise ArgumentError, "Block is required." unless block_given? yield @@options end |
.debug ⇒ Object
Get debug flag.
71 72 73 |
# File 'lib/amazon/ecs.rb', line 71 def self.debug @@debug end |
.debug=(dbg) ⇒ Object
Set debug flag to true or false.
76 77 78 |
# File 'lib/amazon/ecs.rb', line 76 def self.debug=(dbg) @@debug = dbg end |
.item_lookup(item_ids, opts = {}) ⇒ Object
Search an item by ASIN no.
102 103 104 105 106 107 108 |
# File 'lib/amazon/ecs.rb', line 102 def self.item_lookup(item_ids, opts = {}) item_ids = [item_ids] unless item_ids.is_a?(Array) opts[:operation] = 'ItemLookup' opts[:item_id] = item_ids.join(',') self.send_request(opts) end |
.item_search(terms, opts = {}) ⇒ Object
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].
87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/amazon/ecs.rb', line 87 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 |
.options ⇒ Object
Default search options
61 62 63 |
# File 'lib/amazon/ecs.rb', line 61 def self. @@options end |
.options=(opts) ⇒ Object
Set default search options
66 67 68 |
# File 'lib/amazon/ecs.rb', line 66 def self.(opts) @@options = opts end |
.send_request(opts) ⇒ Object
Generic send request to ECS REST service. You have to specify the :operation parameter.
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/amazon/ecs.rb', line 130 def self.send_request(opts) opts = self..merge(opts) if self. # 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.}" end Response.new(res.body) end |
.validate_request(opts) ⇒ Object
146 147 148 |
# File 'lib/amazon/ecs.rb', line 146 def self.validate_request(opts) raise Amazon::RequestError, "" if opts[:associate_tag] end |