@mediocre/walmart-marketplace
Advanced tools
Comparing version 0.0.2 to 0.0.3
42
index.js
@@ -101,2 +101,44 @@ const crypto = require('crypto'); | ||
/** | ||
* Use this API for initial item setup and maintenance. | ||
* @see https://developer.walmart.com/api/us/mp/items#operation/itemBulkUploads | ||
* @param {String} feedType The feed Type. Enum: "item" "RETIRE_ITEM" "MP_ITEM" "MP_WFS_ITEM" "MP_ITEM_MATCH" "MP_MAINTENANCE" "SKU_TEMPLATE_MAP" "SHIPPING_OVERRIDES" "OMNI_WFS" "FITMENT_ACES" "FITMENT_PIES". | ||
* @param {Object} file The request body consists of a Feed file attached to the request based on the feedType selected. | ||
* @param {Object} [options] | ||
* @param {String} [options['WM_QOS.CORRELATION_ID']] A unique ID which identifies each API call and used to track and debug issues. Defaults to a random UUID. | ||
*/ | ||
bulkItemSetup: async function(feedType, file, options, callback) { | ||
try { | ||
// Options are optional | ||
if (!options) { | ||
options = {}; | ||
} else if (typeof options === 'function') { | ||
callback = options; | ||
options = {}; | ||
} | ||
const queryParameters = new URLSearchParams({ feedType }); | ||
const url = `${_options.url}/v3/feeds?${queryParameters.toString()}`; | ||
const response = await fetch(url, { | ||
body: JSON.stringify(file), | ||
headers: { | ||
Accept: 'application/json', | ||
'Content-Type': 'application/json', | ||
'WM_QOS.CORRELATION_ID': options['WM_QOS.CORRELATION_ID'] || crypto.randomUUID(), | ||
'WM_SEC.ACCESS_TOKEN': (await _this.authentication.getAccessToken()).access_token, | ||
'WM_SVC.NAME': _options['WM_SVC.NAME'] | ||
}, | ||
method: 'POST' | ||
}); | ||
if (!response.ok) { | ||
throw new Error(response.statusText, { cause: response }); | ||
} | ||
return finalize(null, await response.json(), callback); | ||
} catch(err) { | ||
return finalize(err, null, callback); | ||
} | ||
}, | ||
/** | ||
* Retrieves an item and displays the item details. | ||
@@ -103,0 +145,0 @@ * @see https://developer.walmart.com/api/us/mp/items#operation/getAnItem |
@@ -18,3 +18,3 @@ { | ||
}, | ||
"version": "0.0.2" | ||
"version": "0.0.3" | ||
} |
@@ -58,2 +58,75 @@ # walmart-marketplace | ||
## walmartMarketplace.items.bulkItemSetup(feedType, file, [options]) | ||
Use this API for initial item setup and maintenance. | ||
https://developer.walmart.com/api/us/mp/items#operation/itemBulkUploads | ||
**Promise Example** | ||
```javascript | ||
const mpItemMatch = { | ||
MPItemFeedHeader: { | ||
locale: 'en', | ||
sellingChannel: 'mpsetupbymatch', | ||
version: '4.2' | ||
}, | ||
MPItem: [{ | ||
Item: { | ||
condition: 'New', | ||
price: 123, | ||
productIdentifiers: { | ||
productId: '123456789012', | ||
productIdType: 'UPC' | ||
}, | ||
ShippingWeight: 1, | ||
sku: '123abc' | ||
} | ||
}] | ||
}; | ||
const response = await walmartMarketplace.items.bulkItemSetup('MP_ITEM_MATCH', mpItemMatch); | ||
console.log(response); | ||
``` | ||
**Callback Example** | ||
```javascript | ||
const mpItemMatch = { | ||
MPItemFeedHeader: { | ||
locale: 'en', | ||
sellingChannel: 'mpsetupbymatch', | ||
version: '4.2' | ||
}, | ||
MPItem: [{ | ||
Item: { | ||
condition: 'New', | ||
price: 123, | ||
productIdentifiers: { | ||
productId: '123456789012', | ||
productIdType: 'UPC' | ||
}, | ||
ShippingWeight: 1, | ||
sku: '123abc' | ||
} | ||
}] | ||
}; | ||
walmartMarketplace.items.bulkItemSetup('MP_ITEM_MATCH', mpItemMatch, function(err, response) { | ||
console.log(response); | ||
}); | ||
``` | ||
**Options** | ||
``` | ||
{ | ||
'WM_QOS.CORRELATION_ID': '00000000-0000-0000-0000-000000000000' // A unique ID which identifies each API call and used to track and debug issues. Defaults to a random UUID. | ||
} | ||
``` | ||
**Returns** | ||
``` | ||
{ | ||
"feedId": "F129C19240844B97A3C6AD8F1A2C4997@AU8BAQA" | ||
} | ||
``` | ||
## walmartMarketplace.items.getAnItem(id, [options]) | ||
@@ -68,3 +141,3 @@ | ||
const itemDetails = await walmartMarketplace.items.getAnItem('97964_KFTest'); | ||
console.log(response); | ||
console.log(itemDetails); | ||
``` | ||
@@ -71,0 +144,0 @@ |
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
28362
198
219
4