Beispiel #1
0
        /// <summary>
        /// The <b>EndItems</b> call is used to end up to 10 specified eBay listings before the date and time at which those listings would normally end per the listing duration.
        /// </summary>
        ///
        /// <param name="EndItemRequestContainerList">
        /// An <b>EndItemRequestContainer</b> container is required for each eBay listing that the seller plans to end through the <b>EndItems</b> call. Up to 10 eBay listings can be ended with one <b>EndItems</b> call.
        /// </param>
        ///
        public EndItemResponseContainerTypeCollection EndItems(EndItemRequestContainerTypeCollection EndItemRequestContainerList)
        {
            this.EndItemRequestContainerList = EndItemRequestContainerList;

            Execute();
            return(ApiResponse.EndItemResponseContainer);
        }
		public void EndItems()
		{
			Assert.IsNotNull(TestData.itemIds);
			Assert.IsTrue(TestData.itemIds.Count>0);

			EndItemsCall api = new EndItemsCall(this.apiContext);
			EndItemRequestContainerTypeCollection endItemsContainers=new EndItemRequestContainerTypeCollection();
			EndItemRequestContainerType container;
			foreach(String itemID in TestData.itemIds)
			{
				container=new EndItemRequestContainerType();
				container.ItemID=itemID;
				container.EndingReason=EndReasonCodeType.LostOrBroken;
				container.MessageID=Convert.ToString(endItemsContainers.Count+1);
				endItemsContainers.Add(container);
			}
			api.EndItemRequestContainerList=endItemsContainers;
			api.Execute();
			
			//check whether the call is success.
			Assert.IsTrue(api.ApiResponse.Ack==AckCodeType.Success || api.ApiResponse.Ack==AckCodeType.Warning,"do not success!");
			Assert.IsNotNull(api.EndItemResponseContainerList);
			Assert.IsTrue(api.EndItemResponseContainerList.Count==TestData.itemIds.Count);
			TestData.itemIds=null;
		}
        public void EndItems()
        {
            Assert.IsNotNull(TestData.itemIds);
            Assert.IsTrue(TestData.itemIds.Count > 0);

            EndItemsCall api = new EndItemsCall(this.apiContext);
            EndItemRequestContainerTypeCollection endItemsContainers = new EndItemRequestContainerTypeCollection();
            EndItemRequestContainerType           container;

            foreach (String itemID in TestData.itemIds)
            {
                container              = new EndItemRequestContainerType();
                container.ItemID       = itemID;
                container.EndingReason = EndReasonCodeType.LostOrBroken;
                container.MessageID    = Convert.ToString(endItemsContainers.Count + 1);
                endItemsContainers.Add(container);
            }
            api.EndItemRequestContainerList = endItemsContainers;
            api.Execute();

            //check whether the call is success.
            Assert.IsTrue(api.ApiResponse.Ack == AckCodeType.Success || api.ApiResponse.Ack == AckCodeType.Warning, "do not success!");
            Assert.IsNotNull(api.EndItemResponseContainerList);
            Assert.IsTrue(api.EndItemResponseContainerList.Count == TestData.itemIds.Count);
            TestData.itemIds = null;
        }
		/// <summary>
		/// Ends up to 10 specified item listings before the date and time at which it would normally end per the listing duration.&nbsp;<b>Also for Half.com</b>.
		/// </summary>
		/// 
		/// <param name="EndItemRequestContainerList">
		/// A single container for an end item request. Multiple containers should be used to end multiple items. Up to ten (10) containers can  be included
		/// per a given EndItems request.
		/// </param>
		///
		public EndItemResponseContainerTypeCollection EndItems(EndItemRequestContainerTypeCollection EndItemRequestContainerList)
		{
			this.EndItemRequestContainerList = EndItemRequestContainerList;

			Execute();
			return ApiResponse.EndItemResponseContainer;
		}
