amazon-book-search-se
Advanced tools
Comparing version 0.0.7 to 0.0.8
@@ -29,4 +29,4 @@ var apacOperationHelper = require('apac').OperationHelper; | ||
} | ||
this.apiClient.execute('ItemSearch', query).then((response) => { | ||
var actionResponse = function actionResponse(response){ | ||
var responseResult = response.result; | ||
@@ -39,23 +39,33 @@ var output = {}; | ||
if(!responseResult.ItemSearchResponse && responseResult.ItemSearchErrorResponse){ | ||
return callback(new Error(responseResult.ItemSearchErrorResponse.Error[0]), null); | ||
return callback(new Error(responseResult.ItemSearchErrorResponse.Error[0]), null); | ||
} | ||
if(!responseResult.ItemSearchResponse.Items[0].Request[0].IsValid[0]){ | ||
return callback(new Error(responseResult.ItemSearchResponse.Items[0].Request[0].Errors[0].Error[0].Message[0]), null); | ||
return callback(new Error(responseResult.ItemSearchResponse.Items[0].Request[0].Errors[0].Error[0].Message[0]), null); | ||
} | ||
var results = responseResult.ItemSearchResponse.Items[0].Item; | ||
var totalResults = responseResult.ItemSearchResponse.Items[0].TotalResults[0]; | ||
var totalPages = responseResult.ItemSearchResponse.Items[0].TotalPages[0]; | ||
if(!results){ | ||
output = { totalResults:0, totalPages:0, currentPage:0, results:[] }; | ||
return callback(null, output); | ||
output = { totalResults:0, totalPages:0, currentPage:0, results:[] }; | ||
return callback(null, output); | ||
} | ||
output = { totalResults: totalResults, totalPages: totalPages, currentPage: page || 1, results: results}; | ||
callback(null, output); | ||
}; | ||
var executeResult = null; | ||
var promise = null; | ||
this.apiClient.execute('ItemSearch', query).then((response) => { | ||
if(response && response.result){ | ||
actionResponse(response); | ||
} else { | ||
response().then(actionResponse); | ||
} | ||
}).catch((err) => { | ||
callback(err, null); | ||
}); | ||
} | ||
}; | ||
module.exports = amazonSearchHelper; |
{ | ||
"name": "amazon-book-search-se", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"description": "Simple wrapper around apac to return book results from Amazon's Product Advertising API. Based on amazon-book-search by kuryaki. Uses apac version 2.0.0.", | ||
@@ -5,0 +5,0 @@ "main": "amazon-book-search-se.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24183
94