rapa 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.rspec +1 -0
- data/CHANGELOG.md +27 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +227 -0
- data/Rakefile +6 -0
- data/circle.yml +3 -0
- data/lib/rapa/alternate_version.rb +26 -0
- data/lib/rapa/browse_node.rb +42 -0
- data/lib/rapa/client.rb +127 -0
- data/lib/rapa/encoder.rb +16 -0
- data/lib/rapa/error.rb +21 -0
- data/lib/rapa/image.rb +26 -0
- data/lib/rapa/language.rb +21 -0
- data/lib/rapa/price.rb +26 -0
- data/lib/rapa/quantity.rb +21 -0
- data/lib/rapa/queries/base_query.rb +120 -0
- data/lib/rapa/queries/list_items_query.rb +19 -0
- data/lib/rapa/queries/search_items_query.rb +26 -0
- data/lib/rapa/resources/base_resource.rb +15 -0
- data/lib/rapa/resources/item_resource.rb +357 -0
- data/lib/rapa/responses/base_response.rb +70 -0
- data/lib/rapa/responses/list_items_response.rb +17 -0
- data/lib/rapa/responses/search_items_response.rb +48 -0
- data/lib/rapa/signer.rb +79 -0
- data/lib/rapa/similar_product.rb +21 -0
- data/lib/rapa/url.rb +21 -0
- data/lib/rapa/version.rb +3 -0
- data/lib/rapa.rb +21 -0
- data/rapa.gemspec +26 -0
- metadata +34 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6759f32d6175ac260576b9fe16678e49e39ce482
|
4
|
+
data.tar.gz: c827b10203a61a7f1ad725a21cb879a97355fd65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d252376839d2195a4743c11e892b1e224d552739d193c8477d498be7db1da4d58f4aee3bf73f839ea4f58beedefd5cbfefe3ddfce3f96eca4331623966ced21
|
7
|
+
data.tar.gz: f0b037b092716cf2c0cc6c71086ae11b8d8e53410749507ec8a955edfcddf96a468810ef3e4bde624fba66889673d58e9c77e3b5e7dd396abd66d4ecb888ffa2
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--require spec_helper
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
## 0.3.0
|
2
|
+
|
3
|
+
- Add `Rapa::Responses::SearchItemsResponse#error`
|
4
|
+
- Add `Rapa::Responses::SearchItemsResponse#has_error?`
|
5
|
+
- Add `Rapa::Responses::SearchItemsResponse#has_valid_request?`
|
6
|
+
- Use `"All"` as default SearchIndex parameter
|
7
|
+
- Fix bug that no files included in gem package
|
8
|
+
|
9
|
+
## 0.2.1
|
10
|
+
|
11
|
+
- Add `Rapa::Responses::SearchItemsResponse#total_pages`
|
12
|
+
- Add `Rapa::Responses::SearchItemsResponse#total_results`
|
13
|
+
- Fix response parser on `Rapa::Client#search_items`
|
14
|
+
|
15
|
+
## 0.2.0
|
16
|
+
|
17
|
+
- Add `Rapa::Client#search_items`
|
18
|
+
|
19
|
+
## 0.1.0
|
20
|
+
|
21
|
+
- Add `Rapa::Resources::ItemResource`
|
22
|
+
- Change required Ruby version from 2.2.2 to 2.3
|
23
|
+
|
24
|
+
## 0.0.1
|
25
|
+
|
26
|
+
- 1st Release :tada:
|
27
|
+
- Add `Rapa::Client#list_items`
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Ryo Nakamura
|
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,227 @@
|
|
1
|
+
# Rapa
|
2
|
+
|
3
|
+
[![CircleCI](https://img.shields.io/circleci/project/github/r7kamura/rapa.svg)](https://circleci.com/gh/r7kamura/rapa)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/rapa.svg)](https://rubygems.org/gems/rapa)
|
5
|
+
[![Documentation](http://img.shields.io/badge/docs-rdoc.info-blue.svg)](http://www.rubydoc.info/github/r7kamura/rapa)
|
6
|
+
|
7
|
+
An API client library for Amazon Product Advertising API, written in Ruby.
|
8
|
+
|
9
|
+
See https://affiliate-program.amazon.com/gp/advertising/api/detail/main.html for more details about Amazon Product Advertising API.
|
10
|
+
|
11
|
+
## Requirements
|
12
|
+
|
13
|
+
- Ruby 2.3 or higher
|
14
|
+
|
15
|
+
## Installation
|
16
|
+
|
17
|
+
Add this line to your application's Gemfile:
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
gem "rapa"
|
21
|
+
```
|
22
|
+
|
23
|
+
And then execute:
|
24
|
+
|
25
|
+
```bash
|
26
|
+
bundle
|
27
|
+
```
|
28
|
+
|
29
|
+
Or install it yourself as:
|
30
|
+
|
31
|
+
```bash
|
32
|
+
gem install rapa
|
33
|
+
```
|
34
|
+
|
35
|
+
## Usage
|
36
|
+
|
37
|
+
### Rapa::Client.new
|
38
|
+
|
39
|
+
Available options:
|
40
|
+
|
41
|
+
- `:access_key_id`
|
42
|
+
- `:associate_tag`
|
43
|
+
- `:secret_access_key`
|
44
|
+
|
45
|
+
Returns a `Rapa::Client`.
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
require "rapa"
|
49
|
+
client = Rapa::Client.new(
|
50
|
+
access_key_id: "...",
|
51
|
+
associate_tag: "...",
|
52
|
+
secret_access_key: "...",
|
53
|
+
)
|
54
|
+
```
|
55
|
+
|
56
|
+
### Rapa::Client#list_items
|
57
|
+
|
58
|
+
Available options:
|
59
|
+
|
60
|
+
- `:asins`
|
61
|
+
- `:domain`
|
62
|
+
- `:related_item_page`
|
63
|
+
- `:relationship_type`
|
64
|
+
- `:response_groups`
|
65
|
+
|
66
|
+
Returns a `Rapa::Responses::ListItemsResponse`.
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
response = client.list_items(
|
70
|
+
asins: ["..."],
|
71
|
+
domain: "...",
|
72
|
+
response_groups: ["..."],
|
73
|
+
)
|
74
|
+
```
|
75
|
+
|
76
|
+
### Rapa::Client#search_items
|
77
|
+
|
78
|
+
Available options:
|
79
|
+
|
80
|
+
- `:domain`
|
81
|
+
- `:keywords`
|
82
|
+
- `:related_item_page`
|
83
|
+
- `:relationship_type`
|
84
|
+
- `:response_groups`
|
85
|
+
- `:search_index`
|
86
|
+
|
87
|
+
Returns a `Rapa::Responses::SearchItemsResponse`.
|
88
|
+
|
89
|
+
```ruby
|
90
|
+
response = client.search_items(
|
91
|
+
domain: "...",
|
92
|
+
keywords: ["..."],
|
93
|
+
response_groups: ["..."],
|
94
|
+
)
|
95
|
+
```
|
96
|
+
|
97
|
+
### Rapa::Responses::SearchItemsResponse
|
98
|
+
|
99
|
+
Available methods:
|
100
|
+
|
101
|
+
- `#error`
|
102
|
+
- `#has_error?`
|
103
|
+
- `#has_valid_request?`
|
104
|
+
- `#total_pages`
|
105
|
+
- `#total_results`
|
106
|
+
|
107
|
+
### Rapa::Resources::ItemResource
|
108
|
+
|
109
|
+
Available methods:
|
110
|
+
|
111
|
+
- `#adult_product?`
|
112
|
+
- `#alternate_versions`
|
113
|
+
- `#asin`
|
114
|
+
- `#authors`
|
115
|
+
- `#binding`
|
116
|
+
- `#browse_nodes`
|
117
|
+
- `#creator_name`
|
118
|
+
- `#creator_role`
|
119
|
+
- `#ean`
|
120
|
+
- `#episode_sequence`
|
121
|
+
- `#genre`
|
122
|
+
- `#has_customer_reviews?`
|
123
|
+
- `#image_hi_res`
|
124
|
+
- `#image_large`
|
125
|
+
- `#image_medium`
|
126
|
+
- `#image_small`
|
127
|
+
- `#image_swatch`
|
128
|
+
- `#image_thumbnail`
|
129
|
+
- `#image_tiny`
|
130
|
+
- `#isbn`
|
131
|
+
- `#item_height`
|
132
|
+
- `#item_length`
|
133
|
+
- `#item_width`
|
134
|
+
- `#label`
|
135
|
+
- `#languages`
|
136
|
+
- `#manufacturer`
|
137
|
+
- `#number_of_pages`
|
138
|
+
- `#package_height`
|
139
|
+
- `#package_length`
|
140
|
+
- `#package_weight`
|
141
|
+
- `#package_width`
|
142
|
+
- `#product_group`
|
143
|
+
- `#product_type_name`
|
144
|
+
- `#publication_date`
|
145
|
+
- `#publisher`
|
146
|
+
- `#related_item_count`
|
147
|
+
- `#related_item_page`
|
148
|
+
- `#related_item_page_count`
|
149
|
+
- `#related_items`
|
150
|
+
- `#relationship`
|
151
|
+
- `#relationship_type`
|
152
|
+
- `#release_date`
|
153
|
+
- `#running_time`
|
154
|
+
- `#sales_rank`
|
155
|
+
- `#season_sequence`
|
156
|
+
- `#similar_products`
|
157
|
+
- `#studio`
|
158
|
+
- `#title`
|
159
|
+
- `#url_add_to_wishlist`
|
160
|
+
- `#url_all_customer_reviews`
|
161
|
+
- `#url_all_offers`
|
162
|
+
- `#url_customer_reviews_iframe`
|
163
|
+
- `#url_details_page`
|
164
|
+
- `#url_tell_a_friend`
|
165
|
+
|
166
|
+
## Hints
|
167
|
+
|
168
|
+
### Domain
|
169
|
+
|
170
|
+
Available domain examples:
|
171
|
+
|
172
|
+
- `"ca"`
|
173
|
+
- `"cn"`
|
174
|
+
- `"co.jp"`
|
175
|
+
- `"co.uk"`
|
176
|
+
- `"com"`
|
177
|
+
- `"com.br"`
|
178
|
+
- `"com.mx"`
|
179
|
+
- `"de"`
|
180
|
+
- `"es"`
|
181
|
+
- `"fr"`
|
182
|
+
- `"in"`
|
183
|
+
- `"it"`
|
184
|
+
|
185
|
+
### SearchIndex
|
186
|
+
|
187
|
+
Available SearchIndex examples:
|
188
|
+
|
189
|
+
- `"All"`
|
190
|
+
- `"Apparel"`
|
191
|
+
- `"Appliances"`
|
192
|
+
- `"Automotive"`
|
193
|
+
- `"Baby"`
|
194
|
+
- `"Beauty"`
|
195
|
+
- `"Blended"`
|
196
|
+
- `"Books"`
|
197
|
+
- `"Classical"`
|
198
|
+
- `"CreditCards"`
|
199
|
+
- `"DVD"`
|
200
|
+
- `"Electronics"`
|
201
|
+
- `"ForeignBooks"`
|
202
|
+
- `"GiftCards"`
|
203
|
+
- `"Grocery"`
|
204
|
+
- `"HealthPersonalCare"`
|
205
|
+
- `"Hobbies"`
|
206
|
+
- `"HomeImprovement"`
|
207
|
+
- `"Industrial"`
|
208
|
+
- `"Jewelry"`
|
209
|
+
- `"KindleStore"`
|
210
|
+
- `"Kitchen"`
|
211
|
+
- `"Marketplace"`
|
212
|
+
- `"MP3Downloads"`
|
213
|
+
- `"Music"`
|
214
|
+
- `"MusicalInstruments"`
|
215
|
+
- `"OfficeProducts"`
|
216
|
+
- `"PCHardware"`
|
217
|
+
- `"PetSupplies"`
|
218
|
+
- `"Shoes"`
|
219
|
+
- `"Software"`
|
220
|
+
- `"SportingGoods"`
|
221
|
+
- `"Toys"`
|
222
|
+
- `"Video"`
|
223
|
+
- `"VideoDownload"`
|
224
|
+
- `"VideoGames"`
|
225
|
+
- `"Watches"`
|
226
|
+
|
227
|
+
See http://docs.aws.amazon.com/AWSECommerceService/latest/DG/localevalues.html for more details.
|
data/Rakefile
ADDED
data/circle.yml
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
module Rapa
|
2
|
+
class AlternateVersion
|
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 binding
|
18
|
+
source["Binding"]
|
19
|
+
end
|
20
|
+
|
21
|
+
# @return [String]
|
22
|
+
def title
|
23
|
+
source["Title"]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Rapa
|
2
|
+
class BrowseNode
|
3
|
+
# @return [Hash]
|
4
|
+
attr_reader :source
|
5
|
+
|
6
|
+
# @param source [Hash]
|
7
|
+
def initialize(source)
|
8
|
+
@source = source
|
9
|
+
end
|
10
|
+
|
11
|
+
# @return [Array<Rapa::BrowseNode>, nil]
|
12
|
+
def children
|
13
|
+
if child_sources = source.dig("Children", "BrowseNode")
|
14
|
+
child_sources.map do |child_source|
|
15
|
+
::Rapa::BrowseNode.new(child_source)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# @return [Integer]
|
21
|
+
def id
|
22
|
+
source["BrowseNodeId"].to_i
|
23
|
+
end
|
24
|
+
|
25
|
+
# @return [String]
|
26
|
+
def name
|
27
|
+
source["Name"]
|
28
|
+
end
|
29
|
+
|
30
|
+
# @return [Rapa::BrowseNode, nil]
|
31
|
+
def parent
|
32
|
+
if parent_source = source.dig("Ancestors", "BrowseNode")
|
33
|
+
::Rapa::BrowseNode.new(parent_source)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# @return [String]
|
38
|
+
def title
|
39
|
+
source["Title"]
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/rapa/client.rb
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
require "faraday"
|
2
|
+
require "faraday_middleware"
|
3
|
+
require "uri"
|
4
|
+
|
5
|
+
module Rapa
|
6
|
+
class Client
|
7
|
+
# @param access_key_id [String]
|
8
|
+
# @param associate_tag [String]
|
9
|
+
# @param secret_access_key [String]
|
10
|
+
def initialize(access_key_id:, associate_tag:, secret_access_key:)
|
11
|
+
@access_key_id = access_key_id
|
12
|
+
@associate_tag = associate_tag
|
13
|
+
@secret_access_key = secret_access_key
|
14
|
+
end
|
15
|
+
|
16
|
+
# @return [Faraday::Connection]
|
17
|
+
def connection
|
18
|
+
@connection ||= ::Faraday::Connection.new do |connection|
|
19
|
+
connection.adapter :net_http
|
20
|
+
connection.response :xml
|
21
|
+
connection.options.params_encoder = ::Rapa::Encoder.new
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# @param asins [Array<String>]
|
26
|
+
# @param domain [String]
|
27
|
+
# @param related_item_page [Integer, nil]
|
28
|
+
# @param relationship_type [String, nil]
|
29
|
+
# @param response_groups [Array<String>, nil]
|
30
|
+
# @return [Rapa::Responses::ListItemsResponse]
|
31
|
+
def list_items(
|
32
|
+
asins:,
|
33
|
+
domain:,
|
34
|
+
related_item_page: nil,
|
35
|
+
relationship_type: nil,
|
36
|
+
response_groups: nil
|
37
|
+
)
|
38
|
+
send_request(
|
39
|
+
asins: asins,
|
40
|
+
domain: domain,
|
41
|
+
query_class: ::Rapa::Queries::ListItemsQuery,
|
42
|
+
related_item_page: related_item_page,
|
43
|
+
relationship_type: relationship_type,
|
44
|
+
response_class: ::Rapa::Responses::ListItemsResponse,
|
45
|
+
response_groups: response_groups,
|
46
|
+
)
|
47
|
+
end
|
48
|
+
|
49
|
+
# @param domain [String]
|
50
|
+
# @param keywords [Array<String>]
|
51
|
+
# @param related_item_page [Integer, nil]
|
52
|
+
# @param relationship_type [String, nil]
|
53
|
+
# @param response_groups [Array<String>, nil]
|
54
|
+
# @param search_index [String, nil]
|
55
|
+
# @return [Rapa::Responses::SearchItemsResponse]
|
56
|
+
def search_items(
|
57
|
+
domain:,
|
58
|
+
keywords:,
|
59
|
+
related_item_page: nil,
|
60
|
+
relationship_type: nil,
|
61
|
+
response_groups: nil,
|
62
|
+
search_index: nil
|
63
|
+
)
|
64
|
+
send_request(
|
65
|
+
domain: domain,
|
66
|
+
keywords: keywords,
|
67
|
+
query_class: ::Rapa::Queries::SearchItemsQuery,
|
68
|
+
related_item_page: related_item_page,
|
69
|
+
relationship_type: relationship_type,
|
70
|
+
response_class: ::Rapa::Responses::SearchItemsResponse,
|
71
|
+
response_groups: response_groups,
|
72
|
+
search_index: search_index,
|
73
|
+
)
|
74
|
+
end
|
75
|
+
|
76
|
+
private
|
77
|
+
|
78
|
+
# @private
|
79
|
+
# @return [String]
|
80
|
+
def access_key_id
|
81
|
+
@access_key_id
|
82
|
+
end
|
83
|
+
|
84
|
+
# @private
|
85
|
+
# @return [String]
|
86
|
+
def associate_tag
|
87
|
+
@associate_tag
|
88
|
+
end
|
89
|
+
|
90
|
+
# @private
|
91
|
+
# @return [Hash]
|
92
|
+
def common_query_options
|
93
|
+
{
|
94
|
+
access_key_id: access_key_id,
|
95
|
+
associate_tag: associate_tag,
|
96
|
+
}
|
97
|
+
end
|
98
|
+
|
99
|
+
# @private
|
100
|
+
# @return [String]
|
101
|
+
def secret_access_key
|
102
|
+
@secret_access_key
|
103
|
+
end
|
104
|
+
|
105
|
+
# @private
|
106
|
+
# @param domain [String]
|
107
|
+
# @param query_class [Class]
|
108
|
+
# @param response_class [Class]
|
109
|
+
# @return [Rapa::Responses::BaseResponse]
|
110
|
+
def send_request(domain:, query_class:, response_class:, **options)
|
111
|
+
query_options = common_query_options.merge(options)
|
112
|
+
query = query_class.new(query_options)
|
113
|
+
url = ::Rapa::Url.new(domain: domain)
|
114
|
+
uri = ::URI.parse(url.to_s)
|
115
|
+
query_string = query.to_s
|
116
|
+
signature = ::Rapa::Signer.new(
|
117
|
+
host: uri.host,
|
118
|
+
http_method: "GET",
|
119
|
+
key: secret_access_key,
|
120
|
+
path: uri.path,
|
121
|
+
query_string: query_string,
|
122
|
+
).sign
|
123
|
+
faraday_response = connection.get(uri, query.to_hash.merge(Signature: signature))
|
124
|
+
response_class.new(faraday_response)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
data/lib/rapa/encoder.rb
ADDED
data/lib/rapa/error.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
module Rapa
|
2
|
+
class Error
|
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 code
|
13
|
+
source["Code"]
|
14
|
+
end
|
15
|
+
|
16
|
+
# @return [String]
|
17
|
+
def message
|
18
|
+
source["Message"]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/rapa/image.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
module Rapa
|
2
|
+
class Image
|
3
|
+
# @return [Hash]
|
4
|
+
attr_reader :source
|
5
|
+
|
6
|
+
# @param source [Hash]
|
7
|
+
def initialize(source)
|
8
|
+
@source = source
|
9
|
+
end
|
10
|
+
|
11
|
+
# @return [Integer]
|
12
|
+
def height
|
13
|
+
::Rapa::Quantity.new(source["Height"])
|
14
|
+
end
|
15
|
+
|
16
|
+
# @return [String]
|
17
|
+
def url
|
18
|
+
source["URL"]
|
19
|
+
end
|
20
|
+
|
21
|
+
# @return [Integer]
|
22
|
+
def width
|
23
|
+
::Rapa::Quantity.new(source["Width"])
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Rapa
|
2
|
+
class Language
|
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 name
|
13
|
+
source["Name"]
|
14
|
+
end
|
15
|
+
|
16
|
+
# @return [String]
|
17
|
+
def type
|
18
|
+
source["Type"]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/rapa/price.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
module Rapa
|
2
|
+
class Price
|
3
|
+
# @return [Hash]
|
4
|
+
attr_reader :source
|
5
|
+
|
6
|
+
# @param source [Hash]
|
7
|
+
def initialize(source)
|
8
|
+
@source = source
|
9
|
+
end
|
10
|
+
|
11
|
+
# @return [Integer]
|
12
|
+
def amount
|
13
|
+
source["Amount"].to_i
|
14
|
+
end
|
15
|
+
|
16
|
+
# @return [String]
|
17
|
+
def currency_code
|
18
|
+
source["CurrencyCode"]
|
19
|
+
end
|
20
|
+
|
21
|
+
# @return [String]
|
22
|
+
def formatted_price
|
23
|
+
source["FormattedPrice"]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Rapa
|
2
|
+
class Quantity
|
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 units
|
13
|
+
source["Units"]
|
14
|
+
end
|
15
|
+
|
16
|
+
# @return [Integer]
|
17
|
+
def value
|
18
|
+
source["__content__"].to_i
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|