Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

new methods for easier access of various fields

  • Loading branch information...
commit 38d86720a702c3a384e2e47ce68d6197b1771089 1 parent 45daee7
@jackdempsey authored
Showing with 21 additions and 0 deletions.
  1. +21 −0 lib/asin/item.rb
View
21 lib/asin/item.rb
@@ -16,9 +16,30 @@ def initialize(hash)
@raw = Hashie::Mash.new(hash)
end
+ def asin
+ @raw.ASIN
+ end
+
def title
@raw.ItemAttributes.Title
end
+
+ def cents
+ price_container = @raw.ItemAttributes.ListPrice ||
+ @raw.OfferSummary.LowestUsedPrice
+ if amount = price_container.Amount
+ amount.to_i
+ end
+ end
+
+ def url
+ @raw.DetailPageURL
+ end
+
+ def description
+ (@raw.EditorialReviews.EditorialReview.Content rescue nil) ||
+ (@raw.ItemAttributes.Feature.join('.') rescue nil)
+ end
end
end

5 comments on commit 38d8672

@phoet

i am currently working on a way to configure the item class in ASIN. if you are interested have a look at the latest commit

phoet@3b2b969

@jackdempsey

Awesome, that will definitely come in handy. I also started looking at using foo!.bar!.bam calls with Hashie so things don't blow up "no bar method on nil" if something doesn't quite work right.

Thanks, will come back to this in a bit and take a look at the new code when ready!

@phoet

it would be great if you open a pull request, so that your commits can be merged into the project

@jackdempsey

I'd be happy to--I've just been working on this fork with my own needs in mind, and it seems that your recent changes are designed to help people do this sort of thing more on their own....so, if there's a commit range you'd like to merge in, I'm happy to help make it happen!

@phoet

exactly. i want to provide a simple way to exchange the returned result-classes for item and cart.

as i already stated, just open a pull request, i will cherypick the changes that make sense to me for general usage.

Please sign in to comment.
Something went wrong with that request. Please try again.