private static void AddItem(ApiContext apiContext, ItemType item) { AddItemCall apiCall = new AddItemCall(apiContext); apiContext.ApiLogManager.RecordMessage("Beginning to call eBay, please wait...", MessageType.Information, MessageSeverity.Informational); try { FeeTypeCollection fees = apiCall.AddItem(item); apiContext.ApiLogManager.RecordMessage("Completed the call", MessageType.Information, MessageSeverity.Informational); apiContext.ApiLogManager.RecordMessage("The item was listed successfully", MessageType.Information, MessageSeverity.Informational); apiContext.ApiLogManager.RecordMessage("*************** BEGINNING OF THE LIST", MessageType.Information, MessageSeverity.Informational); foreach (FeeType i in fees) { apiContext.ApiLogManager.RecordMessage(String.Format("{0} = {1}", i.Name, i.Fee.Value), MessageType.Information, MessageSeverity.Informational); } apiContext.ApiLogManager.RecordMessage("*************** END OF THE LIST", MessageType.Information, MessageSeverity.Informational); } catch (Exception e) { apiContext.ApiLogManager.RecordMessage(e.Message, MessageType.Information, MessageSeverity.Informational); throw; } }
private void BtnVerifyAddItem_Click(object sender, System.EventArgs e) { try { TxtItemId.Text = ""; TxtListingFee.Text = ""; ItemType item = FillItem(); VerifyAddItemCall apicall = new VerifyAddItemCall(Context); // eBay Developer Technical Support Team(DTS) - Devanathan // Dated: 24-Feb-2016 9:33PM // Following If condition and for loop were commented to add a dummy image URL for bypass upload site hosting call for VerifyAddItem call /* * if (ListPictures.Items.Count > 0) * { * 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); * } */ // eBay Developer Technical Support Team(DTS) - Devanathan // Dated: 24-Feb-2016 9:33PM // Added the following four lines of code dummy image URL for bypass upload site hosting call for VerifyAddItem call item.PictureDetails = new PictureDetailsType(); item.PictureDetails.PhotoDisplaySpecified = true; item.PictureDetails.PhotoDisplay = PhotoDisplayCodeType.None; item.PictureDetails.PictureURL = new StringCollection(); item.PictureDetails.PictureURL.Add("http://i.ebayimg.com/00/s/MTAwMFgxMDAw/z/Oi4AAOSwzgRWzsz9/$_12.JPG?set_id=880000500F"); FeeTypeCollection fees = apicall.VerifyAddItem(item); 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 ReviseItem() { ItemType itemTest = TestData.NewItem; Assert.IsNotNull(itemTest); // ReviseItemCall rviCall = new ReviseItemCall(this.apiContext); ItemType item = new ItemType(); item.ItemID = itemTest.ItemID; item.StartPrice = new AmountType(); item.StartPrice.Value = 2.89; item.StartPrice.currencyID = CurrencyCodeType.USD; rviCall.Item = item; //verify fisrt rviCall.VerifyOnly = true; rviCall.Execute(); FeeTypeCollection fees = rviCall.FeeList; //check whether the call is success. Assert.IsTrue(rviCall.AbstractResponse.Ack == AckCodeType.Success || rviCall.AbstractResponse.Ack == AckCodeType.Warning, "do not success!"); // Call GetItem and then compare the startPrice. GetItemCall getItem1 = new GetItemCall(this.apiContext); DetailLevelCodeType[] detailLevels1 = new DetailLevelCodeType[] { DetailLevelCodeType.ReturnAll }; getItem1.DetailLevelList = new DetailLevelCodeTypeCollection(detailLevels1); ItemType returnedItem1 = getItem1.GetItem(itemTest.ItemID); Assert.AreNotEqual(returnedItem1.StartPrice.Value, item.StartPrice.Value); //revise rviCall.VerifyOnly = false; rviCall.Execute(); // Let's wait for the server to "digest" the data. System.Threading.Thread.Sleep(1000); //check whether the call is success. Assert.IsTrue(rviCall.AbstractResponse.Ack == AckCodeType.Success || rviCall.AbstractResponse.Ack == AckCodeType.Warning, "do not success!"); // 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(itemTest.ItemID); Assert.AreEqual(returnedItem2.StartPrice.Value, item.StartPrice.Value); // Update itemTest. TestData.NewItem = returnedItem2; }
static void Main(string[] args) { try { Console.WriteLine("+++++++++++++++++++++++++++++++++++++++"); Console.WriteLine("+ Welcome to eBay SDK for .Net Sample +"); Console.WriteLine("+ - ConsoleAddFixedPriceItem +"); Console.WriteLine("+++++++++++++++++++++++++++++++++++++++"); //[Step 1] Initialize eBay ApiContext object ApiContext apiContext = GetApiContext(); //[Step 2] Create a new ItemType object ItemType item = BuildItem(); //[Step 3] Create Call object and execute the Call AddFixedPriceItemCall apiCall = new AddFixedPriceItemCall(apiContext); Console.WriteLine("Begin to call eBay API, please wait ..."); FeeTypeCollection fees = apiCall.AddFixedPriceItem(item); Console.WriteLine("End to call eBay API, show call result ..."); Console.WriteLine(); //[Step 4] Handle the result returned Console.WriteLine("The item was listed successfully!"); double listingFee = 0.0; foreach (FeeType fee in fees) { if (fee.Name == "ListingFee") { listingFee = fee.Fee.Value; } } Console.WriteLine(String.Format("Listing fee is: {0}", listingFee)); Console.WriteLine(String.Format("Listed Item ID: {0}", item.ItemID)); } catch (Exception ex) { Console.WriteLine("Fail to list the item : " + ex.Message); } Console.WriteLine(); Console.WriteLine("Press any key to close the program."); Console.ReadKey(); }
private void BtnAddItem_Click(object sender, System.EventArgs e) { try { TxtItemId.Text = ""; TxtListingFee.Text = ""; ItemType item = FillItem(); AddItemCall apicall = new AddItemCall(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); } FeeTypeCollection fees = apicall.AddItem(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); } }
//Update an item on Ebay public void AddItemEbay(string sneakerID) { try { MessageBox.Show("Prepare to list the item " + SQLConnect.Select("Select ShoeName from Shoe where ShoeID = '" + sneakerID + "';") + " on Ebay"); //[Step 1] Initialize eBay ApiContext object ApiContext apiContext = GetApiContext(); //[Step 2] Create a new ItemType object ItemType item = BuildItem(sneakerID); //[Step 3] Create Call object and execute the Call AddItemCall apiCall = new AddItemCall(apiContext); //Note_MS("Begin to call eBay API, please wait ..."); FeeTypeCollection fees = new FeeTypeCollection(); // fees = apiCall.AddItem(item); //Note_MS("End to call eBay API, show call result ..."); //[Step 4] Handle the result returned MessageBox.Show("The item " + SQLConnect.Select("Select ShoeName from Shoe where ShoeID = '" + sneakerID + "';") + " was listed successfully!"); double listingFee = 0.0; foreach (FeeType fee in fees) { if (fee.Name == "ListingFee") { listingFee = fee.Fee.Value; } } //MessageBox.Show(String.Format("Listing fee is: {0}", listingFee)); //MessageBox.Show(String.Format("Listed Item ID: {0}", item.ItemID)); } catch (Exception ex) { //throw ex; MessageBox.Show("Fail to list the item : " + ex.StackTrace); } }
//list to eBay private void addItem() { try { // ApiContext apiContext = this.controller.ApiContext; AddItemCall api = new AddItemCall(apiContext); // Create the item ItemType item = new ItemType(); item.Site = apiContext.Site; item.Country = CountryCodeType.US; item.ListingType = (ListingTypeCodeType)Enum.Parse(typeof(ListingTypeCodeType), (this.listingTypeComboBox.SelectedItem as ListItem).Value); if (item.ListingType.Equals(ListingTypeCodeType.LeadGeneration)) { item.ListingSubtype2 = ListingSubtypeCodeType.ClassifiedAd; } item.Title = this.titleTextBox.Text; item.Description = this.descriptionTextBox.Text; item.Currency = this.getCurrencyType(item.Site); if (this.startPriceTextBox.Text != string.Empty) { item.StartPrice = new AmountType(); item.StartPrice.currencyID = item.Currency; item.StartPrice.Value = Convert.ToDouble(this.startPriceTextBox.Text); } if (this.binTextBox.Text != string.Empty) { item.BuyItNowPrice = new AmountType(); item.BuyItNowPrice.currencyID = item.Currency; item.BuyItNowPrice.Value = Convert.ToDouble(this.binTextBox.Text); } item.Quantity = Int32.Parse(this.quantityTextBox.Text); item.Location = this.locationTextBox.Text; item.ListingDuration = (this.durationComboBox.SelectedItem as ListItem).Value; ListingEnhancementsCodeTypeCollection enhancements = new ListingEnhancementsCodeTypeCollection(); enhancements.Add(ListingEnhancementsCodeType.BoldTitle); item.ListingEnhancement = enhancements; // Set Item Condtion ConditionEnabledCodeType condition = this.controller.CategoryFacade.ConditionEnabled; if (condition == ConditionEnabledCodeType.Enabled || condition == ConditionEnabledCodeType.Required) { ListItem li = this.conditionComboBox.SelectedItem as ListItem; int conditionId = int.Parse(li.Value); item.ConditionID = conditionId; } // Set Attributes property. item.PrimaryCategory = new CategoryType(); item.PrimaryCategory.CategoryID = this.controller.CategoryFacade.CategoryID; if (this.controller.CategoryFacade.ItemSpecificEnabled == ItemSpecificsEnabledCodeType.Enabled && this.controller.CategoryFacade.ItemSpecificsCache != null) { item.ItemSpecifics = this.controller.CategoryFacade.ItemSpecificsCache; } // Motor if (this.controller.ApiContext.Site == SiteCodeType.eBayMotors && this.subTitleTextBox.Text.Length > 0) { MotorAttributeHelper mh = new MotorAttributeHelper(item.AttributeSetArray[0]); mh.Subtitle = this.subTitleTextBox.Text; if (this.depositAmountTextBox.Text.Length > 0) { mh.DepositAmount = Decimal.Parse(this.depositAmountTextBox.Text); } } if ((this.shippingServiceComboBox.SelectedItem as ListItem).Value != "None") { //add shipping information item.ShippingDetails = getShippingDetails((this.shippingServiceComboBox.SelectedItem as ListItem).Value); } //add handling time item.DispatchTimeMax = 1; SellerProfilesType sellerProfile = new SellerProfilesType(); //add return policy if (this.controller.CategoryFacade.ReturnPolicyEnabled) { if (this.controller.CategoryFacade.ReturnPolicyProfileCache != null) { sellerProfile.SellerReturnProfile = this.controller.CategoryFacade.ReturnPolicyProfileCache; } else if (this.controller.CategoryFacade.ReturnPolicyCache != null) { item.ReturnPolicy = this.controller.CategoryFacade.ReturnPolicyCache; } } if (paymentProfileIdTextBox.Text != "" || paymentProfileNameTextBox.Text != "") { sellerProfile.SellerPaymentProfile = new SellerPaymentProfileType(); if (this.paymentProfileIdTextBox.Text != "") { sellerProfile.SellerPaymentProfile.PaymentProfileID = Int64.Parse(paymentProfileIdTextBox.Text); sellerProfile.SellerPaymentProfile.PaymentProfileIDSpecified = true; } sellerProfile.SellerPaymentProfile.PaymentProfileName = paymentProfileNameTextBox.Text; } if (shippingProfileIdTextBox.Text != "" || shippingProfileNameTextBox.Text != "") { sellerProfile.SellerShippingProfile = new SellerShippingProfileType(); if (this.shippingProfileIdTextBox.Text != "") { sellerProfile.SellerShippingProfile.ShippingProfileID = Int64.Parse(shippingProfileIdTextBox.Text); sellerProfile.SellerShippingProfile.ShippingProfileIDSpecified = true; } sellerProfile.SellerShippingProfile.ShippingProfileName = shippingProfileNameTextBox.Text; } //get shipping locations item.ShipToLocations = getShppingLocations(); //set payments setPaymentMethods(item); // set seller profiles item.SellerProfiles = sellerProfile; FeeTypeCollection fees = api.AddItem(item); viewItemInfo(item); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public async Task <ItemType> AddItem(CommerceContext commerceContext, SellableItem sellableItem) { using (var activity = CommandActivity.Start(commerceContext, this)) { var ebayItemComponent = sellableItem.GetComponent <EbayItemComponent>(); try { //Instantiate the call wrapper class var apiCall = new AddFixedPriceItemCall(await GetEbayContext(commerceContext).ConfigureAwait(false)); var item = await PrepareItem(commerceContext, sellableItem).ConfigureAwait(false); //Send the call to eBay and get the results FeeTypeCollection feeTypeCollection = apiCall.AddFixedPriceItem(item); foreach (var feeItem in feeTypeCollection) { 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 Added", EventUser = commerceContext.CurrentCsrId() }); ebayItemComponent.EbayId = item.ItemID; ebayItemComponent.Status = "Listed"; sellableItem.GetComponent <TransientListMembershipsComponent>().Memberships.Add("Ebay_Listed"); await commerceContext.AddMessage("Info", "EbayCommand.AddItem", new [] { item.ItemID }, $"Item Listed:{item.ItemID}").ConfigureAwait(false); 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", "EbayCommand.AddItem", new [] { existingId }, $"ExistingId:{existingId}-ComponentId:{ebayItemComponent.EbayId}").ConfigureAwait(false); ebayItemComponent.EbayId = existingId; ebayItemComponent.Status = "Listed"; ebayItemComponent.History.Add(new HistoryEntryModel { EventMessage = "Existing Listing Linked", EventUser = commerceContext.CurrentCsrId() }); sellableItem.GetComponent <TransientListMembershipsComponent>().Memberships.Add("Ebay_Listed"); } else { commerceContext.Logger.LogError($"Ebay.AddItem.Exception: Message={ex.Message}"); await commerceContext.AddMessage("Error", "Ebay.AddItem.Exception", new [] { ex }, ex.Message).ConfigureAwait(false); ebayItemComponent.History.Add(new HistoryEntryModel { EventMessage = $"Error-{ex.Message}", EventUser = commerceContext.CurrentCsrId() }); } } 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 static void AddItem(ApiContext apiContext) { AddItemCall apiCall = new AddItemCall(apiContext); apiContext.ApiLogManager.RecordMessage("Beginning to call eBay, please wait...", MessageType.Information, MessageSeverity.Informational); try { ItemType item = new ItemType(); item.ProductListingDetails = new ProductListingDetailsType() { UPC = "610214624192", DetailsURL = "http://www.google.com", IncludePrefilledItemInformation = true, IncludePrefilledItemInformationSpecified = true, IncludeStockPhotoURL = true, IncludeStockPhotoURLSpecified = true, StockPhotoURL = "http://i.ebayimg.com/02/!!eFW3!wBGM~$(KGrHqF,!lcE1F1IqYejBNUs+NoIJg~~_7.JPG?set_id=89040003C1" }; item.Title = "Dell Streak 7 16GB, Wi-Fi + 4G (T-Mobile), 7in - Black"; item.Description = "Cool smartphone"; item.ListingType = ListingTypeCodeType.FixedPriceItem; item.ConditionDisplayName = "New"; // listing price item.Currency = CurrencyCodeType.USD; item.StartPrice = new AmountType() { Value = (Double)161.83, currencyID = CurrencyCodeType.USD }; // listing duration item.ListingDuration = "Days_10"; // item location and country item.Location = "Farmington"; item.Country = CountryCodeType.US; // listing category item.PrimaryCategory = new CategoryType() { CategoryID = "171485" }; // item quantity item.Quantity = 300; // payment methods item.PaymentMethods = new BuyerPaymentMethodCodeTypeCollection( new BuyerPaymentMethodCodeType[] { BuyerPaymentMethodCodeType.PayPal } ); item.PayPalEmailAddress = "*****@*****.**"; // item condition, new item.ConditionID = 1000; // handling time is required item.DispatchTimeMax = 5; item.ShippingDetails = BuildShippingDetailsType(); // Return policy item.ReturnPolicy = new ReturnPolicyType(); item.ReturnPolicy.ReturnsAcceptedOption = "ReturnsAccepted"; FeeTypeCollection fees = apiCall.AddItem(item); apiContext.ApiLogManager.RecordMessage("Completed the call", MessageType.Information, MessageSeverity.Informational); apiContext.ApiLogManager.RecordMessage("The item was listed successfully", MessageType.Information, MessageSeverity.Informational); apiContext.ApiLogManager.RecordMessage("*************** BEGINNING OF THE LIST", MessageType.Information, MessageSeverity.Informational); foreach (FeeType i in fees) { apiContext.ApiLogManager.RecordMessage(String.Format("{0} = {1}", i.Name, i.Fee.Value), MessageType.Information, MessageSeverity.Informational); } apiContext.ApiLogManager.RecordMessage("*************** END OF THE LIST", MessageType.Information, MessageSeverity.Informational); } catch (Exception e) { apiContext.ApiLogManager.RecordMessage(e.Message, MessageType.Information, MessageSeverity.Informational); throw; } }
private void BtnReviseItem_Click(object sender, System.EventArgs e) { try { TxtItemId.Text = ""; TxtListingFee.Text = ""; BtnGetItem.Visible = false; // Populate the Item ItemType item = new ItemType(); item.ItemID = TxtReviseItemId.Text; CurrencyCodeType currencyCode = CurrencyUtility.GetDefaultCurrencyCodeType(Context.Site); 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(); } 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(); if (ChkPayPalEmailAddress.Checked) { deletedFields.Add("Item.payPalEmailAddress"); } if (ChkApplicationData.Checked) { deletedFields.Add("Item.applicationData"); } ReviseItemCall apicall = new ReviseItemCall(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; apicall.ReviseItem(item, deletedFields, false); TxtItemId.Text = item.ItemID; FeeTypeCollection fees = apicall.FeeList; 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); } }
private string addItem(MySQLWrapper.eBayItem ebayItem) { string listedItemId = "-1"; StringBuilder htmlDescription = new StringBuilder(); TextReader tr = new StreamReader("template.txt"); htmlDescription.Insert(0, tr.ReadToEnd()); tr.Close(); htmlDescription.Replace("{0}", ebayItem.Title); htmlDescription.Replace("{1}", ebayItem.Author); htmlDescription.Replace("{2}", ebayItem.Publisher); htmlDescription.Replace("{3}", ebayItem.publishDate); htmlDescription.Replace("{4}", ebayItem.Binding); htmlDescription.Replace("{5}", ebayItem.ISBN); if (ebayItem.UPC != "") { htmlDescription.Replace("{6}", "<b>UPC : </b>" + ebayItem.UPC + "</br>"); } else { htmlDescription.Replace("{6}", ""); } htmlDescription.Replace("{7}", ebayItem.Weight.ToString()); htmlDescription.Replace("{8}", ebayItem.Notes); htmlDescription.Replace("{9}", ebayItem.Description); ItemType item = new ItemType(); item.InventoryTrackingMethod = InventoryTrackingMethodCodeType.SKU; item.SKU = ebayItem.SKU; // Title max length 55 chars if (ebayItem.Title.Length > 55) { item.Title = ebayItem.Title.Substring(0, 54); } else { item.Title = ebayItem.Title; } if (ebayItem.Image != "") { item.PictureDetails = new PictureDetailsType(); item.PictureDetails.PictureURL.Add(ebayItem.Image); } item.Description = htmlDescription.ToString(); item.Currency = CurrencyCodeType.INR; item.ListingType = ListingTypeCodeType.FixedPriceItem; item.Quantity = ebayItem.Quantity; item.PostalCode = eBayLister.UserSettings.Default.itemPincode; item.Location = eBayLister.UserSettings.Default.itemCityState; item.Country = (CountryCodeType)Enum.Parse(typeof(CountryCodeType), eBayLister.UserSettings.Default.itemCountry, true); item.ListingDuration = getListingDuration(); item.PrimaryCategory = new CategoryType(); if (eBayLister.UserSettings.Default.ListInCategory.Equals("Other Books")) { item.PrimaryCategory.CategoryID = "268"; } else { item.PrimaryCategory.CategoryID = "37558"; } item.StartPrice = new AmountType(); item.StartPrice.currencyID = CurrencyCodeType.INR; item.StartPrice.Value = ebayItem.Price * Convert.ToDouble(eBayLister.UserSettings.Default.ConversionRate); item.PaymentMethods = new BuyerPaymentMethodCodeTypeCollection(); item.PaymentMethods.Add(BuyerPaymentMethodCodeType.PaisaPayAccepted); item.ShippingDetails = this.getShippingDetails(); item.ReturnPolicy = this.getReturnPolicy(); string handlingTime = eBayLister.UserSettings.Default.handlingTime; handlingTime = handlingTime.Remove(handlingTime.IndexOf(' ')); item.DispatchTimeMax = Convert.ToInt32(handlingTime); AttributeType conditionAttribute = new AttributeType(); conditionAttribute.attributeLabel = "Condition"; ValTypeCollection valueCollection = new ValTypeCollection(); ValType valueType = new ValType(); if (ebayItem.bookCondition.Contains("Used")) { valueType.ValueLiteral = "Used"; } else { valueType.ValueLiteral = "New"; } valueCollection.Add(valueType); conditionAttribute.Value = valueCollection; item.AttributeArray = new AttributeTypeCollection(); item.AttributeArray.Add(conditionAttribute); AddItemCall apiCall = new AddItemCall(context); FeeTypeCollection fees = apiCall.AddItem(item); foreach (FeeType fee in fees) { if (fee.Name == "ListingFee") { addLogStatus("Success! Listing Fee : " + Convert.ToString(fee.Fee.Value)); } } listedItemId = apiCall.ItemID; return(listedItemId); }
private bool verifyAddItem(MySQLWrapper.eBayItem ebayItem) { bool itemListing = false; TextReader tr = new StreamReader("template.txt"); StringBuilder htmlDescription = new StringBuilder(); htmlDescription.Insert(0, tr.ReadToEnd()); tr.Close(); htmlDescription.Replace("{0}", ebayItem.Title); htmlDescription.Replace("{1}", ebayItem.Author); htmlDescription.Replace("{2}", ebayItem.Publisher); htmlDescription.Replace("{3}", ebayItem.publishDate); htmlDescription.Replace("{4}", ebayItem.Binding); htmlDescription.Replace("{5}", ebayItem.ISBN); if (ebayItem.UPC != "") { htmlDescription.Replace("{6}", "<b>UPC : </b>" + ebayItem.UPC + "</br>"); } else { htmlDescription.Replace("{6}", ""); } htmlDescription.Replace("{7}", ebayItem.Weight.ToString()); htmlDescription.Replace("{8}", ebayItem.Notes); htmlDescription.Replace("{9}", ebayItem.Description); ItemType item = new ItemType(); item.SKU = ebayItem.SKU; item.Title = ebayItem.Title; item.Description = htmlDescription.ToString(); item.Currency = CurrencyCodeType.INR; item.Country = CountryCodeType.IN; item.ListingType = ListingTypeCodeType.FixedPriceItem; item.Quantity = ebayItem.Quantity; item.Location = eBayLister.UserSettings.Default.itemCityState; item.ListingDuration = getListingDuration(); item.PrimaryCategory = new CategoryType(); if (eBayLister.UserSettings.Default.ListInCategory.Equals("Other Books")) { item.PrimaryCategory.CategoryID = "268"; } else { item.PrimaryCategory.CategoryID = "37558"; } item.StartPrice = new AmountType(); item.StartPrice.currencyID = CurrencyCodeType.INR; item.StartPrice.Value = ebayItem.Price * Convert.ToDouble(eBayLister.UserSettings.Default.ConversionRate); item.PaymentMethods = new BuyerPaymentMethodCodeTypeCollection(); item.PaymentMethods.Add(BuyerPaymentMethodCodeType.PaisaPayAccepted); item.ShippingDetails = this.getShippingDetails(); item.ReturnPolicy = this.getReturnPolicy(); string handlingTime = eBayLister.UserSettings.Default.handlingTime; handlingTime = handlingTime.Remove(handlingTime.IndexOf(' ')); item.DispatchTimeMax = Convert.ToInt32(handlingTime); AttributeType conditionAttribute = new AttributeType(); conditionAttribute.attributeLabel = "Condition"; ValTypeCollection valueCollection = new ValTypeCollection(); ValType valueType = new ValType(); if (ebayItem.bookCondition.Contains("Used")) { valueType.ValueLiteral = "Used"; } else { valueType.ValueLiteral = "New"; } valueCollection.Add(valueType); conditionAttribute.Value = valueCollection; item.AttributeArray = new AttributeTypeCollection(); item.AttributeArray.Add(conditionAttribute); VerifyAddItemCall apiCall = new VerifyAddItemCall(context); try { FeeTypeCollection fees = apiCall.VerifyAddItem(item); foreach (FeeType fee in fees) { if (fee.Name == "ListingFee") { addLogStatus("Success! Listing Fee : " + Convert.ToString(fee.Fee.Value)); } } itemListing = true; } catch (ApiException ex) { itemListing = false; MessageBox.Show(ex.Message); Console.WriteLine(ex.Message); } return(itemListing); }