lib/amazon/ecs.rb in amazon-ecs-2.4.0 vs lib/amazon/ecs.rb in amazon-ecs-2.5.0
- old
+ new
@@ -30,11 +30,11 @@
module Amazon
class RequestError < StandardError; end
class Ecs
- VERSION = '2.4.0'
+ VERSION = '2.5.0'
SERVICE_URLS = {
:us => 'http://webservices.amazon.com/onca/xml',
:uk => 'http://webservices.amazon.co.uk/onca/xml',
:ca => 'http://webservices.amazon.ca/onca/xml',
@@ -57,11 +57,11 @@
@@options = {
:version => "2013-08-01",
:service => "AWSECommerceService"
}
- @@debug = false
+ @@debug = ENV['DEBUG_AMAZON_ECS'] || false
# Default search options
def self.options
@@options
end
@@ -132,17 +132,22 @@
# 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}"
+ log("Request URL: #{request_url}")
res = Net::HTTP.get_response(URI::parse(request_url))
+ log("Response:\n#{res.body}\n\n")
+
+ ecs_res = Response.new(res.body)
unless res.kind_of? Net::HTTPSuccess
- raise Amazon::RequestError, "HTTP Response: #{res.code} #{res.message}"
+ err_msg = "HTTP Response: #{res.code} #{res.message}"
+ err_msg += " - #{ecs_res.error}" if ecs_res.error
+ raise Amazon::RequestError, err_msg
end
- Response.new(res.body)
+ ecs_res
end
def self.validate_request(opts)
raise Amazon::RequestError, "" if opts[:associate_tag]
end
@@ -268,10 +273,10 @@
opts = opts.sort do |c,d|
c[0].to_s <=> d[0].to_s
end
opts.each do |e|
- log "Adding #{e[0]}=#{e[1]}"
+ log("Adding #{e[0]}=#{e[1]}")
next unless e[1]
e[1] = e[1].join(',') if e[1].is_a? Array
# v = URI.encode(e[1].to_s, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
v = self.url_encode(e[1].to_s)
qs << "&" unless qs.length == 0