amazon-sp-api
Advanced tools
Comparing version 0.5.6 to 0.6.0
// For a list of required and optional body, query or path parameters for resources please see official references: | ||
// --> https://github.com/amzn/selling-partner-api-docs/tree/main/references | ||
const {readdirSync} = require('fs'); | ||
const path = require('path'); | ||
module.exports = { | ||
...require('./resources/aplusContent'), | ||
...require('./resources/authorization'), | ||
...require('./resources/catalogItems'), | ||
...require('./resources/fbaInboundEligibility'), | ||
...require('./resources/fbaInventory'), | ||
...require('./resources/fbaSmallAndLight'), | ||
...require('./resources/feeds'), | ||
...require('./resources/finances'), | ||
...require('./resources/fulfillmentInbound'), | ||
...require('./resources/fulfillmentOutbound'), | ||
...require('./resources/listingsItems'), | ||
...require('./resources/merchantFulfillment'), | ||
...require('./resources/messaging'), | ||
...require('./resources/notifications'), | ||
...require('./resources/orders'), | ||
...require('./resources/productFees'), | ||
...require('./resources/productPricing'), | ||
...require('./resources/productTypesDefinitions'), | ||
...require('./resources/reports'), | ||
...require('./resources/sales'), | ||
...require('./resources/sellers'), | ||
...require('./resources/services'), | ||
...require('./resources/shipmentInvoicing'), | ||
...require('./resources/shipping'), | ||
...require('./resources/solicitations'), | ||
...require('./resources/tokens'), | ||
...require('./resources/uploads'), | ||
...require('./resources/vendorDirectFulfillmentInventory'), | ||
...require('./resources/vendorDirectFulfillmentOrders'), | ||
...require('./resources/vendorDirectFulfillmentPayments'), | ||
...require('./resources/vendorDirectFulfillmentShipping'), | ||
...require('./resources/vendorDirectFulfillmentTransactions'), | ||
...require('./resources/vendorInvoices'), | ||
...require('./resources/vendorOrders'), | ||
...require('./resources/vendorShipments'), | ||
...require('./resources/vendorTransactionStatus') | ||
...readdirSync(__dirname + '/resources').reduce((eps, ep) => { | ||
eps = typeof eps !== 'object' ? {} : eps; | ||
if (path.extname(ep) === '.js'){ | ||
return Object.assign(eps, { | ||
...require('./resources/' + ep) | ||
}); | ||
} | ||
return eps; | ||
}) | ||
}; |
module.exports = { | ||
listingsItems:{ | ||
__versions:[ | ||
'2020-09-01' | ||
'2020-09-01', | ||
'2021-08-01' | ||
], | ||
__operations:[ | ||
'getListingsItem', | ||
'putListingsItem', | ||
@@ -11,4 +13,5 @@ 'deleteListingsItem', | ||
], | ||
...require('./versions/listings_items/listingsItems_2020-09-01') | ||
...require('./versions/listings_items/listingsItems_2020-09-01'), | ||
...require('./versions/listings_items/listingsItems_2021-08-01') | ||
} | ||
}; |
@@ -9,3 +9,3 @@ const utils = require('../../../utils'); | ||
api_path:'/catalog/2020-12-01/items', | ||
restore_rate:1 | ||
restore_rate:0.2 | ||
}); | ||
@@ -12,0 +12,0 @@ }, |
@@ -9,3 +9,3 @@ module.exports = { | ||
api_path:'/fba/inventory/v1/summaries', | ||
restore_rate:0.012 | ||
restore_rate:0.5 | ||
}); | ||
@@ -12,0 +12,0 @@ } |
@@ -26,8 +26,7 @@ const crypto = require('crypto-js'); | ||
_sortQuery(query){ | ||
if (query && Object.keys(query).length){ | ||
// Sort query params by key, because it needs to be sorted for correct signature creation | ||
return Object.keys(query).sort().reduce((r, k) => (r[k] = query[k], r), {}); | ||
} | ||
return; | ||
// Double encoding the api path will fix issues with path variables containing UTF-8 chars or whitespace (i.e. SKUs) | ||
_encodeApiPath(api_path){ | ||
return api_path.split('/').map((url_part) => { | ||
return encodeURIComponent(encodeURIComponent(url_part)); | ||
}).join('/'); | ||
} | ||
@@ -37,17 +36,13 @@ | ||
if (query){ | ||
query = qs.stringify(query, {arrayFormat:'comma'}); | ||
let encoded_query_obj = {}; | ||
let query_params = query.split('&'); | ||
query_params.map((query_param) => { | ||
let param_key_value = query_param.split('='); | ||
encoded_query_obj[param_key_value[0]] = param_key_value[1]; | ||
// We have to replace whitespace with a '+' sign to prevent request from receiving an "Invalid Input" error when query includes whitespace | ||
return qs.stringify(query, { | ||
encodeValuesOnly:true, | ||
encoder:(str) => { | ||
return encodeURIComponent(str.replace(/ /g, '+')); | ||
}, | ||
arrayFormat:'comma', | ||
sort:(a, b) => { | ||
return a.localeCompare(b); | ||
} | ||
}); | ||
encoded_query_obj = this._sortQuery(encoded_query_obj); | ||
let encoded_query_arr = []; | ||
for (let key in encoded_query_obj){ | ||
encoded_query_arr.push(key + '=' + encoded_query_obj[key]); | ||
} | ||
if (encoded_query_arr.length){ | ||
return encoded_query_arr.join('&'); | ||
} | ||
} | ||
@@ -74,3 +69,3 @@ return ''; | ||
canonical.push(params.method); | ||
canonical.push(params.api_path); | ||
canonical.push(this._encodeApiPath(params.api_path)); | ||
canonical.push(encoded_query_string); | ||
@@ -113,4 +108,2 @@ canonical.push('host:' + this._api_endpoint); | ||
req_params.query = this._sortQuery(req_params.query); | ||
this._createUTCISODate(); | ||
@@ -117,0 +110,0 @@ |
{ | ||
"name": "amazon-sp-api", | ||
"version": "0.5.6", | ||
"version": "0.6.0", | ||
"description": "Amazon Selling Partner API client", | ||
@@ -28,3 +28,3 @@ "main": "index.js", | ||
"csvtojson": "^2.0.10", | ||
"fast-xml-parser": "^3.20.3", | ||
"fast-xml-parser": "^3.21.1", | ||
"iconv-lite": "^0.6.3", | ||
@@ -34,6 +34,6 @@ "qs": "^6.10.1" | ||
"devDependencies": { | ||
"@types/node": "^14.17.29", | ||
"@types/node": "^16.11.6", | ||
"chai": "^4.3.4", | ||
"dotenv": "^8.6.0", | ||
"mocha": "^8.4.0", | ||
"dotenv": "^10.0.0", | ||
"mocha": "^9.1.3", | ||
"moment": "^2.29.1" | ||
@@ -48,4 +48,4 @@ }, | ||
}, | ||
"homepage": "https://github.com/amz-tools/amazon-sp-api", | ||
"homepage": "https://amz.tools", | ||
"types": "./lib/typings/index.d.ts" | ||
} |
@@ -217,3 +217,3 @@ # amazon-sp-api (client for the Amazon Selling Partner API) | ||
method:'GET', | ||
restricted_data_token:'<RESTRICTED_DATA_TOKEN>' | ||
restricted_data_token:'<RESTRICTED_DATA_TOKEN>', | ||
options:{ | ||
@@ -465,3 +465,3 @@ version:'<OPERATION_ENDPOINT_VERSION>', | ||
compressionAlgorithm:'GZIP', // Only included if report is compressed | ||
encryptionDetails:{ | ||
encryptionDetails:{ // Only included if old reports endpoint version used (2020-09-04) | ||
standard:'AES', | ||
@@ -586,3 +586,3 @@ initializationVector:'<INITIALIZATION_VECTOR>', | ||
The `listCatalogItems` operation doesn't respect the restore rate yet, meaning it restores a lot slower than the default restore rate of 6 requests per second. | ||
Some operations don't respect the correct restore rate yet, meaning they restore a lot slower than the default restore rate. | ||
@@ -593,2 +593,2 @@ Some endpoints might have issues with special charsets like UTF-8. I.e. the `finances` operations return invalid UTF-8 encodings for all data prior to May 2020 resulting in JSON parse errors. | ||
If you are selling on the european market we might be able to support you with everything else that can't be done with the API, i.e. review management, product sourcing or sales and revenue estimations for products. Feel free to visit us at [https://amz.tools](https://amz.tools). | ||
If you are selling on the european market we might be able to support you with everything else that can't be done with the API, i.e. a detailed sales dashboard, review management, product sourcing or sales and revenue estimations for products. Feel free to visit us at [https://amz.tools](https://amz.tools). |
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
206039
105
5691
7
Updatedfast-xml-parser@^3.21.1