Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@mediocre/walmart-marketplace

Package Overview
Dependencies
Maintainers
3
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mediocre/walmart-marketplace - npm Package Compare versions

Comparing version 0.0.5 to 1.0.0

217

index.js

@@ -145,2 +145,55 @@ const crypto = require('crypto');

}
},
/**
* Updates the inventory for a given item.
* @see https://developer.walmart.com/api/us/mp/inventory#operation/updateInventoryForAnItem
* @param {Object} inventory
* @param {String} inventory.sku A seller-provided Product ID. Response will have decoded value.
* @param {Object} inventory.quantity
* @param {Number} inventory.quantity.amount Inventory Count.
* @param {String} inventory.quantity.unit The unit of measurement. Example: 'EACH'.
* @param {Object} [options]
* @param {String} [options.shipNode] The shipNode for which the inventory is requested.
* @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.
*/
updateInventory: async function(inventory, options, callback) {
try {
// Options are optional
if (!options) {
options = {};
} else if (typeof options === 'function') {
callback = options;
options = {};
}
const queryParameters = new URLSearchParams({ sku: inventory.sku });
['shipNode'].forEach(key => {
if (Object.hasOwn(options, key)) {
queryParameters.set(key, options[key]);
}
});
const url = `${_options.url}/v3/inventory?${queryParameters.toString()}`;
const response = await fetch(url, {
body: JSON.stringify(inventory),
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: 'PUT'
});
if (!response.ok) {
throw new Error(response.statusText, { cause: response });
}
return finalize(null, await response.json(), callback);
} catch(err) {
return finalize(err, null, callback);
}
}

@@ -279,2 +332,166 @@ };

