From d27409f80537c4119548f94a14fdaaedc8b497d5 Mon Sep 17 00:00:00 2001 From: Dan Milne Date: Mon, 14 Oct 2019 11:44:55 +1100 Subject: [PATCH] Method to get width, height, depth and weight from item. Bump gem version --- CHANGELOG.md | 3 +++ lib/paapi/item.rb | 20 ++++++++++++++++++++ lib/paapi/version.rb | 2 +- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dca857d..da248f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.0.6 +- Handle more date parsing failures. +- Get width, height, depth and weight from items ## 0.0.5 - Merged pull request #3 allowing options to be passed into the get_items and get_variations request diff --git a/lib/paapi/item.rb b/lib/paapi/item.rb index a8ce38d..9e7256f 100644 --- a/lib/paapi/item.rb +++ b/lib/paapi/item.rb @@ -122,6 +122,26 @@ module Paapi get(%w{ItemInfo TechnicalInfo Formats DisplayValues}) end + def height + data = get(%w{ItemInfo ProductInfo ItemDimensions Height}) + [data.dig('DisplayValue'), data.dig('Unit')].join(' ') + end + + def length + data = get(%w{ItemInfo ProductInfo ItemDimensions Length}) + [data.dig('DisplayValue'), data.dig('Unit')].join(' ') + end + + def width + data = get(%w{ItemInfo ProductInfo ItemDimensions Width}) + [data.dig('DisplayValue'), data.dig('Unit')].join(' ') + end + + def weight + data = get(%w{ItemInfo ProductInfo ItemDimensions Weight}) + [data.dig('DisplayValue'), data.dig('Unit')].join(' ') + end + def kindle? !package.nil? && package&.include?('Kindle eBook') end diff --git a/lib/paapi/version.rb b/lib/paapi/version.rb index cb284b6..fb5da25 100644 --- a/lib/paapi/version.rb +++ b/lib/paapi/version.rb @@ -1,3 +1,3 @@ module Paapi - VERSION = '0.0.5' + VERSION = '0.0.6' end