rapa 0.5.7 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +38 -0
- data/lib/rapa.rb +7 -2
- data/lib/rapa/client.rb +18 -0
- data/lib/rapa/queries/lookup_browse_node.rb +19 -0
- data/lib/rapa/resources/browse_node_resource.rb +35 -0
- data/lib/rapa/responses/base_response.rb +0 -14
- data/lib/rapa/responses/multiple_resources_response.rb +19 -0
- data/lib/rapa/responses/{list_items_response.rb → multiple_resources_response/list_items_response.rb} +1 -1
- data/lib/rapa/responses/{search_items_response.rb → multiple_resources_response/search_items_response.rb} +1 -1
- data/lib/rapa/responses/single_resource_response.rb +6 -0
- data/lib/rapa/responses/single_resource_response/lookup_browse_node_response.rb +44 -0
- data/lib/rapa/version.rb +1 -1
- metadata +9 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1818b2a706381589ac6fc00d485ebe1bba04254a
|
4
|
+
data.tar.gz: ae107e261a4337568d482ae9498d9e16aa197906
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d8969b4008e6e1b4cd70fcd2beaba06cf9ffa84277ec5577297dde562d03ea7c8b05e980432772ac177b055980273205fc02cbbc59e1c9d39c856d9ec324379
|
7
|
+
data.tar.gz: 8c1ef3179e5b67eb957548717b678ca82bf35f0ccadc8110a4a1ddb467eb360f69b66e2ccd91a2d4b336b7b6a09940782a9d78cff06bce905cc4857ea3d5be2a
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -74,6 +74,24 @@ response = client.list_items(
|
|
74
74
|
)
|
75
75
|
```
|
76
76
|
|
77
|
+
### Rapa::Client#lookup_browse_node
|
78
|
+
|
79
|
+
Available options:
|
80
|
+
|
81
|
+
- `:browse_node_id`
|
82
|
+
- `:domain`
|
83
|
+
- `:response_groups`
|
84
|
+
|
85
|
+
Returns a `Rapa::Responses::LookupBrowseNodeResponse`.
|
86
|
+
|
87
|
+
```ruby
|
88
|
+
response = client.lookup_browse_node(
|
89
|
+
browse_node_id: "...",
|
90
|
+
domain: "...",
|
91
|
+
response_groups: ["..."],
|
92
|
+
)
|
93
|
+
```
|
94
|
+
|
77
95
|
### Rapa::Client#search_items
|
78
96
|
|
79
97
|
Available options:
|
@@ -98,6 +116,15 @@ response = client.search_items(
|
|
98
116
|
)
|
99
117
|
```
|
100
118
|
|
119
|
+
### Rapa::Responses::LookupBrowseNodeResponse
|
120
|
+
|
121
|
+
Available methods:
|
122
|
+
|
123
|
+
- `#error`
|
124
|
+
- `#has_error?`
|
125
|
+
- `#has_valid_request?`
|
126
|
+
- `#response_group(group)`
|
127
|
+
|
101
128
|
### Rapa::Responses::SearchItemsResponse
|
102
129
|
|
103
130
|
Available methods:
|
@@ -108,6 +135,17 @@ Available methods:
|
|
108
135
|
- `#total_pages`
|
109
136
|
- `#total_results`
|
110
137
|
|
138
|
+
### Rapa::Resources::BrowseNodeResource
|
139
|
+
|
140
|
+
Available methods:
|
141
|
+
|
142
|
+
- `#asin`
|
143
|
+
- `#author`
|
144
|
+
- `#eook?`
|
145
|
+
- `#product_group`
|
146
|
+
- `#title`
|
147
|
+
- `#url_details_page`
|
148
|
+
|
111
149
|
### Rapa::Resources::ItemResource
|
112
150
|
|
113
151
|
Available methods:
|
data/lib/rapa.rb
CHANGED
@@ -10,12 +10,17 @@ require "rapa/price"
|
|
10
10
|
require "rapa/quantity"
|
11
11
|
require "rapa/queries/base_query"
|
12
12
|
require "rapa/queries/list_items_query"
|
13
|
+
require "rapa/queries/lookup_browse_node"
|
13
14
|
require "rapa/queries/search_items_query"
|
14
15
|
require "rapa/resources/base_resource"
|
16
|
+
require "rapa/resources/browse_node_resource"
|
15
17
|
require "rapa/resources/item_resource"
|
16
18
|
require "rapa/responses/base_response"
|
17
|
-
require "rapa/responses/
|
18
|
-
require "rapa/responses/
|
19
|
+
require "rapa/responses/multiple_resources_response"
|
20
|
+
require "rapa/responses/multiple_resources_response/list_items_response"
|
21
|
+
require "rapa/responses/multiple_resources_response/search_items_response"
|
22
|
+
require "rapa/responses/single_resource_response"
|
23
|
+
require "rapa/responses/single_resource_response/lookup_browse_node_response"
|
19
24
|
require "rapa/signer"
|
20
25
|
require "rapa/similar_product"
|
21
26
|
require "rapa/url"
|
data/lib/rapa/client.rb
CHANGED
@@ -22,6 +22,24 @@ module Rapa
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
+
# @param browse_node_id [Integer]
|
26
|
+
# @param domain [String]
|
27
|
+
# @param response_groups [Array<String>, nil]
|
28
|
+
# @return [Rapa::Responses::LookupBrowseNodeResponse]
|
29
|
+
def lookup_browse_node(
|
30
|
+
browse_node_id:,
|
31
|
+
domain:,
|
32
|
+
response_groups: nil
|
33
|
+
)
|
34
|
+
send_request(
|
35
|
+
browse_node_id: browse_node_id,
|
36
|
+
domain: domain,
|
37
|
+
query_class: ::Rapa::Queries::LookupBrowseNode,
|
38
|
+
response_class: ::Rapa::Responses::LookupBrowseNodeResponse,
|
39
|
+
response_groups: response_groups
|
40
|
+
)
|
41
|
+
end
|
42
|
+
|
25
43
|
# @param item_ids [Array<String>]
|
26
44
|
# @param domain [String]
|
27
45
|
# @param id_type [String, nil]
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Rapa
|
2
|
+
module Queries
|
3
|
+
class LookupBrowseNode < BaseQuery
|
4
|
+
OPERATION = "BrowseNodeLookup"
|
5
|
+
|
6
|
+
property :BrowseNodeId
|
7
|
+
|
8
|
+
# @return [String]
|
9
|
+
def BrowseNodeId
|
10
|
+
options[:browse_node_id].to_s
|
11
|
+
end
|
12
|
+
|
13
|
+
# @note Override
|
14
|
+
def Operation
|
15
|
+
OPERATION
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Rapa
|
2
|
+
module Resources
|
3
|
+
class BrowseNodeResource < BaseResource
|
4
|
+
# @return [String]
|
5
|
+
def asin
|
6
|
+
source["ASIN"]
|
7
|
+
end
|
8
|
+
|
9
|
+
# @return [String]
|
10
|
+
def author
|
11
|
+
source["Author"]
|
12
|
+
end
|
13
|
+
|
14
|
+
# @return [Boolean]
|
15
|
+
def ebook?
|
16
|
+
source["ProductGroup"] == "eBooks"
|
17
|
+
end
|
18
|
+
|
19
|
+
# @return [String]
|
20
|
+
def product_group
|
21
|
+
source["ProductGroup"]
|
22
|
+
end
|
23
|
+
|
24
|
+
# @return [String]
|
25
|
+
def title
|
26
|
+
source["Title"]
|
27
|
+
end
|
28
|
+
|
29
|
+
# @return [String]
|
30
|
+
def url_details_page
|
31
|
+
source["DetailPageURL"]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -1,8 +1,6 @@
|
|
1
1
|
module Rapa
|
2
2
|
module Responses
|
3
3
|
class BaseResponse
|
4
|
-
include ::Enumerable
|
5
|
-
|
6
4
|
# @param faraday_response [Faraday::Response]
|
7
5
|
def initialize(faraday_response)
|
8
6
|
@faraday_response = faraday_response
|
@@ -13,23 +11,11 @@ module Rapa
|
|
13
11
|
faraday_response.body
|
14
12
|
end
|
15
13
|
|
16
|
-
# @note Implementation for Enumerable
|
17
|
-
def each(&block)
|
18
|
-
resources.each(&block)
|
19
|
-
end
|
20
|
-
|
21
14
|
# @return [Faraday::Utils::Headers]
|
22
15
|
def headers
|
23
16
|
faraday_response.headers
|
24
17
|
end
|
25
18
|
|
26
|
-
# @return [Array<Rapa::Resources::ItemResource>]
|
27
|
-
def resources
|
28
|
-
sources.map do |source|
|
29
|
-
resource_class.new(source)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
19
|
# @return [Integer]
|
34
20
|
def status
|
35
21
|
faraday_response.status
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Rapa
|
2
|
+
module Responses
|
3
|
+
class MultipleResourcesResponse < BaseResponse
|
4
|
+
include ::Enumerable
|
5
|
+
|
6
|
+
# @note Implementation for Enumerable
|
7
|
+
def each(&block)
|
8
|
+
resources.each(&block)
|
9
|
+
end
|
10
|
+
|
11
|
+
# @return [Array<Rapa::Resources::ItemResource>]
|
12
|
+
def resources
|
13
|
+
sources.map do |source|
|
14
|
+
resource_class.new(source)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Rapa
|
2
|
+
module Responses
|
3
|
+
class LookupBrowseNodeResponse < SingleResourceResponse
|
4
|
+
# @return [Rapa::Error, nil]
|
5
|
+
def error
|
6
|
+
if value = body.dig("BrowseNodeLookupErrorResponse", "Error")
|
7
|
+
::Rapa::Error.new(value)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
# @return [Boolean]
|
12
|
+
def has_error?
|
13
|
+
!error.nil?
|
14
|
+
end
|
15
|
+
|
16
|
+
# @return [Boolean]
|
17
|
+
def has_valid_request?
|
18
|
+
body.dig("BrowseNodeLookupResponse", "BrowseNodes", "Request", "IsValid") == "True"
|
19
|
+
end
|
20
|
+
|
21
|
+
# @return [Array<Rapa::Resources::BrowseNodeResource>, nil]
|
22
|
+
def response_group(group)
|
23
|
+
item = sources.find { |source| source["Type"] == group }
|
24
|
+
unless item.nil?
|
25
|
+
item["TopItem"].map do |source|
|
26
|
+
resource_class.new(source)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
# @note Override
|
34
|
+
def resource_class
|
35
|
+
::Rapa::Resources::BrowseNodeResource
|
36
|
+
end
|
37
|
+
|
38
|
+
# @note Override
|
39
|
+
def source_or_sources
|
40
|
+
body.dig("BrowseNodeLookupResponse", "BrowseNodes", "BrowseNode", "TopItemSet")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/rapa/version.rb
CHANGED
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.
|
4
|
+
version: 0.6.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-11-
|
11
|
+
date: 2017-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -163,12 +163,17 @@ files:
|
|
163
163
|
- lib/rapa/quantity.rb
|
164
164
|
- lib/rapa/queries/base_query.rb
|
165
165
|
- lib/rapa/queries/list_items_query.rb
|
166
|
+
- lib/rapa/queries/lookup_browse_node.rb
|
166
167
|
- lib/rapa/queries/search_items_query.rb
|
167
168
|
- lib/rapa/resources/base_resource.rb
|
169
|
+
- lib/rapa/resources/browse_node_resource.rb
|
168
170
|
- lib/rapa/resources/item_resource.rb
|
169
171
|
- lib/rapa/responses/base_response.rb
|
170
|
-
- lib/rapa/responses/
|
171
|
-
- lib/rapa/responses/
|
172
|
+
- lib/rapa/responses/multiple_resources_response.rb
|
173
|
+
- lib/rapa/responses/multiple_resources_response/list_items_response.rb
|
174
|
+
- lib/rapa/responses/multiple_resources_response/search_items_response.rb
|
175
|
+
- lib/rapa/responses/single_resource_response.rb
|
176
|
+
- lib/rapa/responses/single_resource_response/lookup_browse_node_response.rb
|
172
177
|
- lib/rapa/signer.rb
|
173
178
|
- lib/rapa/similar_product.rb
|
174
179
|
- lib/rapa/url.rb
|