this.orders = {
/**
* Retrieves the details of all the orders for specified search criteria.
* @see https://developer.walmart.com/api/us/mp/orders#operation/getAllOrders
* @param {Object} [options]
* @param {Boolean} [options.autoPagination] If true, automatically fetches all pages of results. Defaults to false.
* @param {String} [options.createdEndDate] Fetches all purchase orders that were created before this date. Default is current date. Use either UTC or ISO 8601 formats. Date example: '2020-03-16'(yyyy-MM-dd). Date with Timestamp example: '2020-03-16T10:30:15Z'(yyyy-MM-dd'T'HH:mm:ssZ).
* @param {String} [options.createdStartDate] Fetches all purchase orders that were created after this date. Default is current date - 7 days. Use either UTC or ISO 8601 formats. Date example: '2020-03-16'(yyyy-MM-dd). Date with Timestamp example: '2020-03-16T10:30:15Z'(yyyy-MM-dd'T'HH:mm:ssZ).
* @param {String} [options.customerOrderId] The customer order ID.
* @param {String} [options.fromExpectedShipDate] Fetches all purchase orders that have order lines with an expected ship date after this date. Use either UTC or ISO 8601 formats. Date example: '2020-03-16'(yyyy-MM-dd). Date with Timestamp example: '2020-03-16T10:30:15Z'(yyyy-MM-dd'T'HH:mm:ssZ).
* @param {String} [options.lastModifiedEndDate] Fetches all purchase orders that were modified before this date. Use either UTC or ISO 8601 formats. Date example: '2020-03-16'(yyyy-MM-dd). Date with Timestamp example: '2020-03-16T10:30:15Z'(yyyy-MM-dd'T'HH:mm:ssZ).
* @param {String} [options.lastModifiedStartDate] Fetches all purchase orders that were modified after this date. Use either UTC or ISO 8601 formats. Date example: '2020-03-16'(yyyy-MM-dd). Date with Timestamp example: '2020-03-16T10:30:15Z'(yyyy-MM-dd'T'HH:mm:ssZ).
* @param {String} [options.limit] The number of orders to be returned. Cannot be larger than 200. Default: "100".
* @param {String} [options.orderType] Specifies if the order is a regular order or replacement order. Possible values are REGULAR or REPLACEMENT. Provided in response only if query parameter replacementInfo=true.
* @param {String} [options.productInfo] Provides the image URL and product weight in response, if available. Allowed values are true or false. Default: "false".
* @param {String} [options.purchaseOrderId] The purchase order ID. One customer may have multiple purchase orders.
* @param {String} [options.replacementInfo] Provides additional attributes - originalCustomerOrderID, orderType - related to Replacement order, in response, if available. Allowed values are true or false. Default: "false".
* @param {String} [options.shipNodeType] Specifies the type of shipNode. Allowed values are SellerFulfilled(Default), WFSFulfilled and 3PLFulfilled. Default: "SellerFulfilled".
* @param {String} [options.shippingProgramType] Specifies the type of program. Allowed value is TWO_DAY, ONE_DAY.
* @param {String} [options.sku] A seller-provided Product ID.
* @param {String} [options.status] Status of purchase order line. Valid statuses are: Created, Acknowledged, Shipped, Delivered and Cancelled.
* @param {String} [options.toExpectedShipDate] Fetches all purchase orders that have order lines with an expected ship date before this date. Use either UTC or ISO 8601 formats. Date example: '2020-03-16'(yyyy-MM-dd). Date with Timestamp example: '2020-03-16T10:30:15Z'(yyyy-MM-dd'T'HH:mm:ssZ).
* @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.
*/
getAllOrders: async function(options, callback) {
try {
// Options are optional
if (!options) {
options = {};
} else if (typeof options === 'function') {
callback = options;
options = {};
}
const orders = [];
const fetchOrders = async cursor => {
const queryParameters = new URLSearchParams();
['createdEndDate', 'createdStartDate', 'customerOrderId', 'fromExpectedShipDate', 'lastModifiedEndDate', 'lastModifiedStartDate', 'limit', 'orderType', 'productInfo', 'purchaseOrderId', 'replacementInfo', 'shipNodeType', 'shippingProgramType', 'sku', 'status', 'toExpectedShipDate'].forEach(key => {
if (Object.hasOwn(options, key)) {
queryParameters.set(key, options[key]);
}
});
if (cursor) {
queryParameters.set('nextCursor', cursor);
}
const url = `${_options.url}/v3/orders?${queryParameters.toString()}`;
const response = await fetch(url, {
headers: {
Accept: 'application/json',
'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 });
}
const data = await response.json();
if (Array.isArray(data?.list?.elements?.order)) {
orders.push(...data.list.elements.order);
// Check for more pages and if pagination is requested
if (options.autoPagination && data?.list?.meta?.nextCursor) {
await fetchOrders(data.list.meta.nextCursor);
}
}
};
// Initial call to fetch orders
await fetchOrders(null);
return finalize(null, orders, callback);
} catch(err) {
return finalize(err, null, callback);
}
},
/**
* Retrieves all the orders with line items that are in the "created" status, that is, these orders have been released from the Walmart Order Management System to the seller for processing. The released orders are the orders that are ready for a seller to fulfill.
* @see https://developer.walmart.com/api/us/mp/orders#operation/getAllReleasedOrders
* @param {Object} [options]
* @param {Boolean} [options.autoPagination] If true, automatically fetches all pages of results. Defaults to false.
* @param {String} [options.createdEndDate] Fetches all purchase orders that were created before this date. Default is current date. Use either UTC or ISO 8601 formats. Date example: '2020-03-16'(yyyy-MM-dd). Date with Timestamp example: '2020-03-16T10:30:15Z'(yyyy-MM-dd'T'HH:mm:ssZ).
* @param {String} [options.createdStartDate] Fetches all purchase orders that were created after this date. Default is current date - 7 days. Use either UTC or ISO 8601 formats. Date example: '2020-03-16'(yyyy-MM-dd). Date with Timestamp example: '2020-03-16T10:30:15Z'(yyyy-MM-dd'T'HH:mm:ssZ).
* @param {String} [options.customerOrderId] The customer order ID.
* @param {String} [options.fromExpectedShipDate] Fetches all purchase orders that have order lines with an expected ship date after this date. Use either UTC or ISO 8601 formats. Date example: '2020-03-16'(yyyy-MM-dd). Date with Timestamp example: '2020-03-16T10:30:15Z'(yyyy-MM-dd'T'HH:mm:ssZ).
* @param {String} [options.limit] The number of orders to be returned. Cannot be larger than 200. Default: "100".
* @param {String} [options.orderType] Specifies if the order is a regular order or replacement order. Possible values are REGULAR or REPLACEMENT. Provided in response only if query parameter replacementInfo=true.
* @param {String} [options.productInfo] Provides the image URL and product weight in response, if available. Allowed values are true or false. Default: "false".
* @param {String} [options.shipNodeType] Specifies the type of shipNode. Allowed values are SellerFulfilled(Default), WFSFulfilled and 3PLFulfilled. Default: "SellerFulfilled".
* @param {String} [options.shippingProgramType] Specifies the type of program. Allowed value is TWO_DAY, ONE_DAY.
* @param {String} [options.sku] A seller-provided Product ID.
* @param {String} [options.toExpectedShipDate] Fetches all purchase orders that have order lines with an expected ship date before this date. Use either UTC or ISO 8601 formats. Date example: '2020-03-16'(yyyy-MM-dd). Date with Timestamp example: '2020-03-16T10:30:15Z'(yyyy-MM-dd'T'HH:mm:ssZ).
* @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.
*/
getAllReleasedOrders: async function(options, callback) {
try {
// Options are optional
if (!options) {
options = {};
} else if (typeof options === 'function') {
callback = options;
options = {};
}
const orders = [];
const fetchOrders = async cursor => {
const queryParameters = new URLSearchParams();
['createdEndDate', 'createdStartDate', 'customerOrderId', 'fromExpectedShipDate', 'limit', 'orderType', 'productInfo', 'purchaseOrderId', 'replacementInfo', 'shipNodeType', 'shippingProgramType', 'sku', 'toExpectedShipDate'].forEach(key => {
if (Object.hasOwn(options, key)) {
queryParameters.set(key, options[key]);
}
});
if (cursor) {
queryParameters.set('nextCursor', cursor);
}
const url = `${_options.url}/v3/orders/released?${queryParameters.toString()}`;
const response = await fetch(url, {
headers: {
Accept: 'application/json',
'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 });
}
const data = await response.json();
if (Array.isArray(data?.list?.elements?.order)) {
orders.push(...data.list.elements.order);
// Check for more pages and if pagination is requested
if (options.autoPagination && data?.list?.meta?.nextCursor) {
await fetchOrders(data.list.meta.nextCursor);
}
}
};
// Initial call to fetch orders
await fetchOrders(null);
return finalize(null, orders, callback);
} catch(err) {
return finalize(err, null, callback);
}
}
};
this.prices = {

@@ -281,0 +498,0 @@ /**

2

package.json

@@ -18,3 +18,3 @@ {

},
"version": "0.0.5"
"version": "1.0.0"
}

@@ -259,2 +259,263 @@ # walmart-marketplace

## walmartMarketplace.orders.getAllOrders([options])
Retrieves the details of all the orders for specified search criteria.
https://developer.walmart.com/api/us/mp/orders#operation/getAllOrders
**Promise Example**
```javascript
const options = {
sku: '97964_KFTest'
};
const orders = await walmartMarketplace.orders.getAllOrders(options);
console.log(orders);
```
**Callback Example**
```javascript
const options = {
sku: '97964_KFTest'
};
walmartMarketplace.orders.getAllOrders(options, function(err, orders) {
console.log(orders);
});
```
**Options**
```
{
autoPagination: false, // If true, automatically fetches all pages of results. Defaults to false.
createdEndDate: '2020-03-16T10:30:15Z', // Fetches all purchase orders that were created before this date. Default is current date. Use either UTC or ISO 8601 formats. Date example: '2020-03-16'(yyyy-MM-dd). Date with Timestamp example: '2020-03-16T10:30:15Z'(yyyy-MM-dd'T'HH:mm:ssZ).
createdStartDate: '2020-03-16T10:30:15Z', // Fetches all purchase orders that were created after this date. Default is current date - 7 days. Use either UTC or ISO 8601 formats. Date example: '2020-03-16'(yyyy-MM-dd). Date with Timestamp example: '2020-03-16T10:30:15Z'(yyyy-MM-dd'T'HH:mm:ssZ).
customerOrderId: '5281956426648', // The customer order ID.
fromExpectedShipDate: '2020-03-16T10:30:15Z', // Fetches all purchase orders that have order lines with an expected ship date after this date. Use either UTC or ISO 8601 formats. Date example: '2020-03-16'(yyyy-MM-dd). Date with Timestamp example: '2020-03-16T10:30:15Z'(yyyy-MM-dd'T'HH:mm:ssZ).
lastModifiedEndDate: '2020-03-16T10:30:15Z', // Fetches all purchase orders that were modified before this date. Use either UTC or ISO 8601 formats. Date example: '2020-03-16'(yyyy-MM-dd). Date with Timestamp example: '2020-03-16T10:30:15Z'(yyyy-MM-dd'T'HH:mm:ssZ).
lastModifiedStartDate: '2020-03-16T10:30:15Z', // Fetches all purchase orders that were modified after this date. Use either UTC or ISO 8601 formats. Date example: '2020-03-16'(yyyy-MM-dd). Date with Timestamp example: '2020-03-16T10:30:15Z'(yyyy-MM-dd'T'HH:mm:ssZ).
limit: '100', // The number of orders to be returned. Cannot be larger than 200. Default: "100".
orderType: 'REGULAR', // Specifies if the order is a regular order or replacement order. Possible values are REGULAR or REPLACEMENT. Provided in response only if query parameter replacementInfo=true.
productInfo: 'false', // Provides the image URL and product weight in response, if available. Allowed values are true or false. Default: "false".
purchaseOrderId: '1796277083022', // The purchase order ID. One customer may have multiple purchase orders.
replacementInfo: 'false', // Provides additional attributes - originalCustomerOrderID, orderType - related to Replacement order, in response, if available. Allowed values are true or false. Default: "false".
shipNodeType: 'SellerFulfilled', // Specifies the type of shipNode. Allowed values are SellerFulfilled(Default), WFSFulfilled and 3PLFulfilled. Default: "SellerFulfilled".
shippingProgramType: 'TWO_DAY', // Specifies the type of program. Allowed value is TWO_DAY, ONE_DAY.
sku: '97964_KFTest', // A seller-provided Product ID.
status: 'Created', // Status of purchase order line. Valid statuses are: Created, Acknowledged, Shipped, Delivered and Cancelled.
toExpectedShipDate: '2020-03-16T10:30:15Z', // Fetches all purchase orders that have order lines with an expected ship date before this date. Use either UTC or ISO 8601 formats. Date example: '2020-03-16'(yyyy-MM-dd). Date with Timestamp example: '2020-03-16T10:30:15Z'(yyyy-MM-dd'T'HH:mm:ssZ).
'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**
```
[
{
"purchaseOrderId": "1796277083022",
"customerOrderId": "5281956426648",
"customerEmailId": "3A31739D8B0A45A1B23F7F8C81C8747F@relay.walmart.com",
"orderType": "REPLACEMENT",
"originalCustomerOrderID": "1234567891234",
"orderDate": 1568466571000,
"shippingInfo": {
"phone": "3155598681",
"estimatedDeliveryDate": 1569438000000,
"estimatedShipDate": 1568700000000,
"methodCode": "Value",
"postalAddress": {
"name": "Kathryn Cole",
"address1": "3258BWarners rd",
"address2": "Garage",
"city": "Warners",
"state": "NY",
"postalCode": "13164",
"country": "USA",
"addressType": "RESIDENTIAL"
}
},
"orderLines": {
"orderLine": [
{
"lineNumber": "4",
"item": {
"productName": "Beba Bean Pee-pee Teepee Airplane - Blue - Laundry Bag",
"sku": "test1"
},
"charges": {
"charge": [
{
"chargeType": "PRODUCT",
"chargeName": "ItemPrice",
"chargeAmount": {
"currency": "USD",
"amount": 10
},
"tax": {
"taxName": "Tax1",
"taxAmount": {
"currency": "USD",
"amount": 0.8
}
}
}
]
},
"orderLineQuantity": {
"unitOfMeasurement": "EACH",
"amount": "1"
},
"statusDate": 1568466647000,
"orderLineStatuses": {
"orderLineStatus": [
{
"status": "Created",
"statusQuantity": {
"unitOfMeasurement": "EACH",
"amount": "1"
}
}
]
},
"fulfillment": {
"fulfillmentOption": "S2H",
"shipMethod": "VALUE",
"pickUpDateTime": 1568919600000
}
}
]
}
}
]
```
## walmartMarketplace.orders.getAllReleaseOrders([options])
Retrieves all the orders with line items that are in the "created" status, that is, these orders have been released from the Walmart Order Management System to the seller for processing. The released orders are the orders that are ready for a seller to fulfill.
https://developer.walmart.com/api/us/mp/orders#operation/getAllReleasedOrders
**Promise Example**
```javascript
const options = {
sku: '97964_KFTest'
};
const orders = await walmartMarketplace.orders.getAllReleaseOrders(options);
console.log(orders);
```
**Callback Example**
```javascript
const options = {
sku: '97964_KFTest'
};
walmartMarketplace.orders.getAllReleaseOrders(options, function(err, orders) {
console.log(orders);
});
```
**Options**
```
{
autoPagination: false, // If true, automatically fetches all pages of results. Defaults to false.
createdEndDate: '2020-03-16T10:30:15Z', // Fetches all purchase orders that were created before this date. Default is current date. Use either UTC or ISO 8601 formats. Date example: '2020-03-16'(yyyy-MM-dd). Date with Timestamp example: '2020-03-16T10:30:15Z'(yyyy-MM-dd'T'HH:mm:ssZ).
createdStartDate: '2020-03-16T10:30:15Z', // Fetches all purchase orders that were created after this date. Default is current date - 7 days. Use either UTC or ISO 8601 formats. Date example: '2020-03-16'(yyyy-MM-dd). Date with Timestamp example: '2020-03-16T10:30:15Z'(yyyy-MM-dd'T'HH:mm:ssZ).
customerOrderId: '5281956426648', // The customer order ID.
fromExpectedShipDate: '2020-03-16T10:30:15Z', // Fetches all purchase orders that have order lines with an expected ship date after this date. Use either UTC or ISO 8601 formats. Date example: '2020-03-16'(yyyy-MM-dd). Date with Timestamp example: '2020-03-16T10:30:15Z'(yyyy-MM-dd'T'HH:mm:ssZ).
limit: '100', // The number of orders to be returned. Cannot be larger than 200. Default: "100".
orderType: 'REGULAR', // Specifies if the order is a regular order or replacement order. Possible values are REGULAR or REPLACEMENT. Provided in response only if query parameter replacementInfo=true.
productInfo: 'false', // Provides the image URL and product weight in response, if available. Allowed values are true or false. Default: "false".
purchaseOrderId: '1796277083022', // The purchase order ID. One customer may have multiple purchase orders.
replacementInfo: 'false', // Provides additional attributes - originalCustomerOrderID, orderType - related to Replacement order, in response, if available. Allowed values are true or false. Default: "false".
shipNodeType: 'SellerFulfilled', // Specifies the type of shipNode. Allowed values are SellerFulfilled(Default), WFSFulfilled and 3PLFulfilled. Default: "SellerFulfilled".
shippingProgramType: 'TWO_DAY', // Specifies the type of program. Allowed value is TWO_DAY, ONE_DAY.
sku: '97964_KFTest', // A seller-provided Product ID.
toExpectedShipDate: '2020-03-16T10:30:15Z', // Fetches all purchase orders that have order lines with an expected ship date before this date. Use either UTC or ISO 8601 formats. Date example: '2020-03-16'(yyyy-MM-dd). Date with Timestamp example: '2020-03-16T10:30:15Z'(yyyy-MM-dd'T'HH:mm:ssZ).
'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**
```
[
{
"purchaseOrderId": "1796277083022",
"customerOrderId": "5281956426648",
"customerEmailId": "3A31739D8B0A45A1B23F7F8C81C8747F@relay.walmart.com",
"orderType": "REPLACEMENT",
"originalCustomerOrderID": "1234567891234",
"orderDate": 1568466571000,
"shippingInfo": {
"phone": "3155598681",
"estimatedDeliveryDate": 1569438000000,
"estimatedShipDate": 1568700000000,
"methodCode": "Value",
"postalAddress": {
"name": "Kathryn Cole",
"address1": "3258BWarners rd",
"address2": "Garage",
"city": "Warners",
"state": "NY",
"postalCode": "13164",
"country": "USA",
"addressType": "RESIDENTIAL"
}
},
"orderLines": {
"orderLine": [
{
"lineNumber": "4",
"item": {
"productName": "Beba Bean Pee-pee Teepee Airplane - Blue - Laundry Bag",
"sku": "test1"
},
"charges": {
"charge": [
{
"chargeType": "PRODUCT",
"chargeName": "ItemPrice",
"chargeAmount": {
"currency": "USD",
"amount": 10
},
"tax": {
"taxName": "Tax1",
"taxAmount": {
"currency": "USD",
"amount": 0.8
}
}
}
]
},
"orderLineQuantity": {
"unitOfMeasurement": "EACH",
"amount": "1"
},
"statusDate": 1568466647000,
"orderLineStatuses": {
"orderLineStatus": [
{
"status": "Created",
"statusQuantity": {
"unitOfMeasurement": "EACH",
"amount": "1"
}
}
]
},
"fulfillment": {
"fulfillmentOption": "S2H",
"shipMethod": "VALUE",
"pickUpDateTime": 1568919600000
}
}
]
}
}
]
```
## walmartMarketplace.prices.updatePrice(price, [options])

@@ -261,0 +522,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc