rapa 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,79 @@
1
+ require "base64"
2
+ require "openssl"
3
+
4
+ module Rapa
5
+ class Signer
6
+ # @param host [String]
7
+ # @param http_method [String]
8
+ # @param key [String]
9
+ # @param path [String]
10
+ # @param query_string [String]
11
+ def initialize(host:, http_method:, key:, path:, query_string:)
12
+ @host = host
13
+ @http_method = http_method
14
+ @key = key
15
+ @path = path
16
+ @query_string = query_string
17
+ end
18
+
19
+ # @return [String]
20
+ def sign
21
+ ::Base64.encode64(
22
+ ::OpenSSL::HMAC.digest(
23
+ digest,
24
+ key,
25
+ source,
26
+ ),
27
+ ).chomp
28
+ end
29
+
30
+ private
31
+
32
+ # @private
33
+ # @return [OpenSSL::Digest]
34
+ def digest
35
+ ::OpenSSL::Digest.new("sha256")
36
+ end
37
+
38
+ # @private
39
+ # @return [String]
40
+ def host
41
+ @host
42
+ end
43
+
44
+ # @private
45
+ # @return [String]
46
+ def http_method
47
+ @http_method
48
+ end
49
+
50
+ # @private
51
+ # @return [String]
52
+ def key
53
+ @key
54
+ end
55
+
56
+ # @private
57
+ # @return [String]
58
+ def path
59
+ @path
60
+ end
61
+
62
+ # @private
63
+ # @return [String]
64
+ def query_string
65
+ @query_string
66
+ end
67
+
68
+ # @private
69
+ # @return [String]
70
+ def source
71
+ [
72
+ http_method,
73
+ host,
74
+ path,
75
+ query_string,
76
+ ].join("\n")
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,21 @@
1
+ module Rapa
2
+ class SimilarProduct
3
+ # @return [Hash]
4
+ attr_reader :source
5
+
6
+ # @param source [Hash]
7
+ def initialize(source)
8
+ @source = source
9
+ end
10
+
11
+ # @return [String]
12
+ def asin
13
+ source["ASIN"]
14
+ end
15
+
16
+ # @return [String]
17
+ def title
18
+ source["Title"]
19
+ end
20
+ end
21
+ end
data/lib/rapa/url.rb ADDED
@@ -0,0 +1,21 @@
1
+ module Rapa
2
+ class Url
3
+ # @param domain [String]
4
+ def initialize(domain:)
5
+ @domain = domain
6
+ end
7
+
8
+ # @note Override
9
+ def to_s
10
+ "http://webservices.amazon.#{domain}/onca/xml"
11
+ end
12
+
13
+ private
14
+
15
+ # @private
16
+ # @return [String]
17
+ def domain
18
+ @domain
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ module Rapa
2
+ VERSION = "0.3.0"
3
+ end
data/lib/rapa.rb ADDED
@@ -0,0 +1,21 @@
1
+ require "rapa/alternate_version"
2
+ require "rapa/browse_node"
3
+ require "rapa/client"
4
+ require "rapa/encoder"
5
+ require "rapa/error"
6
+ require "rapa/image"
7
+ require "rapa/language"
8
+ require "rapa/price"
9
+ require "rapa/quantity"
10
+ require "rapa/queries/base_query"
11
+ require "rapa/queries/list_items_query"
12
+ require "rapa/queries/search_items_query"
13
+ require "rapa/resources/base_resource"
14
+ require "rapa/resources/item_resource"
15
+ require "rapa/responses/base_response"
16
+ require "rapa/responses/list_items_response"
17
+ require "rapa/responses/search_items_response"
18
+ require "rapa/signer"
19
+ require "rapa/similar_product"
20
+ require "rapa/url"
21
+ require "rapa/version"
data/rapa.gemspec ADDED
@@ -0,0 +1,26 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "rapa/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "rapa"
7
+ spec.version = Rapa::VERSION
8
+ spec.authors = ["Ryo Nakamura"]
9
+ spec.email = ["r7kamura@gmail.com"]
10
+ spec.summary = "An API client library for Amazon Product Advertising API, written in Ruby."
11
+ spec.homepage = "https://github.com/r7kamura/rapa"
12
+ spec.license = "MIT"
13
+
14
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
15
+ f.match(%r{^(test|spec|features)/})
16
+ end
17
+ spec.require_paths = ["lib"]
18
+ spec.required_ruby_version = ">= 2.3"
19
+
20
+ spec.add_dependency "faraday"
21
+ spec.add_dependency "faraday_middleware"
22
+ spec.add_dependency "multi_xml"
23
+ spec.add_development_dependency "bundler", "~> 1.13"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "rspec", "~> 3.0"
26
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rapa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-15 00:00:00.000000000 Z
11
+ date: 2017-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -100,7 +100,38 @@ email:
100
100
  executables: []
101
101
  extensions: []
102
102
  extra_rdoc_files: []
103
- files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".rspec"
106
+ - CHANGELOG.md
107
+ - Gemfile
108
+ - LICENSE.txt
109
+ - README.md
110
+ - Rakefile
111
+ - circle.yml
112
+ - lib/rapa.rb
113
+ - lib/rapa/alternate_version.rb
114
+ - lib/rapa/browse_node.rb
115
+ - lib/rapa/client.rb
116
+ - lib/rapa/encoder.rb
117
+ - lib/rapa/error.rb
118
+ - lib/rapa/image.rb
119
+ - lib/rapa/language.rb
120
+ - lib/rapa/price.rb
121
+ - lib/rapa/quantity.rb
122
+ - lib/rapa/queries/base_query.rb
123
+ - lib/rapa/queries/list_items_query.rb
124
+ - lib/rapa/queries/search_items_query.rb
125
+ - lib/rapa/resources/base_resource.rb
126
+ - lib/rapa/resources/item_resource.rb
127
+ - lib/rapa/responses/base_response.rb
128
+ - lib/rapa/responses/list_items_response.rb
129
+ - lib/rapa/responses/search_items_response.rb
130
+ - lib/rapa/signer.rb
131
+ - lib/rapa/similar_product.rb
132
+ - lib/rapa/url.rb
133
+ - lib/rapa/version.rb
134
+ - rapa.gemspec
104
135
  homepage: https://github.com/r7kamura/rapa
105
136
  licenses:
106
137
  - MIT