vacuum 1.5.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +7 -1
- data/lib/vacuum/request.rb +1 -0
- data/lib/vacuum/response.rb +8 -2
- data/lib/vacuum/version.rb +1 -1
- data/test/cassettes/vacuum.yml +35 -1770
- data/test/test_integration.rb +12 -2
- data/test/test_vacuum.rb +12 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7906255d4f787e35bfc22f67b89d406bed807ce0
|
4
|
+
data.tar.gz: 13b236b25c20e725bba1248f5c3905c0e8bae1b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d9102da9a4be4f5d29220d6e4d12569378867da10ce668a2e7f9412ed6f42476a9daf5dcc0cea0c1f02ec37e6ed18aee0b3475b50c207c1d2e70285f06b125d
|
7
|
+
data.tar.gz: 290a282d80dfb9a8c7e7c3a386786b615a696c006cf31ee79066dfac6af0395ef874ba88eedb4aa461af5e1423511527874e88d20bae13a559c628d936c4789c
|
data/README.md
CHANGED
@@ -178,12 +178,18 @@ response = request.item_search(
|
|
178
178
|
|
179
179
|
### Response
|
180
180
|
|
181
|
-
The quick and dirty way to consume a response is to parse
|
181
|
+
The quick and dirty way to consume a response is to parse into a Ruby hash:
|
182
182
|
|
183
183
|
```ruby
|
184
184
|
response.to_h
|
185
185
|
```
|
186
186
|
|
187
|
+
You can also use the `#dig` polyfill:
|
188
|
+
|
189
|
+
```ruby
|
190
|
+
response.dig('ItemSearchResponse', 'Items', 'Item')
|
191
|
+
```
|
192
|
+
|
187
193
|
In production, you may prefer to use a custom parser to do some XML heavy-lifting:
|
188
194
|
|
189
195
|
```ruby
|
data/lib/vacuum/request.rb
CHANGED
@@ -107,6 +107,7 @@ module Vacuum
|
|
107
107
|
method_name = operation.gsub(/(.)([A-Z])/, '\1_\2').downcase
|
108
108
|
define_method(method_name) do |params, opts = {}|
|
109
109
|
params.key?(:query) ? opts = params : opts.update(query: params)
|
110
|
+
opts[:expects] = [200, 403]
|
110
111
|
opts[:query].update('Operation' => operation)
|
111
112
|
|
112
113
|
Response.new(get(opts))
|
data/lib/vacuum/response.rb
CHANGED
@@ -1,19 +1,25 @@
|
|
1
1
|
require 'delegate'
|
2
|
+
require 'dig_rb'
|
3
|
+
require 'forwardable'
|
2
4
|
require 'multi_xml'
|
3
5
|
|
4
6
|
module Vacuum
|
5
7
|
# A wrapper around the Amazon Product Advertising API response.
|
6
8
|
class Response < SimpleDelegator
|
9
|
+
extend Forwardable
|
10
|
+
|
7
11
|
class << self
|
8
12
|
attr_accessor :parser
|
9
13
|
end
|
10
14
|
|
15
|
+
def_delegator :parse, :dig
|
16
|
+
|
17
|
+
attr_writer :parser
|
18
|
+
|
11
19
|
def parser
|
12
20
|
@parser || self.class.parser
|
13
21
|
end
|
14
22
|
|
15
|
-
attr_writer :parser
|
16
|
-
|
17
23
|
def parse
|
18
24
|
parser ? parser.parse(body) : to_h
|
19
25
|
end
|
data/lib/vacuum/version.rb
CHANGED