vacuum 3.0.0 → 3.1.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.
@@ -27,8 +27,6 @@ VCR.configure do |c|
27
27
  end
28
28
  end
29
29
 
30
- HTTPI.log = false
31
-
32
30
  module Vacuum
33
31
  class IntegrationTest < Minitest::Test
34
32
  def setup
data/test/locales.yml CHANGED
@@ -2,22 +2,22 @@
2
2
  :access_key: AKIAIWQTVHVWCQA5THXQ
3
3
  :secret_key: VOhSIqIY1wF5selhhJYJGVnIET9k5q0J8QjTX38i
4
4
  :partner_tag: adabo00-20
5
- - :marketplace: DE
6
- :access_key: AKIAIRMMTDVD7JUI65HA
7
- :secret_key: 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
8
- :partner_tag: partly0e-21
9
5
  - :marketplace: ES
10
- :access_key: AKIAIRMMTDVD7JUI65HA
11
- :secret_key: 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
12
- :partner_tag: partly01-21
13
- # - :marketplace: FR
14
- # :access_key: AKIAJDNYBNMN23YBFK3A
15
- # :secret_key: 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
16
- # :partner_tag: adabo-21
17
- # - :marketplace: IT
18
- # :access_key: AKIAIIJY6LYBYWTHITZQ
19
- # :secret_key: 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
20
- # :partner_tag: adabo0c-21
6
+ :access_key: AKIAJJF26BJLZLSJLFBQ
7
+ :secret_key: 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
8
+ :partner_tag: adabo00-21
9
+ - :marketplace: DE
10
+ :access_key: AKIAJGN5UNM43HHV5MZA
11
+ :secret_key: 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
12
+ :partner_tag: adabo23-21
13
+ - :marketplace: FR
14
+ :access_key: AKIAJDNYBNMN23YBFK3A
15
+ :secret_key: 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
16
+ :partner_tag: adabo-21
17
+ - :marketplace: IT
18
+ :access_key: AKIAJVBAH4XJHK6YF46Q
19
+ :secret_key: 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
20
+ :partner_tag: adabo0c-21
21
21
  - :marketplace: GB
22
22
  :access_key: AKIAJPAXMP45DOQJPHJQ
23
23
  :secret_key: feZKxFjRGLtmEO3JXpmCGdDaCPA7AHiVFBhQ/fkf
@@ -25,4 +25,4 @@
25
25
  - :marketplace: US
26
26
  :access_key: AKIAIWQTVHVWCQA5THXQ
27
27
  :secret_key: VOhSIqIY1wF5selhhJYJGVnIET9k5q0J8QjTX38i
28
- :partner_tag: adabo-20
28
+ :partner_tag: adabo-20
@@ -10,6 +10,14 @@
10
10
  :access_key: access_key
11
11
  :secret_key: secret_key
12
12
  :partner_tag: partner_tag
13
+ - :marketplace: FR
14
+ :access_key: access_key
15
+ :secret_key: secret_key
16
+ :partner_tag: partner_tag
17
+ - :marketplace: IT
18
+ :access_key: access_key
19
+ :secret_key: secret_key
20
+ :partner_tag: partner_tag
13
21
  - :marketplace: GB
14
22
  :access_key: access_key
15
23
  :secret_key: secret_key
@@ -5,31 +5,39 @@ require 'vacuum/locale'
5
5
 
6
6
  module Vacuum
7
7
  class TestLocale < Minitest::Test
8
- def test_find
9
- assert_kind_of Locale, Locale.find(:us)
8
+ def test_host
9
+ locale = Locale.new(:us, credentials)
10
+ assert locale.host
10
11
  end
11
12
 
12
- def test_find_uppercase_string
13
- assert_kind_of Locale, Locale.find('US')
13
+ def test_region
14
+ locale = Locale.new(:us, credentials)
15
+ assert locale.region
14
16
  end
15
17
 
16
- def test_find_uk
17
- assert_equal :gb, Locale.find('UK').code
18
+ def test_partner_type_default
19
+ locale = Locale.new(:us, credentials)
20
+ assert locale.partner_type
18
21
  end
19
22
 
20
- def test_raise_if_not_found
23
+ def test_upcased_marketplace
24
+ Locale.new('US', credentials) # does not raise
25
+ end
26
+
27
+ def test_uk
28
+ Locale.new(:uk, credentials) # does not raise
29
+ end
30
+
31
+ def test_not_found
21
32
  assert_raises Locale::NotFound do
22
- Locale.find('foo')
33
+ Locale.new(:foo, credentials)
23
34
  end
