jet-sdk
Version:
Jet.com Marketplace Web Services client with support for all api calls, using ES6 Promises.
79 lines (71 loc) • 1.79 kB
JavaScript
/**
* Products API requests and definitions for Jet web services.
* For information on using, please see examples folder.
*
* @author Robert Saunders
*/
var jet = require('./jet');
/**
* Construct a Products API request for using with jet.Client.invoke()
*
* @param {String} action Action parameter of request
* @param {Object} params Schemas for all supported parameters
*/
function ProductsRequest(action, params) {
var opts = {
name: 'Products',
group: 'Products',
path: 'merchant-skus/',
action: action ? action + '/': '',
params: params
};
return new jet.Request(opts);
}
/**
* A collection of currently supported request constructors. Once created and
* configured, the returned requests can be passed to an jet client `invoke` call
* @type {Object}
*/
var calls = exports.requests = {
/**
* Returns a product and attributes
*/
GetProductBySKU: function() {
return new ProductsRequest('', {
SKU: { name: 'SKU', required: true}
});
},
/**
* Returns a product SKU list
*/
GetProductSKU: function() {
return new ProductsRequest('', {
offset: { name: 'offset', required: false},
limit: { name: 'limit', required: false}
});
},
/**
* Returns a product price
*/
GetProductPrice: function() {
return new ProductsRequest('price', {
SKU: { name: 'SKU', required: true}
});
},
/**
* Returns a product inventory
*/
GetProductInventory: function() {
return new ProductsRequest('inventory', {
SKU: { name: 'SKU', required: true}
});
},
/**
* Returns a product inventory
*/
GetProductShippingException: function() {
return new ProductsRequest('shippingexception', {
SKU: { name: 'SKU', required: true}
});
}
};