@mediocre/walmart-marketplace
Advanced tools
Comparing version 0.0.1 to 0.0.2
47
index.js
@@ -101,2 +101,49 @@ const crypto = require('crypto'); | ||
/** | ||
* Retrieves an item and displays the item details. | ||
* @see https://developer.walmart.com/api/us/mp/items#operation/getAnItem | ||
* @param {String} id Represents the seller-specified unique ID for each item. Takes SKU code by default. If you require more specific item codes, such as GTIN, UPC, ISBN, EAN, or ITEM_ID, you need to use the productIdType query parameter and specify the desired code e.g. productIdType=GTIN. | ||
* @param {Object} [options] | ||
* @param {String} [options.condition] The value of product condition, (e.g. New). | ||
* @param {String} [options.productIdType] Item code type specifier allows to filter by specific code type, (e.g. GTIN). | ||
* @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. | ||
*/ | ||
getAnItem: async function(id, options, callback) { | ||
try { | ||
// Options are optional | ||
if (!options) { | ||
options = {}; | ||
} else if (typeof options === 'function') { | ||
callback = options; | ||
options = {}; | ||
} | ||
const queryParameters = new URLSearchParams(); | ||
['condition', 'productIdType'].forEach(key => { | ||
if (Object.hasOwn(options, key)) { | ||
queryParameters.set(key, options[key]); | ||
} | ||
}); | ||
const url = `${_options.url}/v3/items/${id}?${queryParameters.toString()}`; | ||
const response = await fetch(url, { | ||
headers: { | ||
Accept: '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'] | ||
} | ||
}); | ||
if (!response.ok) { | ||
throw new Error(response.statusText, { cause: response }); | ||
} | ||
return finalize(null, await response.json(), callback); | ||
} catch(err) { | ||
return finalize(err, null, callback); | ||
} | ||
}, | ||
/** | ||
* Completely deactivates and un-publishes an item from the site. | ||
@@ -103,0 +150,0 @@ * @see https://developer.walmart.com/api/us/mp/items#operation/retireAnItem |
@@ -18,3 +18,3 @@ { | ||
}, | ||
"version": "0.0.1" | ||
"version": "0.0.2" | ||
} |
@@ -58,2 +58,56 @@ # walmart-marketplace | ||
## walmartMarketplace.items.getAnItem(id, [options]) | ||
Retrieves an item and displays the item details. | ||
https://developer.walmart.com/api/us/mp/items#operation/getAnItem | ||
**Promise Example** | ||
```javascript | ||
const itemDetails = await walmartMarketplace.items.getAnItem('97964_KFTest'); | ||
console.log(response); | ||
``` | ||
**Callback Example** | ||
```javascript | ||
walmartMarketplace.items.getAnItem('97964_KFTest', function(err, itemDetails) { | ||
console.log(itemDetails); | ||
}); | ||
``` | ||
**Options** | ||
``` | ||
{ | ||
condition: 'New', // The value of product condition, (e.g. Restored). Enum: "New" "New without box" "New without tags" "Restored Premium" "Restored" "Remanufactured" "Open Box" "Pre-Owned: Like New" "Pre-Owned: Good" "Pre-Owned: Fair" "New with defects" | ||
productIdType: 'SKU', // Item code type specifier allows to filter by specific code type, (e.g. GTIN). Enum: "GTIN" "UPC" "ISBN" "EAN" "SKU" "ITEM_ID" | ||
'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** | ||
``` | ||
{ | ||
"ItemResponse": [ | ||
{ | ||
"mart": "WALMART_US", | ||
"sku": "30348_KFTest", | ||
"condition": "New", | ||
"wpid": "0RCPILAXM0C1", | ||
"upc": "", | ||
"gtin": "06932096330348", | ||
"productName": "Kidsform Adjustable Infant Baby Carrier Sling Wrap Rider Carrier Backpack Front/Back Pack Khaki, Blue, Pink 4 Carrying Position Modes With Storage Bag", | ||
"shelf": "[\"Home Page\",\"Baby\",\"Baby Activities & Gear\",\"Baby Carriers\"]", | ||
"productType": "Baby Carriers", | ||
"price": { | ||
"currency": "USD", | ||
"amount": 3 | ||
}, | ||
"publishedStatus": "PUBLISHED", | ||
"lifecycleStatus": "ACTIVE" | ||
} | ||
], | ||
"totalItems": 1 | ||
} | ||
``` | ||
## walmartMarketplace.items.retireAnItem(sku, [options]) | ||
@@ -60,0 +114,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
24542
160
146
3