Beispiel #5
0
        public void SubmitProductEndItemFeeds(List <ItemFeed> itemFeeds, string submittedBy)
        {
            // let's take out the items which have no item id
            itemFeeds.RemoveAll(x => string.IsNullOrEmpty(x.ItemId));

            // determine if there's product feed to post
            if (!itemFeeds.Any())
            {
                _logger.LogWarning(LogEntryType.eBayEndListing, "No eBay products for end listing.");
                return;
            }

            // set the log file name
            _context.ApiLogManager.ApiLoggerList.Add(new FileLogger(string.Format(_logDirectory, MethodBase.GetCurrentMethod().Name), false, true, true));

            // we can specify up to 10 listing to end in single request
            var totalBatches  = Math.Ceiling(itemFeeds.Count / 10.0);
            var failedBatches = new List <ItemFeed>();

            for (var i = 0; i < totalBatches; i++)
            {
                // send product end listing by batches
                var batchedProducts = itemFeeds.Skip(i * 10).Take(10).ToList();
                var itemRequestList = new EndItemRequestContainerTypeCollection();

                try
                {
                    foreach (var product in batchedProducts)
                    {
                        var itemRequest = new EndItemRequestContainerType
                        {
                            MessageID             = product.EisSKU,
                            ItemID                = product.ItemId,
                            EndingReason          = EndReasonCodeType.NotAvailable,
                            EndingReasonSpecified = true,
                        };

                        itemRequestList.Add(itemRequest);
                    }

                    // create the api call and send the request
                    var apiCall  = new EndItemsCall(_context);
                    var response = apiCall.EndItems(itemRequestList);

                    // update the product eBay' ItemId to null
                    _logger.SeteBayItemIdToNull(batchedProducts);
                }
                catch (Exception ex)
                {
                    var description = string.Format("Batch: {0}/{1} - Error in submitting END_ITEM feed. \nError Message: {2} \nRequested by: {3}",
                                                    i + 1,
                                                    totalBatches,
                                                    EisHelper.GetExceptionMessage(ex),
                                                    submittedBy);
                    _logger.LogError(LogEntryType.eBayEndListing, description, ex.StackTrace);
                    Console.WriteLine(description);

                    // add the batched items to the list for resubmission 1 by 1
                    failedBatches.AddRange(batchedProducts);
                }
            }

            if (failedBatches.Any())
            {
                _logger.LogInfo(LogEntryType.eBayEndListing, string.Format("Starting sending END_ITEM feed for failed batches. Count: {0}", failedBatches.Count));

                // iterate and send each item
                foreach (var item in failedBatches)
                {
                    SubmitSingleProductEndItem(item, submittedBy);
                }

                _logger.LogInfo(LogEntryType.eBayEndListing, string.Format("Resubmission for {0} failed items for END_ITEM feed has been completed.", failedBatches.Count()));
            }
            else
            {
                _logger.LogInfo(LogEntryType.eBayEndListing, string.Format("Successfully posted product END_ITEM feed for {0} - {1} product items. \nRequested by: {2}",
                                                                           ChannelName, itemFeeds.Count, submittedBy));
            }
        }
Beispiel #6
0
        private void EndActiveAuctions(IEnumerable <Article> articles)
        {
            try
            {
                GetSellerListRequestType request = new GetSellerListRequestType();

                request.Version = "0.1";

                request.GranularityLevelSpecified = true;
                request.GranularityLevel          = GranularityLevelCodeType.Coarse;

                // Setting the date-range filter. This call required either EndTimeFrom & EndTimeTo pair OR StartTimeFrom & StartTimeTo pair
                // as a required input parameter.
                request.EndTimeFromSpecified = true;
                request.EndTimeFrom          = DateTime.Now.ToUniversalTime();

                request.EndTimeToSpecified = true;
                request.EndTimeTo          = DateTime.Now.AddDays(14).ToUniversalTime();

                // Setting the Pagination which is a required input parameter for GetSellerList call
                PaginationType pagination = new PaginationType();
                pagination.EntriesPerPageSpecified = true;
                pagination.EntriesPerPage          = 200;
                pagination.PageNumberSpecified     = true;
                pagination.PageNumber = 1;

                request.Pagination = pagination;

                GetSellerListResponseType response    = new GetSellerListResponseType();
                GetSellerListCall         listApiCall = new GetSellerListCall(apiContext);
                response = (GetSellerListResponseType)listApiCall.ExecuteRequest(request);

                if (response.Ack == AckCodeType.Success)
                {
                    EndItemsCall endApiCall = new EndItemsCall(apiContext);
                    EndItemRequestContainerTypeCollection endItems = new EndItemRequestContainerTypeCollection();

                    foreach (ItemType item in response.ItemArray)
                    {
                        EndItemRequestContainerType endItem = new EndItemRequestContainerType();
                        endItem.EndingReason          = EndReasonCodeType.NotAvailable;
                        endItem.EndingReasonSpecified = true;
                        endItem.MessageID             = item.ItemID;
                        endItem.ItemID = item.ItemID;
                        endItems.Add(endItem);
                    }

                    if (endItems.Count > 0)
                    {
                        EndItemResponseContainerTypeCollection endResponse = endApiCall.EndItems(endItems);

                        String errMsg = String.Empty;
                        foreach (EndItemResponseContainerType item in endResponse)
                        {
                            errMsg += EvaluateErrorMessages(item.Errors);
                        }

                        if (errMsg != String.Empty)
                        {
                            Assert.Fail(errMsg);
                        }
                    }
                }
                else
                {
                    String errMsg = EvaluateErrorMessages(response.Errors);
                    if (errMsg != String.Empty)
                    {
                        Assert.Fail(errMsg);
                    }
                }
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }