amazon-ecs 2.3.1 → 2.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +5 -13
  2. data/CHANGELOG +7 -3
  3. data/README.md +132 -0
  4. data/lib/amazon/ecs.rb +9 -8
  5. metadata +9 -9
  6. data/Readme.rdoc +0 -130
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- OTI5MTdjZGRmZTVlOTkwNTg4MDY5MmEzMTY1MTg4NzgwNTYwNDNiNQ==
5
- data.tar.gz: !binary |-
6
- NTZlZjZkZmY0NDA3ZmQxOTFiZDUwMDRlNmY0MGFlNDg3ODU5MTA4MQ==
2
+ SHA1:
3
+ metadata.gz: 207bda3e459d08432050f5d72fcefc625a962a03
4
+ data.tar.gz: 28f7778b0db01f73cdbde8ec9158912a1d9940d4
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- MTJiODllZDhlNGM4M2JhNDlmZWNiNGYwYTAzYWUzZjhmMWMwZWJjZDM1MGU0
10
- MjFiZDc4Yzg0YTkwOTY3YzkzY2M3YWQ5ODEwYjE4NWVjNTUwYTI1ZmI2ZmNk
11
- MDI2YjQwMDkxYTA0NDdjNWYwMjU4ZDkzNTgzZTE4YjFiOGRmOGM=
12
- data.tar.gz: !binary |-
13
- ZjVlMDVjZmU4NmQ5Y2RiOWE3MDEzNGY3ZThmY2NmOTJlNjEzOWZlMTY5MWQ4
14
- MjIwMzcwYzJmOTBmOTNlYTFiNmM5NWIzYWJhM2UwZTRjNGU2ZmVmOTZmYzBl
15
- NTJjMDI0YzRhZmU5ZDllNDRkZTA1Y2QxYzgxY2Y0Njk4Mzc1OTM=
6
+ metadata.gz: 98cd2d491d2e17a61fdd6e0a32ebdbbe9dc0a1e6b50512b5ea778f81e81a2efb8a2f7efc4e03bf27079ddd459695e8a81a3d3b6e11da861c71b874fdb2c34d09
7
+ data.tar.gz: ec62d34b79046694d49e5bccd975dc3d02a8af66dcc56053915e89261fa7195776864a0b22c0e59c7a6952597ee33812d9c86fcf75dc0d192883ae3298cef58b
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ 2.3.2 2015-01-04
2
+ ----------------
3
+ * Add support for Amazon MX
4
+
1
5
  2.3.1 2015-04-01
2
6
  ----------------
3
7
  * Add support for Amazon IN and BR
@@ -8,7 +12,7 @@
8
12
 
9
13
  2.2.5 2014-03-08
10
14
  ----------------
11
- * Replaced Digest::Digest deprecated call
15
+ * Replaced Digest::Digest deprecated call
12
16
  * Read AWS_ACCESS_KEY_ID and AWS_SECRET_KEY env variables when running test
13
17
 
14
18
  2.2.4 2012-01-01
@@ -103,7 +107,7 @@
103
107
  0.5.1 2007-02-08
104
108
  ----------------
105
109
  * Fixed Amazon Japan and France URL error
106
- * Removed opts.delete(:search_index) from item_lookup, SearchIndex param is allowed
110
+ * Removed opts.delete(:search_index) from item_lookup, SearchIndex param is allowed
107
111
  when looking for a book with IdType other than the ASIN.
108
112
  * Check for defined? RAILS_DEFAULT_LOGGER to avoid exception for non-rails ruby app
109
113
  * Added check for LOGGER constant if RAILS_DEFAULT_LOGGER is not defined
@@ -112,4 +116,4 @@
112
116
 
113
117
  0.5.0 2006-09-12
114
118
  ----------------
