paapi_mini 0.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.
- checksums.yaml +7 -0
- data/.idea/.gitignore +8 -0
- data/.idea/modules.xml +8 -0
- data/.idea/paapi_mini.iml +23 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +10 -0
- data/LICENSE.txt +21 -0
- data/README.md +63 -0
- data/Rakefile +12 -0
- data/lib/aws_v4_auth.rb +211 -0
- data/lib/http_client.rb +69 -0
- data/lib/paapi_mini/version.rb +5 -0
- data/lib/paapi_mini.rb +41 -0
- data/paapi_mini.gemspec +39 -0
- data/sig/paapi_mini.rbs +4 -0
- metadata +61 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2fe6b5e86b7884e190fc6a4216deaa262a1d9d0ed15176cefa2cd409174ba931
|
4
|
+
data.tar.gz: 236cb6789ac6140643819c6333c664592bfc8969b0fa06a8e8b4bb57f11498cf
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 46514b47c10ff8493d1abb427e735465a30b0fcb09e416d08d6c371b2b250c176b297c1c53d41c208bc7b400e73687fb9d4911989e35d79891de50d71df213e9
|
7
|
+
data.tar.gz: fc421e43462fdcd9efdd30385ad32f254739436573e42ec1bfb3993ebe04530d135db5d3a8df990568569d6fc89ea384f1b41700450f5ff549cfaf71ea0c1d9c
|
data/.idea/.gitignore
ADDED
data/.idea/modules.xml
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project version="4">
|
3
|
+
<component name="ProjectModuleManager">
|
4
|
+
<modules>
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/paapi_mini.iml" filepath="$PROJECT_DIR$/.idea/paapi_mini.iml" />
|
6
|
+
</modules>
|
7
|
+
</component>
|
8
|
+
</project>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<module type="RUBY_MODULE" version="4">
|
3
|
+
<component name="ModuleRunConfigurationManager">
|
4
|
+
<shared />
|
5
|
+
</component>
|
6
|
+
<component name="NewModuleRootManager">
|
7
|
+
<content url="file://$MODULE_DIR$">
|
8
|
+
<sourceFolder url="file://$MODULE_DIR$/features" isTestSource="true" />
|
9
|
+
<sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
|
10
|
+
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
|
11
|
+
</content>
|
12
|
+
<orderEntry type="jdk" jdkName="rbenv: 3.1.2" jdkType="RUBY_SDK" />
|
13
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
14
|
+
<orderEntry type="library" scope="PROVIDED" name="bundler (v2.3.7, rbenv: 3.1.2) [gem]" level="application" />
|
15
|
+
<orderEntry type="library" scope="PROVIDED" name="minitest (v5.16.3, rbenv: 3.1.2) [gem]" level="application" />
|
16
|
+
<orderEntry type="library" scope="PROVIDED" name="rake (v13.0.6, rbenv: 3.1.2) [gem]" level="application" />
|
17
|
+
</component>
|
18
|
+
<component name="RakeTasksCache">
|
19
|
+
<option name="myRootTask">
|
20
|
+
<RakeTaskImpl id="rake" />
|
21
|
+
</option>
|
22
|
+
</component>
|
23
|
+
</module>
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2022 oco
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# PaapiMini
|
2
|
+
|
3
|
+
* This is a Gem for easy Amazon product search.<br>
|
4
|
+
Before using it, you need to pass Amazon Associate review and get ACCESS_KEY etc. as preparation.
|
5
|
+
* [Amazon Product Advertising API 5.0](https://webservices.amazon.com/paapi5/documentation/) is supported.
|
6
|
+
* This Gem is implemented using only the Ruby standard-attached library, so it does not depend on other Gems.
|
7
|
+
|
8
|
+
* Ruby versions that have been tested by rbenv
|
9
|
+
```
|
10
|
+
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-darwin20]
|
11
|
+
ruby 3.0.0rc1 (2020-12-20 master 8680ae9cbd) [x86_64-darwin20]
|
12
|
+
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-darwin21]
|
13
|
+
```
|
14
|
+
* We have not tested Ruby for Windows at this time.<br>
|
15
|
+
Also, since the author's Amazon Associate review is conducted by Amazon.co.jp, we are only able to test from this region.<br>
|
16
|
+
Therefore, the default behavior of the API is Amazon.co.jp. It is possible to change it with an argument.<br>
|
17
|
+
We would appreciate it if you could provide us with feedback if you can confirm that it works on the Windows version or in regions other than Amazon.co.jp.
|
18
|
+
|
19
|
+
## Installation
|
20
|
+
|
21
|
+
Add this line to your application's Gemfile:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
gem 'paapi_mini'
|
25
|
+
```
|
26
|
+
|
27
|
+
And then execute:
|
28
|
+
|
29
|
+
$ bundle install
|
30
|
+
|
31
|
+
Or install it yourself as:
|
32
|
+
|
33
|
+
$ gem install paapi_mini
|
34
|
+
|
35
|
+
## Usage
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
require 'paapi_mini'
|
39
|
+
|
40
|
+
# The keyword argument to the search_items method can be used to refine the condition.
|
41
|
+
# Please refer to the official reference for the specifications of each argument.
|
42
|
+
# See Also https://webservices.amazon.com/paapi5/documentation/search-items.html
|
43
|
+
# Default Values.
|
44
|
+
# item_page: 1,
|
45
|
+
# min_price: 1,
|
46
|
+
# max_price: 100000,
|
47
|
+
# min_review_rating: 1,
|
48
|
+
# host: "webservices.amazon.co.jp",
|
49
|
+
# region: "us-west-2",
|
50
|
+
# market_place: "www.amazon.co.jp"
|
51
|
+
|
52
|
+
res = PaapiMini::search_items(ENV['ACCESS_KEY'], ENV['SECRET_KEY'], ENV['PARTNER_TAG'],
|
53
|
+
keywords: "Ruby", min_review_rating: 3)
|
54
|
+
|
55
|
+
# res is Net::HTTPResponse Object
|
56
|
+
# See Also https://docs.ruby-lang.org/
|
57
|
+
puts res.code
|
58
|
+
puts res.body
|
59
|
+
```
|
60
|
+
|
61
|
+
## License
|
62
|
+
|
63
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/lib/aws_v4_auth.rb
ADDED
@@ -0,0 +1,211 @@
|
|
1
|
+
require 'digest'
|
2
|
+
require 'openssl'
|
3
|
+
require 'time'
|
4
|
+
require 'uri'
|
5
|
+
|
6
|
+
module PaapiMini
|
7
|
+
|
8
|
+
class Auth
|
9
|
+
|
10
|
+
attr_reader :access_key,
|
11
|
+
:secret_key,
|
12
|
+
:path,
|
13
|
+
:region,
|
14
|
+
:service,
|
15
|
+
:http_method_name,
|
16
|
+
:headers,
|
17
|
+
:payload,
|
18
|
+
:xamz_date,
|
19
|
+
:current_date,
|
20
|
+
:signed_headers
|
21
|
+
|
22
|
+
HMAC_ALGORITHM = 'AWS4-HMAC-SHA256'
|
23
|
+
AWS4_REQUEST = 'aws4_request'
|
24
|
+
|
25
|
+
public
|
26
|
+
|
27
|
+
# Make Auth Headers Strings for Amazon Product Advertising API 5.0
|
28
|
+
# reference: https://webservices.amazon.com/paapi5/documentation/without-sdk.html
|
29
|
+
# https://webservices.amazon.com/paapi5/documentation/sending-request.html#signing
|
30
|
+
# important! https://webservices.amazon.co.jp/paapi5/scratchpad/
|
31
|
+
def make_headers
|
32
|
+
@headers['X-Amz-Date'] = @xamz_date
|
33
|
+
@headers['X-Amz-Content-Sha256'] = OpenSSL::Digest::SHA256.hexdigest(@payload)
|
34
|
+
|
35
|
+
canonical_url = prepare_canonical_request(@http_method_name, @path, @headers['X-Amz-Content-Sha256'])
|
36
|
+
string_to_sign = prepare_string_to_sign(canonical_url)
|
37
|
+
signature = calculate_signature(string_to_sign)
|
38
|
+
@headers['Authorization'] = build_authorization_string(signature)
|
39
|
+
Hash[@headers]
|
40
|
+
end
|
41
|
+
|
42
|
+
# URI文字列の生成
|
43
|
+
# create_search_itemsを呼び出していないと機能しない
|
44
|
+
def make_uri
|
45
|
+
"https://#{@headers['Host']}#{@path}"
|
46
|
+
end
|
47
|
+
|
48
|
+
def prepare_canonical_request(http_method_name, path, payload)
|
49
|
+
canonical_url = []
|
50
|
+
uri = URI.parse(path.to_s)
|
51
|
+
canonical_url << http_method_name
|
52
|
+
canonical_url << "#{uri.path}\n"
|
53
|
+
|
54
|
+
@signed_headers = []
|
55
|
+
headers = @headers.sort_by(&:first)
|
56
|
+
canonical_headers = []
|
57
|
+
headers.each do |key, value|
|
58
|
+
@signed_headers << key.downcase
|
59
|
+
canonical_headers << "#{key.downcase}:#{value}"
|
60
|
+
end
|
61
|
+
|
62
|
+
canonical_url << "#{canonical_headers.join("\n")}\n"
|
63
|
+
canonical_url << @signed_headers.join(";")
|
64
|
+
canonical_url << payload
|
65
|
+
canonical_url.join("\n")
|
66
|
+
end
|
67
|
+
|
68
|
+
def prepare_string_to_sign(canonical_url)
|
69
|
+
string_to_sign = []
|
70
|
+
string_to_sign << HMAC_ALGORITHM
|
71
|
+
string_to_sign << @xamz_date
|
72
|
+
string_to_sign << "#{@current_date}/#{@region}/#{@service}/#{AWS4_REQUEST}"
|
73
|
+
string_to_sign << OpenSSL::Digest::SHA256.hexdigest(canonical_url)
|
74
|
+
string_to_sign.join("\n")
|
75
|
+
end
|
76
|
+
|
77
|
+
def calculate_signature(string_to_sign)
|
78
|
+
OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), signature_key(), string_to_sign)
|
79
|
+
end
|
80
|
+
|
81
|
+
def build_authorization_string(signature)
|
82
|
+
build_authorization_string = []
|
83
|
+
build_authorization_string << "Credential=#{credentials_path}"
|
84
|
+
build_authorization_string << "SignedHeaders=#{@signed_headers.join(";")}"
|
85
|
+
build_authorization_string << "Signature=#{signature}"
|
86
|
+
"#{HMAC_ALGORITHM} #{build_authorization_string.join(", ")}"
|
87
|
+
end
|
88
|
+
|
89
|
+
def credentials_path
|
90
|
+
credentials = [@access_key, @current_date, region, service, AWS4_REQUEST]
|
91
|
+
credentials.join("/")
|
92
|
+
end
|
93
|
+
|
94
|
+
protected
|
95
|
+
|
96
|
+
|
97
|
+
def initialize(access_key, secret_key, path, region, service, http_method_name, headers, payload)
|
98
|
+
@access_key, @secret_key, @path = access_key, secret_key, path
|
99
|
+
@region, @service, @http_method_name = region, service, http_method_name
|
100
|
+
@headers, @payload = headers, payload
|
101
|
+
@xamz_date, @current_date = Auth::utc_timestamp(Time.now)
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
# https://docs.aws.amazon.com/general/latest/gr/signature-v4-examples.html#signature-v4-examples-ruby
|
107
|
+
def signature_key
|
108
|
+
secret = "AWS4#{@secret_key}"
|
109
|
+
date = Auth::hmac_sha_256(secret, @current_date)
|
110
|
+
region = Auth::hmac_sha_256(date, @region)
|
111
|
+
service = Auth::hmac_sha_256(region, @service)
|
112
|
+
Auth::hmac_sha_256(service, AWS4_REQUEST)
|
113
|
+
end
|
114
|
+
|
115
|
+
class << self
|
116
|
+
|
117
|
+
# SearchItems
|
118
|
+
# https://webservices.amazon.com/paapi5/documentation/search-items.html
|
119
|
+
# SearchIndex
|
120
|
+
# https://webservices.amazon.com/paapi5/documentation/locale-reference/japan.html
|
121
|
+
def create_search_items(access_key,
|
122
|
+
secret_key,
|
123
|
+
partner_tag,
|
124
|
+
keywords:,
|
125
|
+
item_page: 1,
|
126
|
+
min_price: 1,
|
127
|
+
max_price: 100000,
|
128
|
+
min_review_rating: 1,
|
129
|
+
host: "webservices.amazon.co.jp",
|
130
|
+
region: "us-west-2",
|
131
|
+
market_place: "www.amazon.co.jp")
|
132
|
+
|
133
|
+
service = 'ProductAdvertisingAPI'
|
134
|
+
http_method_name = 'POST'
|
135
|
+
api_path = '/paapi5/searchitems'
|
136
|
+
|
137
|
+
headers = {}
|
138
|
+
headers['Content-Encoding'] = 'amz-1.0'
|
139
|
+
headers['Host'] = host
|
140
|
+
headers['X-Amz-Target'] = 'com.amazon.paapi5.v1.ProductAdvertisingAPIv1.SearchItems'
|
141
|
+
|
142
|
+
request_payload = <<~EOS
|
143
|
+
{
|
144
|
+
"Keywords": "#{keywords}",
|
145
|
+
"Resources": [
|
146
|
+
"BrowseNodeInfo.WebsiteSalesRank",
|
147
|
+
"CustomerReviews.Count",
|
148
|
+
"CustomerReviews.StarRating",
|
149
|
+
"Images.Primary.Small",
|
150
|
+
"Images.Primary.Medium",
|
151
|
+
"ItemInfo.ByLineInfo",
|
152
|
+
"ItemInfo.ContentInfo",
|
153
|
+
"ItemInfo.ContentRating",
|
154
|
+
"ItemInfo.Classifications",
|
155
|
+
"ItemInfo.ManufactureInfo",
|
156
|
+
"ItemInfo.ProductInfo",
|
157
|
+
"ItemInfo.TechnicalInfo",
|
158
|
+
"ItemInfo.Title",
|
159
|
+
"ItemInfo.TradeInInfo",
|
160
|
+
"Offers.Listings.Condition",
|
161
|
+
"Offers.Listings.Condition.ConditionNote",
|
162
|
+
"Offers.Listings.Condition.SubCondition",
|
163
|
+
"Offers.Listings.DeliveryInfo.IsAmazonFulfilled",
|
164
|
+
"Offers.Listings.DeliveryInfo.IsFreeShippingEligible",
|
165
|
+
"Offers.Listings.DeliveryInfo.IsPrimeEligible",
|
166
|
+
"Offers.Listings.DeliveryInfo.ShippingCharges",
|
167
|
+
"Offers.Listings.IsBuyBoxWinner",
|
168
|
+
"Offers.Listings.LoyaltyPoints.Points",
|
169
|
+
"Offers.Listings.MerchantInfo",
|
170
|
+
"Offers.Listings.Price",
|
171
|
+
"Offers.Listings.ProgramEligibility.IsPrimeExclusive",
|
172
|
+
"Offers.Listings.ProgramEligibility.IsPrimePantry",
|
173
|
+
"Offers.Listings.Promotions",
|
174
|
+
"Offers.Listings.SavingBasis",
|
175
|
+
"Offers.Summaries.HighestPrice",
|
176
|
+
"Offers.Summaries.LowestPrice",
|
177
|
+
"Offers.Summaries.OfferCount",
|
178
|
+
"ParentASIN",
|
179
|
+
"SearchRefinements"
|
180
|
+
],
|
181
|
+
"SearchIndex": "All",
|
182
|
+
"PartnerTag": "#{partner_tag}",
|
183
|
+
"PartnerType": "Associates",
|
184
|
+
"Marketplace": "#{market_place}",
|
185
|
+
"Operation": "SearchItems",
|
186
|
+
"ItemPage": #{item_page},
|
187
|
+
"MinReviewsRating": #{min_review_rating},
|
188
|
+
"MinPrice": #{min_price},
|
189
|
+
"MaxPrice": #{max_price},
|
190
|
+
"CurrencyOfPreference":"JPY",
|
191
|
+
"Condition":"New",
|
192
|
+
"DeliveryFlags":["FulfilledByAmazon"]
|
193
|
+
}
|
194
|
+
EOS
|
195
|
+
|
196
|
+
Auth.new(access_key, secret_key, api_path, region, service, http_method_name, headers, request_payload)
|
197
|
+
end
|
198
|
+
|
199
|
+
def hmac_sha_256(key, base_string)
|
200
|
+
OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha256'), key, base_string)
|
201
|
+
end
|
202
|
+
|
203
|
+
def utc_timestamp(time)
|
204
|
+
now = time.utc
|
205
|
+
return now.strftime("%Y%m%dT%H%M%SZ"), now.strftime("%Y%m%d")
|
206
|
+
end
|
207
|
+
|
208
|
+
end
|
209
|
+
|
210
|
+
end
|
211
|
+
end
|
data/lib/http_client.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'net/https'
|
3
|
+
require 'uri'
|
4
|
+
|
5
|
+
module PaapiMini
|
6
|
+
module Http
|
7
|
+
|
8
|
+
# Exception
|
9
|
+
class Error < StandardError
|
10
|
+
def initialize(msg = 'HttpClient Error Message.')
|
11
|
+
super
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# Post
|
16
|
+
def self.post(uri, payload, headers, options = {})
|
17
|
+
begin
|
18
|
+
parsed_uri, http = create_http(uri, options.has_key?(:proxy_url) ? options[:proxy_url] : nil)
|
19
|
+
req = Net::HTTP::Post.new(parsed_uri.request_uri)
|
20
|
+
|
21
|
+
headers.each do |key, value|
|
22
|
+
req[key.to_s] = value.to_s
|
23
|
+
end
|
24
|
+
|
25
|
+
if options.has_key?(:basic_auth)
|
26
|
+
req.basic_auth(options[:basic_auth][0], options[:basic_auth][1])
|
27
|
+
end
|
28
|
+
|
29
|
+
req.body = payload
|
30
|
+
http.request(req)
|
31
|
+
rescue => e
|
32
|
+
raise PaapiMini::Http::Error.new("#{e.message} #{e.backtrace}" )
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
class << self
|
37
|
+
private
|
38
|
+
|
39
|
+
def create_http(uri, proxy_uri)
|
40
|
+
parsed_uri = URI.parse(uri)
|
41
|
+
if parsed_uri.to_s == ""
|
42
|
+
raise PaapiMini::Http::Error.new("URI parse error. uri=>#{uri}")
|
43
|
+
end
|
44
|
+
|
45
|
+
http = if !proxy_uri.nil? && proxy_uri.length > 0
|
46
|
+
parsed_proxy_uri = URI.parse(proxy_uri)
|
47
|
+
if parsed_proxy_uri.to_s == ""
|
48
|
+
raise PaapiMini::Http::Error.new("URI parse error. proxy_uri=>#{proxy_uri}")
|
49
|
+
end
|
50
|
+
|
51
|
+
# Proxy Server
|
52
|
+
proxy_class = Net::HTTP::Proxy(parsed_proxy_uri.host.to_s, parsed_proxy_uri.port)
|
53
|
+
proxy_class.new(parsed_uri.host, parsed_uri.port)
|
54
|
+
else
|
55
|
+
Net::HTTP.new(parsed_uri.host.to_s, parsed_uri.port)
|
56
|
+
end
|
57
|
+
|
58
|
+
http.open_timeout = 5
|
59
|
+
http.read_timeout = 5
|
60
|
+
|
61
|
+
if parsed_uri.scheme == 'https'
|
62
|
+
http.use_ssl = true
|
63
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
64
|
+
end
|
65
|
+
[parsed_uri, http]
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
data/lib/paapi_mini.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "paapi_mini/version"
|
4
|
+
require_relative 'aws_v4_auth'
|
5
|
+
require_relative 'http_client'
|
6
|
+
|
7
|
+
module PaapiMini
|
8
|
+
class Error < StandardError; end
|
9
|
+
|
10
|
+
def self.search_items(access_key,
|
11
|
+
secret_key,
|
12
|
+
partner_tag,
|
13
|
+
keywords,
|
14
|
+
item_page: 1,
|
15
|
+
min_price: 1,
|
16
|
+
max_price: 100000,
|
17
|
+
min_review_rating: 1,
|
18
|
+
host: "webservices.amazon.co.jp",
|
19
|
+
region: "us-west-2",
|
20
|
+
market_place: "www.amazon.co.jp")
|
21
|
+
|
22
|
+
aws_auth = Auth.create_search_items(access_key,
|
23
|
+
secret_key,
|
24
|
+
partner_tag,
|
25
|
+
keywords: keywords,
|
26
|
+
item_page: item_page,
|
27
|
+
min_price: min_price,
|
28
|
+
max_price: max_price,
|
29
|
+
min_review_rating: min_review_rating,
|
30
|
+
host: host,
|
31
|
+
region: region,
|
32
|
+
market_place: market_place)
|
33
|
+
|
34
|
+
aws_auth_headers = aws_auth.make_headers
|
35
|
+
aws_auth_headers['Content-Type'] = 'application/json; charset=utf-8'
|
36
|
+
|
37
|
+
return Http.post(aws_auth.make_uri, aws_auth.payload, aws_auth_headers)
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
end
|
data/paapi_mini.gemspec
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/paapi_mini/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "paapi_mini"
|
7
|
+
spec.version = PaapiMini::VERSION
|
8
|
+
spec.authors = ["oco"]
|
9
|
+
spec.email = ["osio.toshimasa@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = "Simple Amazon SearchItems By Amazon Advertising Product API."
|
12
|
+
spec.description = "This Gem is implemented using only the Ruby standard library, so it does not depend on other Gems"
|
13
|
+
spec.homepage = "https://github.com/osio-toshimasa/paapi_mini"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = ">= 2.7.0"
|
16
|
+
|
17
|
+
# spec.metadata["allowed_push_host"] = ""
|
18
|
+
|
19
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
20
|
+
spec.metadata["source_code_uri"] = "https://github.com/osio-toshimasa/paapi_mini"
|
21
|
+
spec.metadata["changelog_uri"] = "https://github.com/osio-toshimasa/paapi_mini/CHANGELOG.md"
|
22
|
+
|
23
|
+
# Specify which files should be added to the gem when it is released.
|
24
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
25
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
26
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
27
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
28
|
+
end
|
29
|
+
end
|
30
|
+
spec.bindir = "exe"
|
31
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
32
|
+
spec.require_paths = ["lib"]
|
33
|
+
|
34
|
+
# Uncomment to register a new dependency of your gem
|
35
|
+
# spec.add_dependency "example-gem", "~> 1.0"
|
36
|
+
|
37
|
+
# For more information and examples about making a new gem, check out our
|
38
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
39
|
+
end
|
data/sig/paapi_mini.rbs
ADDED
metadata
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: paapi_mini
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- oco
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-10-16 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: This Gem is implemented using only the Ruby standard library, so it does
|
14
|
+
not depend on other Gems
|
15
|
+
email:
|
16
|
+
- osio.toshimasa@gmail.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- ".idea/.gitignore"
|
22
|
+
- ".idea/modules.xml"
|
23
|
+
- ".idea/paapi_mini.iml"
|
24
|
+
- CHANGELOG.md
|
25
|
+
- Gemfile
|
26
|
+
- LICENSE.txt
|
27
|
+
- README.md
|
28
|
+
- Rakefile
|
29
|
+
- lib/aws_v4_auth.rb
|
30
|
+
- lib/http_client.rb
|
31
|
+
- lib/paapi_mini.rb
|
32
|
+
- lib/paapi_mini/version.rb
|
33
|
+
- paapi_mini.gemspec
|
34
|
+
- sig/paapi_mini.rbs
|
35
|
+
homepage: https://github.com/osio-toshimasa/paapi_mini
|
36
|
+
licenses:
|
37
|
+
- MIT
|
38
|
+
metadata:
|
39
|
+
homepage_uri: https://github.com/osio-toshimasa/paapi_mini
|
40
|
+
source_code_uri: https://github.com/osio-toshimasa/paapi_mini
|
41
|
+
changelog_uri: https://github.com/osio-toshimasa/paapi_mini/CHANGELOG.md
|
42
|
+
post_install_message:
|
43
|
+
rdoc_options: []
|
44
|
+
require_paths:
|
45
|
+
- lib
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: 2.7.0
|
51
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
requirements: []
|
57
|
+
rubygems_version: 3.3.7
|
58
|
+
signing_key:
|
59
|
+
specification_version: 4
|
60
|
+
summary: Simple Amazon SearchItems By Amazon Advertising Product API.
|
61
|
+
test_files: []
|