eBay大中华区API开发者平台 开发者专区

搜 索
首页>API开发者平台>技术文档>Java SDK - RelistFixedPriceItem可以将已下架的一口价商品重新刊登上架

技术文档

问题
Java SDK - RelistFixedPriceItem可以将已下架的一口价商品重新刊登上架
解答
0
人觉得答案有帮助)

总述

调用GetCategoryFeatures获取可用的Item Condition Definition,然后将某个Condition ID传递给AddItemReviseItem call

下面例程基于Java SDK调用GetCategoryFeatures。指定为US站点上编号63861的Category

package com.ebay.test; 
import com.ebay.sdk.ApiAccount; 
import com.ebay.sdk.ApiContext; 
import com.ebay.sdk.ApiCredential; 
import com.ebay.sdk.ApiLogging; 
import com.ebay.sdk.CallRetry; 
import com.ebay.sdk.call.GetCategoryFeaturesCall; 
import com.ebay.soap.eBLBaseComponents.CategoryFeatureType; 
import com.ebay.soap.eBLBaseComponents.ConditionEnabledCodeType; 
import com.ebay.soap.eBLBaseComponents.ConditionType; 
import com.ebay.soap.eBLBaseComponents.DetailLevelCodeType; 
import com.ebay.soap.eBLBaseComponents.SiteCodeType;

public class AppGetCategoryFeatures {

public static ApiContext createApiContext() {

ApiContext apiContext = new ApiContext(); 
ApiLogging apiLogging = new ApiLogging(); 
apiContext.setApiLogging(apiLogging); 
CallRetry cr = new CallRetry(); 
cr.setMaximumRetries(3); 
cr.setDelayTime(1000); // Wait for one second between each retry-call.

String[] apiErrorCodes = new String[] { "502" };

// Set trigger exceptions for CallRetry. 
cr.setTriggerApiErrorCodes(apiErrorCodes);

// Build a dummy SdkSoapException so that we can get its Class. 
Class[] tcs = new Class[] { com.ebay.sdk.SdkSoapException.class }; 
cr.setTriggerExceptions(tcs); 
apiContext.setCallRetry(cr); 
apiContext.setTimeout(180000);

ApiCredential cred = new ApiCredential(); 
apiContext.setApiServerUrl("https://api.sandbox.ebay.com/wsapi"); 
// apiContext.setApiServerUrl("https://api.ebay.com/wsapi");

ApiAccount ac = cred.getApiAccount(); 
ac.setApplication(YOUR-APPID); 
ac.setDeveloper(YOUR-DEVID); 
ac.setCertificate(YOUR-CERTID); 
cred.seteBayToken(YOUR-TOKEN); 
apiContext.setApiCredential(cred);

return apiContext;

}

private static GetCategoryFeaturesCall getCatFeature(String categoryId, SiteCodeType site) {

GetCategoryFeaturesCall request = new GetCategoryFeaturesCall( 
createApiContext()); 
request.setSite(site); 
request.setDetailLevel(new DetailLevelCodeType[] { DetailLevelCodeType.RETURN_ALL });

request.setCategoryID(categoryId); 
request.setOutputSelector(new String[] { 
"Category.ConditionEnabled", 
"Category.ConditionValues.Condition.ID", 
"Category.ConditionValues.Condition.DisplayName" });

try {

request.getCategoryFeatures();

catch (Exception e) { 
e.printStackTrace(); 
}

return request;

}

public static void main(String[] args) {

GetCategoryFeaturesCall cf = getCatFeature("63861", SiteCodeType.US);

/* 
* Since we call GetCategoryFeatures for a specified category, so we 
* just get the first category element here 
*/

CategoryFeatureType feature = cf.getReturnedCategory()[0];

/* 
* If condition Enabled is disabled, then DO NOT pass conditionID in 
* AddItem or ReviseItem for this category 
*/

if (feature.getConditionEnabled().equals(ConditionEnabledCodeType.ENABLED)) {

for (ConditionType con : feature.getConditionValues().getCondition())

System.out.println(con.getID() + " - " + con.getDisplayName()); 
}

}

}

 

运行代码后,你会看到此Category的Condition ID Definitionf如下所示:

1000 - New with tags

1500 - New without tags

1750 - New with defects

3000 - Pre-owned

 

选择某个condition ID,如"New with tags"。在 AddItemReviseItem调用中设置condtionID为 "1000"

...

AddItemCall request = new AddItemCall(createApiContext()); 
ItemType item = new ItemType(); 
item.setConditionID(1000);

...

request.setItem(item); 
request.addItem();

...

 

版本信息

上示例程基于此特定的版本信息:

API 架构版本

673

Java SDK 版本

eBay Java SDK v673 Full Release (for JDK 1.5 and 1.6)

 

  附件
   • HTML document AppGetCategoryFeatures.java
 • HTML document AppAddItem.java

 


答案对您有帮助吗?

是,对我很有帮助
否,没解决我的问题