vacuum 3.3.0 → 3.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +21 -27
- data/lib/vacuum/locale.rb +1 -0
- data/lib/vacuum/matcher.rb +16 -0
- data/lib/vacuum/request.rb +52 -3
- data/lib/vacuum/resource.rb +62 -0
- data/lib/vacuum/response.rb +2 -0
- data/lib/vacuum/version.rb +1 -1
- data/test/integration/test_requests.rb +62 -0
- data/test/{vacuum → unit}/test_locale.rb +0 -0
- data/test/{vacuum → unit}/test_operation.rb +0 -0
- data/test/unit/test_request.rb +61 -0
- data/test/unit/test_resource.rb +12 -0
- data/test/{vacuum → unit}/test_response.rb +0 -0
- metadata +22 -15
- data/test/vacuum/test_request.rb +0 -77
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4fabab10f086746082267c99d3c91d1b5efded68a7a39bac4e963125d1979d9
|
4
|
+
data.tar.gz: 8e8b4fc57cbd15da857f867b4ac3a0986a2664157047b0192272140c96a5475f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6075c9237d5b5556312e5afbce35d5e4cd573cf705de305e04ffa3e9a853202d6f4499937f991eda1c65c33a84c5e8625f043eb391161fd96e4a827aa9f6f5a5
|
7
|
+
data.tar.gz: e031688b51fed66acd8b8442e2475c1b0d6ec7ed991e74e6df63c427017407da0799cbca46baa0a496b480fd9725d80f8e5ad379fb872c4448d6fd43bc419621
|
data/README.md
CHANGED
@@ -6,6 +6,8 @@
|
|
6
6
|
|
7
7
|
Vacuum is a Ruby wrapper to [Amazon Product Advertising API 5.0](https://webservices.amazon.com/paapi5/documentation/). The API provides programmatic access to query product information on the Amazon marketplaces.
|
8
8
|
|
9
|
+
Cart Form functionality is not covered by this gem but is a primary focus on [carriage gem](https://github.com/skatkov/carriage)
|
10
|
+
|
9
11
|
You need to [register first](https://webservices.amazon.com/paapi5/documentation/register-for-pa-api.html) to use the API.
|
10
12
|
|
11
13
|
![vacuum](http://f.cl.ly/items/2k2X0e2u0G3k1c260D2u/vacuum.png)
|
@@ -98,15 +100,15 @@ You can also `#dig` into this hash.
|
|
98
100
|
response.dig('ItemsResult', 'Items')
|
99
101
|
```
|
100
102
|
|
101
|
-
###
|
103
|
+
### Logging
|
102
104
|
|
103
|
-
|
105
|
+
Write requests and reponses to a logger using the logging feature of the [HTTP gem](https://github.com/httprb/http) under the hood:
|
104
106
|
|
105
107
|
```ruby
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
108
|
+
require 'logger'
|
109
|
+
|
110
|
+
logger = Logger.new(STDOUT)
|
111
|
+
request.use(logging: {logger: logger})
|
110
112
|
```
|
111
113
|
|
112
114
|
### Bring your parser
|
@@ -131,25 +133,11 @@ VCR.insert_cassette('cassette_name',
|
|
131
133
|
match_requests_on: [Vacuum::Matcher])
|
132
134
|
```
|
133
135
|
|
134
|
-
In RSpec,
|
136
|
+
In RSpec, use the `:paapi` metadata.
|
135
137
|
|
136
138
|
```ruby
|
137
139
|
require 'vacuum/matcher'
|
138
140
|
|
139
|
-
RSpec.configure do |config|
|
140
|
-
config.around do |example|
|
141
|
-
if example.metadata[:paapi]
|
142
|
-
metadata = example.metadata[:paapi]
|
143
|
-
metadata = {} if metadata == true
|
144
|
-
example.metadata[:vcr] = metadata.merge(
|
145
|
-
match_requests_on: [Vacuum::Matcher]
|
146
|
-
)
|
147
|
-
end
|
148
|
-
|
149
|
-
example.run
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
141
|
# in your test
|
154
142
|
it 'queries Amazon', :paapi do
|
155
143
|
end
|
@@ -157,22 +145,28 @@ end
|
|
157
145
|
|
158
146
|
## Development
|
159
147
|
|
160
|
-
Clone the repo and install dependencies.
|
148
|
+
Clone the repo and install dependencies.
|
149
|
+
|
150
|
+
```sh
|
151
|
+
bundle install
|
152
|
+
```
|
153
|
+
|
154
|
+
Tests and Rubocop should now pass as-is.
|
161
155
|
|
162
156
|
```sh
|
163
157
|
bundle exec rake
|
164
158
|
```
|
165
159
|
|
166
|
-
By default,
|
160
|
+
By default, the tests stub requests. Use the `RECORD` env var to record new interactions.
|
167
161
|
|
168
162
|
```sh
|
169
|
-
bundle exec
|
163
|
+
RECORD=true bundle exec rake test
|
170
164
|
```
|
171
165
|
|
172
|
-
You can
|
166
|
+
You can set the `LIVE` env var to run all tests against live data.
|
173
167
|
|
174
|
-
```
|
175
|
-
bundle exec
|
168
|
+
```sh
|
169
|
+
LIVE=true bundle exec rake test
|
176
170
|
```
|
177
171
|
|
178
172
|
In either case, add actual API credentials to a [`locales.yml`](https://github.com/hakanensari/vacuum/blob/master/test/locales.yml.example) file under `test`.
|
data/lib/vacuum/locale.rb
CHANGED
@@ -19,6 +19,7 @@ module Vacuum
|
|
19
19
|
it: ['webservices.amazon.it', 'eu-west-1'],
|
20
20
|
jp: ['webservices.amazon.co.jp', 'us-west-2'],
|
21
21
|
mx: ['webservices.amazon.com.mx', 'us-east-1'],
|
22
|
+
nl: ['webservices.amazon.nl', 'eu-west-1'],
|
22
23
|
sg: ['webservices.amazon.sg', 'us-west-2'],
|
23
24
|
es: ['webservices.amazon.es', 'eu-west-1'],
|
24
25
|
tr: ['webservices.amazon.com.tr', 'eu-west-1'],
|
data/lib/vacuum/matcher.rb
CHANGED
@@ -53,3 +53,19 @@ module Vacuum
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
56
|
+
|
57
|
+
if defined?(RSpec)
|
58
|
+
RSpec.configure do |config|
|
59
|
+
config.around do |example|
|
60
|
+
if example.metadata[:paapi]
|
61
|
+
metadata = example.metadata[:paapi]
|
62
|
+
metadata = {} if metadata == true
|
63
|
+
example.metadata[:vcr] = metadata.merge(
|
64
|
+
match_requests_on: [Vacuum::Matcher]
|
65
|
+
)
|
66
|
+
end
|
67
|
+
|
68
|
+
example.run
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
data/lib/vacuum/request.rb
CHANGED
@@ -4,6 +4,7 @@ require 'http'
|
|
4
4
|
|
5
5
|
require 'vacuum/locale'
|
6
6
|
require 'vacuum/operation'
|
7
|
+
require 'vacuum/resource'
|
7
8
|
require 'vacuum/response'
|
8
9
|
|
9
10
|
module Vacuum
|
@@ -33,6 +34,7 @@ module Vacuum
|
|
33
34
|
end
|
34
35
|
|
35
36
|
# Returns details about specified browse nodes
|
37
|
+
#
|
36
38
|
# @see https://webservices.amazon.com/paapi5/documentation/getbrowsenodes.html
|
37
39
|
# @overload get_browse_nodes(browse_node_ids:, languages_of_preference: nil, marketplace: nil, partner_tag: nil, partner_type: nil, resources: nil)
|
38
40
|
# @param [Array<String,Integer>,String,Integer] browse_node_ids
|
@@ -48,6 +50,7 @@ module Vacuum
|
|
48
50
|
end
|
49
51
|
|
50
52
|
# Returns the attributes of one or more items
|
53
|
+
#
|
51
54
|
# @see https://webservices.amazon.com/paapi5/documentation/get-items.html
|
52
55
|
# @overload get_items(condition: nil, currency_of_preference: nil, item_id_type: nil, item_ids:, languages_of_preference: nil, marketplace: nil, merchant: nil, offer_count: nil, partner_tag: nil, partner_type: nil, resources: nil)
|
53
56
|
# @param [String,nil] condition
|
@@ -69,6 +72,7 @@ module Vacuum
|
|
69
72
|
|
70
73
|
# Returns a set of items that are the same product, but differ according to
|
71
74
|
# a consistent theme
|
75
|
+
#
|
72
76
|
# @see https://webservices.amazon.com/paapi5/documentation/get-variations.html
|
73
77
|
# @overload get_variations(asin:, condition: nil, currency_of_preference: nil, languages_of_preference: nil, marketplace: nil, merchant: nil, offer_count: nil, partner_tag: nil, partner_type: nil, resources: nil, variation_count: nil, variation_page: nil)
|
74
78
|
# @param [String] asin
|
@@ -89,6 +93,7 @@ module Vacuum
|
|
89
93
|
end
|
90
94
|
|
91
95
|
# Searches for items on Amazon based on a search query
|
96
|
+
#
|
92
97
|
# @see https://webservices.amazon.com/paapi5/documentation/search-items.html
|
93
98
|
# @overload search_items(actor: nil, artist: nil, author: nil, availability: nil, brand: nil, browse_node_id: nil, condition: nil, currency_of_preference: nil, delivery_flags: nil, item_count: nil, item_page: nil, keywords: nil, languages_of_preference: nil, marketplace: nil, max_price: nil, merchant: nil, min_price: nil, min_reviews_rating: nil, min_savings_percent: nil, offer_count: nil, partner_tag: nil, partner_type: nil, resources: nil, search_index: nil, sort_by: nil, title: nil)
|
94
99
|
# @param [String,nil] actor
|
@@ -119,17 +124,61 @@ module Vacuum
|
|
119
124
|
request('SearchItems', params)
|
120
125
|
end
|
121
126
|
|
122
|
-
#
|
127
|
+
# Flags as persistent
|
123
128
|
#
|
129
|
+
# @param [Integer] timeout
|
124
130
|
# @return [self]
|
125
|
-
def persistent
|
126
|
-
|
131
|
+
def persistent(timeout: 5)
|
132
|
+
host = "https://#{locale.host}"
|
133
|
+
@client = client.persistent(host, timeout: timeout)
|
134
|
+
|
127
135
|
self
|
128
136
|
end
|
129
137
|
|
138
|
+
# @!method use(*features)
|
139
|
+
# Turn on {https://github.com/httprb/http HTTP} features
|
140
|
+
#
|
141
|
+
# @param features
|
142
|
+
# @return [self]
|
143
|
+
#
|
144
|
+
# @!method via(*proxy)
|
145
|
+
# Make a request through an HTTP proxy
|
146
|
+
#
|
147
|
+
# @param [Array] proxy
|
148
|
+
# @raise [HTTP::Request::Error] if HTTP proxy is invalid
|
149
|
+
# @return [self]
|
150
|
+
%i[timeout via through headers use].each do |method_name|
|
151
|
+
define_method(method_name) do |*args, &block|
|
152
|
+
@client = client.send(method_name, *args, &block)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
130
156
|
private
|
131
157
|
|
158
|
+
def validate(params)
|
159
|
+
validate_keywords(params)
|
160
|
+
validate_resources(params)
|
161
|
+
end
|
162
|
+
|
163
|
+
def validate_keywords(params)
|
164
|
+
return unless params[:keywords]
|
165
|
+
return if params[:keywords].is_a?(String)
|
166
|
+
|
167
|
+
raise ArgumentError, ':keyword argument expects a String'
|
168
|
+
end
|
169
|
+
|
170
|
+
def validate_resources(params)
|
171
|
+
return unless params[:resources]
|
172
|
+
|
173
|
+
raise ArgumentError, ':resources argument expects an Array' unless params[:resources].is_a?(Array)
|
174
|
+
|
175
|
+
params[:resources].each do |resource|
|
176
|
+
raise ArgumentError, "There is not such resource: #{resource}" unless Resource.valid?(resource)
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
132
180
|
def request(operation_name, params)
|
181
|
+
validate(params)
|
133
182
|
@operation = Operation.new(operation_name, params: params, locale: locale)
|
134
183
|
response = client.headers(operation.headers)
|
135
184
|
.post(operation.url, body: operation.body)
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Vacuum
|
4
|
+
# Resources determine what information will be returned in the API response
|
5
|
+
#
|
6
|
+
# @see https://webservices.amazon.com/paapi5/documentation/resources.html
|
7
|
+
class Resource
|
8
|
+
ALL = %w[BrowseNodeInfo.BrowseNodes
|
9
|
+
BrowseNodeInfo.BrowseNodes.Ancestor
|
10
|
+
BrowseNodeInfo.BrowseNodes.SalesRank
|
11
|
+
BrowseNodeInfo.WebsiteSalesRank
|
12
|
+
Images.Primary.Small
|
13
|
+
Images.Primary.Medium
|
14
|
+
Images.Primary.Large
|
15
|
+
Images.Variants.Small
|
16
|
+
Images.Variants.Medium
|
17
|
+
Images.Variants.Large
|
18
|
+
ItemInfo.ByLineInfo
|
19
|
+
ItemInfo.Classifications
|
20
|
+
ItemInfo.ContentInfo
|
21
|
+
ItemInfo.ContentRating
|
22
|
+
ItemInfo.ExternalIds
|
23
|
+
ItemInfo.Features
|
24
|
+
ItemInfo.ManufactureInfo
|
25
|
+
ItemInfo.ProductInfo
|
26
|
+
ItemInfo.TechnicalInfo
|
27
|
+
ItemInfo.Title
|
28
|
+
ItemInfo.TradeInInfo
|
29
|
+
Offers.Listings.Availability.MaxOrderQuantity
|
30
|
+
Offers.Listings.Availability.Message
|
31
|
+
Offers.Listings.Availability.MinOrderQuantity
|
32
|
+
Offers.Listings.Availability.Type
|
33
|
+
Offers.Listings.Condition
|
34
|
+
Offers.Listings.Condition.SubCondition
|
35
|
+
Offers.Listings.DeliveryInfo.IsAmazonFulfilled
|
36
|
+
Offers.Listings.DeliveryInfo.IsFreeShippingEligible
|
37
|
+
Offers.Listings.DeliveryInfo.IsPrimeEligible
|
38
|
+
Offers.Listings.IsBuyBoxWinner
|
39
|
+
Offers.Listings.LoyaltyPoints.Points
|
40
|
+
Offers.Listings.MerchantInfo
|
41
|
+
Offers.Listings.Price
|
42
|
+
Offers.Listings.ProgramEligibility.IsPrimeExclusive
|
43
|
+
Offers.Listings.ProgramEligibility.IsPrimePantry
|
44
|
+
Offers.Listings.Promotions
|
45
|
+
Offers.Listings.SavingBasis
|
46
|
+
Offers.Summaries.HighestPrice
|
47
|
+
Offers.Summaries.LowestPrice
|
48
|
+
Offers.Summaries.OfferCount
|
49
|
+
ParentASIN].freeze
|
50
|
+
private_constant :ALL
|
51
|
+
|
52
|
+
# @!attribute [r] all
|
53
|
+
# @return [Array<String>]
|
54
|
+
def self.all
|
55
|
+
ALL
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.valid?(resource)
|
59
|
+
ALL.include?(resource)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/lib/vacuum/response.rb
CHANGED
@@ -12,6 +12,7 @@ module Vacuum
|
|
12
12
|
# @!method dig(*key)
|
13
13
|
# Delegates to the Hash returned by {Response#to_h} to extract a nested
|
14
14
|
# value specified by the sequence of keys
|
15
|
+
#
|
15
16
|
# @param [String] key one or more keys
|
16
17
|
# @see https://ruby-doc.org/core/Hash.html#method-i-dig
|
17
18
|
def_delegator :to_h, :dig
|
@@ -38,6 +39,7 @@ module Vacuum
|
|
38
39
|
end
|
39
40
|
|
40
41
|
# Casts body to Hash
|
42
|
+
#
|
41
43
|
# @return [Hash]
|
42
44
|
def to_h
|
43
45
|
JSON.parse(body)
|
data/lib/vacuum/version.rb
CHANGED
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'integration_helper'
|
4
|
+
|
5
|
+
module Vacuum
|
6
|
+
class TestRequests < IntegrationTest
|
7
|
+
def test_get_browse_nodes
|
8
|
+
requests.each do |request|
|
9
|
+
response = request.get_browse_nodes(browse_node_ids: ['3045'])
|
10
|
+
assert_equal 200, response.status
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_get_items
|
15
|
+
requests.each do |request|
|
16
|
+
response = request.get_items(item_ids: ['B07212L4G2'])
|
17
|
+
assert_equal 200, response.status
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_get_items_with_all_resources
|
22
|
+
requests.each do |request|
|
23
|
+
response = request.get_items(item_ids: 'B07212L4G2',
|
24
|
+
resources: Resource.all)
|
25
|
+
assert_equal 200, response.status
|
26
|
+
item = response.dig('ItemsResult', 'Items').first
|
27
|
+
assert item.key?('BrowseNodeInfo')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_get_variations
|
32
|
+
requests.each do |request|
|
33
|
+
response = request.get_variations(asin: 'B07212L4G2')
|
34
|
+
assert_equal 200, response.status
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_search_items
|
39
|
+
requests.each do |request|
|
40
|
+
response = request.search_items(keywords: 'Harry Potter')
|
41
|
+
assert_equal 200, response.status
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_persistent
|
46
|
+
request = requests.sample
|
47
|
+
refute request.client.persistent?
|
48
|
+
request.persistent
|
49
|
+
assert request.client.persistent?
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_logging
|
53
|
+
require 'logger'
|
54
|
+
logdev = StringIO.new
|
55
|
+
logger = Logger.new(logdev)
|
56
|
+
request = requests.sample
|
57
|
+
request.use(logging: { logger: logger })
|
58
|
+
request.search_items(keywords: 'Harry Potter')
|
59
|
+
refute_empty logdev.string
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
File without changes
|
File without changes
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'helper'
|
4
|
+
require 'vacuum/request'
|
5
|
+
|
6
|
+
module Vacuum
|
7
|
+
class TestRequest < Minitest::Test
|
8
|
+
def test_search_keywords
|
9
|
+
err = assert_raises(ArgumentError) do
|
10
|
+
api.search_items(keywords: ['Harry Potter'])
|
11
|
+
end
|
12
|
+
|
13
|
+
assert_equal ':keyword argument expects a String', err.message
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_search_resources
|
17
|
+
err = assert_raises(ArgumentError) do
|
18
|
+
api.search_items(
|
19
|
+
keywords: 'Harry Potter',
|
20
|
+
resources: %w[Images.Primary.Large ItemInfo.ExternalIds Offer.Listings.Price]
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
assert_equal 'There is not such resource: Offer.Listings.Price', err.message
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_get_items_wrong_resource
|
28
|
+
err = assert_raises(ArgumentError) do
|
29
|
+
api.get_items(
|
30
|
+
item_ids: :B07212L4G2,
|
31
|
+
resources: %w[BrowseNodeInfo.BrowseNode.SalesRank]
|
32
|
+
)
|
33
|
+
end
|
34
|
+
|
35
|
+
assert_equal 'There is not such resource: BrowseNodeInfo.BrowseNode.SalesRank', err.message
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_get_variations_wrong_resource
|
39
|
+
err = assert_raises(ArgumentError) do
|
40
|
+
api.get_variations(asin: 'B07212L4G2', resources: %w[BrowseNodeInfo.BrowseNode.SalesRank])
|
41
|
+
end
|
42
|
+
|
43
|
+
assert_equal 'There is not such resource: BrowseNodeInfo.BrowseNode.SalesRank', err.message
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_resource_not_array
|
47
|
+
err = assert_raises(ArgumentError) do
|
48
|
+
api.get_items(item_ids: :B07212L4G2, resources: 'foo')
|
49
|
+
end
|
50
|
+
|
51
|
+
assert_equal ':resources argument expects an Array', err.message
|
52
|
+
end
|
53
|
+
|
54
|
+
def api
|
55
|
+
@api ||= Vacuum::Request.new(marketplace: 'US',
|
56
|
+
access_key: 'key',
|
57
|
+
secret_key: 'secret',
|
58
|
+
partner_tag: 'tag')
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
File without changes
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vacuum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hakan Ensari
|
8
|
+
- Stanislav Katkov
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2020-
|
12
|
+
date: 2020-05-27 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: aws-sigv4
|
@@ -84,16 +85,16 @@ dependencies:
|
|
84
85
|
name: simplecov
|
85
86
|
requirement: !ruby/object:Gem::Requirement
|
86
87
|
requirements:
|
87
|
-
- -
|
88
|
+
- - '='
|
88
89
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
90
|
+
version: 0.17.1
|
90
91
|
type: :development
|
91
92
|
prerelease: false
|
92
93
|
version_requirements: !ruby/object:Gem::Requirement
|
93
94
|
requirements:
|
94
|
-
- -
|
95
|
+
- - '='
|
95
96
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
97
|
+
version: 0.17.1
|
97
98
|
- !ruby/object:Gem::Dependency
|
98
99
|
name: vcr
|
99
100
|
requirement: !ruby/object:Gem::Requirement
|
@@ -139,6 +140,7 @@ dependencies:
|
|
139
140
|
description: A wrapper to the Amazon Product Advertising API
|
140
141
|
email:
|
141
142
|
- me@hakanensari.com
|
143
|
+
- sk@skylup.com
|
142
144
|
executables: []
|
143
145
|
extensions: []
|
144
146
|
extra_rdoc_files: []
|
@@ -150,18 +152,21 @@ files:
|
|
150
152
|
- lib/vacuum/matcher.rb
|
151
153
|
- lib/vacuum/operation.rb
|
152
154
|
- lib/vacuum/request.rb
|
155
|
+
- lib/vacuum/resource.rb
|
153
156
|
- lib/vacuum/response.rb
|
154
157
|
- lib/vacuum/version.rb
|
155
158
|
- test/cassettes/vacuum.yml
|
156
159
|
- test/helper.rb
|
160
|
+
- test/integration/test_requests.rb
|
157
161
|
- test/integration_helper.rb
|
158
162
|
- test/locales.rb
|
159
163
|
- test/locales.yml
|
160
164
|
- test/locales.yml.example
|
161
|
-
- test/
|
162
|
-
- test/
|
163
|
-
- test/
|
164
|
-
- test/
|
165
|
+
- test/unit/test_locale.rb
|
166
|
+
- test/unit/test_operation.rb
|
167
|
+
- test/unit/test_request.rb
|
168
|
+
- test/unit/test_resource.rb
|
169
|
+
- test/unit/test_response.rb
|
165
170
|
homepage: https://github.com/hakanensari/vacuum
|
166
171
|
licenses:
|
167
172
|
- MIT
|
@@ -174,7 +179,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
174
179
|
requirements:
|
175
180
|
- - ">="
|
176
181
|
- !ruby/object:Gem::Version
|
177
|
-
version: '2.
|
182
|
+
version: '2.5'
|
178
183
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
179
184
|
requirements:
|
180
185
|
- - ">="
|
@@ -186,11 +191,13 @@ signing_key:
|
|
186
191
|
specification_version: 4
|
187
192
|
summary: Amazon Product Advertising in Ruby
|
188
193
|
test_files:
|
194
|
+
- test/unit/test_operation.rb
|
195
|
+
- test/unit/test_request.rb
|
196
|
+
- test/unit/test_resource.rb
|
197
|
+
- test/unit/test_response.rb
|
198
|
+
- test/unit/test_locale.rb
|
189
199
|
- test/helper.rb
|
190
|
-
- test/
|
191
|
-
- test/vacuum/test_request.rb
|
192
|
-
- test/vacuum/test_response.rb
|
193
|
-
- test/vacuum/test_locale.rb
|
200
|
+
- test/integration/test_requests.rb
|
194
201
|
- test/cassettes/vacuum.yml
|
195
202
|
- test/integration_helper.rb
|
196
203
|
- test/locales.rb
|
data/test/vacuum/test_request.rb
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'integration_helper'
|
4
|
-
|
5
|
-
module Vacuum
|
6
|
-
class TestRequest < IntegrationTest
|
7
|
-
def test_get_browse_nodes
|
8
|
-
requests.each do |request|
|
9
|
-
response = request.get_browse_nodes(browse_node_ids: ['3045'])
|
10
|
-
assert_equal 200, response.status
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_get_items
|
15
|
-
requests.each do |request|
|
16
|
-
response = request.get_items(item_ids: ['B07212L4G2'])
|
17
|
-
assert_equal 200, response.status
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_get_items_with_all_resources
|
22
|
-
requests.each do |request|
|
23
|
-
response = request.get_items(item_ids: 'B07212L4G2',
|
24
|
-
resources: ALL_RESOURCES)
|
25
|
-
item = response.dig('ItemsResult', 'Items').first
|
26
|
-
assert item.key?('BrowseNodeInfo')
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_get_variations
|
31
|
-
requests.each do |request|
|
32
|
-
response = request.get_variations(asin: 'B07212L4G2')
|
33
|
-
assert_equal 200, response.status
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_search_items
|
38
|
-
requests.each do |request|
|
39
|
-
response = request.search_items(keywords: 'Harry Potter')
|
40
|
-
assert_equal 200, response.status
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_persistent
|
45
|
-
request = requests.sample
|
46
|
-
refute request.client.persistent?
|
47
|
-
request.persistent
|
48
|
-
assert request.client.persistent?
|
49
|
-
end
|
50
|
-
|
51
|
-
ALL_RESOURCES =
|
52
|
-
%w[BrowseNodeInfo.BrowseNodes BrowseNodeInfo.BrowseNodes.Ancestor
|
53
|
-
BrowseNodeInfo.BrowseNodes.SalesRank BrowseNodeInfo.WebsiteSalesRank
|
54
|
-
Images.Primary.Small Images.Primary.Medium Images.Primary.Large
|
55
|
-
Images.Variants.Small Images.Variants.Medium Images.Variants.Large
|
56
|
-
ItemInfo.ByLineInfo ItemInfo.Classifications ItemInfo.ContentInfo
|
57
|
-
ItemInfo.ContentRating ItemInfo.ExternalIds ItemInfo.Features
|
58
|
-
ItemInfo.ManufactureInfo ItemInfo.ProductInfo ItemInfo.TechnicalInfo
|
59
|
-
ItemInfo.Title ItemInfo.TradeInInfo
|
60
|
-
Offers.Listings.Availability.MaxOrderQuantity
|
61
|
-
Offers.Listings.Availability.Message
|
62
|
-
Offers.Listings.Availability.MinOrderQuantity
|
63
|
-
Offers.Listings.Availability.Type Offers.Listings.Condition
|
64
|
-
Offers.Listings.Condition.SubCondition
|
65
|
-
Offers.Listings.DeliveryInfo.IsAmazonFulfilled
|
66
|
-
Offers.Listings.DeliveryInfo.IsFreeShippingEligible
|
67
|
-
Offers.Listings.DeliveryInfo.IsPrimeEligible
|
68
|
-
Offers.Listings.IsBuyBoxWinner Offers.Listings.LoyaltyPoints.Points
|
69
|
-
Offers.Listings.MerchantInfo Offers.Listings.Price
|
70
|
-
Offers.Listings.ProgramEligibility.IsPrimeExclusive
|
71
|
-
Offers.Listings.ProgramEligibility.IsPrimePantry
|
72
|
-
Offers.Listings.Promotions Offers.Listings.SavingBasis
|
73
|
-
Offers.Summaries.HighestPrice Offers.Summaries.LowestPrice
|
74
|
-
Offers.Summaries.OfferCount ParentASIN].freeze
|
75
|
-
private_constant :ALL_RESOURCES
|
76
|
-
end
|
77
|
-
end
|