Comparing version 0.2.0 to 0.3.0
30
index.js
@@ -44,3 +44,9 @@ /** | ||
Price.prototype.country = function (country) { | ||
if (endpointMap[country]) this.opts.endpoint = country; | ||
// Find matching endpoints | ||
var match = endpointMap.filter(function (e) { | ||
return e.code === country.toUpperCase() || e.name === country; | ||
}); | ||
// Set the first matching endpoint | ||
if (match.length > 0) this.opts.endpoint = match[0].endpoint; | ||
return this; | ||
@@ -142,13 +148,13 @@ }; | ||
var endpointMap = { | ||
'canada': 'webservices.amazon.ca', | ||
'china': 'webservices.amazon.cn', | ||
'germany': 'webservices.amazon.de', | ||
'spain': 'webservices.amazon.es', | ||
'france': 'webservices.amazon.fr', | ||
'italy': 'webservices.amazon.it', | ||
'japan': 'webservices.amazon.jp', | ||
'uk': 'webservices.amazon.uk', | ||
'us': 'webservices.amazon.us', | ||
}; | ||
var endpointMap = [ | ||
{ name: 'canada', code: 'CA', endpoint: 'webservices.amazon.ca' }, | ||
{ name: 'china', code: 'CN', endpoint: 'webservices.amazon.cn' }, | ||
{ name: 'germany', code: 'DE', endpoint: 'webservices.amazon.de' }, | ||
{ name: 'spain', code: 'ES', endpoint: 'webservices.amazon.es' }, | ||
{ name: 'france', code: 'FR', endpoint: 'webservices.amazon.fr' }, | ||
{ name: 'italy', code: 'IT', endpoint: 'webservices.amazon.it' }, | ||
{ name: 'japan', code: 'JP', endpoint: 'webservices.amazon.jp' }, | ||
{ name: 'uk', code: 'GB', endpoint: 'webservices.amazon.uk' }, | ||
{ name: 'us', code: 'US', endpoint: 'webservices.amazon.us' } | ||
]; | ||
@@ -155,0 +161,0 @@ var defaultExtractions = { |
{ | ||
"name": "aws-price", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "Amazon product API price lookup simplified", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
2
t.js
@@ -6,3 +6,3 @@ var util = require('util'); | ||
.associate('vi01d-20') | ||
.country('italy') | ||
.country('de') | ||
@@ -9,0 +9,0 @@ a.done(function (err, res) { |
16223
8
141