class Rapa::Resources::ItemResource

Public Instance Methods

adult_product?() click to toggle source

@return [Boolean, nil]

# 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_versions() click to toggle source

@return [Array<Rapa::AlternateVersion>]

# 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() click to toggle source

@return [String]

# File lib/rapa/resources/item_resource.rb, line 28
def asin
  source["ASIN"]
end
authors() click to toggle source

@return [Array<String>]

# 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() click to toggle source

@return [String, nil]

# File lib/rapa/resources/item_resource.rb, line 45
def binding
  source.dig("ItemAttributes", "Binding")
end
browse_nodes() click to toggle source

@return [Array<Rapa::BrowseNode>]

# 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() click to toggle source

@return [String, nil]

# File lib/rapa/resources/item_resource.rb, line 78
def creator_name
  if creators.first
    creators.first.name
  end
end
creator_role() click to toggle source

@return [String, nil]

# File lib/rapa/resources/item_resource.rb, line 85
def creator_role
  if creators.first
    creators.first.role
  end
end
creators() click to toggle source

@return [Array<Rapa::Creator>]

# 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() click to toggle source

@return [String, nil]

# File lib/rapa/resources/item_resource.rb, line 92
def ean
  source.dig("ItemAttributes", "EAN")
end
ebook?() click to toggle source

@return [Boolean]

# File lib/rapa/resources/item_resource.rb, line 97
def ebook?
  source.dig("ItemAttributes", "ProductGroup") == "eBooks"
end
episode_sequence() click to toggle source

@return [Integer, nil]

# File lib/rapa/resources/item_resource.rb, line 102
def episode_sequence
  if value = source.dig("ItemAttributes", "EpisodeSequence")
    value.to_i
  end
end
genre() click to toggle source

@return [String, nil]

# File lib/rapa/resources/item_resource.rb, line 109
def genre
  source.dig("ItemAttributes", "Genre")
end
has_customer_reviews?() click to toggle source

@return [Boolean]

# File lib/rapa/resources/item_resource.rb, line 114
def has_customer_reviews?
  source.dig("CustomerReviews", "HasReviews") == "true"
end
image_hi_res() click to toggle source

@return [Rapa::Image, nil]

# File lib/rapa/resources/item_resource.rb, line 119
def image_hi_res
  find_image("HiResImage")
end
image_large() click to toggle source

@return [Rapa::Image, nil]

# File lib/rapa/resources/item_resource.rb, line 124
def image_large
  find_image("LargeImage")
end
image_medium() click to toggle source

@return [Rapa::Image, nil]

# File lib/rapa/resources/item_resource.rb, line 129
def image_medium
  find_image("MediumImage")
end
image_small() click to toggle source

@return [Rapa::Image, nil]

# File lib/rapa/resources/item_resource.rb, line 134
def image_small
  find_image("SmallImage")
end
image_swatch() click to toggle source

@return [Rapa::Image, nil]

# File lib/rapa/resources/item_resource.rb, line 139
def image_swatch
  find_image("SwatchImage")
end
image_thumbnail() click to toggle source

@return [Rapa::Image, nil]

# File lib/rapa/resources/item_resource.rb, line 144
def image_thumbnail
  find_image("ThumbnailImage")
end
image_tiny() click to toggle source

@return [Rapa::Image, nil]

# File lib/rapa/resources/item_resource.rb, line 149
def image_tiny
  find_image("TinyImage")
end
isbn() click to toggle source

@return [String, nil]

# File lib/rapa/resources/item_resource.rb, line 154
def isbn
  source.dig("ItemAttributes", "ISBN")
end
item_height() click to toggle source

@return [Rapa::Quantity]

# 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_length() click to toggle source

@return [Rapa::Quantity]

# 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_width() click to toggle source

@return [Rapa::Quantity]

# 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() click to toggle source

@return [String, nil]

# File lib/rapa/resources/item_resource.rb, line 180
def label
  source.dig("ItemAttributes", "Label")
end
languages() click to toggle source

@return [Array<Rapa::Language>]

# 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() click to toggle source

@return [String, nil]

# File lib/rapa/resources/item_resource.rb, line 199
def manufacturer
  source.dig("ItemAttributes", "Manufacturer")
end
number_of_pages() click to toggle source

@return [Integer, nil]

# 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_height() click to toggle source

@return [Rapa::Quantity]

# 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_length() click to toggle source

@return [Rapa::Quantity]

# 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_weight() click to toggle source

@return [Rapa::Quantity]

# 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_width() click to toggle source

@return [Rapa::Quantity]

# 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() click to toggle source

@return [Rapa::Price, nil]

# 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_new() click to toggle source

@return [Rapa::Price, nil]

# 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_used() click to toggle source

@return [Rapa::Price, nil]

# 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() click to toggle source

