Skip to content

Commit

Permalink
Merge pull request #30 from kyletcarlson/master
Browse files Browse the repository at this point in the history
Added more methods to simplify accessing certain nodes.
  • Loading branch information
phoet committed Jan 10, 2014
2 parents d339e85 + 61c7e1c commit 45803af
Show file tree
Hide file tree
Showing 4 changed files with 171 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--color
--fail-fast
134 changes: 133 additions & 1 deletion lib/asin/simple_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,145 @@ def details_url
@raw.DetailPageURL
end

def sales_rank
@raw.SalesRank
end

def review
@raw.EditorialReviews!.EditorialReview!.Content
end

def image_url
@raw.LargeImage!.URL
end
end

# <ItemAttributes>
def author
@raw.ItemAttributes!.Author
end

def binding
@raw.ItemAttributes!.Binding
end

def brand
@raw.ItemAttributes!.Brand
end

def ean
@raw.ItemAttributes!.EAN
end

def edition
@raw.ItemAttributes!.Edition
end

def isbn
@raw.ItemAttributes!.isbn
end

def item_dimensions
@raw.ItemAttributes!.ItemDimensions
end

# hundredths of an inch
def item_height
@raw.ItemAttributes!.ItemDimensions.Height
end

# hundredths of an inch
def item_length
@raw.ItemAttributes!.ItemDimensions.Length
end

# hundredths of an inch
def item_width
@raw.ItemAttributes!.ItemDimensions.Width
end

# hundredths of a pound
def item_weight
@raw.ItemAttributes!.ItemDimensions.Weight
end

def package_dimensions
@raw.ItemAttributes!.PackageDimensions
end

# hundredths of an inch
def package_height
@raw.ItemAttributes!.PackageDimensions.Height
end

# hundredths of an inch
def package_length
@raw.ItemAttributes!.PackageDimensions.Length
end

# hundredths of an inch
def package_width
@raw.ItemAttributes!.PackageDimensions.Width
end

# hundredths of a pound
def package_weight
@raw.ItemAttributes!.PackageDimensions.Weight
end

def label
@raw.ItemAttributes!.Label
end

def language
@raw.ItemAttributes!.Languages.Language.first.Name
end

def formatted_price
@raw.ItemAttributes!.ListPrice.FormattedPrice
end

def manufacturer
@raw.ItemAttributes!.Manufacturer
end

def mpn
@raw.ItemAttributes!.MPN
end

def page_count
@raw.ItemAttributes!.NumberOfPages
end

def part_number
@raw.ItemAttributes!.PartNumber
end

def product_group
@raw.ItemAttributes!.ProductGroup
end

def publication_date
@raw.ItemAttributes!.PublicationDate
end

def publisher
@raw.ItemAttributes!.Publisher
end

def sku
@raw.ItemAttributes!.SKU
end

def studio
@raw.ItemAttributes!.Studio
end

def total_new
@raw.OfferSummary!.TotalNew
end

def total_used
@raw.OfferSummary!.TotalUsed
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,4 @@ http_interactions:
new to programming. &lt;/p&gt;</Content><IsLinkSuppressed>0</IsLinkSuppressed></EditorialReview></EditorialReviews></Item></Items></ItemLookupResponse>
http_version:
recorded_at: Tue, 25 Sep 2012 20:04:40 GMT
recorded_with: VCR 2.2.5
recorded_with: VCR 2.2.5
35 changes: 35 additions & 0 deletions spec/lib/search_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,45 @@ module ASIN
item = items.first
item.asin.should eql(ANY_ASIN)
item.title.should =~ /Learn Objective/
item.sales_rank.should == '209840'
item.amount.should eql(3999)
item.details_url.should eql("http://www.amazon.com/Learn-Objective-C-Mac-Series/dp/1430218150%3FSubscriptionId%3DAKIAIBNLWSCV5OXMPD6A%26tag%3Dphoet-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D1430218150")
item.image_url.should eql("http://ecx.images-amazon.com/images/I/41kq5bDvnUL.jpg")
item.review.should =~ /Take your coding skills to the next level/

# <ItemAttributes>
item.item_height.should == "925"
item.item_length.should == "752"
item.item_width.should == "71"
item.item_weight.should == "137"
item.package_height.should == "102"
item.package_length.should == "921"
item.package_width.should == "701"
item.package_weight.should == "123"

item.author.count.should == 2
item.author.first.should == "Scott Knaster"
item.binding.should == "Paperback"
item.brand.should == "Apress"
item.ean.should == "9781430218159"
item.edition == "1"
item.isbn == "1430218150"
item.label.should == "Apress"
item.language.should == "English"
item.formatted_price.should == "$39.99"
item.manufacturer.should == "Apress"
item.mpn.should == "978-1-4302-1815-9"
item.page_count.should == "360"
item.part_number.should == "978-1-4302-1815-9"
item.product_group.should == "Book"
item.publication_date.should == "2009-01-07"
item.publisher.should == "Apress"
item.sku.should == "mon0001920250"
item.studio.should == "Apress"

# <OfferSummary>
item.total_new.should == "56"
item.total_used.should == "62"
end

it "should lookup multiple response groups", :vcr do
Expand Down

0 comments on commit 45803af

Please sign in to comment.