public void AddToItemDescription() { string message, description, itemID, originalDes; ItemType item; bool isSuccess; Assert.IsNotNull(TestData.NewItem2, "Failed because no item available -- requires successful AddItem test"); AddToItemDescriptionCall api = new AddToItemDescriptionCall(this.apiContext); itemID = TestData.NewItem2.ItemID; originalDes = TestData.NewItem2.Description; description = "SDK appended text."; DetailLevelCodeTypeCollection detailLevel = new DetailLevelCodeTypeCollection(); DetailLevelCodeType type = DetailLevelCodeType.ReturnAll; detailLevel.Add(type); api.DetailLevelList = detailLevel; // Make API call. api.AddToItemDescription(itemID, description); System.Threading.Thread.Sleep(3000); //check whether the call is success. Assert.IsTrue(api.ApiResponse.Ack == AckCodeType.Success || api.ApiResponse.Ack == AckCodeType.Warning, "do not success!"); isSuccess = ItemHelper.GetItem(TestData.NewItem2, this.apiContext, out message, out item); Assert.IsTrue(isSuccess, message); Assert.IsTrue(message == string.Empty, message); Assert.IsNotNull(item.Description, "the item description is null"); Assert.Greater(item.Description.Length, originalDes.Length); }
public void AddToItemDescription() { string message,description,itemID,originalDes; ItemType item; bool isSuccess; Assert.IsNotNull(TestData.NewItem2, "Failed because no item available -- requires successful AddItem test"); AddToItemDescriptionCall api = new AddToItemDescriptionCall(this.apiContext); itemID = TestData.NewItem2.ItemID; originalDes = TestData.NewItem2.Description; description="SDK appended text."; DetailLevelCodeTypeCollection detailLevel=new DetailLevelCodeTypeCollection(); DetailLevelCodeType type=DetailLevelCodeType.ReturnAll; detailLevel.Add(type); api.DetailLevelList=detailLevel; // Make API call. api.AddToItemDescription(itemID,description); System.Threading.Thread.Sleep(3000); //check whether the call is success. Assert.IsTrue(api.ApiResponse.Ack==AckCodeType.Success || api.ApiResponse.Ack==AckCodeType.Warning,"do not success!"); isSuccess=ItemHelper.GetItem(TestData.NewItem2,this.apiContext,out message,out item); Assert.IsTrue(isSuccess,message); Assert.IsTrue(message==string.Empty,message); Assert.IsNotNull(item.Description,"the item description is null"); Assert.Greater(item.Description.Length,originalDes.Length); }
public OrderType[] DownloadNeweBayOrder(DateTime?fromTime, DateTime?toTime) { try { GetOrdersCall getOrdersCall; GetOrdersRequestType getOrdersRequest; PaginationType paging = new PaginationType(); int totalPage; DetailLevelCodeTypeCollection detailLevelColl = new DetailLevelCodeTypeCollection(); detailLevelColl.Add(DetailLevelCodeType.ReturnAll); List <OrderType> returnOrders = new List <OrderType>(); foreach (var apiContext in _eBayAPIContextProvider.GetAPIContext()) { getOrdersCall = new GetOrdersCall(apiContext); getOrdersRequest = new GetOrdersRequestType(); getOrdersRequest.OrderRole = TradingRoleCodeType.Seller; getOrdersRequest.DetailLevel = detailLevelColl; //var getOrderRequestDatetimeNow = DateTime.Now.AddMinutes(-2); if (fromTime != null) { getOrdersRequest.CreateTimeFrom = ((DateTime)fromTime).ToUniversalTime(); } if (toTime != null) { getOrdersRequest.CreateTimeTo = ((DateTime)toTime).ToUniversalTime(); } int pageNumber = 1; do { paging.EntriesPerPage = 100; paging.PageNumber = pageNumber; getOrdersRequest.Pagination = paging; var getOrdersResponse = getOrdersCall.ExecuteRequest(getOrdersRequest) as GetOrdersResponseType; if (getOrdersResponse.OrderArray != null && getOrdersResponse.OrderArray.Count > 0) { returnOrders.AddRange(getOrdersResponse.OrderArray.ToArray()); } totalPage = getOrdersResponse.PaginationResult.TotalNumberOfPages; pageNumber++; } while (pageNumber <= totalPage); } return(returnOrders.ToArray()); } catch (Exception ex) { return(default(OrderType[])); } }
/// <summary> /// init the call /// </summary> /// <param name="api"></param> private static void setBasicInfo(ref GetCategoriesCall api) { //set basic info to the call api.CategorySiteID = Convert.ToString(0); DetailLevelCodeTypeCollection detailLevel = new DetailLevelCodeTypeCollection(); DetailLevelCodeType type = DetailLevelCodeType.ReturnAll; detailLevel.Add(type); api.DetailLevelList = detailLevel; }
public OrderType[] GeteBayOrdersByOrderLineItemID(IList <string> orderLineItemIDs) { try { if (orderLineItemIDs == null || orderLineItemIDs.Count == 0) { return(default(OrderType[])); } GetOrderTransactionsCall getOrderTransactionCall; GetOrderTransactionsRequestType getOrderTransactionRequest; DetailLevelCodeTypeCollection detailLevelColl = new DetailLevelCodeTypeCollection(); detailLevelColl.Add(DetailLevelCodeType.ItemReturnDescription); var apiContext = _eBayApiContextProvider.GetAPIContext(); List <OrderType> returnOrders = new List <OrderType>(); getOrderTransactionCall = new GetOrderTransactionsCall(apiContext); getOrderTransactionRequest = new GetOrderTransactionsRequestType(); getOrderTransactionRequest.DetailLevel = detailLevelColl; int pageSize = 20; int totalPage = Convert.ToInt32(Math.Ceiling(Convert.ToDecimal(orderLineItemIDs.Count()) / Convert.ToDecimal(pageSize))); int pageNumber = 1; do { getOrderTransactionRequest.ItemTransactionIDArray = new ItemTransactionIDTypeCollection(); var lstTransactionIDs = orderLineItemIDs.Select(olid => new ItemTransactionIDType() { OrderLineItemID = olid }).Skip((pageNumber - 1) * pageSize).Take(pageSize); getOrderTransactionRequest.ItemTransactionIDArray.AddRange(lstTransactionIDs.ToArray()); var getOrderTransactionResponse = getOrderTransactionCall.ExecuteRequest(getOrderTransactionRequest) as GetOrderTransactionsResponseType; if (getOrderTransactionResponse.OrderArray != null && getOrderTransactionResponse.OrderArray.Count > 0) { returnOrders.AddRange(getOrderTransactionResponse.OrderArray.ToArray()); } pageNumber++; } while (pageNumber <= totalPage); return(returnOrders.ToArray()); } catch (Exception ex) { LogManager.Instance.Error(ex.Message); throw ex; } }
public ItemType GetSoldItemSnapshot(string orderLineItemID) { try { var apiContext = _eBayApiContextProvider.GetAPIContext(); var getItemCall = new GetItemCall(apiContext); ItemType retItem = null; var orderLineItemIDSpilt = orderLineItemID.Split('-'); if (orderLineItemIDSpilt.Count() == 2) { var detailLevel = new DetailLevelCodeTypeCollection(); detailLevel.Add(DetailLevelCodeType.ItemReturnDescription); var getItemRequest = new GetItemRequestType() { ItemID = orderLineItemIDSpilt[0], TransactionID = orderLineItemIDSpilt[1], DetailLevel = detailLevel }; int failTimes = 0; bool isSuccess = false; do { try { var response = getItemCall.ExecuteRequest(getItemRequest) as GetItemResponseType; //lstSoldItem.Add(response.Item); isSuccess = true; retItem = response.Item; } catch (Exception ex) { failTimes++; LogManager.Instance.Error($"Get item itemID:{getItemRequest.ItemID}, transactionID:{getItemRequest.TransactionID} failed. {ex.ToString()}"); } }while (failTimes < 5 && !isSuccess); //if (!isSuccess) // throw new Exception($"Get item itemID:{getItemRequest.ItemID}, transactionID:{getItemRequest.TransactionID} failed for {failTimes} times."); } return(retItem); //return lstSoldItem.ToArray(); } catch (Exception ex) { LogManager.Instance.Error(ex.ToString()); throw ex; } }
public void SetUserNotes() { Assert.IsNotNull(TestData.NewItem2, "Failed because no item available -- requires successful AddItem test"); SetUserNotesCall api = new SetUserNotesCall(this.apiContext); api.Action = SetUserNotesActionCodeType.AddOrUpdate; api.ItemID = TestData.NewItem2.ItemID; api.NoteText = "Notes for eBay SDK sanity test."; DetailLevelCodeTypeCollection detailLevel=new DetailLevelCodeTypeCollection(); DetailLevelCodeType type=DetailLevelCodeType.ReturnAll; detailLevel.Add(type); api.DetailLevelList=detailLevel; // Make API call. api.Execute(); System.Threading.Thread.Sleep(3000); //check whether the call is success. //eBayNotes can not get by calling GetItemCall. Assert.IsTrue(api.ApiResponse.Ack==AckCodeType.Success || api.ApiResponse.Ack==AckCodeType.Warning,"do not success!"); }
public void SetUserNotes() { Assert.IsNotNull(TestData.NewItem2, "Failed because no item available -- requires successful AddItem test"); SetUserNotesCall api = new SetUserNotesCall(this.apiContext); api.Action = SetUserNotesActionCodeType.AddOrUpdate; api.ItemID = TestData.NewItem2.ItemID; api.NoteText = "Notes for eBay SDK sanity test."; DetailLevelCodeTypeCollection detailLevel = new DetailLevelCodeTypeCollection(); DetailLevelCodeType type = DetailLevelCodeType.ReturnAll; detailLevel.Add(type); api.DetailLevelList = detailLevel; // Make API call. api.Execute(); System.Threading.Thread.Sleep(3000); //check whether the call is success. //eBayNotes can not get by calling GetItemCall. Assert.IsTrue(api.ApiResponse.Ack == AckCodeType.Success || api.ApiResponse.Ack == AckCodeType.Warning, "do not success!"); }
/// <summary> /// init the call /// </summary> /// <param name="api"></param> private static void setBasicInfo(ref GetCategoriesCall api) { //set basic info to the call api.CategorySiteID=Convert.ToString(0); DetailLevelCodeTypeCollection detailLevel=new DetailLevelCodeTypeCollection(); DetailLevelCodeType type=DetailLevelCodeType.ReturnAll; detailLevel.Add(type); api.DetailLevelList=detailLevel; }
public void AddItemFull3() { bool isSucess,isProductSearchPageAvailable; bool existing=false,isbnExisting=false; string message; Int32Collection attributes=new Int32Collection(); CategoryTypeCollection categories=null; CharacteristicsSetTypeCollection characteristics=null; ItemType item= ItemHelper.BuildItem(); //check whether the category is catalog enabled. isSucess=CategoryHelper.IsCatagoryEnabled(this.apiContext,PSPACATEGORYID.ToString(),CategoryEnableCodeType.ProductSearchPageAvailable,out isProductSearchPageAvailable,out message); Assert.IsTrue(isSucess,message); Assert.IsTrue(isProductSearchPageAvailable,message); isSucess=CategoryHelper.IsCatagoryEnabled(this.apiContext,PSPACATEGORYID.ToString(),CategoryEnableCodeType.CatalogEnabled,out isProductSearchPageAvailable,out message); Assert.IsTrue(isSucess,message); Assert.IsTrue(isProductSearchPageAvailable,message); //modify item information approporiately. item.PrimaryCategory.CategoryID=PSPACATEGORYID.ToString(); item.Description = "check whether the item can be added by GetProductSearchPage method way,This is a test item created by eBay SDK SanityTest."; //get characters information using GetCategory2CSCall GetCategory2CSCall csCall=new GetCategory2CSCall(this.apiContext); DetailLevelCodeTypeCollection levels=new DetailLevelCodeTypeCollection(); DetailLevelCodeType level=new DetailLevelCodeType(); level=DetailLevelCodeType.ReturnAll; levels.Add(level); csCall.DetailLevelList=levels; csCall.CategoryID=PSPACATEGORYID.ToString(); csCall.Execute(); //check whether the call is success. Assert.IsTrue(csCall.AbstractResponse.Ack==AckCodeType.Success || csCall.AbstractResponse.Ack==AckCodeType.Warning,"do not success!"); Assert.IsNotNull(csCall.ApiResponse.MappedCategoryArray); Assert.Greater(csCall.ApiResponse.MappedCategoryArray.Count,0); categories=csCall.ApiResponse.MappedCategoryArray; foreach(CategoryType category in categories) { if(string.Compare(category.CategoryID,PSPACATEGORYID)==0) { characteristics=category.CharacteristicsSets; existing= true; break; } } //confirm that the category was in the mapping category. Assert.IsTrue(existing,PSPACATEGORYID+" do not exist in the mapping category"); Assert.IsNotNull(characteristics); Assert.Greater(characteristics.Count,0); foreach(CharacteristicsSetType characteristic in characteristics) { attributes.Add(characteristic.AttributeSetID); } //confirm that there is real attributeset in the mapping category. Assert.AreEqual(attributes.Count,1);//there is only one AttributeSetID in the category 279. GetProductSearchPageCall searchPageCall=new GetProductSearchPageCall(this.apiContext); searchPageCall.AttributeSetIDList=attributes; DetailLevelCodeTypeCollection levels2=new DetailLevelCodeTypeCollection(); DetailLevelCodeType level2=new DetailLevelCodeType(); level2=DetailLevelCodeType.ReturnAll; levels2.Add(level2); searchPageCall.DetailLevelList=levels2; searchPageCall.Execute(); //check whether the call is success. Assert.IsTrue(searchPageCall.ApiResponse.Ack==AckCodeType.Success || searchPageCall.ApiResponse.Ack==AckCodeType.Warning,"do not success!"); Assert.AreEqual(searchPageCall.ApiResponse.ProductSearchPage.Count,1);//for the input attributeset id is only one. Assert.IsNotNull(searchPageCall.ApiResponse.ProductSearchPage[0].SearchCharacteristicsSet);//for the input attributeset id is only one. Assert.IsNotNull(searchPageCall.ApiResponse.ProductSearchPage[0].SearchCharacteristicsSet.Characteristics); Assert.Greater(searchPageCall.ApiResponse.ProductSearchPage[0].SearchCharacteristicsSet.Characteristics.Count,0); //check the isbn-13 attribute id exists and its value has not been changed. CharacteristicTypeCollection chs = searchPageCall.ApiResponse.ProductSearchPage[0].SearchCharacteristicsSet.Characteristics; foreach(CharacteristicType charactersic in chs) { //check whether the isbn attribute can be used if(charactersic.AttributeID==ISBN13ATTRIBUTEID && (string.Compare(charactersic.Label.Name,"ISBN-13",true)==0)) { isbnExisting=true; break; } } Assert.IsTrue(isbnExisting,"the isbn attribute id is not existing or has been changed!"); //using GetProductSearchResults call to find products. ProductSearchType productSearch=new ProductSearchType(); productSearch.AttributeSetID=attributes[0]; SearchAttributesTypeCollection searchAttributes=new SearchAttributesTypeCollection(); SearchAttributesType searchAttribute=new SearchAttributesType(); searchAttribute.AttributeID=ISBN13ATTRIBUTEID; ValTypeCollection vals=new ValTypeCollection(); ValType val=new ValType(); val.ValueLiteral=ISBN; vals.Add(val); searchAttribute.ValueList=vals; searchAttributes.Add(searchAttribute); productSearch.SearchAttributes=searchAttributes; GetProductSearchResultsCall searchResultsCall=new GetProductSearchResultsCall(this.apiContext); searchResultsCall.ProductSearchList=new ProductSearchTypeCollection(new ProductSearchType[]{productSearch}); searchResultsCall.Execute(); //check whether the call is success. Assert.IsTrue(searchResultsCall.ApiResponse.Ack==AckCodeType.Success || searchResultsCall.ApiResponse.Ack==AckCodeType.Warning,"do not success!"); Assert.Greater(searchResultsCall.ApiResponse.ProductSearchResult.Count,0); Assert.AreEqual(int.Parse(searchResultsCall.ApiResponse.ProductSearchResult[0].NumProducts),1); Assert.Greater(searchResultsCall.ApiResponse.ProductSearchResult[0].AttributeSet.Count,0); Assert.Greater(searchResultsCall.ApiResponse.ProductSearchResult[0].AttributeSet[0].ProductFamilies.Count,0); Assert.IsFalse(searchResultsCall.ApiResponse.ProductSearchResult[0].AttributeSet[0].ProductFamilies[0].hasMoreChildren); Assert.IsNotNull(searchResultsCall.ApiResponse.ProductSearchResult[0].AttributeSet[0].ProductFamilies[0].ParentProduct.productID); string productID=searchResultsCall.ApiResponse.ProductSearchResult[0].AttributeSet[0].ProductFamilies[0].ParentProduct.productID; ProductListingDetailsType plist=new ProductListingDetailsType(); plist.ProductID=productID; plist.IncludePrefilledItemInformation=true; plist.IncludeStockPhotoURL=true; item.ProductListingDetails=plist; FeeTypeCollection fees; VerifyAddItemCall vi = new VerifyAddItemCall(apiContext); fees = vi.VerifyAddItem(item); Assert.IsNotNull(fees); AddItemCall addItemCall = new AddItemCall(apiContext);; fees = addItemCall.AddItem(item); //check whether the call is success. Assert.IsTrue(addItemCall.AbstractResponse.Ack==AckCodeType.Success || addItemCall.AbstractResponse.Ack==AckCodeType.Warning,"do not success!"); Assert.IsTrue(item.ItemID!=string.Empty); Assert.IsNotNull(fees); //caution check ItemType itemOut; isSucess=ItemHelper.GetItem(item,this.apiContext,out message, out itemOut); Assert.IsTrue(isSucess,message); Assert.IsNotNull(itemOut,"Item is null"); Assert.Greater(itemOut.AttributeSetArray.Count,0); Assert.Greater(itemOut.AttributeSetArray[0].Attribute.Count,0); Assert.Greater(itemOut.AttributeSetArray[0].Attribute[0].Value.Count,0); }
protected void Page_Load(object sender, EventArgs e) { //get request parameter StringCollection itemIds = new StringCollection(); String itemId = Request.QueryString["itemId"]; itemIds.Add(itemId); //create AddToWatchListCall object AddToWatchListCall addToWatchListCall = new AddToWatchListCall(apiContext); try { //call AddToWatchList service addToWatchListCall.AddToWatchList(itemIds, null); //create GetMyeBayBuyingCall object GetMyeBayBuyingCall getMyeBayBuyingCall = new GetMyeBayBuyingCall(apiContext); //configure call parameters DetailLevelCodeTypeCollection level = new DetailLevelCodeTypeCollection(); level.Add(DetailLevelCodeType.ReturnAll); getMyeBayBuyingCall.DetailLevelList = level; //call GetMyeBayBuying service getMyeBayBuyingCall.GetMyeBayBuying(); //show result if (getMyeBayBuyingCall.WatchListReturn != null) { ItemTypeCollection items = getMyeBayBuyingCall.WatchListReturn.ItemArray; if (items != null) { // watching count watchCount.Text = "Total number of watching items : " + items.Count; //title TableRow titlerow = new TableRow(); TableHeaderCell titlecell0 = new TableHeaderCell(); titlecell0.Text = "Item ID"; titlecell0.BorderWidth = 1; titlerow.Cells.Add(titlecell0); TableHeaderCell titlecell1 = new TableHeaderCell(); titlecell1.Text = "Garrlery"; titlecell1.BorderWidth = 1; titlerow.Cells.Add(titlecell1); TableHeaderCell titlecell2 = new TableHeaderCell(); titlecell2.Text = "Title(Click to view item on eBay)"; titlecell2.BorderWidth = 1; titlerow.Cells.Add(titlecell2); TableHeaderCell titlecell3 = new TableHeaderCell(); titlecell3.Text = "Current Price"; titlecell3.BorderWidth = 1; titlerow.Cells.Add(titlecell3); watchList.Rows.Add(titlerow); //data for (int i = 0; i < items.Count; i++) { TableRow tblrow = new TableRow(); for (int j = 0; j < 1; j++) { TableCell tblcell0 = new TableCell(); tblcell0.Text = items[i].ItemID; tblcell0.BorderWidth = 1; tblrow.Cells.Add(tblcell0); TableCell tblcell1 = new TableCell(); if (items[i].PictureDetails != null) { tblcell1.Text = "<img src=" + items[i].PictureDetails.GalleryURL + ">"; } tblcell1.BorderWidth = 1; tblrow.Cells.Add(tblcell1); TableCell tblcell2 = new TableCell(); tblcell2.Text = "<a href=" + items[i].ListingDetails.ViewItemURL + ">" + items[i].Title + "</a>"; tblcell2.BorderWidth = 1; tblrow.Cells.Add(tblcell2); TableCell tblcell3 = new TableCell(); tblcell3.Text = "$" + items[i].SellingStatus.CurrentPrice.Value.ToString(); tblcell3.BorderWidth = 1; tblrow.Cells.Add(tblcell3); } watchList.Rows.Add(tblrow); } } } } catch (Exception exc) { errorMsg.Text = exc.Message; } }
public OrderType[] GeteBayOrdersByOrderLineItemID(IList <OrderLineItemIDObject> orderLineItemIDs) { try { if (orderLineItemIDs == null || orderLineItemIDs.Count == 0) { return(default(OrderType[])); } GetOrderTransactionsCall getOrderTransactionCall; GetOrderTransactionsRequestType getOrderTransactionRequest; DetailLevelCodeTypeCollection detailLevelColl = new DetailLevelCodeTypeCollection(); detailLevelColl.Add(DetailLevelCodeType.ReturnAll); var apiContexts = _eBayAPIContextProvider.GetAPIContext(); List <OrderType> returnOrders = new List <OrderType>(); var orderLineItemIDGroup = orderLineItemIDs.GroupBy(i => i.SellerID); foreach (var sellerGroupItemID in orderLineItemIDGroup) { var apiContext = apiContexts.Where(c => c.ApiCredential.eBayAccount.UserName.ToLower().Equals(sellerGroupItemID.Key.ToLower())).FirstOrDefault(); if (apiContext != null) { getOrderTransactionCall = new GetOrderTransactionsCall(apiContext); getOrderTransactionRequest = new GetOrderTransactionsRequestType(); getOrderTransactionRequest.DetailLevel = detailLevelColl; int pageSize = 20; int totalPage = Convert.ToInt32(Math.Ceiling(Convert.ToDecimal(sellerGroupItemID.Count()) / Convert.ToDecimal(pageSize))); int pageNumber = 1; do { getOrderTransactionRequest.ItemTransactionIDArray = new ItemTransactionIDTypeCollection(); var lstTransactionIDs = sellerGroupItemID.Select(gi => new ItemTransactionIDType() { OrderLineItemID = gi.OrderLineItemID }).Skip((pageNumber - 1) * pageSize).Take(pageSize); getOrderTransactionRequest.ItemTransactionIDArray.AddRange(lstTransactionIDs.ToArray()); var getOrderTransactionResponse = getOrderTransactionCall.ExecuteRequest(getOrderTransactionRequest) as GetOrderTransactionsResponseType; if (getOrderTransactionResponse.OrderArray != null && getOrderTransactionResponse.OrderArray.Count > 0) { returnOrders.AddRange(getOrderTransactionResponse.OrderArray.ToArray()); } pageNumber++; } while (pageNumber <= totalPage); //foreach (var orderLineItemIDObj in sellerGroupItemID) //{ //} } } return(returnOrders.ToArray()); } catch (Exception ex) { return(default(OrderType[])); } }