Merge branch 'master' into add_condition

This commit is contained in:
Dan Milne
2020-08-21 22:38:57 +10:00
6 changed files with 70 additions and 219 deletions

View File

@@ -1,3 +1,6 @@
## 0.1.2
- Use Contributor RoleType, rather than Role. RoleType uses lowercase, rather than capitalised.
## 0.1.0
- Remove Nameable dependancy and return the data as the API returns it.

View File

@@ -54,32 +54,36 @@ module Paapi
end
def contributors_of(kind)
kind = kind.to_s.gsub(/([[:alpha:]]+)/) { |w| w.capitalize }
contributors.select { |e| e['Role'] == kind }&.map { |e| e.dig('Name') }&.reject {|n| n.to_s.empty?}
kind = kind.to_s.gsub(/([[:alpha:]]+)/) { |w| w.downcase }
contributors.select { |e| e['RoleType'] == kind }&.map { |e| e.dig('Name') }&.reject {|n| n.to_s.empty?}
end
def actors
contributors_of 'Actor'
contributors_of 'actor'
end
def artists
contributors_of 'Artist'
contributors_of 'artist'
end
def authors
contributors_of 'Author'
contributors_of 'author'
end
def director
contributors_of 'director'
end
def illustrators
contributors_of 'Illustrator'
contributors_of 'illustrator'
end
def narrators
contributors_of 'Narrator'
contributors_of 'narrator'
end
def publishers
contributors_of 'Publisher'
contributors_of 'publisher'
end
def languages

View File

@@ -1,3 +1,3 @@
module Paapi
VERSION = '0.1.1'
VERSION = '0.1.2'
end

View File

@@ -1,176 +0,0 @@
{
"ItemsResult": {
"Items": [
{
"ASIN": "055357342X",
"DetailPageURL": "https://www.amazon.co.uk/dp/055357342X?tag=bookie0a-21&linkCode=ogi&th=1&psc=1",
"Images": {
"Primary": {
"Large": {
"Height": 500,
"URL": "https://m.media-amazon.com/images/I/51e6nhYq5TL.jpg",
"Width": 305
}
}
},
"ItemInfo": {
"ByLineInfo": {
"Contributors": [
{
"Locale": "en_GB",
"Name": ".",
"Role": "Author"
}
],
"Manufacturer": {
"DisplayValue": "Non Basic Stock Line",
"Label": "Manufacturer",
"Locale": "en_GB"
}
},
"ContentInfo": {
"Languages": {
"DisplayValues": [
{
"DisplayValue": "English",
"Type": "Published"
},
{
"DisplayValue": "English",
"Type": "Original Language"
},
{
"DisplayValue": "English",
"Type": "Unknown"
}
],
"Label": "Language",
"Locale": "en_GB"
},
"PagesCount": {
"DisplayValue": 1216,
"Label": "NumberOfPages",
"Locale": "en_US"
},
"PublicationDate": {
"DisplayValue": "2003-03-31T00:00:01Z",
"Label": "PublicationDate",
"Locale": "en_US"
}
},
"ExternalIds": {
"EANs": {
"DisplayValues": [
"9780553573428",
"8601419066322"
],
"Label": "EAN",
"Locale": "en_US"
},
"ISBNs": {
"DisplayValues": [
"055357342X",
"9780553573428"
],
"Label": "ISBN",
"Locale": "en_US"
}
},
"ManufactureInfo": {
"ItemPartNumber": {
"DisplayValue": "2606220",
"Label": "PartNumber",
"Locale": "en_US"
}
},
"ProductInfo": {
"ItemDimensions": {
"Height": {
"DisplayValue": 6.79,
"Label": "Height",
"Locale": "en_GB",
"Unit": "Inches"
},
"Length": {
"DisplayValue": 4.15,
"Label": "Length",
"Locale": "en_GB",
"Unit": "Inches"
},
"Weight": {
"DisplayValue": 1.1,
"Label": "Weight",
"Locale": "en_GB",
"Unit": "Pounds"
},
"Width": {
"DisplayValue": 1.84,
"Label": "Width",
"Locale": "en_GB",
"Unit": "Inches"
}
},
"ReleaseDate": {
"DisplayValue": "2003-03-31T00:00:01Z",
"Label": "ReleaseDate",
"Locale": "en_US"
},
"UnitCount": {
"DisplayValue": 1,
"Label": "NumberOfItems",
"Locale": "en_US"
}
},
"Title": {
"DisplayValue": "A Storm of Swords: 3 (Song of Ice and Fire)",
"Label": "Title",
"Locale": "en_GB"
}
},
"Offers": {
"Listings": [
{
"Availability": {
"Message": "In stock."
},
"Condition": {
"SubCondition": {
"Value": "Good"
},
"Value": "Used"
},
"DeliveryInfo": {
"IsAmazonFulfilled": false,
"IsFreeShippingEligible": false,
"IsPrimeEligible": false
},
"Id": "qEdfDwnCbF1NN%2BoQaXjEqwhIlFU7YWAAbBQQwHwmcADHFnoCIv5Togd4trXxwSzuMkkctQROwxy%2FU6ji1KMHtObuOdTk%2Bj6nsFYvij%2F2qZE2XlsDsmnX8Lp1w4ySASam7wCQy5XDtxA7Rt%2BWtYWS0NMRzYw0C9lU",
"MerchantInfo": {
"DefaultShippingCountry": "GB",
"Id": "A2P4VIAF254M7F",
"Name": "The Cotswold Library"
},
"Price": {
"Amount": 3.44,
"Currency": "GBP",
"DisplayAmount": "£3.44",
"Savings": {
"Amount": 6.55,
"Currency": "GBP",
"DisplayAmount": "£6.55 (66%)",
"Percentage": 66
}
},
"SavingBasis": {
"Amount": 9.99,
"Currency": "GBP",
"DisplayAmount": "£9.99"
},
"ViolatesMAP": false
}
]
}
}
]
}
}

