public void RelistItemFull() { Assert.IsNotNull(TestData.EndedItem2); TestData.EndedItem2.ApplicationData = "this is new appilcation data which is specified by " + DateTime.Now.ToShortDateString(); RelistItemCall rviCall = new RelistItemCall(this.apiContext); ItemType item = TestData.EndedItem2; item.CategoryMappingAllowed = true; item.CategoryMappingAllowed = true; rviCall.Item = item; StringCollection fields = new StringCollection(); String field = "Item.ApplicationData"; fields.Add(field); rviCall.DeletedFieldList = fields; rviCall.Execute(); //check whether the call is success. Assert.IsTrue(rviCall.AbstractResponse.Ack == AckCodeType.Success || rviCall.AbstractResponse.Ack == AckCodeType.Warning, "do not success!"); Assert.IsNotNull(rviCall.FeeList, "the Fees is null"); /* * foreach(FeeType fee in rviCall.FeeList) * { * isTherePropertyNull=ReflectHelper.IsProperteValueNotNull(fee,out nullPropertyNums,out nullPropertyNames); * Assert.IsTrue(isTherePropertyNull,"there are" +nullPropertyNums.ToString()+ " properties value is null. (" +nullPropertyNames+ ")"); * }*/ Assert.IsNotNull(rviCall.ItemID, "the ItemID is null"); Assert.IsNotNull(rviCall.StartTime, "the StartTime is null"); //Assert.IsTrue(false,"NewItem:"+TestData.NewItem.ItemID+";EndedItem:"+TestData.EndedItem.ItemID+";NewItem2:"+TestData.NewItem2.ItemID+";EndedItem2:"+TestData.EndedItem2.ItemID); }
public void Relist(ApiContext apiContext, System.Diagnostics.EventLog eventLog = null) { ItemType itemType = ToItemType(); RelistItemCall apiCall = new RelistItemCall(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.RelistItem(itemType); RelistedItemID = itemType.ItemID; IsApiCallSuccess = true; } catch (Exception e) { if (eventLog != null) { eventLog.WriteEntry(string.Format("An error occured while relisting an item... ItemID={0}, Quantity={1}, Price={2}, Message={3}", itemType.ItemID, itemType.Quantity, itemType.StartPrice.Value, e.Message)); } IsApiCallSuccess = false; ApiCallErrorMessage = e.Message; } Console.WriteLine("item was relisted, result={0}", IsApiCallSuccess); }
public async Task <ItemType> RelistItem(CommerceContext commerceContext, SellableItem sellableItem) { using (var activity = CommandActivity.Start(commerceContext, this)) { //Instantiate the call wrapper class var apiCall = new RelistItemCall(await GetEbayContext(commerceContext).ConfigureAwait(false)); if (sellableItem.HasComponent <EbayItemComponent>()) { var ebayItemComponent = sellableItem.GetComponent <EbayItemComponent>(); try { var item = await PrepareItem(commerceContext, sellableItem); item.ItemID = ebayItemComponent.EbayId; //item.ListingDuration = "Days_" + 10; //Send the call to eBay and get the results var feeResult = apiCall.RelistItem(item, new StringCollection()); ebayItemComponent.EbayId = item.ItemID; ebayItemComponent.Status = "Listed"; sellableItem.GetComponent <TransientListMembershipsComponent>().Memberships.Add("Ebay_Listed"); foreach (var feeItem in feeResult) { var fee = feeItem as FeeType; ebayItemComponent.Fees.Add(new AwardedAdjustment { Adjustment = new Money(fee.Fee.currencyID.ToString(), System.Convert.ToDecimal(fee.Fee.Value)), AdjustmentType = "Fee", Name = fee.Name }); } ebayItemComponent.History.Add(new HistoryEntryModel { EventMessage = "Listing Relisted", EventUser = commerceContext.CurrentCsrId() }); return(item); } catch (Exception ex) { if (ex.Message.Contains("It looks like this listing is for an item you already have on eBay")) { var existingId = ex.Message.Substring(ex.Message.IndexOf("(") + 1); existingId = existingId.Substring(0, existingId.IndexOf(")")); await commerceContext.AddMessage("Warn", "Ebay.RelistItem", new Object[] { }, $"ExistingId:{existingId}-ComponentId:{ebayItemComponent.EbayId}").ConfigureAwait(false); ebayItemComponent.EbayId = existingId; ebayItemComponent.Status = "Listed"; sellableItem.GetComponent <TransientListMembershipsComponent>().Memberships.Add("Ebay_Listed"); } else { commerceContext.Logger.LogError($"Ebay.RelistItem.Exception: Message={ex.Message}"); await commerceContext.AddMessage("Error", "Ebay.RelistItem.Exception", new Object[] { ex }, ex.Message).ConfigureAwait(false); } } } else { commerceContext.Logger.LogError($"EbayCommand.RelistItem.Exception: Message=ebayCommand.RelistItem.NoEbayItemComponent"); await commerceContext.AddMessage("Error", "Ebay.RelistItem.Exception", new Object[] { }, "ebayCommand.RelistItem.NoEbayItemComponent").ConfigureAwait(false); } return(new ItemType()); } }
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 BtnRelistItem_Click(object sender, System.EventArgs e) { try { TxtItemId.Text = ""; TxtListingFee.Text = ""; BtnGetItem.Visible = false; // Populate the Item ItemType item = new ItemType(); item.ItemID = TxtRelistItemId.Text; if (TxtTitle.Text.Length > 0) { item.Title = this.TxtTitle.Text; } if (TxtDescription.Text.Length > 0) { item.Description = this.TxtDescription.Text; } if (CboDuration.SelectedIndex != -1) { item.ListingDuration = CboDuration.SelectedItem.ToString(); } CurrencyCodeType currencyCode = CurrencyUtility.GetDefaultCurrencyCodeType(Context.Site); if (TxtStartPrice.Text.Length > 0) { item.StartPrice = new AmountType(); item.StartPrice.currencyID = currencyCode; item.StartPrice.Value = Double.Parse(this.TxtStartPrice.Text, NumberStyles.Currency); } if (TxtReservePrice.Text.Length > 0) { item.ReservePrice = new AmountType(); item.ReservePrice.currencyID = currencyCode; item.ReservePrice.Value = Double.Parse(this.TxtReservePrice.Text, NumberStyles.Currency); } if (TxtBuyItNowPrice.Text.Length > 0) { item.BuyItNowPrice = new AmountType(); item.BuyItNowPrice.currencyID = currencyCode; item.BuyItNowPrice.Value = Double.Parse(this.TxtBuyItNowPrice.Text, NumberStyles.Currency); } if (CboEnableBestOffer.SelectedIndex != -1) { item.BestOfferDetails = new BestOfferDetailsType(); item.BestOfferDetails.BestOfferEnabled = Boolean.Parse(CboEnableBestOffer.SelectedItem.ToString()); } StringCollection deletedFields = new StringCollection(); //drop tag action if (ChkCategory2.Checked) { deletedFields.Add("item.secondaryCategory"); } if (ChkPayPalEmailAddress.Checked) { deletedFields.Add("item.payPalEmailAddress"); } if (ChkApplicationData.Checked) { deletedFields.Add("item.applicationData"); } RelistItemCall apicall = new RelistItemCall(Context); if (ListPictures.Items.Count > 0) { apicall.PictureFileList = new StringCollection(); item.PictureDetails = new PictureDetailsType(); item.PictureDetails.PhotoDisplay = (PhotoDisplayCodeType)Enum.Parse(typeof(PhotoDisplayCodeType), CboPicDisplay.SelectedItem.ToString()); } foreach (string pic in ListPictures.Items) { apicall.PictureFileList.Add(pic); } apicall.DeletedFieldList = deletedFields; FeeTypeCollection fees = apicall.RelistItem(item); TxtItemId.Text = item.ItemID; BtnGetItem.Visible = true; foreach (FeeType fee in fees) { if (fee.Name == "ListingFee") { TxtListingFee.Text = fee.Fee.Value.ToString(); break; } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void relistItems() { MySQLWrapper s = null; try { changeStatus("Initializing..."); addLogStatus("Initializing..."); if (!initialize()) { throw new Exception("ERROR : Unable to connect to eBay Service"); } s = new MySQLWrapper(); GetMyeBaySellingCall eBaySelling = new GetMyeBaySellingCall(context); PaginatedItemArrayType pArr = new PaginatedItemArrayType(); eBaySelling.UnsoldList = new ItemListCustomizationType(); eBaySelling.UnsoldList.Include = true; eBaySelling.GetMyeBaySelling(); ItemTypeCollection unsoldItems = new ItemTypeCollection(); pArr = eBaySelling.UnsoldListReturn; if (pArr != null) { string sku = ""; unsoldItems = pArr.ItemArray; RelistItemCall relistItem = new RelistItemCall(context); StringCollection deleteFieldList = new StringCollection(); ItemType tItem = new ItemType(); changeStatus("ReListing..."); addLogStatus("Total Unsold items : " + unsoldItems.Count); for (int i = 0; i < unsoldItems.Count; i++) { tItem.ItemID = unsoldItems[i].ItemID; sku = s.getSKU(unsoldItems[i].ItemID); if (sku != "") { relistItem.RelistItem(tItem); s.updateReListedItem(sku, relistItem.ItemID); s.addToLogs(sku, "Re-Listed with Item Id : " + relistItem.ItemID); addLogStatus("Item : " + unsoldItems[i].ItemID + " relisted with Item ID : " + relistItem.ItemID); } else { throw new Exception("ItemId : " + unsoldItems[i].ItemID + " not found in database!"); } } addLogStatus("Done!"); } else { addLogStatus("No Unsold Items!"); } } catch (Exception ex) { addLogStatus("ERROR : " + ex.Message); } finally { s.destroy(); destroy(); } }
void RelistEbayItem(string szItem, double dNewStartingPrice, double dNewBuyNowPrice, string szNewCategory, string szNumberofDays, string szListingType) { txtResults.Text = " "; ApiContext oContext = new ApiContext(); // set the dev,app,cert information oContext.ApiCredential.ApiAccount.Developer = ConfigurationManager.AppSettings["DevID"]; oContext.ApiCredential.ApiAccount.Application = ConfigurationManager.AppSettings["AppID"]; oContext.ApiCredential.ApiAccount.Certificate = ConfigurationManager.AppSettings["CertID"]; // set the AuthToken oContext.ApiCredential.eBayToken = ConfigurationManager.AppSettings["UserToken"]; // set the base SOAP URL .. use https://api.sandbox.ebay.com/wsapi for Sandbox calls //oContext.SoapApiServerUrl = "https://api.ebay.com/wsapi"; oContext.SoapApiServerUrl = ConfigurationManager.AppSettings["ServerUrl"]; // set the Site of the Context oContext.Site = eBay.Service.Core.Soap.SiteCodeType.US; // very important, let's setup the logging ApiLogManager oLogManager = new ApiLogManager(); oLogManager.ApiLoggerList.Add(new eBay.Service.Util.FileLogger("GetSellerList459NETSDK.log", true, true, true)); oLogManager.EnableLogging = true; oContext.ApiLogManager = oLogManager; // the WSDL Version used for this SDK build oContext.Version = "459"; // set the CallRetry properties CallRetry oCallRetry = new CallRetry(); // set the delay between each retry to 1 millisecond oCallRetry.DelayTime = 1; // set the maximum number of retries oCallRetry.MaximumRetries = 3; // set the error codes on which to retry StringCollection oErrorCodes = new StringCollection(); oErrorCodes.Add("10007"); // Internal error to the application ... general error oErrorCodes.Add("2"); // unsupported verb error oErrorCodes.Add("251"); // eBay Structured Exception ... general error oCallRetry.TriggerErrorCodes = oErrorCodes; // set the exception types on which to retry TypeCollection oExceptions = new TypeCollection(); oExceptions.Add(typeof(System.Net.ProtocolViolationException)); // the "Client found response content type of 'text/plain'" exception is of type SdkException, so let's add that to the list oExceptions.Add(typeof(SdkException)); oCallRetry.TriggerExceptions = oExceptions; // set CallRetry back to ApiContext oContext.CallRetry = oCallRetry; // set the timeout to 2 minutes oContext.Timeout = 120000; RelistItemCall oRelistItemCall = new RelistItemCall(oContext); // set the Version used in the call oRelistItemCall.Version = oContext.Version; // set the Site of the call oRelistItemCall.Site = oContext.Site; // enable the compression feature oRelistItemCall.EnableCompression = true; ItemType item = new ItemType(); item.ItemID = szItem; item.BuyItNowPrice = new AmountType(); item.BuyItNowPrice.Value = dNewBuyNowPrice; item.StartPrice = new AmountType(); item.StartPrice.Value = dNewStartingPrice; item.StartPrice.currencyID = CurrencyCodeType.USD; item.BuyItNowPrice.currencyID = CurrencyCodeType.USD; item.ListingType = new ListingTypeCodeType(); item.ListingType = ListingTypeCodeType.Chinese; item.DispatchTimeMax = 2; item.ReturnPolicy = new ReturnPolicyType(); item.ReturnPolicy.ReturnsAcceptedOption = "ReturnsAccepted"; //item.ReturnPolicy.ReturnsWithin = "Days_3"; item.ReturnPolicy.ShippingCostPaidBy = "Buyer"; item.ReturnPolicy.ReturnsWithinOption = "Days_3"; item.ReturnPolicy.RefundOption = "Exchange"; item.ReturnPolicy.Description = "Retund policy applies to item that are sold with Guaranteed or Warranty. Refund policy does not apply to anything that is being sold AS-IS with no warranty. Please read item description carefully. If you have any questions about warranty please do not hesitate to call us at 303-521-3869 or email us"; //item.ListingDuration =szNumberofDays; //item.ListingDuration = "Days_7"; try { oRelistItemCall.RelistItem(item); } catch (ApiException oApiEx) { // process exception ... pass to caller, implement retry logic here or in caller, whatever you want to do txtResults.Text = oApiEx.Message; return; } catch (SdkException oSdkEx) { // process exception ... pass to caller, implement retry logic here or in caller, whatever you want to do txtResults.Text = oSdkEx.Message; return; } catch (Exception oEx) { // process exception ... pass to caller, implement retry logic here or in caller, whatever you want to do txtResults.Text = oEx.Message; return; } DataGridViewRow theRow = dataGridView1.Rows[dataGridView1.SelectedRows[0].Index]; theRow.DefaultCellStyle.BackColor = Color.Red; Cursor.Current = Cursors.Default; }