115
- Initial Release
119
+ Initial Release
@@ -0,0 +1,132 @@
1
+ # amazon-ecs
2
+
3
+ `amazon-ecs` is a generic Ruby wrapper to access Amazon Product Advertising API.
4
+
5
+ You can easily extend the library to support any of the operations supported by the API.
6
+
7
+ The library wraps around Nokogiri element object. It provides an easy access to the XML response
8
+ structure through an XML path instead of an object attribute. The idea is the API evolves,
9
+ there will be changes to the XML schema. With `amazon-ecs`, your code will still work, only
10
+ the XML path needs to be updated.
11
+
12
+ ## Installation
13
+
14
+ ```shell
15
+ gem install amazon-ecs
16
+ ```
17
+
18
+ ## How to use it
19
+
20
+ ```ruby
21
+ require 'amazon/ecs'
22
+
23
+ # Configure your access key, secret key and other options such as the associate tag.
24
+ # Options set in the configure block will be merged with the pre-configured default
25
+ # options, i.e.
26
+ # options[:version] => "2011-08-01"
27
+ # options[:service] => "AWSECommerceService"
28
+ Amazon::Ecs.configure do |options|
29
+ options[:AWS_access_key_id] = '[your access key]'
30
+ options[:AWS_secret_key] = '[you secret key]'
31
+ options[:associate_tag] = '[your associate tag]'
32
+ end
33
+
34
+ # Or if you need to replace the default options, overwrite the options value, e.g.
35
+ # Amazon::Ecs.options = {
36
+ # :version => "2013-08-01",
37
+ # :service => "AWSECommerceService"
38
+ # :associate_tag => '[your associate tag]',
39
+ # :AWS_access_key_id => '[your developer token]',
40
+ # :AWS_secret_key => '[your secret access key]'
41
+ # }
42
+
43
+ # options passed with the method call will be merged with the default options
44
+ res = Amazon::Ecs.item_search('ruby', {:response_group => 'Medium', :sort => 'salesrank'})
45
+
46
+ # search amazon uk
47
+ res = Amazon::Ecs.item_search('ruby', :country => 'uk')
48
+
49
+ # search all items, default search index is Books
50
+ res = Amazon::Ecs.item_search('ruby', :search_index => 'All')
51
+
52
+ # some common response object methods
53
+ res.is_valid_request? # return true if request is valid
54
+ res.has_error? # return true if there is an error
55
+ res.error # return error message if there is any
56
+ res.total_pages # return total pages
57
+ res.total_results # return total results
58
+ res.item_page # return current page no if :item_page option is provided
59
+
60
+ # traverse through each item (Amazon::Element)
61
+ res.items.each do |item|
62
+ # retrieve string value using XML path
63
+ item.get('ASIN')
64
+ item.get('ItemAttributes/Title')
65
+
66
+ # return Amazon::Element instance
67
+ item_attributes = item.get_element('ItemAttributes')
68
+ item_attributes.get('Title')
69
+
70
+ # return first author or a string array of authors
71
+ item_attributes.get('Author') # 'Author 1'
72
+ item_attributes.get_array('Author') # ['Author 1', 'Author 2', ...]
73
+
74
+ # return an hash of children text values with the element names as the keys
75
+ item.get_hash('SmallImage') # {:url => ..., :width => ..., :height => ...}
76
+
77
+ # return the first matching path as Amazon::Element
78
+ item_height = item.get_element('ItemDimensions/Height')
79
+
80
+ # retrieve attributes from Amazon::Element
81
+ item_height.attributes['Units'] # 'hundredths-inches'
82
+
83
+ # return an array of Amazon::Element
84
+ authors = item.get_elements('Author')
85
+
86
+ # return Nokogiri::XML::NodeSet object or nil if not found
87
+ reviews = item/'EditorialReview'
88
+
89
+ # traverse through Nokogiri elements
90
+ reviews.each do |review|
91
+ # Getting hash value out of Nokogiri element
92
+ Amazon::Element.get_hash(review) # [:source => ..., :content ==> ...]
93
+
94
+ # Or to get unescaped HTML values
95
+ Amazon::Element.get_unescaped(review, 'Source')
96
+ Amazon::Element.get_unescaped(review, 'Content')
97
+
98
+ # Or this way
99
+ el = Amazon::Element.new(review)
100
+ el.get_unescaped('Source')
101
+ el.get_unescaped('Content')
102
+ end
103
+ end
104
+ ```
105
+
106
+ For operations other than `item_search` and `item_lookup`, you could use `Amazon::Ecs.send_request`, e.g.
107
+ ```ruby
108
+ Amazon::Ecs.send_request(:operation => 'BrowseNodeLookup', :browse_node_id => 123)
109
+ Amazon::Ecs.send_request(:operation => 'SimilarityLookup',:item_id => 12345678)
110
+ ```
111
+
112
+ Or you could extend `Amazon::Ecs`:
113
+ ```ruby
114
+ module Amazon
115
+ class Ecs
116
+ def self.similarity_lookup(item_id, opts={})
117
+ opts[:operation] = 'SimilarityLookup'
118
+ opts[:item_id] = item_id
119
+
120
+ self.send_request(opts)
121
+ end
122
+ end
123
+ end
124
+
125
+ Amazon::Ecs.similarity_lookup('[item_id]', :param1 => 'abc', :param2 => 'xyz')
126
+ ```
127
+
128
+ Refer to [Amazon Product Advertising API](https://affiliate-program.amazon.com/gp/advertising/api/detail/main.html) documentation for more information on the operations and request parameters supported.
129
+
130
+ ## License
131
+
132
+ [The MIT License]
@@ -32,20 +32,21 @@ module Amazon
32
32
  class RequestError < StandardError; end
33
33
 
34
34
  class Ecs
35
- VERSION = '2.3.1'
35
+ VERSION = '2.3.2'
36
36
 
37
37
  SERVICE_URLS = {
38
- :us => 'http://ecs.amazonaws.com/onca/xml',
39
- :uk => 'http://ecs.amazonaws.co.uk/onca/xml',
40
- :ca => 'http://ecs.amazonaws.ca/onca/xml',
41
- :de => 'http://ecs.amazonaws.de/onca/xml',
42
- :jp => 'http://ecs.amazonaws.jp/onca/xml',
43
- :fr => 'http://ecs.amazonaws.fr/onca/xml',
38
+ :us => 'http://webservices.amazon.com/onca/xml',
39
+ :uk => 'http://webservices.amazon.co.uk/onca/xml',
40
+ :ca => 'http://webservices.amazon.ca/onca/xml',
41
+ :de => 'http://webservices.amazon.de/onca/xml',
42
+ :jp => 'http://webservices.amazon.co.jp/onca/xml',
43
+ :fr => 'http://webservices.amazon.fr/onca/xml',
44
44
  :it => 'http://webservices.amazon.it/onca/xml',
45
45
  :cn => 'http://webservices.amazon.cn/onca/xml',
46
46
  :es => 'http://webservices.amazon.es/onca/xml',
47
47
  :in => 'http://webservices.amazon.in/onca/xml',
48
- :br => 'http://webservices.amazon.com.br/onca/xml'
48
+ :br => 'http://webservices.amazon.com.br/onca/xml',
49
+ :mx => 'http://webservices.amazon.com.mx/onca/xml'
49
50
  }
50
51
 
51
52
  OPENSSL_DIGEST_SUPPORT = OpenSSL::Digest.constants.include?( 'SHA256' ) ||
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amazon-ecs
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.1
4
+ version: 2.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Herryanto Siatono
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-31 00:00:00.000000000 Z
11
+ date: 2016-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.4'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.4'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: ruby-hmac
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0.3'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0.3'
41
41
  description: Generic Amazon Product Advertising Ruby API.
@@ -47,8 +47,8 @@ files:
47
47
  - CHANGELOG
48
48
  - Gemfile
49
49
  - MIT-LICENSE
50
+ - README.md
50
51
  - Rakefile
51
- - Readme.rdoc
52
52
  - amazon-ecs.gemspec
53
53
  - lib/amazon/ecs.rb
54
54
  - test/amazon/ecs_test.rb
@@ -62,12 +62,12 @@ require_paths:
62
62
  - lib
63
63
  required_ruby_version: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - ! '>='
65
+ - - ">="
66
66
  - !ruby/object:Gem::Version
67
67
  version: '0'
68
68
  required_rubygems_version: !ruby/object:Gem::Requirement
69
69
  requirements:
70
- - - ! '>='
70
+ - - ">="
71
71
  - !ruby/object:Gem::Version
72
72
  version: '0'
73
73
  requirements: []
@@ -1,130 +0,0 @@
1
- == amazon-ecs
2
-
3
- Amazon ECS is a generic Ruby wrapper to access Amazon Product Advertising API.
4
-
5
- You can easily extend the library to support any of the operations supported by the API.
6
-
7
- The library wraps around Nokogiri element object. It provides an easy access to the XML response
8
- structure through an XML path instead of an object attribute. The idea is the API evolves,
9
- there will be changes to the XML schema. With Amazon ECS, your code will still work, only
10
- the XML path needs to be updated.
11
-
12
- == INSTALLATION
13
-
14
- $ gem install amazon-ecs
15
-
16
- == EXAMPLE
17
-
18
- require 'amazon/ecs'
19
-
20
- # Configure your access key, secret key and other options such as the associate tag.
21
- # Options set in the configure block will add/update to the default options, i.e.
22
- # options[:version] => "2011-08-01"
23
- # options[:service] => "AWSECommerceService"
24
- Amazon::Ecs.configure do |options|
25
- options[:AWS_access_key_id] = '[your access key]'
26
- options[:AWS_secret_key] = '[you secret key]'
27
- options[:associate_tag] = '[your associate tag]'
28
- end
29
-
30
- # Or if you need to replace the default options, set the options value directly.
31
- # Amazon::Ecs.options = {
32
- # :version => "2013-08-01",
33
- # :service => "AWSECommerceService"
34
- # :associate_tag => '[your associate tag]',
35
- # :AWS_access_key_id => '[your developer token]',
36
- # :AWS_secret_key => '[your secret access key]'
37
- # }
38
-
39
- # options provided on method call will merge with the default options
40
- res = Amazon::Ecs.item_search('ruby', {:response_group => 'Medium', :sort => 'salesrank'})
41
-
42
- # search amazon uk
43
- res = Amazon::Ecs.item_search('ruby', :country => 'uk')
44
-
45
- # search all items, default search index is Books
46
- res = Amazon::Ecs.item_search('ruby', :search_index => 'All')
47
-
48
- # some common response object methods
49
- res.is_valid_request? # return true if request is valid
50
- res.has_error? # return true if there is an error
51
- res.error # return error message if there is any
52
- res.total_pages # return total pages
53
- res.total_results # return total results
54
- res.item_page # return current page no if :item_page option is provided
55
-
56
- # traverse through each item (Amazon::Element)
57
- res.items.each do |item|
58
- # retrieve string value using XML path
59
- item.get('ASIN')
60
- item.get('ItemAttributes/Title')
61
-
62
- # return Amazon::Element instance
63
- item_attributes = item.get_element('ItemAttributes')
64
- item_attributes.get('Title')
65
-
66
- # return first author or a string array of authors
67
- item_attributes.get('Author') # 'Author 1'
68
- item_attributes.get_array('Author') # ['Author 1', 'Author 2', ...]
69
-
70
- # return an hash of children text values with the element names as the keys
71
- item.get_hash('SmallImage') # {:url => ..., :width => ..., :height => ...}
72
-
73
- # return the first matching path as Amazon::Element
74
- item_height = item.get_element('ItemDimensions/Height')
75
-
76
- # retrieve attributes from Amazon::Element
77
- item_height.attributes['Units'] # 'hundredths-inches'
78
-
79
- # return an array of Amazon::Element
80
- authors = item.get_elements('Author')
81
-
82
- # return Nokogiri::XML::NodeSet object or nil if not found
83
- reviews = item/'EditorialReview'
84
-
85
- # traverse through Nokogiri elements
86
- reviews.each do |review|
87
- # Getting hash value out of Nokogiri element
88
- Amazon::Element.get_hash(review) # [:source => ..., :content ==> ...]
89
-
90
- # Or to get unescaped HTML values
91
- Amazon::Element.get_unescaped(review, 'Source')
92
- Amazon::Element.get_unescaped(review, 'Content')
93
-
94
- # Or this way
95
- el = Amazon::Element.new(review)
96
- el.get_unescaped('Source')
97
- el.get_unescaped('Content')
98
- end
99
- end
100
-
101
- # Extend Amazon::Ecs, replace 'other_operation' with the appropriate name
102
- module Amazon
103
- class Ecs
104
- def self.other_operation(item_id, opts={})
105
- opts[:operation] = '[other valid operation supported by Product Advertising API]'
106
-
107
- # setting default option value
108
- opts[:item_id] = item_id
109
-
110
- self.send_request(opts)
111
- end
112
- end
113
- end
114
-
115
- Amazon::Ecs.other_operation('[item_id]', :param1 => 'abc', :param2 => 'xyz')
116
-
117
- Refer to the Amazon Product Advertising API documentation for more information:
118
- https://affiliate-program.amazon.com/gp/advertising/api/detail/main.html
119
-
120
- == SOURCE CODES
121
-
122
- * http://github.com/jugend/amazon-ecs
123
-
124
- == CREDITS
125
-
126
- Thanks to Dan Milne and Bryan Housel for the pull requests.
127
-
128
- == LICENSE
129
-
130
- [The MIT License]