public void SubmitSingleProductReviseFeed(MarketplaceProductFeedDto productFeed, string submittedBy) { try { // create Amazon envelope object for the single eisProduct var envelope = RequestHelper.CreateSingleProductFeedEnvelope(productFeed, AmazonEnvelopeMessageOperationType.PartialUpdate); // parse the envelope into file var xmlFullName = XmlParser.WriteXmlToFile(envelope, "AmazonSingleProductReviseFeed"); var submitFeedController = new SubmitFeedController(_amazonClient, _logger, _credential.MarketplaceId, _credential.MerchantId, submittedBy); var streamResponse = submitFeedController.SubmitFeedAndGetResponse(xmlFullName, AmazonFeedType._POST_PRODUCT_DATA_); parsedResultStreamAndLogReport(streamResponse, AmazonEnvelopeMessageType.Product, submittedBy); _logger.LogInfo(LogEntryType.AmazonReviseItem, string.Format("{0} - Successfully posted single product revise feed for EisSKU \'{1}\'.\nRequested by: {2}", ChannelName, productFeed.EisSKU, submittedBy)); } catch (Exception ex) { var description = string.Format("{0} - Error in submitting single product revise feed for EisSKU \'{1}\'. \nError Message: {1} \nRequested by: {2}", ChannelName, EisHelper.GetExceptionMessage(ex), submittedBy, productFeed.EisSKU); _logger.Add(LogEntrySeverity.Error, LogEntryType.AmazonReviseItem, description, ex.StackTrace); } }
/// <summary> /// Create Amazon envelope for the single eisProduct feed /// </summary> /// <param name="productPostFeed">The EIS eisProduct object</param> /// <param name="operationType">The type of Amazon operation</param> /// <returns></returns> public static AmazonEnvelope CreateSingleProductFeedEnvelope(MarketplaceProductFeedDto productPostFeed, AmazonEnvelopeMessageOperationType operationType) { // create Amazon envelope object var amazonEnvelope = new AmazonEnvelope { Header = new Header { DocumentVersion = "1.01", MerchantIdentifier = MerchantId }, MessageType = AmazonEnvelopeMessageType.Product, PurgeAndReplace = false, PurgeAndReplaceSpecified = true }; // create the eisProduct envelope message var envelopeMessages = new List <AmazonEnvelopeMessage>(); var message = new AmazonEnvelopeMessage { MessageID = "1", OperationType = operationType, OperationTypeSpecified = true, Item = createProductModelForAmazon(productPostFeed) }; // convert to array and set its message envelopeMessages.Add(message); amazonEnvelope.Message = envelopeMessages.ToArray(); return(amazonEnvelope); }
public void Should_SubmitSingleProductListingFeed() { // arrange var provider = new eBayMarketplaceInventoryProvider(new LogService()); var products = new List <MarketplaceProductFeedDto>(); var credential = new eBayCredentialDto { Mode = "LIVE", DeveloperId = "d8e0124a-5a63-4ed9-837e-7007ab23dc97", ApplicationId = "MikeGert-EshopoIn-PRD-c99eeec0d-398c2471", CertificationId = "PRD-99eeec0d62f3-d4b0-452e-975e-3260", UserToken = "AgAAAA**AQAAAA**aAAAAA**+693Vw**nY+sHZ2PrBmdj6wVnY+sEZ2PrA2dj6AFkYunCpGAog6dj6x9nY+seQ**b1gDAA**AAMAAA**YLcBqF5Immyn9wi6om4+5CzSH1cTG1FaiVyYEN7Zj6++w6ccm8gvrnw06sUcHeGDPoYXaut5r5O1hVj3/uX+qbuibMSaO2Qd+K3rZkCeHy/cNRwsaOwx7ierR9bE5l6dITf/RS5VfFIZ9b4f4ARXmzycnuCuIveceOwPInSJOuFhALyCT6gkrgZ5N1iFDNN8KqaiIIusDNAUAmOfdHByCqeEv8E44ktkJGgmrvYSCMaLnjQYn5VYVFLeOQmhtQVwZWOUxnnUTOEvDUdBRiuHTrqVIUy7CP0LGKpuWeqay2xLSYLcgvcKTeZykHJErimP/suhOMHB9PlQAc+OIeVzsp95cusuMJNXOqb3XwPKzJHMa3zUiLdr17lIkkTe83uEXVhHv0DG5tWIp1+1JWQxCTbRInoEFN6wat+kijS2nwWjPDDPylI8ToYefc2jVdhEwkUwPFv0OXPmp4QQoNMh437f+1xwKi6p6KEP+Q21pr4krDsE0XLh36aHNmg0WTj3Wf1ehMTmeeLoExK+YG2TnPKBWIzXsd67Q2e1ZONe/efQZaUMbTy3UR2uqTPcZsWEpiShiCOppWGc3zCX7C/XgmMjgSWTMejhLyh8Y2eqf+xkXFfj3iQGuKr50kAp0TzpzBZG1LSJuLNBI+gxfXwteT8yX5NCHXX/MCWSIobL+Kb7Cq0r2x63oumUJkkCi2hXK5rckLbar+ukpR/1hpAxlOUckgs87qOimwN+p7z27LelPoohzTfJR3RJ9Ccq+fjg" }; var product = new MarketplaceProductFeedDto { UPC = "784034224341", EisSKU = "CJ10800000000891", Name = "K-Jewelry11® Women's Fashion Lime & Emerald Mixed Stone Silver Stretch Bracelet Gift For Her", Description = "K-Jewelry11® Women's Fashion Lime & Emerald Mixed Stone Silver Stretch", eBayProductFeed = new eBayProductFeed { Title = "Jewelry11® Women's Fashion Lime ", SubTitle = "Jewelry11® Women's Fashion Lime", CategoryId = 75040, Duration = "Days_5", Location = "11221", ListType = "FixedPriceItem" }, ImageUrls = new List <string> { "http://www.costumejewelry1.com/media/catalog/product/cache/1/small_image/125x/9df78eab33525d08d6e5fb8d27136e95/0/8/0805470051992.jpg" } }; products.Add(product); // act provider.Credential = credential; provider.SubmitSingleProductListingFeed(product, "KigwaTest"); // assert }
public void Should_Send_ReviseListing() { // Arrange EisInventoryContext _context = new EisInventoryContext(); var bcOrderInventoryProvider = new BigCommerceMarketplaceInventoryProvider(); bcOrderInventoryProvider.Credential = _credential; var eisSKU = ""; var productListFeed = new List <MarketplaceProductFeedDto>(); var product = _context.products.FirstOrDefault(o => o.EisSKU == eisSKU); var productBC = _context.productbigcommerces.FirstOrDefault(o => o.EisSKU == eisSKU); var productFeed = new MarketplaceProductFeedDto() { EisSKU = product.EisSKU, Name = product.Name, ItemWidth = product.ItemWidth, ItemHeight = product.ItemHeight, Description = product.Description, UPC = product.UPC }; productFeed.BigCommerceProductFeed = new BigCommerceProductFeed() { EisSKU = productBC.EisSKU, Price = productBC.Price, ProductsType = productBC.ProductsType.Value, Condition = productBC.Condition, Categories = productBC.Categories, CategoryId = productBC.CategoryId, ProductId = productBC.ProductId, Brand = productBC.Brand }; productListFeed.Add(productFeed); // Act bcOrderInventoryProvider.SubmitProductsReviseFeed(productListFeed, "Test"); // Assert }
private static string getParsedeBayDescriptionTemplate(MarketplaceProductFeedDto productFeed, string eBayDescriptionTemplate) { eBayDescriptionTemplate = eBayDescriptionTemplate.Replace("[Product.EisSKU]", productFeed.EisSKU); eBayDescriptionTemplate = eBayDescriptionTemplate.Replace("[Product.Name]", productFeed.Name); eBayDescriptionTemplate = eBayDescriptionTemplate.Replace("[Product.Description]", productFeed.Description); // replace the images if there's any for (var index = 0; index < 5 && index < productFeed.ImageUrls.Count; index++) { var imageUrl = productFeed.ImageUrls[index]; #if DEBUG imageUrl = "https://d1wj636tbzfwwf.cloudfront.net/static/images/studios/homepage/stories-brandon-1.jpg"; #endif eBayDescriptionTemplate = eBayDescriptionTemplate.Replace(string.Format("[Product.ImageURL{0}]", index + 1), imageUrl); } eBayDescriptionTemplate = eBayDescriptionTemplate.Replace("[ProducteBay.ItemId]", productFeed.eBayProductFeed.ItemId); eBayDescriptionTemplate = eBayDescriptionTemplate.Replace("[ProducteBay.Title]", productFeed.eBayProductFeed.Title); eBayDescriptionTemplate = eBayDescriptionTemplate.Replace("[ProducteBay.SubTitle]", productFeed.eBayProductFeed.SubTitle); eBayDescriptionTemplate = eBayDescriptionTemplate.Replace("[ProducteBay.Description]", productFeed.eBayProductFeed.Description); eBayDescriptionTemplate = eBayDescriptionTemplate.Replace("[Product.FactorQty]", productFeed.FactorQuantity.ToString()); return(eBayDescriptionTemplate); }
public void SubmitSingleProductReviseFeed(MarketplaceProductFeedDto productFeed, string submittedBy) { if (string.IsNullOrEmpty(productFeed.eBayProductFeed.ItemId)) { _logger.LogWarning(LogEntryType.eBayProductRevise, string.Format("Unable to sent product revise feed due no item id found for this product: {0}", productFeed.EisSKU)); return; } try { // set the log file name _context.ApiLogManager.ApiLoggerList.Add(new FileLogger(string.Format(_logDirectory, MethodBase.GetCurrentMethod().Name), false, true, true)); var apiCall = new ReviseFixedPriceItemCall(_context); // build item type var itemType = RequestHelper.CreateItemType(productFeed, _credential.eBayDescriptionTemplate); itemType.ItemID = productFeed.eBayProductFeed.ItemId; // send the request and get the fee collection var fees = apiCall.ReviseFixedPriceItem(itemType, new StringCollection()); var feeContainers = new List <ItemContainer>(); // parse the fees for revising the item if (fees != null) { foreach (FeeType fee in fees) { if (fee.Fee.Value <= 0) { continue; } var container = new ItemContainer { EisSKU = productFeed.EisSKU, ItemId = productFeed.eBayProductFeed.ItemId }; container.Fees.Add(new Fee { Name = fee.Name, Amount = fee.Fee.Value, CurrencyCode = fee.Fee.currencyID.ToString(), ActionFeedType = eBayConstants.ITEM_REVISED }); feeContainers.Add(container); } // insert the fees to database and don't update the product eBay item id logAndUpdateProductItemId(feeContainers, LogEntryType.eBayProductRevise, true); } } catch (Exception ex) { var description = string.Format("Error in submitting single product revise feed for {0} - {3}. \nError Message: {1} \nRequested by: {2}", ChannelName, EisHelper.GetExceptionMessage(ex), submittedBy, productFeed.EisSKU); _logger.Add(LogEntrySeverity.Error, LogEntryType.eBayProductRevise, description, ex.StackTrace); } }
public void SubmitSingleProductListingFeed(MarketplaceProductFeedDto productFeed, string submittedBy) { if (productFeed.eBayProductFeed == null || productFeed.eBayProductFeed.CategoryId == null) { _logger.LogWarning(LogEntryType.eBayProductListing, string.Format("Unable to create listing for this product - {0} due to no eBay details or category id.", productFeed.EisSKU)); return; } if (!string.IsNullOrEmpty(productFeed.eBayProductFeed.ItemId)) { _logger.LogWarning(LogEntryType.eBayProductListing, string.Format("The EIS product {0} is already listed in eBay. Please do the product revise feed instead!", productFeed.EisSKU)); return; } try { // set the log file name _context.ApiLogManager.ApiLoggerList.Add(new FileLogger(string.Format(_logDirectory, MethodBase.GetCurrentMethod().Name), false, true, true)); var apiCall = new AddItemCall(_context); // parse the product feed for eBay item var itemType = RequestHelper.CreateItemType(productFeed, _credential.eBayDescriptionTemplate); // send the request and get the fee collection var fees = apiCall.AddItem(itemType); var container = new ItemContainer { EisSKU = productFeed.EisSKU, ItemId = itemType.ItemID }; foreach (FeeType fee in fees) { if (fee.Fee.Value <= 0) { continue; } container.Fees.Add(new Fee { Name = fee.Name, Amount = fee.Fee.Value, CurrencyCode = fee.Fee.currencyID.ToString(), ActionFeedType = eBayConstants.ITEM_ADDED }); } logAndUpdateProductItemId(new List <ItemContainer> { container }, LogEntryType.eBayProductListing); } catch (Exception ex) { var description = string.Format("Error in submitting single product feed for {0} - {3}. \nError Message: {1} \nRequested by: {2}", ChannelName, EisHelper.GetExceptionMessage(ex), submittedBy, productFeed.EisSKU); _logger.Add(LogEntrySeverity.Error, LogEntryType.eBayProductListing, description, ex.StackTrace); } }
private static AmazonWebServiceModels.Product createProductModelForAmazon(MarketplaceProductFeedDto productPost) { var product = new AmazonWebServiceModels.Product(); try { product.SKU = productPost.EisSKU; product.LaunchDate = DateTime.UtcNow; product.ReleaseDate = DateTime.UtcNow; product.StandardProductID = new StandardProductID { Type = StandardProductIDType.ASIN, Value = productPost.AmazonProductFeed.ASIN }; product.ProductTaxCode = productPost.AmazonProductFeed.TaxCode; product.Condition = new ConditionInfo { ConditionType = parsedCondition(productPost.AmazonProductFeed.Condition), ConditionNote = productPost.AmazonProductFeed.ConditionNote }; if ((productPost.AmazonProductFeed.PackageQty ?? 0) > 0) { product.ItemPackageQuantity = productPost.AmazonProductFeed.PackageQty.ToString(); } if ((productPost.AmazonProductFeed.NumOfItems ?? 0) > 0) { product.NumberOfItems = productPost.AmazonProductFeed.NumOfItems.ToString(); } // create the instance for each category and sub-category var mainCategoryObj = _magicallyCreateInstance(productPost.ProductType.AmazonMainClassName); var subCategoryObj = _magicallyCreateInstance(productPost.ProductType.AmazonSubClassName); var productTypeObj = _magicallyCreateProductType(productPost.ProductType.AmazonMainClassName, subCategoryObj); // set the eisProduct type for main category _setProductTypeForMainCategory(mainCategoryObj, productTypeObj); product.ProductData = new ProductProductData { Item = mainCategoryObj, }; product.DescriptionData = new ProductDescriptionData { Title = productPost.Name, Description = productPost.Description, IsGiftWrapAvailable = productPost.AmazonProductFeed.IsAllowGiftWrap, IsGiftWrapAvailableSpecified = true, IsGiftMessageAvailable = productPost.AmazonProductFeed.IsAllowGiftMsg, IsGiftMessageAvailableSpecified = true, }; if (!string.IsNullOrEmpty(productPost.Brand)) { product.DescriptionData.Brand = productPost.Brand; } if ((productPost.AmazonProductFeed.MaxOrderQty ?? 0) > 0) { product.DescriptionData.MaxOrderQuantity = productPost.AmazonProductFeed.MaxOrderQty.ToString(); } // set the product's package dimensions if (((productPost.PkgLength ?? 0) != 0) || ((productPost.PkgWidth ?? 0) != 0) || ((productPost.PkgHeight ?? 0) != 0)) { product.DescriptionData.PackageDimensions = new Dimensions() { Length = new LengthDimension { unitOfMeasure = parsedUnitOfLengthMeasurement(productPost.PkgLenghtUnit), Value = productPost.PkgLength ?? 0 }, Width = new LengthDimension { unitOfMeasure = parsedUnitOfLengthMeasurement(productPost.PkgLenghtUnit), Value = productPost.PkgWidth ?? 0 }, Height = new LengthDimension { unitOfMeasure = parsedUnitOfLengthMeasurement(productPost.PkgLenghtUnit), Value = productPost.PkgHeight ?? 0 } }; } // set the product's package weight if ((productPost.PkgWeight ?? 0) != 0) { product.DescriptionData.PackageWeight = new PositiveNonZeroWeightDimension { unitOfMeasure = parsedUnitOfWeightMeasurement(productPost.PkgWeightUnit), Value = productPost.PkgWeight ?? 1 }; } // set the product's item dimensions if (((productPost.ItemLength ?? 0) != 0) || ((productPost.ItemWidth ?? 0) != 0) || ((productPost.ItemHeight ?? 0) != 0)) { product.DescriptionData.ItemDimensions = new Dimensions() { Length = new LengthDimension { unitOfMeasure = parsedUnitOfLengthMeasurement(productPost.ItemLenghtUnit), Value = productPost.ItemLength ?? 0 }, Width = new LengthDimension { unitOfMeasure = parsedUnitOfLengthMeasurement(productPost.ItemLenghtUnit), Value = productPost.ItemWidth ?? 0 }, Height = new LengthDimension { unitOfMeasure = parsedUnitOfLengthMeasurement(productPost.ItemLenghtUnit), Value = productPost.ItemHeight ?? 0 } }; } // set the product's item weight ? if ((productPost.ItemWeight ?? 0) != 0) { product.DescriptionData.ShippingWeight = new PositiveWeightDimension { unitOfMeasure = parsedUnitOfWeightMeasurement(productPost.ItemWeightUnit), Value = productPost.ItemWeight ?? 1 }; } } catch (Exception ex) { throw ex; } return(product); }
public static ItemType CreateItemType(MarketplaceProductFeedDto productFeed, string eBayDescriptionTemplate) { try { var item = new ItemType(); // set-up the defaults item.Currency = CurrencyCodeType.USD; item.CurrencySpecified = true; item.Country = CountryCodeType.US; item.CountrySpecified = true; item.PaymentMethods = new BuyerPaymentMethodCodeTypeCollection(); item.PaymentMethods.AddRange(new BuyerPaymentMethodCodeType[] { BuyerPaymentMethodCodeType.PayPal }); item.PayPalEmailAddress = _payPalEmailAddress; item.AutoPay = productFeed.eBayProductFeed.IsRequireAutoPayment; item.RegionID = "0"; // set the specified values from the passed objects item.SKU = productFeed.EisSKU; item.Title = productFeed.eBayProductFeed.Title; item.InventoryTrackingMethod = InventoryTrackingMethodCodeType.SKU; item.InventoryTrackingMethodSpecified = true; // init the item description from the template if (!string.IsNullOrEmpty(eBayDescriptionTemplate)) { item.Description = getParsedeBayDescriptionTemplate(productFeed, eBayDescriptionTemplate); } else { item.Description = productFeed.eBayProductFeed.Description; } if (!string.IsNullOrEmpty(productFeed.eBayProductFeed.SubTitle)) { item.SubTitle = productFeed.eBayProductFeed.SubTitle; } // set the product quantity if its more than ZERO if (productFeed.eBayInventoryFeed.InventoryQuantity > 0) { item.Quantity = productFeed.eBayInventoryFeed.InventoryQuantity; item.QuantitySpecified = true; } // set the product's category item.PrimaryCategory = new CategoryType(); item.PrimaryCategory.CategoryID = productFeed.eBayProductFeed.CategoryId != null ? productFeed.eBayProductFeed.CategoryId.ToString() : productFeed.ProductType.EbaySubCategoryCode; // set the product's condion item.ConditionID = productFeed.eBayProductFeed.Condition_; // 1000 - New, 3000 - Used item.ConditionIDSpecified = true; item.Location = productFeed.eBayProductFeed.Location; // should be the postal code if (!string.IsNullOrEmpty(productFeed.UPC)) { item.ProductListingDetails = new ProductListingDetailsType { UPC = productFeed.UPC, }; } // set the listing type for this product item.ListingType = EnumHelper.ParseEnum <ListingTypeCodeType>(productFeed.eBayProductFeed.ListType); // should we explicitly set to FixedPriceItem item.ListingTypeSpecified = true; item.ListingDuration = productFeed.eBayProductFeed.Duration; // set its start and reserver price for the Auction listing type if (productFeed.eBayProductFeed.ListType == ListingTypeCodeType.Auction.ToString()) { item.StartPrice = new AmountType { currencyID = CurrencyCodeType.USD, Value = (double)productFeed.eBayInventoryFeed.StartPrice }; item.BuyItNowPrice = new AmountType { currencyID = CurrencyCodeType.USD, Value = (double)productFeed.eBayInventoryFeed.BinPrice }; item.ReservePrice = new AmountType { currencyID = CurrencyCodeType.USD, Value = (double)productFeed.eBayInventoryFeed.ReservePrice }; } else { // otherwise,it's a fixed price item, we will use the BinPrice/BuyItNowPrice for its StartPrice item.StartPrice = new AmountType { currencyID = CurrencyCodeType.USD, Value = (double)productFeed.eBayInventoryFeed.BinPrice }; } // add the product images if (productFeed.ImageUrls.Any()) { // set the picture details type item.PictureDetails = new PictureDetailsType(); item.PictureDetails.GalleryType = GalleryTypeCodeType.None; item.PictureDetails.PictureURL = new StringCollection(); for (var index = 0; index < productFeed.ImageUrls.Count; index++) { var imageUrl = productFeed.ImageUrls[index]; #if DEBUG imageUrl = "https://d1wj636tbzfwwf.cloudfront.net/static/images/studios/homepage/stories-brandon-1.jpg"; #endif item.PictureDetails.PictureURL.Add(imageUrl); } } // add the product enhancements var enhancements = new ListingEnhancementsCodeTypeCollection(); if (productFeed.eBayProductFeed.IsBoldTitle) { enhancements.Add(ListingEnhancementsCodeType.BoldTitle); } if (enhancements.Count > 0) { item.ListingEnhancement = enhancements; } item.DispatchTimeMax = productFeed.eBayProductFeed.DispatchTimeMax; // add the item shipping information item.ShippingDetails = createShippingDetails(productFeed.eBayProductFeed); // add the policy for the item item.ReturnPolicy = createPolicyForUS(productFeed.eBayProductFeed); return(item); } catch (Exception) { return(null); } }