amazon-ecs 2.1.1 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +13 -7
- data/lib/amazon/ecs.rb +16 -12
- data/test/amazon/ecs_test.rb +20 -3
- metadata +6 -6
data/README
CHANGED
@@ -21,16 +21,22 @@ For HPricot dependency implementation, please install 1.2.x version or checkout
|
|
21
21
|
|
22
22
|
require 'amazon/ecs'
|
23
23
|
|
24
|
-
#
|
25
|
-
|
26
|
-
|
27
|
-
#
|
28
|
-
|
24
|
+
# Set the default options; options will be camelized and converted to REST request parameters.
|
25
|
+
# associate_tag and AWS_access_key_id are required options, associate_tag is required option
|
26
|
+
# since API version 2011-08-01.
|
27
|
+
#
|
28
|
+
# To sign your request, include AWS_secret_key.
|
29
|
+
Amazon::Ecs.options = {
|
30
|
+
:associate_tag => '[your associate tag]',
|
31
|
+
:AWS_access_key_id => '[your developer token]',
|
32
|
+
:AWS_secret_key => '[your secret access key]'
|
33
|
+
}
|
29
34
|
|
30
35
|
# alternatively,
|
31
36
|
Amazon::Ecs.configure do |options|
|
32
|
-
|
33
|
-
|
37
|
+
options[:associate_tag] = '[your associate tag]'
|
38
|
+
options[:AWS_access_key_id] = '[your access key]'
|
39
|
+
options[:AWS_secret_key] = '[you secret key]'
|
34
40
|
end
|
35
41
|
|
36
42
|
# options provided on method call will merge with the default options
|
data/lib/amazon/ecs.rb
CHANGED
@@ -32,13 +32,15 @@ module Amazon
|
|
32
32
|
class RequestError < StandardError; end
|
33
33
|
|
34
34
|
class Ecs
|
35
|
-
SERVICE_URLS = {
|
36
|
-
:
|
37
|
-
:
|
38
|
-
:
|
39
|
-
:
|
40
|
-
:
|
41
|
-
:
|
35
|
+
SERVICE_URLS = {
|
36
|
+
:us => 'http://ecs.amazonaws.com/onca/xml',
|
37
|
+
:uk => 'http://ecs.amazonaws.co.uk/onca/xml',
|
38
|
+
:ca => 'http://ecs.amazonaws.ca/onca/xml',
|
39
|
+
:de => 'http://ecs.amazonaws.de/onca/xml',
|
40
|
+
:jp => 'http://ecs.amazonaws.jp/onca/xml',
|
41
|
+
:fr => 'http://ecs.amazonaws.fr/onca/xml',
|
42
|
+
:it => 'http://webservices.amazon.it/onca/xml',
|
43
|
+
:cn => 'http://webservices.amazon.cn/onca/xml'
|
42
44
|
}
|
43
45
|
|
44
46
|
OPENSSL_DIGEST_SUPPORT = OpenSSL::Digest.constants.include?( 'SHA256' ) ||
|
@@ -47,7 +49,7 @@ module Amazon
|
|
47
49
|
OPENSSL_DIGEST = OpenSSL::Digest::Digest.new( 'sha256' ) if OPENSSL_DIGEST_SUPPORT
|
48
50
|
|
49
51
|
@@options = {
|
50
|
-
:version => "
|
52
|
+
:version => "2011-08-01",
|
51
53
|
:service => "AWSECommerceService"
|
52
54
|
}
|
53
55
|
|
@@ -126,6 +128,10 @@ module Amazon
|
|
126
128
|
end
|
127
129
|
Response.new(res.body)
|
128
130
|
end
|
131
|
+
|
132
|
+
def self.validate_request(opts)
|
133
|
+
raise Amazon::RequestError, "" if opts[:associate_tag]
|
134
|
+
end
|
129
135
|
|
130
136
|
# Response object returned after a REST call to Amazon service.
|
131
137
|
class Response
|
@@ -216,7 +222,7 @@ module Amazon
|
|
216
222
|
request_url = SERVICE_URLS[country.to_sym]
|
217
223
|
raise Amazon::RequestError, "Invalid country '#{country}'" unless request_url
|
218
224
|
|
219
|
-
secret_key = opts.delete(:
|
225
|
+
secret_key = opts.delete(:AWS_secret_key)
|
220
226
|
request_host = URI.parse(request_url).host
|
221
227
|
|
222
228
|
qs = ''
|
@@ -243,11 +249,9 @@ module Amazon
|
|
243
249
|
unless secret_key.nil?
|
244
250
|
request_to_sign="GET\n#{request_host}\n/onca/xml\n#{qs}"
|
245
251
|
signature = "&Signature=#{sign_request(request_to_sign, secret_key)}"
|
246
|
-
else
|
247
|
-
raise Amazon::RequestError, "Must provide aWS_secret_key to sign request"
|
248
252
|
end
|
249
253
|
|
250
|
-
"#{request_url}
|
254
|
+
"#{request_url}?#{qs}#{signature}"
|
251
255
|
end
|
252
256
|
|
253
257
|
def self.url_encode(string)
|
data/test/amazon/ecs_test.rb
CHANGED
@@ -15,9 +15,13 @@ class Amazon::EcsTest < Test::Unit::TestCase
|
|
15
15
|
|
16
16
|
Amazon::Ecs.configure do |options|
|
17
17
|
options[:response_group] = 'Large'
|
18
|
-
options[:
|
19
|
-
options[:
|
18
|
+
options[:AWS_access_key_id] = AWS_ACCESS_KEY_ID
|
19
|
+
options[:AWS_secret_key] = AWS_SECRET_KEY
|
20
|
+
options[:associate_tag] = 'bookjetty-20'
|
20
21
|
end
|
22
|
+
|
23
|
+
# To print debug information
|
24
|
+
# Amazon::Ecs.debug = true
|
21
25
|
|
22
26
|
# Test item_search
|
23
27
|
def test_item_search
|
@@ -31,7 +35,6 @@ class Amazon::EcsTest < Test::Unit::TestCase
|
|
31
35
|
end
|
32
36
|
|
33
37
|
def test_item_search_with_special_characters
|
34
|
-
Amazon::Ecs.debug = true
|
35
38
|
resp = Amazon::Ecs.item_search('()*&^%$')
|
36
39
|
assert resp.is_valid_request?,
|
37
40
|
"Not a valid request"
|
@@ -185,4 +188,18 @@ class Amazon::EcsTest < Test::Unit::TestCase
|
|
185
188
|
assert_equal resp.total_results, dumped_resp.total_results
|
186
189
|
assert_equal resp.total_pages, dumped_resp.total_pages
|
187
190
|
end
|
191
|
+
|
192
|
+
def test_other_service_urls
|
193
|
+
Amazon::Ecs::SERVICE_URLS.each do |key, value|
|
194
|
+
next if key == :us
|
195
|
+
|
196
|
+
begin
|
197
|
+
resp = Amazon::Ecs.item_search('ruby', :country => key)
|
198
|
+
assert resp, "#{key} service url (#{value}) is invalid"
|
199
|
+
rescue => e
|
200
|
+
assert false, "'#{key}' service url (#{value}) is invalid. Error: #{e}"
|
201
|
+
puts e.backtrace
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
188
205
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amazon-ecs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,12 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-09-
|
12
|
+
date: 2011-09-06 00:00:00.000000000 +08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: nokogiri
|
17
|
-
requirement: &
|
17
|
+
requirement: &2156946340 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: 1.4.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *2156946340
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: ruby-hmac
|
28
|
-
requirement: &
|
28
|
+
requirement: &2156945860 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,7 +33,7 @@ dependencies:
|
|
33
33
|
version: 0.3.2
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *2156945860
|
37
37
|
description: Generic Amazon Product Advertising Ruby API
|
38
38
|
email: herryanto@gmail.com
|
39
39
|
executables: []
|