ebay-api
Version:
eBay API for Node and Browser
340 lines (339 loc) • 13.7 kB
JavaScript
import Restful from '../../index.js';
/**
* The Inventory API is used to create and manage inventory, and then to publish and manage this inventory on an eBay
* marketplace.
*/
export default class Inventory extends Restful {
get basePath() {
return '/sell/inventory/v1';
}
/**
* This call retrieves all defined details of the inventory location that is specified by the
* <b>merchantLocationKey</b> path parameter.
*
* @param merchantLocationKey A unique merchant-defined key (ID) for an inventory location.
*/
getInventoryLocation(merchantLocationKey) {
const key = encodeURIComponent(merchantLocationKey);
return this.get(`/location/${key}`);
}
/**
* <p>This call disables the inventory location that is specified in the <code>merchantLocationKey</code> path
* parameter.
*
* @param merchantLocationKey A unique merchant-defined key (ID) for an inventory location.
*/
disableInventoryLocation(merchantLocationKey) {
const key = encodeURIComponent(merchantLocationKey);
return this.post(`/location/${key}/disable`);
}
/**
* <p>This call enables a disabled inventory location that is specified in the <code>merchantLocationKey</code>
* path parameter.
*
* @param merchantLocationKey A unique merchant-defined key (ID) for an inventory location.
*/
enableInventoryLocation(merchantLocationKey) {
const key = encodeURIComponent(merchantLocationKey);
return this.post(`/location/${key}/enable`);
}
/**
* This call retrieves all defined details for every inventory location associated with the seller's account.
*
* @param limit The value passed in this query parameter sets the maximum number of records to return per page of
* data.
* @param offset The value passed in this query parameter sets the page number to retrieve.
*/
getInventoryLocations({ limit, offset, } = {}) {
return this.get(`/location`, {
params: {
limit,
offset,
},
});
}
/**
* <p>Use this call to create a new inventory location.
*
* @param merchantLocationKey A unique merchant-defined key (ID) for an inventory location.
* @param body Inventory Location details
*/
createInventoryLocation(merchantLocationKey, body) {
const key = encodeURIComponent(merchantLocationKey);
return this.post(`/location/${key}`, body);
}
/**
* <p>This call deletes the inventory location that is specified in the <code>merchantLocationKey</code> path
* parameter.
*
* @param merchantLocationKey A unique merchant-defined key (ID) for an inventory location.
*/
deleteInventoryLocation(merchantLocationKey) {
const key = encodeURIComponent(merchantLocationKey);
return this.delete(`/location/${key}`);
}
/**
* <p>Use this call to update non-physical location details for an existing inventory location.
*
* @param merchantLocationKey A unique merchant-defined key (ID) for an inventory location.
* @param body The inventory location details to be updated (other than the address and geo co-ordinates).
*/
updateInventoryLocation(merchantLocationKey, body) {
const key = encodeURIComponent(merchantLocationKey);
return this.post(`/location/${key}/update_location_details`, body);
}
/**
* This call retrieves the inventory item record for a given SKU.
*
* @param sku his is the seller-defined SKU value of the product whose inventory item record you wish to
* retrieve.<br/><br/><strong>Max length</strong>: 50.
*/
getInventoryItem(sku) {
sku = encodeURIComponent(sku);
return this.get(`/inventory_item/${sku}`);
}
/**
* This call creates a new inventory item record or replaces an existing inventory item record.
*
* @param sku The seller-defined SKU value for the inventory item is required whether the seller is creating a new
* inventory item, or updating an existing inventory item.
* @param body Details of the inventory item record.
*/
createOrReplaceInventoryItem(sku, body) {
sku = encodeURIComponent(sku);
return this.put(`/inventory_item/${sku}`, body);
}
/**
* This call is used to delete an inventory item record associated with a specified SKU.
*
* @param sku The seller-defined SKU value for the inventory item is required whether the seller is creating a new
* inventory item, or updating an existing inventory item.
*/
deleteInventoryItem(sku) {
sku = encodeURIComponent(sku);
return this.delete(`/inventory_item/${sku}`);
}
/**
* This call retrieves all inventory item records defined for the seller's account.
*
* @param limit The value passed in this query parameter sets the maximum number of records to return per page of
* data.
* @param offset The value passed in this query parameter sets the page number to retrieve.
*/
getInventoryItems({ limit, offset, } = {}) {
return this.get(`/inventory_item`, {
params: {
limit,
offset,
},
});
}
/**
* This call is used by the seller to update the total ship-to-home quantity of one inventory item,
* and/or to update the price and/or quantity of one or more offers associated with one inventory item.
*
* @param body BulkPriceQuantity
*/
bulkUpdatePriceQuantity(body) {
return this.post(`/bulk_update_price_quantity`, body);
}
/**
* This call can be used to create and/or update up to 25 new inventory item records.
*
* @param body BulkInventoryItem
*/
bulkCreateOrReplaceInventoryItem(body) {
return this.post(`/bulk_create_or_replace_inventory_item`, body);
}
/**
* This call retrieves up to 25 inventory item records. The SKU value of each inventory item record to retrieve is
* specified in the request payload.
*
* @param body BulkInventoryItem
*/
bulkGetInventoryItem(body) {
return this.post(`/bulk_get_inventory_item`, body);
}
/**
* This call is used by the seller to retrieve the list of products that are compatible with the inventory item.
*
* @param sku A SKU (stock keeping unit) is an unique identifier defined by a seller for a product
*/
getProductCompatibility(sku) {
sku = encodeURIComponent(sku);
return this.get(`/inventory_item/${sku}/product_compatibility`);
}
/**
* This call is used by the seller to create or replace a list of products that are compatible with the inventory
* item.
*
* @param sku A SKU (stock keeping unit) is an unique identifier defined by a seller for a product
* @param body Details of the compatibility
*/
createOrReplaceProductCompatibility(sku, body) {
sku = encodeURIComponent(sku);
return this.put(`/inventory_item/${sku}/product_compatibility`, body);
}
/**
* This call is used by the seller to delete the list of products that are compatible with the inventory item that
* is associated with the compatible product list.
*
* @param sku A SKU (stock keeping unit) is an unique identifier defined by a seller for a product
*/
deleteProductCompatibility(sku) {
sku = encodeURIComponent(sku);
return this.delete(`/inventory_item/${sku}/product_compatibility`);
}
/**
* This call retrieves all existing offers for the specified SKU value.
*
* @param sku The seller-defined SKU value is passed in as a query parameter.
* @param marketplace_id The unique identifier of the eBay marketplace.
* @param format This enumeration value sets the listing format for the offer.
* @param limit The value passed in this query parameter sets the maximum number of records to return per page of
* data.
* @param offset The value passed in this query parameter sets the page number to retrieve.
*/
getOffers({ sku, marketplaceId, format, limit, offset, } = {}) {
return this.get(`/offer`, {
params: {
sku,
marketplace_id: marketplaceId,
format,
limit,
offset,
},
});
}
/**
* This call retrieves a specific published or unpublished offer.
*
* @param offerId The unique identifier of the offer that is to be retrieved.
*/
getOffer(offerId) {
offerId = encodeURIComponent(offerId);
return this.get(`/offer/${offerId}`);
}
/**
* This call creates an offer for a specific inventory item on a specific eBay marketplace.
*
* @param body Details of the offer for the channel
*/
createOffer(body) {
return this.post(`/offer`, body);
}
/**
* This call updates an existing offer.
*
* @param offerId The unique identifier of the offer that is being updated.
* @param body Details of the offer for the channel
*/
updateOffer(offerId, body) {
offerId = encodeURIComponent(offerId);
return this.put(`/offer/${offerId}`, body);
}
/**
* If used against an unpublished offer, this call will permanently delete that offer.
*
* @param offerId The unique identifier of the offer to delete.
*/
deleteOffer(offerId) {
return this.delete(`/offer/${offerId}`);
}
/**
* This call is used to convert an unpublished offer into a published offer, or live eBay listing.
*
* @param offerId The unique identifier of the offer that is to be published.
*/
publishOffer(offerId) {
const id = encodeURIComponent(offerId);
return this.post(`/offer/${id}/publish/`);
}
/**
* This call is used to convert all unpublished offers associated with an inventory item group into an active,
* multiple-variation listing.
*
* @param body PublishByInventoryItemGroupRequest
*/
publishOfferByInventoryItemGroup(body) {
return this.post(`/offer/publish_by_inventory_item_group/`, body);
}
/**
* This call is used to end a multiple-variation eBay listing that is associated with the specified inventory item
* group.
*
* @param body WithdrawByInventoryItemGroupRequest
*/
withdrawOfferByInventoryItemGroup(body) {
return this.post(`/offer/withdraw_by_inventory_item_group`, body);
}
/**
* This call is used to retrieve the expected listing fees for up to 250 unpublished offers.
*
* @param body OfferKeysWithId
*/
getListingFees(body) {
return this.post(`/offer/get_listing_fees`, body);
}
/**
* This call creates multiple offers (up to 25) for specific inventory items on a specific eBay marketplace.
*
* @param body BulkEbayOfferDetailsWithKeys
*/
bulkCreateOffer(body) {
return this.post(`/bulk_create_offer`, body);
}
/**
* This call is used to convert unpublished offers (up to 25) into published offers, or live eBay listings.
*
* @param body BulkOffer
*/
bulkPublishOffer(body) {
return this.post(`/bulk_publish_offer`, body);
}
/**
* This call is used to end a single-variation listing that is associated with the specified offer.
*
* @param offerId he unique identifier of the offer that is to be withdrawn.
*/
withdrawOffer(offerId) {
const id = encodeURIComponent(offerId);
return this.post(`/offer/${id}/withdraw`);
}
/**
* This call retrieves the inventory item group for a given <strong>inventoryItemGroupKey</strong> value.
*
* @param inventoryItemGroupKey The unique identifier of an inventory item group.
*/
getInventoryItemGroup(inventoryItemGroupKey) {
inventoryItemGroupKey = encodeURIComponent(inventoryItemGroupKey);
return this.get(`/inventory_item_group/${inventoryItemGroupKey}`);
}
/**
* This call creates a new inventory item group or updates an existing inventory item group.
*
* @param inventoryItemGroupKey Unique identifier of the inventory item group.
* @param body Details of the inventory Item Group
*/
createOrReplaceInventoryItemGroup(inventoryItemGroupKey, body) {
inventoryItemGroupKey = encodeURIComponent(inventoryItemGroupKey);
return this.put(`/inventory_item_group/${inventoryItemGroupKey}`, body);
}
/**
* This call deletes the inventory item group for a given <strong>inventoryItemGroupKey</strong> value.
*
* @param inventoryItemGroupKey Unique identifier of the inventory item group.
*/
deleteInventoryItemGroup(inventoryItemGroupKey) {
return this.delete(`/inventory_item_group/${inventoryItemGroupKey}`);
}
/**
* This call is used to convert existing eBay Listings to the corresponding Inventory API objects.
*
* @param body BulkMigrateListing
*/
bulkMigrateListing(body) {
return this.post(`/bulk_migrate_listing`, body);
}
}
Inventory.id = 'Inventory';