Class: Rapa::Resources::ItemResource
Instance Method Summary
collapse
#initialize, #source
Instance Method Details
#adult_product? ⇒ Boolean?
7
8
9
10
11
|
# File 'lib/rapa/resources/item_resource.rb', line 7
def adult_product?
if flag_source = source.dig("ItemAttributes", "IsAdultProduct")
flag_source != "0"
end
end
|
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/rapa/resources/item_resource.rb', line 14
def alternate_versions
case alternate_version_source_or_sources = source.dig("AlternateVersions", "AlternateVersion")
when ::Array
alternate_version_source_or_sources
when ::Hash
[alternate_version_source_or_sources]
else
[]
end.map do |alternate_version_source|
::Rapa::AlternateVersion.new(alternate_version_source)
end
end
|
#asin ⇒ String
28
29
30
|
# File 'lib/rapa/resources/item_resource.rb', line 28
def asin
source["ASIN"]
end
|
#authors ⇒ Array<String>
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/rapa/resources/item_resource.rb', line 33
def authors
case author_source_or_sources = source.dig("ItemAttributes", "Author")
when ::Array
author_source_or_sources
when ::String
[author_source_or_sources]
else
[]
end
end
|
#binding ⇒ String?
45
46
47
|
# File 'lib/rapa/resources/item_resource.rb', line 45
def binding
source.dig("ItemAttributes", "Binding")
end
|
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/rapa/resources/item_resource.rb', line 50
def browse_nodes
case browse_node_source_or_sources = source.dig("BrowseNodes", "BrowseNode")
when ::Array
browse_node_source_or_sources
when ::Hash
[browse_node_source_or_sources]
else
[]
end.map do |browse_node_source|
::Rapa::BrowseNode.new(browse_node_source)
end
end
|
#creator_name ⇒ String?
78
79
80
81
82
|
# File 'lib/rapa/resources/item_resource.rb', line 78
def creator_name
if creators.first
creators.first.name
end
end
|
#creator_role ⇒ String?
85
86
87
88
89
|
# File 'lib/rapa/resources/item_resource.rb', line 85
def creator_role
if creators.first
creators.first.role
end
end
|
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/rapa/resources/item_resource.rb', line 64
def creators
case creator_source_or_sources = source.dig("ItemAttributes", "Creator")
when ::Array
creator_source_or_sources
when ::Hash
[creator_source_or_sources]
else
[]
end.map do |creator_source|
::Rapa::Creator.new(creator_source)
end
end
|
#ean ⇒ String?
92
93
94
|
# File 'lib/rapa/resources/item_resource.rb', line 92
def ean
source.dig("ItemAttributes", "EAN")
end
|
#ebook? ⇒ Boolean
97
98
99
|
# File 'lib/rapa/resources/item_resource.rb', line 97
def ebook?
source.dig("ItemAttributes", "ProductGroup") == "eBooks"
end
|
#episode_sequence ⇒ Integer?
102
103
104
105
106
|
# File 'lib/rapa/resources/item_resource.rb', line 102
def episode_sequence
if value = source.dig("ItemAttributes", "EpisodeSequence")
value.to_i
end
end
|
#genre ⇒ String?
109
110
111
|
# File 'lib/rapa/resources/item_resource.rb', line 109
def genre
source.dig("ItemAttributes", "Genre")
end
|
#has_customer_reviews? ⇒ Boolean
114
115
116
|
# File 'lib/rapa/resources/item_resource.rb', line 114
def has_customer_reviews?
source.dig("CustomerReviews", "HasReviews") == "true"
end
|
119
120
121
|
# File 'lib/rapa/resources/item_resource.rb', line 119
def image_hi_res
find_image("HiResImage")
end
|
124
125
126
|
# File 'lib/rapa/resources/item_resource.rb', line 124
def image_large
find_image("LargeImage")
end
|
129
130
131
|
# File 'lib/rapa/resources/item_resource.rb', line 129
def image_medium
find_image("MediumImage")
end
|
134
135
136
|
# File 'lib/rapa/resources/item_resource.rb', line 134
def image_small
find_image("SmallImage")
end
|
139
140
141
|
# File 'lib/rapa/resources/item_resource.rb', line 139
def image_swatch
find_image("SwatchImage")
end
|
144
145
146
|
# File 'lib/rapa/resources/item_resource.rb', line 144
def image_thumbnail
find_image("ThumbnailImage")
end
|
149
150
151
|
# File 'lib/rapa/resources/item_resource.rb', line 149
def image_tiny
find_image("TinyImage")
end
|
#isbn ⇒ String?
154
155
156
|
# File 'lib/rapa/resources/item_resource.rb', line 154
def isbn
source.dig("ItemAttributes", "ISBN")
end
|
159
160
161
162
163
|
# File 'lib/rapa/resources/item_resource.rb', line 159
def item_height
if quantity_source = source.dig("ItemAttributes", "ItemDimensions", "Height")
::Rapa::Quantity.new(quantity_source)
end
end
|
166
167
168
169
170
|
# File 'lib/rapa/resources/item_resource.rb', line 166
def item_length
if quantity_source = source.dig("ItemAttributes", "ItemDimensions", "Length")
::Rapa::Quantity.new(quantity_source)
end
end
|
173
174
175
176
177
|
# File 'lib/rapa/resources/item_resource.rb', line 173
def item_width
if quantity_source = source.dig("ItemAttributes", "ItemDimensions", "Width")
::Rapa::Quantity.new(quantity_source)
end
end
|
#label ⇒ String?
180
181
182
|
# File 'lib/rapa/resources/item_resource.rb', line 180
def label
source.dig("ItemAttributes", "Label")
end
|
185
186
187
188
189
190
191
192
193
194
195
196
|
# File 'lib/rapa/resources/item_resource.rb', line 185
def languages
case language_source_or_sources = source.dig("ItemAttributes", "Languages", "Language")
when ::Array
language_source_or_sources
when ::Hash
[language_source_or_sources]
else
[]
end.map do |language_source|
::Rapa::Language.new(language_source)
end
end
|
#manufacturer ⇒ String?
199
200
201
|
# File 'lib/rapa/resources/item_resource.rb', line 199
def manufacturer
source.dig("ItemAttributes", "Manufacturer")
end
|
#number_of_pages ⇒ Integer?
204
205
206
207
208
|
# File 'lib/rapa/resources/item_resource.rb', line 204
def number_of_pages
if value = source.dig("ItemAttributes", "NumberOfPages")
value.to_i
end
end
|
211
212
213
214
215
|
# File 'lib/rapa/resources/item_resource.rb', line 211
def package_height
if quantity_source = source.dig("ItemAttributes", "PackageDimensions", "Height")
::Rapa::Quantity.new(quantity_source)
end
end
|
218
219
220
221
222
|
# File 'lib/rapa/resources/item_resource.rb', line 218
def package_length
if quantity_source = source.dig("ItemAttributes", "PackageDimensions", "Length")
::Rapa::Quantity.new(quantity_source)
end
end
|
225
226
227
228
229
|
# File 'lib/rapa/resources/item_resource.rb', line 225
def package_weight
if quantity_source = source.dig("ItemAttributes", "PackageDimensions", "Weight")
::Rapa::Quantity.new(quantity_source)
end
end
|
232
233
234
235
236
|
# File 'lib/rapa/resources/item_resource.rb', line 232
def package_width
if quantity_source = source.dig("ItemAttributes", "PackageDimensions", "Width")
::Rapa::Quantity.new(quantity_source)
end
end
|
#price_lowest_collectible ⇒ Rapa::Price?
239
240
241
242
243
|
# File 'lib/rapa/resources/item_resource.rb', line 239
def price_lowest_collectible
if price_source = source.dig("OfferSummary", "LowestCollectiblePrice")
::Rapa::Price.new(price_source)
end
end
|
246
247
248
249
250
|
# File 'lib/rapa/resources/item_resource.rb', line 246
def price_lowest_new
if price_source = source.dig("OfferSummary", "LowestNewPrice")
::Rapa::Price.new(price_source)
end
end
|
253
254
255
256
257
|
# File 'lib/rapa/resources/item_resource.rb', line 253
def price_lowest_used
if price_source = source.dig("OfferSummary", "LowestUsedPrice")
::Rapa::Price.new(price_source)
end
end
|
#product_group ⇒ String?
260
261
262
|
# File 'lib/rapa/resources/item_resource.rb', line 260
def product_group
source.dig("ItemAttributes", "ProductGroup")
end
|
#product_type_name ⇒ String?
265
266
267
|
# File 'lib/rapa/resources/item_resource.rb', line 265
def product_type_name
source.dig("ItemAttributes", "ProductTypeName")
end
|
#publication_date ⇒ Date?
270
271
272
273
274
|
# File 'lib/rapa/resources/item_resource.rb', line 270
def publication_date
if value = source.dig("ItemAttributes", "PublicationDate")
parse_date(value)
end
end
|
#publisher ⇒ String?
277
278
279
|
# File 'lib/rapa/resources/item_resource.rb', line 277
def publisher
source.dig("ItemAttributes", "Publisher")
end
|
282
283
284
285
286
|
# File 'lib/rapa/resources/item_resource.rb', line 282
def related_item_count
if value = source.dig("RelatedItems", "RelatedItemCount")
value.to_i
end
end
|
#related_item_page ⇒ Integer?
289
290
291
292
293
|
# File 'lib/rapa/resources/item_resource.rb', line 289
def related_item_page
if value = source.dig("RelatedItems", "RelatedItemPage")
value.to_i
end
end
|
#related_item_page_count ⇒ Integer?
296
297
298
299
300
|
# File 'lib/rapa/resources/item_resource.rb', line 296
def related_item_page_count
if value = source.dig("RelatedItems", "RelatedItemPageCount")
value.to_i
end
end
|
303
304
305
306
307
308
309
310
311
312
313
314
|
# File 'lib/rapa/resources/item_resource.rb', line 303
def related_items
case item_source_or_sources = source.dig("RelatedItems", "RelatedItem")
when ::Array
item_source_or_sources
when ::Hash
[item_source_or_sources]
else
[]
end.map do |related_item_source|
::Rapa::Resources::ItemResource.new(related_item_source["Item"])
end
end
|
#relationship ⇒ String?
317
318
319
|
# File 'lib/rapa/resources/item_resource.rb', line 317
def relationship
source.dig("RelatedItems", "Relationship")
end
|
#relationship_type ⇒ String?
322
323
324
|
# File 'lib/rapa/resources/item_resource.rb', line 322
def relationship_type
source.dig("RelatedItems", "RelationshipType")
end
|
#release_date ⇒ Date?
327
328
329
330
331
|
# File 'lib/rapa/resources/item_resource.rb', line 327
def release_date
if value = source.dig("ItemAttributes", "ReleaseDate")
parse_date(value)
end
end
|
334
335
336
337
338
|
# File 'lib/rapa/resources/item_resource.rb', line 334
def running_time
if value = source.dig("ItemAttributes", "RunningTime")
::Rapa::Quantity.new(value)
end
end
|
#sales_rank ⇒ Integer?
341
342
343
|
# File 'lib/rapa/resources/item_resource.rb', line 341
def sales_rank
source["SalesRank"]
end
|
#season_sequence ⇒ Integer?
346
347
348
349
350
|
# File 'lib/rapa/resources/item_resource.rb', line 346
def season_sequence
if value = source.dig("ItemAttributes", "SeasonSequence")
value.to_i
end
end
|
353
354
355
356
357
358
359
360
361
362
363
364
|
# File 'lib/rapa/resources/item_resource.rb', line 353
def similar_products
case similar_product_source_or_sources = source["SimilarProducts"]
when ::Array
similar_product_sources
when ::Hash
[similar_product_source_or_sources]
else
[]
end.map do |similar_product_source|
::Rapa::SimilarProduct.new(similar_product_source)
end
end
|
#studio ⇒ String?
367
368
369
|
# File 'lib/rapa/resources/item_resource.rb', line 367
def studio
source.dig("ItemAttributes", "Studio")
end
|
#title ⇒ String?
372
373
374
|
# File 'lib/rapa/resources/item_resource.rb', line 372
def title
source.dig("ItemAttributes", "Title")
end
|
#url_add_to_wishlist ⇒ String?
377
378
379
|
# File 'lib/rapa/resources/item_resource.rb', line 377
def url_add_to_wishlist
item_links["Add To Wishlist"]
end
|
#url_all_customer_reviews ⇒ String?
382
383
384
|
# File 'lib/rapa/resources/item_resource.rb', line 382
def url_all_customer_reviews
item_links["All Customer Reviews"]
end
|
#url_all_offers ⇒ String?
387
388
389
|
# File 'lib/rapa/resources/item_resource.rb', line 387
def url_all_offers
item_links["All Offers"]
end
|
#url_customer_reviews_iframe ⇒ String?
392
393
394
|
# File 'lib/rapa/resources/item_resource.rb', line 392
def url_customer_reviews_iframe
source.dig("CustomerReviews", "IFrameURL")
end
|
#url_details_page ⇒ String
397
398
399
|
# File 'lib/rapa/resources/item_resource.rb', line 397
def url_details_page
source["DetailPageURL"]
end
|
#url_tell_a_friend ⇒ String?
402
403
404
|
# File 'lib/rapa/resources/item_resource.rb', line 402
def url_tell_a_friend
item_links["Tell A Friend"]
end
|