24
35
  end
25
36
 
26
- def test_build_url
27
- assert_equal 'https://webservices.amazon.com/paapi5/foo',
28
- Locale.find('US').build_url('Foo')
29
- end
37
+ private
30
38
 
31
- def test_marketplace
32
- assert_equal 'www.amazon.com', Locale.find('US').marketplace
39
+ def credentials
40
+ { access_key: '123', secret_key: '123', partner_tag: 'xyz-20' }
33
41
  end
34
42
  end
35
43
  end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'minitest/autorun'
4
+ require 'vacuum/locale'
5
+ require 'vacuum/operation'
6
+
7
+ module Vacuum
8
+ class TestOperation < Minitest::Test
9
+ def setup
10
+ @operation = Operation.new('Action', params: { foo: 1 }, locale: locale)
11
+ end
12
+
13
+ def test_body
14
+ assert @operation.body
15
+ end
16
+
17
+ def test_url
18
+ assert @operation.url
19
+ end
20
+
21
+ def test_headers
22
+ assert @operation.headers
23
+ end
24
+
25
+ private
26
+
27
+ def locale
28
+ Locale.new(:us, access_key: '123', secret_key: '123', partner_tag: 'xyz')
29
+ end
30
+ end
31
+ end
@@ -3,25 +3,25 @@
3
3
  require 'integration_helper'
4
4
 
5
5
  module Vacuum
6
- class RequestTest < IntegrationTest
6
+ class TestRequest < IntegrationTest
7
7
  def test_get_browse_nodes
8
8
  requests.each do |request|
9
9
  response = request.get_browse_nodes(browse_node_ids: ['3045'])
10
- refute response.error?
10
+ assert_equal 200, response.status
11
11
  end
12
12
  end
13
13
 
14
14
  def test_get_items
15
15
  requests.each do |request|
16
16
  response = request.get_items(item_ids: ['B07212L4G2'])
17
- refute response.error?
17
+ assert_equal 200, response.status
18
18
  end
19
19
  end
20
20
 
21
- def test_get_items_with_options
21
+ def test_get_items_with_all_resources
22
22
  requests.each do |request|
23
23
  response = request.get_items(item_ids: 'B07212L4G2',
24
- resources: ['BrowseNodeInfo.BrowseNodes'])
24
+ resources: ALL_RESOURCES)
25
25
  item = response.dig('ItemsResult', 'Items').first
26
26
  assert item.key?('BrowseNodeInfo')
27
27
  end
@@ -30,15 +30,48 @@ module Vacuum
30
30
  def test_get_variations
31
31
  requests.each do |request|
32
32
  response = request.get_variations(asin: 'B07212L4G2')
33
- refute response.error?
33
+ assert_equal 200, response.status
34
34
  end
35
35
  end
36
36
 
37
37
  def test_search_items
38
38
  requests.each do |request|
39
39
  response = request.search_items(keywords: 'Harry Potter')
40
- refute response.error?
40
+ assert_equal 200, response.status
41
41
  end
42
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
43
76
  end
44
77
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vacuum
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hakan Ensari
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-30 00:00:00.000000000 Z
11
+ date: 2019-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sigv4
@@ -25,19 +25,19 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: httpi
28
+ name: http
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '2.0'
33
+ version: '4.0'
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
- version: '2.0'
40
+ version: '4.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: minitest
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -134,6 +134,7 @@ files:
134
134
  - lib/vacuum.rb
135
135
  - lib/vacuum/locale.rb
136
136
  - lib/vacuum/matcher.rb
137
+ - lib/vacuum/operation.rb
137
138
  - lib/vacuum/request.rb
138
139
  - lib/vacuum/response.rb
139
140
  - lib/vacuum/version.rb
@@ -143,6 +144,7 @@ files:
143
144
  - test/locales.yml
144
145
  - test/locales.yml.example
145
146
  - test/vacuum/test_locale.rb
147
+ - test/vacuum/test_operation.rb
146
148
  - test/vacuum/test_request.rb
147
149
  - test/vacuum/test_response.rb
148
150
  homepage: https://github.com/hakanensari/vacuum
@@ -169,6 +171,7 @@ signing_key:
169
171
  specification_version: 4
170
172
  summary: Amazon Product Advertising in Ruby
171
173
  test_files:
174
+ - test/vacuum/test_operation.rb
172
175
  - test/vacuum/test_request.rb
173
176
  - test/vacuum/test_response.rb
174
177
  - test/vacuum/test_locale.rb