public EbayFacade() { InitializeContext(); api2call = new AddFixedPriceItemCall(Context); reviseItemCall = new ReviseFixedPriceItemCall(Context); deleteItemCall = new EndItemCall(Context); }
public void RelistFixedPriceItem() { Assert.IsNotNull(TestData.EndedFixedPriceItem); // RelistFixedPriceItemCall rviCall = new RelistFixedPriceItemCall(this.apiContext); ItemType item = new ItemType(); item.ItemID = TestData.EndedFixedPriceItem.ItemID; item.StartPrice = new AmountType(); item.StartPrice.Value = 1.98; item.StartPrice.currencyID = CurrencyCodeType.USD; rviCall.RelistFixedPriceItem(item, null); // Let's wait for the server to "digest" the data. System.Threading.Thread.Sleep(1000); // Call GetItem and then compare the startPrice. GetItemCall getItem = new GetItemCall(this.apiContext); DetailLevelCodeType[] detailLevels = new DetailLevelCodeType[] { DetailLevelCodeType.ReturnAll }; getItem.DetailLevelList = new DetailLevelCodeTypeCollection(detailLevels); ItemType returnedItem = getItem.GetItem(item.ItemID); // Make sure it's relisted. /* Assert.AreEqual(returnedItem.ListingDetails.getRelistedItemID().Value, TestData.EndedItem); */ Assert.AreEqual(returnedItem.StartPrice.Value, item.StartPrice.Value); // End the new created item. EndItemCall api = new EndItemCall(this.apiContext); // Set the item to be ended. api.ItemID = item.ItemID; api.EndingReason = EndReasonCodeType.NotAvailable; api.Execute(); }
public void EndChineseAuctionItem() { Assert.IsNotNull(TestData.ChineseAuctionItem, "Failed because no item available -- requires successful AddItem test"); ItemType item = TestData.ChineseAuctionItem; EndItemCall api = new EndItemCall(this.apiContext); // Set the item to be ended. api.ItemID = item.ItemID; api.EndingReason = EndReasonCodeType.NotAvailable; api.Execute(); //check whether the call is success. Assert.IsTrue(api.ApiResponse.Ack==AckCodeType.Success||api.ApiResponse.Ack==AckCodeType.Warning,"do not success!"); }
public void EndItemFull() { Assert.IsNotNull(TestData.NewItem2, "Failed because no item available -- requires successful AddItem test"); ItemType item = TestData.NewItem2; EndItemCall api = new EndItemCall(this.apiContext); // Set the item to be ended. api.ItemID = item.ItemID; api.EndingReason = EndReasonCodeType.NotAvailable; api.Execute(); //check whether the call is success. Assert.IsTrue(api.ApiResponse.Ack==AckCodeType.Success || api.ApiResponse.Ack==AckCodeType.Warning,"do not success!"); TestData.EndedItem2 = TestData.NewItem2; Assert.IsNotNull(TestData.EndedItem2); //Assert.IsTrue(false,"NewItem:"+TestData.NewItem.ItemID+";EndedItem:"+TestData.EndedItem.ItemID+";NewItem2:"+TestData.NewItem2.ItemID+";EndedItem2:"+TestData.EndedItem2.ItemID); }
/// <summary> /// end an item /// </summary> /// <param name="apiContext"></param> /// <param name="item"></param> /// <param name="isSuccess"></param> /// <param name="message"></param> /// <returns></returns> public static bool EndItem(ApiContext apiContext,ItemType item,out string message) { message=string.Empty; EndItemCall api = new EndItemCall(apiContext); // Set the item to be ended. api.ItemID = item.ItemID; api.EndingReason = EndReasonCodeType.NotAvailable; try { api.Execute(); } catch(Exception e) { message=e.Message; return false; } return true; }
public async Task <bool> EndItemListing(CommerceContext commerceContext, SellableItem sellableItem, string reason) { using (CommandActivity.Start(commerceContext, this)) { try { var apiCall = new eBay.Service.Call.EndItemCall(await this.GetEbayContext(commerceContext)); if (sellableItem.HasComponent <EbayItemComponent>()) { var ebayItemComponent = sellableItem.GetComponent <EbayItemComponent>(); var reasonCodeType = EndReasonCodeType.NotAvailable; switch (reason) { case "NotAvailable": reasonCodeType = EndReasonCodeType.NotAvailable; break; case "CustomCode": reasonCodeType = EndReasonCodeType.CustomCode; break; case "Incorrect": reasonCodeType = EndReasonCodeType.Incorrect; break; case "LostOrBroken": reasonCodeType = EndReasonCodeType.LostOrBroken; break; case "OtherListingError": reasonCodeType = EndReasonCodeType.OtherListingError; break; case "SellToHighBidder": reasonCodeType = EndReasonCodeType.SellToHighBidder; break; case "Sold": reasonCodeType = EndReasonCodeType.Sold; break; default: reasonCodeType = EndReasonCodeType.CustomCode; break; } if (string.IsNullOrEmpty(ebayItemComponent.EbayId)) { ebayItemComponent.Status = "LostSync"; } else { if (ebayItemComponent.Status != "Ended") { // Call Ebay and End the Item Listing try { apiCall.EndItem(ebayItemComponent.EbayId, reasonCodeType); ebayItemComponent.Status = "Ended"; } catch (Exception ex) { if (ex.Message == "The auction has already been closed.") { // Capture a case where the listing has expired naturally and it can now no longer be ended. reason = "Expired"; ebayItemComponent.Status = "Ended"; } else { commerceContext.Logger.LogError(ex, $"EbayCommand.EndItemListing.Exception: Message={ex.Message}"); await commerceContext.AddMessage("Error", "EbayCommand.EndItemListing", new object[] { ex }, ex.Message); } } } } ebayItemComponent.ReasonEnded = reason; ebayItemComponent.History.Add(new HistoryEntryModel { EventMessage = "Listing Ended", EventUser = commerceContext.CurrentCsrId() }); sellableItem.GetComponent <TransientListMembershipsComponent>().Memberships.Add("Ebay_Ended"); await this._commerceCommander.PersistEntity(commerceContext, sellableItem); await this._commerceCommander.Command <ListCommander>() .RemoveItemsFromList(commerceContext, "Ebay_Listed", new List <string>() { sellableItem.Id }); } } catch (Exception ex) { commerceContext.Logger.LogError($"Ebay.EndItemListing.Exception: Message={ex.Message}"); await commerceContext.AddMessage("Error", "Ebay.EndItemListing.Exception", new object[] { ex }, ex.Message); } return(true); } }
public void RelistItem() { Assert.IsNotNull(TestData.EndedItem); // RelistItemCall rviCall = new RelistItemCall(this.apiContext); ItemType item = new ItemType(); item.ItemID = TestData.EndedItem.ItemID; item.StartPrice = new AmountType(); item.StartPrice.Value = 1.98; item.StartPrice.currencyID = CurrencyCodeType.USD; //StringCollection modList = new StringCollection(); //modList.Add("item.startPrice"); //ModifiedFieldType[] mfList = eBayUtil.CopyModifiedList(modList, null); //rviCall.ModifiedFields = mfList; //verify first VerifyRelistItemCall vriCall = new VerifyRelistItemCall(this.apiContext); vriCall.Item = item; vriCall.Execute(); FeeTypeCollection fees = vriCall.FeeList; Assert.IsNotNull(fees); GetItemCall getItem1 = new GetItemCall(this.apiContext); DetailLevelCodeType[] detailLevels1 = new DetailLevelCodeType[] { DetailLevelCodeType.ReturnAll }; getItem1.DetailLevelList = new DetailLevelCodeTypeCollection(detailLevels1); ItemType returnedItem1 = getItem1.GetItem(item.ItemID); // Make sure it's relisted. /* Assert.AreEqual(returnedItem.ListingDetails.getRelistedItemID().Value, TestData.EndedItem); */ Assert.AreNotEqual(returnedItem1.StartPrice.Value, item.StartPrice.Value); rviCall.Item = item; rviCall.RelistItem(item); // Let's wait for the server to "digest" the data. System.Threading.Thread.Sleep(1000); // Call GetItem and then compare the startPrice. GetItemCall getItem2 = new GetItemCall(this.apiContext); DetailLevelCodeType[] detailLevels2 = new DetailLevelCodeType[] { DetailLevelCodeType.ReturnAll }; getItem2.DetailLevelList = new DetailLevelCodeTypeCollection(detailLevels2); ItemType returnedItem2 = getItem2.GetItem(item.ItemID); // Make sure it's relisted. /* Assert.AreEqual(returnedItem.ListingDetails.getRelistedItemID().Value, TestData.EndedItem); */ Assert.AreEqual(returnedItem2.StartPrice.Value, item.StartPrice.Value); // End the new created item. EndItemCall api = new EndItemCall(this.apiContext); // Set the item to be ended. api.ItemID = item.ItemID; api.EndingReason = EndReasonCodeType.NotAvailable; api.Execute(); }
private void BtnEndItem_Click(object sender, System.EventArgs e) { try { TxtStatus.Text = ""; EndItemCall apicall = new EndItemCall(Context); apicall.EndItem(TxtItemId.Text, (EndReasonCodeType) Enum.Parse(typeof(EndReasonCodeType), CboReason.SelectedItem.ToString())); TxtStatus.Text = apicall.ApiResponse.Ack.ToString(); } catch(Exception ex) { MessageBox.Show(ex.Message); } }