@return [String, nil]

# File lib/rapa/resources/item_resource.rb, line 260
def product_group
  source.dig("ItemAttributes", "ProductGroup")
end
product_type_name() click to toggle source

@return [String, nil]

# File lib/rapa/resources/item_resource.rb, line 265
def product_type_name
  source.dig("ItemAttributes", "ProductTypeName")
end
publication_date() click to toggle source

@return [Date, nil]

# File lib/rapa/resources/item_resource.rb, line 270
def publication_date
  if value = source.dig("ItemAttributes", "PublicationDate")
    parse_date(value)
  end
end
publisher() click to toggle source

@return [String, nil]

# File lib/rapa/resources/item_resource.rb, line 277
def publisher
  source.dig("ItemAttributes", "Publisher")
end
relationship() click to toggle source

@return [String, nil]

# File lib/rapa/resources/item_resource.rb, line 317
def relationship
  source.dig("RelatedItems", "Relationship")
end
relationship_type() click to toggle source

@return [String, nil]

# File lib/rapa/resources/item_resource.rb, line 322
def relationship_type
  source.dig("RelatedItems", "RelationshipType")
end
release_date() click to toggle source

@return [Date, nil]

# File lib/rapa/resources/item_resource.rb, line 327
def release_date
  if value = source.dig("ItemAttributes", "ReleaseDate")
    parse_date(value)
  end
end
running_time() click to toggle source

@return [Rapa::Quantity, nil]

# 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() click to toggle source

@return [Integer, nil]

# File lib/rapa/resources/item_resource.rb, line 341
def sales_rank
  source["SalesRank"]
end
season_sequence() click to toggle source

@return [Integer, nil]

# File lib/rapa/resources/item_resource.rb, line 346
def season_sequence
  if value = source.dig("ItemAttributes", "SeasonSequence")
    value.to_i
  end
end
similar_products() click to toggle source

@return [Array<Rapa::SimilarProduct>]

# 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() click to toggle source

@return [String, nil]

# File lib/rapa/resources/item_resource.rb, line 367
def studio
  source.dig("ItemAttributes", "Studio")
end
title() click to toggle source

@return [String, nil]

# File lib/rapa/resources/item_resource.rb, line 372
def title
  source.dig("ItemAttributes", "Title")
end
url_add_to_wishlist() click to toggle source

@return [String, nil]

# File lib/rapa/resources/item_resource.rb, line 377
def url_add_to_wishlist
  item_links["Add To Wishlist"]
end
url_all_customer_reviews() click to toggle source

@return [String, nil]

# File lib/rapa/resources/item_resource.rb, line 382
def url_all_customer_reviews
  item_links["All Customer Reviews"]
end
url_all_offers() click to toggle source

@return [String, nil]

# File lib/rapa/resources/item_resource.rb, line 387
def url_all_offers
  item_links["All Offers"]
end
url_customer_reviews_iframe() click to toggle source

@return [String, nil]

# File lib/rapa/resources/item_resource.rb, line 392
def url_customer_reviews_iframe
  source.dig("CustomerReviews", "IFrameURL")
end
url_details_page() click to toggle source

@return [String]

# File lib/rapa/resources/item_resource.rb, line 397
def url_details_page
  source["DetailPageURL"]
end
url_tell_a_friend() click to toggle source

@return [String, nil]

# File lib/rapa/resources/item_resource.rb, line 402
def url_tell_a_friend
  item_links["Tell A Friend"]
end

Private Instance Methods

find_image(key) click to toggle source

@param key [String] @return [Rapa::Image, nil]

# File lib/rapa/resources/item_resource.rb, line 410
def find_image(key)
  if image_source = find_image_source(key)
    ::Rapa::Image.new(image_source)
  end
end
find_image_source(key) click to toggle source

@param key [String] @return [Hash, nil]

# File lib/rapa/resources/item_resource.rb, line 418
def find_image_source(key)
  if source[key]
    source[key]
  else
    image_set = source.dig("ImageSets", "ImageSet")
    image_set = image_set.first if image_set.is_a?(::Array)
    if image_set
      image_set[key]
    end
  end
end
item_attributes() click to toggle source

@private @return [Hash, nil]

# File lib/rapa/resources/item_resource.rb, line 432
def item_attributes
  source["ItemAttributes"]
end
parse_date(string) click to toggle source

@param string [String] @return [Date, nil]

# File lib/rapa/resources/item_resource.rb, line 446
def parse_date(string)
  case string
  when /\A\d{1,4}\z/
    ::Date.parse("#{string}-01-01")
  when /\A\d{1,4}-\d{1,2}\z/
    ::Date.parse("#{string}-01")
  when /\A\d{1,4}-\d{1,2}-\d{1,2}\z/
    ::Date.parse(string)
  end
end