paapi 0.1.5 → 0.1.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 108df76951b9a410d040f8da6c7c915262955dce5484328f0f8e8b10cbc65c76
4
- data.tar.gz: db5c684ded7f43e1451e6ffaa3835b1fe552372a7d1e039f0a7977d108c598a2
3
+ metadata.gz: 40f433f95c408becd287ae9cfa62596852bdf95f7819321c3c14bea9e9b45e52
4
+ data.tar.gz: 21fab0c1b0502c992f72f4cc5844396d96757cb6fa807fd7ac0f6c80c2c97835
5
5
  SHA512:
6
- metadata.gz: 689c4019cfc8cb11577e47427bb165a84fd69db9b5e682c81783e460138cc04cb2f1303a3c582eb04e97f868b8fe72eafd05df57c1cfe6eb68ff541ec221724e
7
- data.tar.gz: 7def30214ab3c07e19b04cb8213bcc2f2cf46165ec56e0f9960349b5ab899c4fa71683c7b153bea6407303ef6c4457798740b6f58d7af43e0b589d603b4a1c46
6
+ metadata.gz: e43c529bfa5bf168d605af7f2b32bd5d6910acbb41047cddfeabe7c2566f3b43a9e99ea2ca3b8046d9f7ec1e06ae0e889c2a4dc4dfb840eee20c5cbf4c1dc43a
7
+ data.tar.gz: 98f0ee7c98a77d301d82128c101e5108d57c20d3d096ebc8ea095f9c478289a0fcc676eb9646c4672238ba71d546d389aa07dd9279e03415bd0ada2fdae7c9b3
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 0.1.7 ( Unreleased )
2
+ - Add gem 'net-http-persistent' for connection persistance
3
+ - Remove the code which would use other http clients if available
1
4
  ## 0.1.3
2
5
  - Dropped the HTTP gem and moved to Ruby's Net::HTTP
3
6
  - Merged a branch which adds the Condtion parameter.
