Class: Rapa::Resources::ItemResource

Inherits:
BaseResource show all
Defined in:
lib/rapa/resources/item_resource.rb

Instance Method Summary collapse

Methods inherited from BaseResource

#initialize, #source

Constructor Details

This class inherits a constructor from Rapa::Resources::BaseResource

Instance Method Details

#adult_product?Boolean?

Returns:

  • (Boolean, nil)


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

#alternate_versionsArray<Rapa::AlternateVersion>

Returns:



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

#asinString

Returns:

  • (String)


28
29
30
# File 'lib/rapa/resources/item_resource.rb', line 28

def asin
  source["ASIN"]
end

#authorsArray<String>

Returns:

  • (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

#bindingString?

Returns:

  • (String, nil)


45
46
47
# File 'lib/rapa/resources/item_resource.rb', line 45

def binding
  source.dig("ItemAttributes", "Binding")
end

#browse_nodesArray<Rapa::BrowseNode>

Returns:



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_nameString?

Returns:

  • (String, nil)


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_roleString?

Returns:

  • (String, nil)


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

#creatorsArray<Rapa::Creator>

Returns:



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

#eanString?

Returns:

  • (String, nil)


92
93
94
# File 'lib/rapa/resources/item_resource.rb', line 92

def ean
  source.dig("ItemAttributes", "EAN")
end

#ebook?Boolean

Returns:

  • (Boolean)


97
98
99
# File 'lib/rapa/resources/item_resource.rb', line 97

def ebook?
  source.dig("ItemAttributes", "ProductGroup") == "eBooks"
end

#episode_sequenceInteger?

Returns:

  • (Integer, nil)


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

#genreString?

Returns:

  • (String, nil)


109
110
111
# File 'lib/rapa/resources/item_resource.rb', line 109

def genre
  source.dig("ItemAttributes", "Genre")
end

#has_customer_reviews?Boolean

Returns:

  • (Boolean)


114
115
116
# File 'lib/rapa/resources/item_resource.rb', line 114

def has_customer_reviews?
  source.dig("CustomerReviews", "HasReviews") == "true"
end

#image_hi_resRapa::Image?

Returns:



119
120
121
# File 'lib/rapa/resources/item_resource.rb', line 119

def image_hi_res
  find_image("HiResImage")
end

#image_largeRapa::Image?

Returns:



124
125
126
# File 'lib/rapa/resources/item_resource.rb', line 124

def image_large
  find_image("LargeImage")
end

#image_mediumRapa::Image?

Returns:



129
130
131
# File 'lib/rapa/resources/item_resource.rb', line 129

def image_medium
  find_image("MediumImage")
end

#image_smallRapa::Image?

Returns:



134
135
136
# File 'lib/rapa/resources/item_resource.rb', line 134

def image_small
  find_image("SmallImage")
end

#image_swatchRapa::Image?

Returns:



139
140
141
# File 'lib/rapa/resources/item_resource.rb', line 139

def image_swatch
  find_image("SwatchImage")
end

#image_thumbnailRapa::Image?

Returns:



144
145
146
# File 'lib/rapa/resources/item_resource.rb', line 144

def image_thumbnail
  find_image("ThumbnailImage")
end

#image_tinyRapa::Image?

Returns:



149
150
151
# File 'lib/rapa/resources/item_resource.rb', line 149

def image_tiny
  find_image("TinyImage")
end

#isbnString?

Returns:

  • (String, nil)


154
155
156
# File 'lib/rapa/resources/item_resource.rb', line 154

def isbn
  source.dig("ItemAttributes", "ISBN")
end

#item_heightRapa::Quantity

Returns:



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

#item_lengthRapa::Quantity

Returns:



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

#item_widthRapa::Quantity

Returns:



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

#labelString?

Returns:

  • (String, nil)


180
181
182
# File 'lib/rapa/resources/item_resource.rb', line 180

def label
  source.dig("ItemAttributes", "Label")
end

#languagesArray<Rapa::Language>

Returns:



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

#manufacturerString?

Returns:

  • (String, nil)


199
200
201
# File 'lib/rapa/resources/item_resource.rb', line 199

def manufacturer
  source.dig("ItemAttributes", "Manufacturer")
end

#number_of_pagesInteger?

Returns:

  • (Integer, nil)


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

#package_heightRapa::Quantity

Returns:



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

#package_lengthRapa::Quantity

Returns:



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

#package_weightRapa::Quantity

Returns:



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

#package_widthRapa::Quantity

Returns:



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_collectibleRapa::Price?

Returns:



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

#price_lowest_newRapa::Price?

Returns:



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

#price_lowest_usedRapa::Price?

Returns:



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_groupString?

Returns:

  • (String, nil)


260
261
262
# File 'lib/rapa/resources/item_resource.rb', line 260

def product_group
  source.dig("ItemAttributes", "ProductGroup")
end

#product_type_nameString?

Returns:

  • (String, nil)


265
266
267
# File 'lib/rapa/resources/item_resource.rb', line 265

def product_type_name
  source.dig("ItemAttributes", "ProductTypeName")
end

#publication_dateDate?

Returns:

  • (Date, nil)


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

#publisherString?

Returns:

  • (String, nil)


277
278
279
# File 'lib/rapa/resources/item_resource.rb', line 277

def publisher
  source.dig("ItemAttributes", "Publisher")
end

Returns:

  • (Integer, nil)


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

Returns:

  • (Integer, nil)


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

Returns:

  • (Integer, nil)


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

Returns:



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

#relationshipString?

Returns:

  • (String, nil)


317
318
319
# File 'lib/rapa/resources/item_resource.rb', line 317

def relationship
  source.dig("RelatedItems", "Relationship")
end

#relationship_typeString?

Returns:

  • (String, nil)


322
323
324
# File 'lib/rapa/resources/item_resource.rb', line 322

def relationship_type
  source.dig("RelatedItems", "RelationshipType")
end

#release_dateDate?

Returns:

  • (Date, nil)


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

#running_timeRapa::Quantity?

Returns:



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_rankInteger?

Returns:

  • (Integer, nil)


341
342
343
# File 'lib/rapa/resources/item_resource.rb', line 341

def sales_rank
  source["SalesRank"]
end

#season_sequenceInteger?

Returns:

  • (Integer, nil)


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

#similar_productsArray<Rapa::SimilarProduct>

Returns:



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

#studioString?

Returns:

  • (String, nil)


367
368
369
# File 'lib/rapa/resources/item_resource.rb', line 367

def studio
  source.dig("ItemAttributes", "Studio")
end

#titleString?

Returns:

  • (String, nil)


372
373
374
# File 'lib/rapa/resources/item_resource.rb', line 372

def title
  source.dig("ItemAttributes", "Title")
end

#url_add_to_wishlistString?

Returns:

  • (String, nil)


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_reviewsString?

Returns:

  • (String, nil)


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_offersString?

Returns:

  • (String, nil)


387
388
389
# File 'lib/rapa/resources/item_resource.rb', line 387

def url_all_offers
  item_links["All Offers"]
end

#url_customer_reviews_iframeString?

Returns:

  • (String, nil)


392
393
394
# File 'lib/rapa/resources/item_resource.rb', line 392

def url_customer_reviews_iframe
  source.dig("CustomerReviews", "IFrameURL")
end

#url_details_pageString

Returns:

  • (String)


397
398
399
# File 'lib/rapa/resources/item_resource.rb', line 397

def url_details_page
  source["DetailPageURL"]
end

#url_tell_a_friendString?

Returns:

  • (String, nil)


402
403
404
# File 'lib/rapa/resources/item_resource.rb', line 402

def url_tell_a_friend
  item_links["Tell A Friend"]
end