diff --git a/CHANGELOG.md b/CHANGELOG.md index dab05cd..91dccbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.0.8 +- Fix a bug when accessing an empty name via Item + ## 0.0.7 - Rename Item#json to Item#hash for consistency - Add offer / listing parsing diff --git a/lib/paapi/version.rb b/lib/paapi/version.rb index 8e8edbd..bf3e099 100644 --- a/lib/paapi/version.rb +++ b/lib/paapi/version.rb @@ -1,3 +1,3 @@ module Paapi - VERSION = '0.0.7' + VERSION = '0.0.8' end diff --git a/test/data/get_item_no_contributor.json b/test/data/get_item_no_contributor.json new file mode 100644 index 0000000..714e0ea --- /dev/null +++ b/test/data/get_item_no_contributor.json @@ -0,0 +1,161 @@ +{ + "ItemsResult": { + "Items": [ + { + "ASIN": "1921878657", + "DetailPageURL": "https://www.amazon.com/dp/1921878657?tag=bookie09-20&linkCode=ogi&th=1&psc=1", + "Images": { + "Primary": { + "Large": { + "Height": 500, + "URL": "https://m.media-amazon.com/images/I/61xe6KCK16L.jpg", + "Width": 499 + } + } + }, + "ItemInfo": { + "ByLineInfo": { + "Manufacturer": { + "DisplayValue": "Rockpool Publishing", + "Label": "Manufacturer", + "Locale": "en_US" + } + }, + "ContentInfo": { + "Languages": { + "DisplayValues": [ + { + "DisplayValue": "English", + "Type": "Published" + }, + { + "DisplayValue": "English", + "Type": "Original Language" + }, + { + "DisplayValue": "English", + "Type": "Unknown" + } + ], + "Label": "Language", + "Locale": "en_US" + }, + "PagesCount": { + "DisplayValue": 224, + "Label": "NumberOfPages", + "Locale": "en_US" + }, + "PublicationDate": { + "DisplayValue": "2013-08-01T00:00:01Z", + "Label": "PublicationDate", + "Locale": "en_US" + } + }, + "ExternalIds": { + "EANs": { + "DisplayValues": [ + "9781921878657" + ], + "Label": "EAN", + "Locale": "en_US" + }, + "ISBNs": { + "DisplayValues": [ + "1921878657" + ], + "Label": "ISBN", + "Locale": "en_US" + } + }, + "ManufactureInfo": { + "ItemPartNumber": { + "DisplayValue": "200 colour photos", + "Label": "PartNumber", + "Locale": "en_US" + } + }, + "ProductInfo": { + "ItemDimensions": { + "Height": { + "DisplayValue": 9.0, + "Label": "Height", + "Locale": "en_US", + "Unit": "Inches" + }, + "Length": { + "DisplayValue": 9.0, + "Label": "Length", + "Locale": "en_US", + "Unit": "Inches" + }, + "Weight": { + "DisplayValue": 1.65, + "Label": "Weight", + "Locale": "en_US", + "Unit": "Pounds" + }, + "Width": { + "DisplayValue": 0.6, + "Label": "Width", + "Locale": "en_US", + "Unit": "Inches" + } + }, + "UnitCount": { + "DisplayValue": 1, + "Label": "NumberOfItems", + "Locale": "en_US" + } + }, + "Title": { + "DisplayValue": "Muscle Car Mania: 100 legendary Australian motoring stories (Motoring Series)", + "Label": "Title", + "Locale": "en_US" + } + }, + "Offers": { + "Listings": [ + { + "Availability": { + "Message": "In Stock." + }, + "Condition": { + "SubCondition": { + "Value": "New" + }, + "Value": "New" + }, + "DeliveryInfo": { + "IsAmazonFulfilled": true, + "IsFreeShippingEligible": true, + "IsPrimeEligible": true + }, + "Id": "oGEK9dN87uwQuSy0Cy2FsGZgiQlK9AMvmDO0cvPSFLdVtNKcF4nDn97DsoZMfMiHzI8W4FvyXDbV25mf3XuEwD8FU9znwQ1eZXjWM0aYpY5F1QIJ0Pm44w%3D%3D", + "MerchantInfo": { + "Id": "ATVPDKIKX0DER", + "Name": "Amazon.com" + }, + "Price": { + "Amount": 10.36, + "Currency": "USD", + "DisplayAmount": "$10.36", + "Savings": { + "Amount": 11.59, + "Currency": "USD", + "DisplayAmount": "$11.59 (53%)", + "Percentage": 53 + } + }, + "SavingBasis": { + "Amount": 21.95, + "Currency": "USD", + "DisplayAmount": "$21.95" + }, + "ViolatesMAP": false + } + ] + } + } + ] + } +} \ No newline at end of file diff --git a/test/item_test.rb b/test/item_test.rb index b1c857a..3a1b785 100644 --- a/test/item_test.rb +++ b/test/item_test.rb @@ -16,6 +16,7 @@ class ItemTest < Minitest::Test image_url: 'https://m.media-amazon.com/images/I/51B3xXr-ElL.jpg', eans: ["0889698357999", "6952669003752"], authors: [], + artists: [], brand: 'Funko', model: '35799' } @@ -32,6 +33,7 @@ class ItemTest < Minitest::Test image_url: 'https://m.media-amazon.com/images/I/4107DRyNZpL.jpg', eans: ["0889698264679", "0615912346988"], authors: [], + artists: ['Funko Pop! Marvel:'], brand: 'Funko', model: '26467' } @@ -44,7 +46,22 @@ class ItemTest < Minitest::Test items: [ { asin: "1921878657", - authors: [] + authors: [], + artists: [], + illustrators: [] + } + ] + }, + { + name: 'No Contributors', + response: 'get_item_no_contributor.json', + item_count: 1, + items: [ + { + asin: "1921878657", + authors: [], + illustrators: [], + artists: [] } ] }