Exemplo n.º 1
0
        private FeedSubmissionInfo[] CancelFeedSubmissions(string[] FeedSubmissionIds, EFeedType[] FeedTypeList, DateTime SubmittedFromDate, DateTime SubmittedToDate)
        {
            this.Throttle();
            AmazonCredential             Credentials = this.GetCredential();
            MarketplaceWebServiceClient  Client      = this.GetClient(Credentials);
            CancelFeedSubmissionsRequest Request     = default(CancelFeedSubmissionsRequest);

            if (FeedSubmissionIds != null)
            {
                Request = new CancelFeedSubmissionsRequest()
                {
                    Merchant             = Credentials.MerchantID,
                    FeedSubmissionIdList = new IdList()
                    {
                        Id = FeedSubmissionIds.ToList()
                    }
                }
            }
            ;
            else if (FeedTypeList != null)
            {
                Request = new CancelFeedSubmissionsRequest()
                {
                    Merchant     = Credentials.MerchantID,
                    FeedTypeList = new TypeList()
                    {
                        Type = FeedTypeList.Select(Item => EnumStringHandler.GetEnumString <EFeedType>(Item)).ToList()
                    }
                }
            }
            ;
            else if (SubmittedFromDate != default(DateTime) && SubmittedFromDate != default(DateTime))
            {
                Request = new CancelFeedSubmissionsRequest()
                {
                    Merchant          = Credentials.MerchantID,
                    SubmittedFromDate = SubmittedFromDate,
                    SubmittedToDate   = SubmittedToDate
                }
            }
            ;
            else
            {
                throw new ArgumentException("Error, invalid arguments provided!");
            }
            CancelFeedSubmissionsResponse Response = Client.CancelFeedSubmissions(Request);

            if (Response.IsSetCancelFeedSubmissionsResult())
            {
                CancelFeedSubmissionsResult Result = Response.CancelFeedSubmissionsResult;
                if (Result.IsSetCount())
                {
                    if (Result.Count > 0)
                    {
                        Console.WriteLine($"Successfully canceled [{Result.Count}] feeds!");
                    }
                }

                if (Result.IsSetFeedSubmissionInfo())
                {
                    return(Result.FeedSubmissionInfo.ToArray());
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }