Find the answer to your question
Advanced Search
GetMyeBayBuying Sample using eBay JAVA SDK
Summary
A buyer's all Buying and all Favorite are returned in GetMyeBayBuying. MyeBayBuying data are retuned in WatchList, BidList, BestOfferList, FavoriteSearches and FavoriteSellers properties and can be retrieved using JAVA SDK wrapper class GetMyeBayBuyingCall.
As documented : FavoriteSearches, FavriteSellers, and SecondChanceOffers fields or containers are based on the complex type MyeBaySelectionType, which lets you sort or filter the return values. The sample project provides two help methods: setItemListCustomizationTypeParam() and setMyeBaySelectTypeParam() for constructing GetMyeBayBuying request for a given property which includes Pagination.
Detailed Description
Here are the major methods of the sample project. The full source code can be downloaded below.
/* * construct GetMyeBayBuying api call request **/ public void request() { DetailLevelCodeType[] detailLevels = new DetailLevelCodeType[]{ DetailLevelCodeType.RETURN_ALL }; GetMyeBayBuyingCall gmes = new GetMyeBayBuyingCall(apiContext); gmes.setDetailLevel(detailLevels); // construct data containers that based on ItemListCustomizationType gmes.setBidList(setItemListCustomizationTypeParam(true, 5, 1, ItemSortTypeCodeType.ITEM_ID)); gmes.setWonList(setItemListCustomizationTypeParam(true, 5, 1, ItemSortTypeCodeType.END_TIME)); gmes.setWatchList(setItemListCustomizationTypeParam(true, 5, 1, ItemSortTypeCodeType.END_TIME)); gmes.setLostList(setItemListCustomizationTypeParam(true, 5, 1, ItemSortTypeCodeType.ITEM_ID)); gmes.setWatchList(setItemListCustomizationTypeParam(true, 5, 1, ItemSortTypeCodeType.ITEM_ID)); gmes.setBestOfferList(setItemListCustomizationTypeParam(true, 5, 1, ItemSortTypeCodeType.END_TIME)); // construct data containers that based on MyeBaySelectionType gmes.setFavoriteSearches(setMyeBaySelectTypeParam(true, 5, SortOrderCodeType.ASCENDING)); gmes.setFavoriteSellers(setMyeBaySelectTypeParam(true, 5, SortOrderCodeType.ASCENDING)); try { gmes.getMyeBayBuying(); } catch (Exception e) { if (e instanceof SdkSoapException) { SdkSoapException sdkExe = (SdkSoapException) e; ErrorType errs = sdkExe.getErrorType(); System.out.println("error code " + errs.getErrorCode() + "error shot message" + errs.getShortMessage()); } if (e instanceof ApiException) { //System.out.println(" I am printing ApiExcetpion ..." + e.getMessage()); ApiException apiExe = (ApiException) e; ErrorType[] errs = apiExe.getErrors(); for (int j = 0; j < errs.length; j++) { System.out.println("error code " + errs[j].getErrorCode() + "error shot message" + errs[j].getShortMessage()); } } } // process returned bidlist data PaginatedItemArrayType returnedBidList = gmes.getReturnedBidList(); if (returnedBidList != null) { ItemType[] itemArr = returnedBidList.getItemArray().getItem(); for (ItemType item : itemArr) { System.out.println("item.getItemID()====> " + item.getItemID()); } } // process returned wonlist data PaginatedOrderTransactionArrayType returnedWonList = gmes.getReturnedWonList(); if (returnedWonList != null) { OrderTransactionArrayType ordertranarray = returnedWonList.getOrderTransactionArray(); OrderTransactionType[] trans = ordertranarray.getOrderTransaction(); TransactionType transaction = null; ItemType item = null; for (OrderTransactionType orderTran : trans) { // process an order OrderType order = orderTran.getOrder(); if (order != null) { TransactionArrayType tat = order.getTransactionArray(); // get the SOAP transaction array type TransactionType[] tt = tat.getTransaction(); // loop through each transaction for (TransactionType singleTran : tt) { retrieveTranaction(singleTran, order); } } else { //getting an item returned from a single transaction transaction = orderTran.getTransaction(); retrieveTranaction(transaction, order); } } //end for } // process returned favorite search list data MyeBayFavoriteSearchListType searchesList = gmes.getReturnedFavoriteSearches(); if (searchesList != null) { MyeBayFavoriteSearchType[] favoriteSearchList = searchesList.getFavoriteSearch(); for (MyeBayFavoriteSearchType favoriteSearch : favoriteSearchList) { favoriteSearch.getSearchName(); favoriteSearch.getSearchQuery(); } } } private void retrieveTranaction(TransactionType transaction, OrderType order) { ItemType item = transaction.getItem(); if (transaction.getTotalPrice() != null) { System.out.println("Total: " + transaction.getTotalPrice().getValue()); } String listingType = item.getListingType().toString(); // filter out Half item and StoresFixedPrice items if ((!listingType.equalsIgnoreCase("Half")) && (!listingType.equalsIgnoreCase("StoresFixedPrice"))) { if (item.getSellingStatus().getCurrentPrice() != null) { double price = item.getSellingStatus().getCurrentPrice().getValue(); int number = transaction.getQuantityPurchased().intValue(); System.out.print("quantity purchased: " + number + ", itemSellingPrice: " + price * number); } if (order != null) { System.out.println("OrderID : " + order.getOrderID() + ",Transactionid : " + transaction.getTransactionID() + ", ItemID : " + item.getItemID()); } else { System.out.println(", Transactionid : " + transaction.getTransactionID() + ", ItemID : " + item.getItemID()); } } } /* * Sets pagenation for MyeBaySelectType based object */ private ItemListCustomizationType setItemListCustomizationTypeParam(Boolean includeNote, int entriesPerPage, int pageNum, ItemSortTypeCodeType sortType) { ItemListCustomizationType itemListCust = new ItemListCustomizationType(); PaginationType page = new PaginationType(); page.setEntriesPerPage(entriesPerPage); page.setPageNumber(pageNum); itemListCust.setInclude(includeNote); itemListCust.setPagination(page); itemListCust.setSort(sortType); return itemListCust; } /* * Sets pagenation for MyeBaySelectType based object */ private MyeBaySelectionType setMyeBaySelectTypeParam(Boolean include, int maxResu, SortOrderCodeType sortOrderCode) { MyeBaySelectionType selecType = new MyeBaySelectionType(); selecType.setInclude(include); selecType.setMaxResults(maxResu); selecType.setSort(sortOrderCode); return selecType; } |
Additional Resource
- Documentation: GetMyeBayBuying