Module: TipsanityMerchantExtractor::Amazon::FindAmazon
- Includes:
- TipsanityMerchantExtractor::Amazon
- Defined in:
- lib/tipsanity_merchant_extractor/amazon.rb
Instance Method Summary collapse
Methods included from TipsanityMerchantExtractor::Amazon
extended, #filtered_asin_from_amazon_path, #is_merchant_amazon?, #merchant_amazon_path
Instance Method Details
#find_product_amazon(merchannt_url) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/tipsanity_merchant_extractor/amazon.rb', line 50 def find_product_amazon(merchannt_url) client = ASIN::Client.instance product = client.lookup filtered_asin_from_amazon_path(merchant_url) unless product.empty? @response_object = product @product_name = product.first.title # filtered_asin_from_amazon_path{|is_dp| is_dp == false} ? @description = product.first.raw.EditorialReviews.EditorialReview.Content : @description = product.first.raw.EditorialReviews.EditorialReview.first.Content @description = product.first.raw.keys.include?("EditorialReviews") ? (product.first.raw.EditorialReviews.EditorialReview.kind_of?(Array) ? product.first.raw.EditorialReviews.EditorialReview.first.Content : product.first.raw.EditorialReviews.EditorialReview.Content) : nil @list_price = product.first.amount.to_f/100 || product.first.raw.ItemAttributes.ListPrice.Amount.to_f/100 @currency_code = product.first.raw.ItemAttributes.ListPrice.CurrencyCode @expiry_date = Date.today @image_url = product.first.image_url || product.first.raw.ImageSets.ImageSet.LargeImage.URL @details_url = product.first.details_url @final_price = product.first.raw.include?("OfferSummary") ? ((product.first.raw.OfferSummary.LowestNewPrice and product.first.raw.OfferSummary.LowestNewPrice.Amount) ? product.first.raw.OfferSummary.LowestNewPrice.Amount.to_f/100 : nil) : nil @categories = product.first.raw.ItemAttributes.Binding @product_token = product.first.asin else @response_object = nil @product_name = nil @description = nil @list_price = nil @currency_code = nil @expiry_date = nil @image_url = nil @details_url = nil @final_price = nil @categories = nil end end |