data/README.md CHANGED
@@ -77,13 +77,10 @@ client = Paapi::Client.new(access_key: ENV['access_key'], secret_key: ENV['secre
77
77
  gi = client.get_items(item_ids: '1857231384')
78
78
 
79
79
  si = client.search_items(keywords: 'Harry Potter')
80
- si = client.search_items(keywords: 'Harry Potter', SearchIndex)
81
80
 
82
81
  gv = client.get_variations(asin: 'B00422MCUS')
83
82
  ```
84
83
 
85
- You can access the response as a Hash, or
86
-
87
84
  ## Development
88
85
 
89
86
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
data/lib/paapi/client.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'net/http'
1
+ require 'net/http/persistent'
2
2
  require 'aws-sigv4'
3
3
 
4
4
  module Paapi
@@ -10,9 +10,9 @@ module Paapi
10
10
  def initialize(access_key: Paapi.access_key,
11
11
  secret_key: Paapi.secret_key,
12
12
  partner_tag: Paapi.partner_tag,
13
- market: Paapi.market || DEFAULT_MARKET,
13
+ market: Paapi.market || DEFAULT_MARKET,
14
14
  condition: Paapi.condition || DEFAULT_CONDITION,
15
- resources: Paapi.resources || DEFAULT_RESOURCES,
15
+ resources: Paapi.resources || DEFAULT_RESOURCES,
16
16
  partner_type: DEFAULT_PARTNER_TYPE
17
17
  )
18
18
  raise ArgumentError unless MARKETPLACES.keys.include?(market.to_sym)
@@ -25,13 +25,7 @@ module Paapi
25
25
  self.market = market
26
26
  @partner_tag = partner_tag if !partner_tag.nil?
27
27
 
28
- if defined?(HTTPX)
29
- @http = HTTPX.plugin(:persistent)
30
- elsif defined?(HTTP)
31
- @http = HTTP::Client.new
32
- else
33
- @http = nil
34
- end
28
+ @http = Net::HTTP::Persistent.new name: 'paapi'
35
29
  end
36
30
 
37
31
  def market=(a_market)
@@ -107,24 +101,20 @@ module Paapi
107
101
  headers['X-Amz-Content-Sha256']= signature.headers['x-amz-content-sha256']
108
102
  headers['Authorization'] = signature.headers['authorization']
109
103
  headers['Content-Type'] = 'application/json; charset=utf-8'
110
-
111
- unless @http.nil?
112
- Response.new( @http.with_headers(headers).post(endpoint, json: payload ) )
113
- else
114
- Response.new( Client.post(url: endpoint, body: payload, headers: headers))
115
- end
116
104
 
105
+ Response.new( post(url: endpoint, body: payload, headers: headers))
117
106
  end
118
107
 
119
- def self.post(url:, body:, headers:)
108
+ def post(url:, body:, headers:)
120
109
  uri = URI.parse(url)
121
- request = Net::HTTP::Post.new(uri)
122
- request.content_type = 'application/json; charset=UTF-8'
123
- headers.each { |k, v| request[k] = v }
124
- request.body = body.to_json
125
- Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
126
- http.request(request)
127
- end
110
+
111
+ post_request = Net::HTTP::Post.new(uri.path)
112
+ post_request.content_type = 'application/json; charset=UTF-8'
113
+
114
+ headers.each { |k, v| post_request[k] = v }
115
+ post_request.body = body.to_json
116
+
117
+ http.request uri, post_request
128
118
  end
129
119
  end
130
120
  end
data/lib/paapi/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Paapi
2
- VERSION = '0.1.5'
2
+ VERSION = '0.1.8'
3
3
  end
data/lib/paapi.rb CHANGED
@@ -42,7 +42,7 @@ module Paapi
42
42
 
43
43
  MARKETPLACES = {
44
44
  au: Locale.new(:au, 'Australia', 'webservices.amazon.com.au', 'us-west-2'),
45
- br: Locale.new(:br, 'Brazil', 'webservices.amazon.com.br' 'us-east-1'),
45
+ br: Locale.new(:br, 'Brazil', 'webservices.amazon.com.br', 'us-east-1'),
46
46
  ca: Locale.new(:ca, 'Canada', 'webservices.amazon.ca', 'us-east-1'),
47
47
  fr: Locale.new(:fr, 'France', 'webservices.amazon.fr', 'eu-west-1'),
48
48
  de: Locale.new(:de, 'Germany', 'webservices.amazon.de', 'eu-west-1'),
data/paapi.gemspec CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
14
14
 
15
15
  spec.metadata['homepage_uri'] = spec.homepage
16
16
  spec.metadata['source_code_uri'] = spec.homepage
17
- #spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
17
+ spec.metadata["changelog_uri"] = "https://github.com/dkam/paapi/blob/master/CHANGELOG.md"
18
18
 
19
19
  # Specify which files should be added to the gem when it is released.
20
20
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.add_development_dependency 'rake', '>= 12.3.r3'
30
30
  spec.add_development_dependency 'minitest', '~> 5.0'
31
31
  spec.add_development_dependency 'byebug', '~> 11'
32
- spec.add_development_dependency 'awesome_print', '~> 1.8'
33
32
 
34
33
  spec.add_dependency 'aws-sigv4', '~> 1'
34
+ spec.add_dependency 'net-http-persistent', '~> 4.0', '>= 4.0.1'
35
35
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Milne
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-08-10 00:00:00.000000000 Z
11
+ date: 2023-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -67,33 +67,39 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '11'
69
69
  - !ruby/object:Gem::Dependency
70
- name: awesome_print
70
+ name: aws-sigv4
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '1.8'
76
- type: :development
75
+ version: '1'
76
+ type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '1.8'
82
+ version: '1'
83
83
  - !ruby/object:Gem::Dependency
84
- name: aws-sigv4
84
+ name: net-http-persistent
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '1'
89
+ version: '4.0'
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: 4.0.1
90
93
  type: :runtime
91
94
  prerelease: false
92
95
  version_requirements: !ruby/object:Gem::Requirement
93
96
  requirements:
94
97
  - - "~>"
95
98
  - !ruby/object:Gem::Version
96
- version: '1'
99
+ version: '4.0'
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: 4.0.1
97
103
  description:
98
104
  email:
99
105
  - d@nmilne.com
@@ -123,6 +129,7 @@ licenses:
123
129
  metadata:
124
130
  homepage_uri: https://github.com/dkam/paapi
125
131
  source_code_uri: https://github.com/dkam/paapi
132
+ changelog_uri: https://github.com/dkam/paapi/blob/master/CHANGELOG.md
126
133
  post_install_message:
127
134
  rdoc_options: []
128
135
  require_paths:
@@ -138,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
145
  - !ruby/object:Gem::Version
139
146
  version: '0'
140
147
  requirements: []
141
- rubygems_version: 3.3.7
148
+ rubygems_version: 3.4.12
142
149
  signing_key:
143
150
  specification_version: 4
144
151
  summary: Client library for Amazon's Product Advertising API v5