ReviseInventoryStatus an efficient light-weight call that we recommend sellers use when they want to revise price and/or quantity of their fixed-price listing. The call allows you to revise these parameters for 4 items in a single request.
/**
* Sample code for ReviseInventoryStatus API using eBay Java SDK.
*
* Steps for creating a successful ReviseInventoryStatus call.
*
* 1. Create API Context and set the right credentials.
* 2. Create one InventoryStatusType object for each SKU/Item to be updated.
* 3. Do the necessary changes to the InventoryStatusType object. For setting price, an AmountType object is needed.
* 4. Add all the InventoryStatusType objects to an InventoryStatusType array.
* 5. Set this array to the ReviseInventoryStatusCall object with setInventoryStatus().
* 6. Call the ReviseInventoryStatusCall#reviseInventoryStatus() method.
*
* The following code sample updates inventory (quantity, price or both) for four items belonging to a user.
*/
public class ReviseInventoryStatusSample {
public static void reviseInventoryStatus() {
ApiContext apiContext = new ApiContext(); // Create a new APIContext Object
ApiCredential cred = apiContext.getApiCredential();
// set the server url and credentials for Sandbox
apiContext.setApiServerUrl("https://api.sandbox.ebay.com/wsapi");
cred.seteBayToken("YOUR TOKEN");
apiContext.setApiCredential(cred);
// Enable logging of SOAP requests and responses.
ApiLogging apiLogging = new ApiLogging();
apiContext.setApiLogging(apiLogging);
// Set site to US
apiContext.setSite(SiteCodeType.US);
// Create a new ReviseInventoryStatusCall and initialize it with the APIContext
ReviseInventoryStatusCall risCall = new ReviseInventoryStatusCall(apiContext);
// Revise quantity and price
InventoryStatusType invStatus1 = new InventoryStatusType();
invStatus1.setSKU("CODE_SAMPLE_REVISE_INVSTAT_SKU1");
AmountType newAmtForSKU1 = new AmountType();
newAmtForSKU1.setCurrencyID(CurrencyCodeType.USD);
newAmtForSKU1.setValue(15.00);
invStatus1.setStartPrice(newAmtForSKU1);
invStatus1.setQuantity(2);
InventoryStatusType invStatus2 = new InventoryStatusType();
invStatus2.setSKU("CODE_SAMPLE_REVISE_INVSTAT_SKU2");
AmountType newAmtForSKU2 = new AmountType();
newAmtForSKU2.setCurrencyID(CurrencyCodeType.USD);
newAmtForSKU2.setValue(10);
invStatus2.setStartPrice(newAmtForSKU2);
invStatus2.setQuantity(30);
// Revise Price Only
InventoryStatusType invStatus3 = new InventoryStatusType();
invStatus3.setSKU("CODE_SAMPLE_REVISE_INVSTAT_SKU3");
AmountType newAmtForSKU3 = new AmountType();
newAmtForSKU3.setCurrencyID(CurrencyCodeType.USD);
newAmtForSKU3.setValue(5.00);
invStatus3.setStartPrice(newAmtForSKU3);
// Revise Quantity Only
InventoryStatusType invStatus4 = new InventoryStatusType();
invStatus4.setSKU("CODE_SAMPLE_REVISE_INVSTAT_SKU4");
invStatus4.setQuantity(20);
// Add all the items to be revised, to an array.
InventoryStatusType[] invStatuses = new InventoryStatusType[]{invStatus1, invStatus2, invStatus3, invStatus4};
// Add exception handling - Most of these exceptions can be fatal.
try {
risCall.setInventoryStatus(invStatuses);// add the array to the main call
risCall.reviseInventoryStatus();
} catch (ApiException e) {
e.printStackTrace();
} catch (SdkException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
reviseInventoryStatus();
}
}