public EbayFacade() { InitializeContext(); api2call = new AddFixedPriceItemCall(Context); reviseItemCall = new ReviseFixedPriceItemCall(Context); deleteItemCall = new EndItemCall(Context); }
public void End(ApiContext apiContext, System.Diagnostics.EventLog eventLog = null) { ItemType itemType = ToItemType(); EndItemCall apiCall = new EndItemCall(apiContext); if (eventLog != null) { eventLog.WriteEntry(string.Format("Start relisting an item... ItemID={0}, Quantity={1}, Price={2}", itemType.ItemID, itemType.Quantity, itemType.StartPrice.Value)); } try { apiCall.EndItem(itemType.ItemID, EndReasonCodeType.NotAvailable); IsApiCallSuccess = true; } catch (Exception e) { if (eventLog != null) { eventLog.WriteEntry(string.Format("An error occured while ending an item... ItemID={0}, Quantity={1}, Price={2}, Message={3}", itemType.ItemID, itemType.Quantity, itemType.StartPrice.Value, e.Message)); } IsApiCallSuccess = false; ApiCallErrorMessage = e.Message; } }
public void SubmitSingleProductEndItem(ItemFeed itemFeed, string submittedBy) { try { if (string.IsNullOrEmpty(itemFeed.ItemId)) { _logger.LogInfo(LogEntryType.eBayEndListing, string.Format("Unable to send END_ITEM feed for \'{0}\' since it doesn't have ItemId. \nRequested by: {1}", itemFeed.EisSKU, submittedBy)); return; } // create the end item request var endItemCall = new EndItemCall(_context); endItemCall.EndItem(itemFeed.ItemId, EndReasonCodeType.NotAvailable); // let's set the eBay product ItemId to null _logger.SeteBayItemIdToNull(new List <ItemFeed> { itemFeed }); _logger.LogInfo(LogEntryType.eBayEndListing, string.Format("Successfully posted single END_ITEM feed for {0} - {1} item. \nRequested by: {2} \nAPI Message: {3}", ChannelName, itemFeed.EisSKU, submittedBy, endItemCall.ApiResponse.Message)); } catch (Exception ex) { var description = string.Format("Error in submitting END_ITEM feed for {0}. \nError Message: {2} \nRequested by: {3}", itemFeed.EisSKU, EisHelper.GetExceptionMessage(ex), submittedBy); _logger.LogError(LogEntryType.eBayEndListing, description, ex.StackTrace); } }
public static void EndMyItem(string Token, string ItemID) { ApiContext apiContext = GetApiContext(Token); EndItemCall apiCall = new EndItemCall(apiContext); EndReasonCodeType Endreason = EndReasonCodeType.NotAvailable; apiCall.EndItem(ItemID, Endreason); }
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!"); }
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); } }
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 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 async Task <bool> EndItemListing(CommerceContext commerceContext, SellableItem sellableItem, string reason) { using (var activity = CommandActivity.Start(commerceContext, this)) { //Instantiate the call wrapper class try { var apiCall = new EndItemCall(await 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 [] { ex }, ex.Message).ConfigureAwait(false); } } } } ebayItemComponent.ReasonEnded = reason; ebayItemComponent.History.Add(new HistoryEntryModel { EventMessage = "Listing Ended", EventUser = commerceContext.CurrentCsrId() }); sellableItem.GetComponent <TransientListMembershipsComponent>().Memberships.Add("Ebay_Ended"); var persistResult = await this._commerceCommander.PersistEntity(commerceContext, sellableItem).ConfigureAwait(false); var listRemoveResult = await this._commerceCommander.Command <ListCommander>() .RemoveItemsFromList(commerceContext, "Ebay_Listed", new List <String>() { sellableItem.Id }).ConfigureAwait(false); } } catch (Exception ex) { commerceContext.Logger.LogError($"Ebay.EndItemListing.Exception: Message={ex.Message}"); await commerceContext.AddMessage("Error", "Ebay.EndItemListing.Exception", new Object[] { ex }, ex.Message).ConfigureAwait(false); } 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(); }
protected override void bw_DoWork(object sender, DoWorkEventArgs e) { if (_isWorkerExecuted) { return; } // set the flag the this bw_DoWork has already called _isWorkerExecuted = true; var counter = 0; var service = new CredentialService(); var credential = (eBayCredentialDto)service.GetCredential(CredentialType.EBAY, _systemJob.SupportiveParameters); _itemFeeds = readProductItemFeeds(_systemJob.Parameters); // init the eBay API RequestHelper.SetCredentials(credential); // init the context var context = new ApiContext(); context.ApiCredential = RequestHelper.ApiCredential; context.SoapApiServerUrl = RequestHelper.ServiceUrl; setTotalItemsProcessed(_itemFeeds.Count); _logger.LogInfo(LogEntryType.eBayEndListing, string.Format("{0} items for eBay EndListing has started...", _itemFeeds.Count)); // iterate and submit end item feed to the eBay for (var i = 0; i < _itemFeeds.Count; i++) { var itemFeed = _itemFeeds[i]; var percentage = (((double)i + 1) / _itemFeeds.Count) * 100.00; Console.WriteLine(string.Format("{0:#0.00}% Sending feed 1 x 1 for eBay Product EndItem...", percentage)); // report the progress counter++; _bw.ReportProgress(counter); try { if (string.IsNullOrEmpty(itemFeed.ItemId)) { itemFeed.Status = Status.NOT_PROCESSED; itemFeed.Message = "ItemId is NULL or empty"; continue; } // create the end item request var apiCall = new EndItemCall(context); apiCall.EndItem(itemFeed.ItemId, EndReasonCodeType.NotAvailable); // let's set the eBay product ItemId to null _repo.UpdateeBayEndedItem(itemFeed.EisSKU); itemFeed.Status = Status.SUCCESS; // sleep for 1 second - throttle limit Thread.Sleep(1000); } catch (Exception ex) { Console.WriteLine("Error in submitting eBay product end listing {0}. Error Message: {1}", _itemFeeds[i].EisSKU, EisHelper.GetExceptionMessage(ex)); itemFeed.Status = Status.FAILED; itemFeed.Message = string.Format("Error in sending endlisting feed. Message: {0}", EisHelper.GetExceptionMessage(ex)); } } _logger.LogInfo(LogEntryType.eBayEndListing, string.Format("{0} items for eBay EndListing has finished!", _itemFeeds.Count)); }