mirror of
https://github.com/dkam/paapi.git
synced 2025-12-28 07:04:53 +00:00
Merge branch 'master' into net_http
This commit is contained in:
@@ -1,3 +1,6 @@
|
|||||||
|
## 0.1.2
|
||||||
|
- Use Contributor RoleType, rather than Role. RoleType uses lowercase, rather than capitalised.
|
||||||
|
|
||||||
## 0.1.0
|
## 0.1.0
|
||||||
- Remove Nameable dependancy and return the data as the API returns it.
|
- Remove Nameable dependancy and return the data as the API returns it.
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
`paapi` is a slim wrapper around [Amazon's Product Advertising API 5.0](https://webservices.amazon.com/paapi5/documentation/).
|
`paapi` is a slim wrapper around [Amazon's Product Advertising API 5.0](https://webservices.amazon.com/paapi5/documentation/).
|
||||||
|
|
||||||
This gem is under heavy development and currently incomplete.
|
|
||||||
|
|
||||||
[](https://travis-ci.org/dkam/paapi)
|
[](https://travis-ci.org/dkam/paapi)
|
||||||
|
|
||||||
|
If this gem doesn't meet your needs, try the [Vacumm gem](https://github.com/hakanensari/vacuum).
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
Add this line to your application's Gemfile:
|
Add this line to your application's Gemfile:
|
||||||
@@ -67,7 +67,7 @@ client.partner_tag
|
|||||||
|
|
||||||
The full list of market keys is `au, br, ca, fr, de, in, it, jp, mx, es, tr, ae, uk, us`
|
The full list of market keys is `au, br, ca, fr, de, in, it, jp, mx, es, tr, ae, uk, us`
|
||||||
|
|
||||||
### Using the Paapi
|
### Using Paapi
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
require 'paapi'
|
require 'paapi'
|
||||||
|
|||||||
@@ -54,32 +54,36 @@ module Paapi
|
|||||||
end
|
end
|
||||||
|
|
||||||
def contributors_of(kind)
|
def contributors_of(kind)
|
||||||
kind = kind.to_s.gsub(/([[:alpha:]]+)/) { |w| w.capitalize }
|
kind = kind.to_s.gsub(/([[:alpha:]]+)/) { |w| w.downcase }
|
||||||
contributors.select { |e| e['Role'] == kind }&.map { |e| e.dig('Name') }&.reject {|n| n.to_s.empty?}
|
contributors.select { |e| e['RoleType'] == kind }&.map { |e| e.dig('Name') }&.reject {|n| n.to_s.empty?}
|
||||||
end
|
end
|
||||||
|
|
||||||
def actors
|
def actors
|
||||||
contributors_of 'Actor'
|
contributors_of 'actor'
|
||||||
end
|
end
|
||||||
|
|
||||||
def artists
|
def artists
|
||||||
contributors_of 'Artist'
|
contributors_of 'artist'
|
||||||
end
|
end
|
||||||
|
|
||||||
def authors
|
def authors
|
||||||
contributors_of 'Author'
|
contributors_of 'author'
|
||||||
|
end
|
||||||
|
|
||||||
|
def director
|
||||||
|
contributors_of 'director'
|
||||||
end
|
end
|
||||||
|
|
||||||
def illustrators
|
def illustrators
|
||||||
contributors_of 'Illustrator'
|
contributors_of 'illustrator'
|
||||||
end
|
end
|
||||||
|
|
||||||
def narrators
|
def narrators
|
||||||
contributors_of 'Narrator'
|
contributors_of 'narrator'
|
||||||
end
|
end
|
||||||
|
|
||||||
def publishers
|
def publishers
|
||||||
contributors_of 'Publisher'
|
contributors_of 'publisher'
|
||||||
end
|
end
|
||||||
|
|
||||||
def languages
|
def languages
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ module Paapi
|
|||||||
|
|
||||||
@items_data = @hash.dig('ItemsResult', 'Items')
|
@items_data = @hash.dig('ItemsResult', 'Items')
|
||||||
@items_data ||= @hash.dig('SearchResult', 'Items')
|
@items_data ||= @hash.dig('SearchResult', 'Items')
|
||||||
|
@items_data ||= @hash.dig('VariationsResult', 'Items')
|
||||||
@items_data ||= []
|
@items_data ||= []
|
||||||
|
|
||||||
@items = @items_data.map {|d| Item.new(d)}
|
@items = @items_data.map {|d| Item.new(d)}
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
module Paapi
|
module Paapi
|
||||||
VERSION = '0.1.0'
|
VERSION = '0.1.2'
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
|
|||||||
spec.require_paths = ['lib']
|
spec.require_paths = ['lib']
|
||||||
|
|
||||||
spec.add_development_dependency 'bundler', '~> 2.0'
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
||||||
spec.add_development_dependency 'rake', '~> 10.0'
|
spec.add_development_dependency 'rake', '>= 12.3.r3'
|
||||||
spec.add_development_dependency 'minitest', '~> 5.0'
|
spec.add_development_dependency 'minitest', '~> 5.0'
|
||||||
spec.add_development_dependency 'byebug', '~> 11'
|
spec.add_development_dependency 'byebug', '~> 11'
|
||||||
spec.add_development_dependency 'awesome_print', '~> 1.8'
|
spec.add_development_dependency 'awesome_print', '~> 1.8'
|
||||||
|
|||||||
@@ -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
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -8,8 +8,8 @@
|
|||||||
"Primary": {
|
"Primary": {
|
||||||
"Large": {
|
"Large": {
|
||||||
"Height": 500,
|
"Height": 500,
|
||||||
"URL": "https://m.media-amazon.com/images/I/4107DRyNZpL.jpg",
|
"URL": "https://m.media-amazon.com/images/I/41yp1zQdxqL.jpg",
|
||||||
"Width": 327
|
"Width": 500
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -24,7 +24,8 @@
|
|||||||
{
|
{
|
||||||
"Locale": "en_AU",
|
"Locale": "en_AU",
|
||||||
"Name": "Funko Pop! Marvel:",
|
"Name": "Funko Pop! Marvel:",
|
||||||
"Role": "Artist"
|
"Role": "Artist",
|
||||||
|
"RoleType": "artist"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"Manufacturer": {
|
"Manufacturer": {
|
||||||
@@ -34,6 +35,16 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ContentInfo": {
|
"ContentInfo": {
|
||||||
|
"Languages": {
|
||||||
|
"DisplayValues": [
|
||||||
|
{
|
||||||
|
"DisplayValue": "English",
|
||||||
|
"Type": "Published"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Label": "Language",
|
||||||
|
"Locale": "en_AU"
|
||||||
|
},
|
||||||
"PublicationDate": {
|
"PublicationDate": {
|
||||||
"DisplayValue": "2018-04-04T00:00:01Z",
|
"DisplayValue": "2018-04-04T00:00:01Z",
|
||||||
"Label": "PublicationDate",
|
"Label": "PublicationDate",
|
||||||
@@ -60,10 +71,9 @@
|
|||||||
},
|
},
|
||||||
"Features": {
|
"Features": {
|
||||||
"DisplayValues": [
|
"DisplayValues": [
|
||||||
"From Avengers Infinity War, Thanos, as a stylized POP vinyl from Funko!",
|
"Stylized collectable stands 3 ¾ inches tall, perfect for any Avengers 3 fan!",
|
||||||
"Stylized collectable stands 3 ¾ inches tall, perfect for any Avengers Infinity War fan!",
|
"Collect and display all, Avengers 3 Pop! Vinyl's!",
|
||||||
"Collect and display all Avengers Infinity War POP! Vinyls!",
|
"Check out the other Avengers 3 figures from Funko!"
|
||||||
"Funko POP! is the 2017 Toy of the Year and People's Choice award winner"
|
|
||||||
],
|
],
|
||||||
"Label": "Features",
|
"Label": "Features",
|
||||||
"Locale": "en_AU"
|
"Locale": "en_AU"
|
||||||
@@ -78,6 +88,11 @@
|
|||||||
"DisplayValue": "26467",
|
"DisplayValue": "26467",
|
||||||
"Label": "Model",
|
"Label": "Model",
|
||||||
"Locale": "en_US"
|
"Locale": "en_US"
|
||||||
|
},
|
||||||
|
"Warranty": {
|
||||||
|
"DisplayValue": "No Warranty",
|
||||||
|
"Label": "Warranty",
|
||||||
|
"Locale": "en_AU"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ProductInfo": {
|
"ProductInfo": {
|
||||||
@@ -92,15 +107,33 @@
|
|||||||
"Locale": "en_US"
|
"Locale": "en_US"
|
||||||
},
|
},
|
||||||
"ItemDimensions": {
|
"ItemDimensions": {
|
||||||
|
"Height": {
|
||||||
|
"DisplayValue": 3.75,
|
||||||
|
"Label": "Height",
|
||||||
|
"Locale": "en_AU",
|
||||||
|
"Unit": "Inches"
|
||||||
|
},
|
||||||
|
"Length": {
|
||||||
|
"DisplayValue": 2.5,
|
||||||
|
"Label": "Length",
|
||||||
|
"Locale": "en_AU",
|
||||||
|
"Unit": "Inches"
|
||||||
|
},
|
||||||
"Weight": {
|
"Weight": {
|
||||||
"DisplayValue": 0.85,
|
"DisplayValue": 1.873929227,
|
||||||
"Label": "Weight",
|
"Label": "Weight",
|
||||||
"Locale": "en_AU",
|
"Locale": "en_AU",
|
||||||
"Unit": "Kilograms"
|
"Unit": "Pounds"
|
||||||
|
},
|
||||||
|
"Width": {
|
||||||
|
"DisplayValue": 2.5,
|
||||||
|
"Label": "Width",
|
||||||
|
"Locale": "en_AU",
|
||||||
|
"Unit": "Inches"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ReleaseDate": {
|
"ReleaseDate": {
|
||||||
"DisplayValue": "2018-03-03T00:00:01Z",
|
"DisplayValue": "2019-10-17T00:00:01Z",
|
||||||
"Label": "ReleaseDate",
|
"Label": "ReleaseDate",
|
||||||
"Locale": "en_US"
|
"Locale": "en_US"
|
||||||
},
|
},
|
||||||
@@ -116,7 +149,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Title": {
|
"Title": {
|
||||||
"DisplayValue": "FUNKO POP! Marvel: Avengers Infinity War - Thanos",
|
"DisplayValue": "Funko FUN26467 Action Figure",
|
||||||
"Label": "Title",
|
"Label": "Title",
|
||||||
"Locale": "en_AU"
|
"Locale": "en_AU"
|
||||||
}
|
}
|
||||||
@@ -134,19 +167,19 @@
|
|||||||
"Value": "New"
|
"Value": "New"
|
||||||
},
|
},
|
||||||
"DeliveryInfo": {
|
"DeliveryInfo": {
|
||||||
"IsAmazonFulfilled": false,
|
"IsAmazonFulfilled": true,
|
||||||
"IsFreeShippingEligible": false,
|
"IsFreeShippingEligible": true,
|
||||||
"IsPrimeEligible": false
|
"IsPrimeEligible": true
|
||||||
},
|
},
|
||||||
"Id": "wGlzfgGjBBliOSAG21fYMCH27rYsl4J4q7XnxRDHzyAg8wXkOtJYJV3XrAsR1zd8kkVI0sXgIB%2FGfjyncUv1N43Propx%2B8VnOndyVTyEM0T0%2Fbrd06MYbAgns8Vbs%2BhEePoX6WOKsIrnsVJOPa%2FLS%2FPuUlyyFluU",
|
"Id": "m4oBvLF80AQ1QcznanMQGoFQaAZPT4Zsdo55%2Bb0YB%2FZpO%2F5daaIdhiLUd89%2FkBrWURvZ%2B%2B716QfBjkN0WUUBJp7%2BccDF5ZMNUEzQMDnNPgHmprZ2S8HURd7hb9%2F%2FTS5R",
|
||||||
"MerchantInfo": {
|
"MerchantInfo": {
|
||||||
"Id": "A3A83J10WISLAT",
|
"Id": "ANEGB3WVEVKZB",
|
||||||
"Name": "SupportiveSolutions"
|
"Name": "Amazon AU"
|
||||||
},
|
},
|
||||||
"Price": {
|
"Price": {
|
||||||
"Amount": 17.99,
|
"Amount": 19.99,
|
||||||
"Currency": "AUD",
|
"Currency": "AUD",
|
||||||
"DisplayAmount": "$17.99"
|
"DisplayAmount": "$19.99"
|
||||||
},
|
},
|
||||||
"ViolatesMAP": false
|
"ViolatesMAP": false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,9 +28,9 @@ class ItemTest < Minitest::Test
|
|||||||
item_count: 1,
|
item_count: 1,
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
title: "FUNKO POP! Marvel: Avengers Infinity War - Thanos",
|
title: "Funko FUN26467 Action Figure",
|
||||||
asin: 'B079PQ7T6B',
|
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"],
|
eans: ["0889698264679", "0615912346988"],
|
||||||
authors: [],
|
authors: [],
|
||||||
artists: ['Funko Pop! Marvel:'],
|
artists: ['Funko Pop! Marvel:'],
|
||||||
@@ -64,19 +64,6 @@ class ItemTest < Minitest::Test
|
|||||||
artists: []
|
artists: []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Bad Contributors',
|
|
||||||
response: 'get_item_bad_contributor.json',
|
|
||||||
item_count: 1,
|
|
||||||
items: [
|
|
||||||
{
|
|
||||||
asin: "055357342X",
|
|
||||||
authors: ['.'],
|
|
||||||
illustrators: [],
|
|
||||||
artists: []
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user