View File

@@ -8,8 +8,8 @@
"Primary": {
"Large": {
"Height": 500,
"URL": "https://m.media-amazon.com/images/I/4107DRyNZpL.jpg",
"Width": 327
"URL": "https://m.media-amazon.com/images/I/41yp1zQdxqL.jpg",
"Width": 500
}
}
},
@@ -24,7 +24,8 @@
{
"Locale": "en_AU",
"Name": "Funko Pop! Marvel:",
"Role": "Artist"
"Role": "Artist",
"RoleType": "artist"
}
],
"Manufacturer": {
@@ -34,6 +35,16 @@
}
},
"ContentInfo": {
"Languages": {
"DisplayValues": [
{
"DisplayValue": "English",
"Type": "Published"
}
],
"Label": "Language",
"Locale": "en_AU"
},
"PublicationDate": {
"DisplayValue": "2018-04-04T00:00:01Z",
"Label": "PublicationDate",
@@ -60,10 +71,9 @@
},
"Features": {
"DisplayValues": [
"From Avengers Infinity War, Thanos, as a stylized POP vinyl from Funko!",
"Stylized collectable stands 3 ¾ inches tall, perfect for any Avengers Infinity War fan!",
"Collect and display all Avengers Infinity War POP! Vinyls!",
"Funko POP! is the 2017 Toy of the Year and People's Choice award winner"
"Stylized collectable stands 3 ¾ inches tall, perfect for any Avengers 3 fan!",
"Collect and display all, Avengers 3 Pop! Vinyl's!",
"Check out the other Avengers 3 figures from Funko!"
],
"Label": "Features",
"Locale": "en_AU"
@@ -78,6 +88,11 @@
"DisplayValue": "26467",
"Label": "Model",
"Locale": "en_US"
},
"Warranty": {
"DisplayValue": "No Warranty",
"Label": "Warranty",
"Locale": "en_AU"
}
},
"ProductInfo": {
@@ -92,15 +107,33 @@
"Locale": "en_US"
},
"ItemDimensions": {
"Height": {
"DisplayValue": 3.75,
"Label": "Height",
"Locale": "en_AU",
"Unit": "Inches"
},
"Length": {
"DisplayValue": 2.5,
"Label": "Length",
"Locale": "en_AU",
"Unit": "Inches"
},
"Weight": {
"DisplayValue": 0.85,
"DisplayValue": 1.873929227,
"Label": "Weight",
"Locale": "en_AU",
"Unit": "Kilograms"
"Unit": "Pounds"
},
"Width": {
"DisplayValue": 2.5,
"Label": "Width",
"Locale": "en_AU",
"Unit": "Inches"
}
},
"ReleaseDate": {
"DisplayValue": "2018-03-03T00:00:01Z",
"DisplayValue": "2019-10-17T00:00:01Z",
"Label": "ReleaseDate",
"Locale": "en_US"
},
@@ -116,7 +149,7 @@
}
},
"Title": {
"DisplayValue": "FUNKO POP! Marvel: Avengers Infinity War - Thanos",
"DisplayValue": "Funko FUN26467 Action Figure",
"Label": "Title",
"Locale": "en_AU"
}
@@ -134,19 +167,19 @@
"Value": "New"
},
"DeliveryInfo": {
"IsAmazonFulfilled": false,
"IsFreeShippingEligible": false,
"IsPrimeEligible": false
"IsAmazonFulfilled": true,
"IsFreeShippingEligible": true,
"IsPrimeEligible": true
},
"Id": "wGlzfgGjBBliOSAG21fYMCH27rYsl4J4q7XnxRDHzyAg8wXkOtJYJV3XrAsR1zd8kkVI0sXgIB%2FGfjyncUv1N43Propx%2B8VnOndyVTyEM0T0%2Fbrd06MYbAgns8Vbs%2BhEePoX6WOKsIrnsVJOPa%2FLS%2FPuUlyyFluU",
"Id": "m4oBvLF80AQ1QcznanMQGoFQaAZPT4Zsdo55%2Bb0YB%2FZpO%2F5daaIdhiLUd89%2FkBrWURvZ%2B%2B716QfBjkN0WUUBJp7%2BccDF5ZMNUEzQMDnNPgHmprZ2S8HURd7hb9%2F%2FTS5R",
"MerchantInfo": {
"Id": "A3A83J10WISLAT",
"Name": "SupportiveSolutions"
"Id": "ANEGB3WVEVKZB",
"Name": "Amazon AU"
},
"Price": {
"Amount": 17.99,
"Amount": 19.99,
"Currency": "AUD",
"DisplayAmount": "$17.99"
"DisplayAmount": "$19.99"
},
"ViolatesMAP": false
}

View File

@@ -28,9 +28,9 @@ class ItemTest < Minitest::Test
item_count: 1,
items: [
{
title: "FUNKO POP! Marvel: Avengers Infinity War - Thanos",
title: "Funko FUN26467 Action Figure",
asin: 'B079PQ7T6B',
image_url: 'https://m.media-amazon.com/images/I/4107DRyNZpL.jpg',
image_url: 'https://m.media-amazon.com/images/I/41yp1zQdxqL.jpg',
eans: ["0889698264679", "0615912346988"],
authors: [],
artists: ['Funko Pop! Marvel:'],
@@ -64,19 +64,6 @@ class ItemTest < Minitest::Test
artists: []
}
]
},
{
name: 'Bad Contributors',
response: 'get_item_bad_contributor.json',
item_count: 1,
items: [
{
asin: "055357342X",
authors: ['.'],
illustrators: [],
artists: []
}
]
}
]