public List<Order> ListCreatedOrders(GetUpdatedOrdersRequest updatedOrdersRequest)
        {
            var request = new ListOrdersRequest
            {
                SellerId = _amazonSellerSettings.SellerId,
                MarketplaceId = new MarketplaceIdList().WithId(_amazonSellerSettings.MarketplaceId),
                CreatedAfter = updatedOrdersRequest.LastUpdatedAfter,
                CreatedBefore = updatedOrdersRequest.LastUpdatedBefore,
            };

            return ListOrders(request);
        }
Beispiel #2
1
        /// <summary>
        /// Fetches all orders created in the given time period and processes them locally.        
        /// <param name="startTime">The starting time period of orders to fetch.</param>
        /// <param name="endTime">The ending time period of orders to fetch.</param>
        public void FetchOrders(DateTime time, OrderDateType type)
        {
            ListOrdersRequest request = new ListOrdersRequest();
            if(type == OrderDateType.New)
                request.CreatedAfter = time;
            else
                request.LastUpdatedAfter = time;

            request.SellerId = mwsSellerId;
            request.MarketplaceId = new MarketplaceIdList();
            request.MarketplaceId.Id = new List<string>();
            foreach (string marketplaceId in mwsMarketplaceIdList)
            {
                request.MarketplaceId.Id.Add(marketplaceId);
            }

            List<Order> orderList = new List<Order>();
            ListOrdersResponse response = null;
            OrderFetcher.InvokeRetriable(LIST_ORDERS_DEFAULT_THROTTLE_LIMIT, delegate()
            {
                response = mwsService.ListOrders(request);
                ProcessOrders(response.ListOrdersResult.Orders.Order);
            });

            while (!string.IsNullOrEmpty(response.ListOrdersResult.NextToken))
            {
                // If NextToken is set, continue looping through the orders.
                ListOrdersByNextTokenRequest nextRequest = new ListOrdersByNextTokenRequest();
                nextRequest.NextToken = response.ListOrdersResult.NextToken;
                nextRequest.SellerId = mwsSellerId;

                ListOrdersByNextTokenResponse nextResponse = null;
                OrderFetcher.InvokeRetriable(LIST_ORDERS_DEFAULT_THROTTLE_LIMIT, delegate()
                {
                    nextResponse = mwsService.ListOrdersByNextToken(nextRequest);
                    ProcessOrders(nextResponse.ListOrdersByNextTokenResult.Orders.Order);
                });
            }
        }
        private List<Order> ListOrders(ListOrdersRequest request)
        {
            _amazonLogService.Add(AmazonLogType.Api, AmazonLogStatus.Stage, null, null, AmazonApiSection.Orders,
                   "ListOrders", null, null, null, "Listing Amazon Orders");
            _amazonAnalyticsService.TrackNewApiCall(AmazonApiSection.Orders, "ListOrders");
            var result = _marketplaceWebServiceOrders.ListOrders(request);
            var orders = new List<Order>();
            if (result == null || !result.IsSetListOrdersResult())
                return orders;
            if (result.ListOrdersResult.IsSetOrders() && result.ListOrdersResult.Orders.IsSetOrder())
                orders.AddRange(result.ListOrdersResult.Orders.Order);

            var nextToken = result.ListOrdersResult.NextToken;
            while (!string.IsNullOrWhiteSpace(nextToken))
            {
                _amazonLogService.Add(AmazonLogType.Api, AmazonLogStatus.Stage, null, null, AmazonApiSection.Orders,
                   "ListOrdersByNextToken", null, null, null, "Listing Amazon Orders (Next Token)");
                _amazonAnalyticsService.TrackNewApiCall(AmazonApiSection.Orders, "ListOrdersByNextToken");
                var response = _marketplaceWebServiceOrders.ListOrdersByNextToken(new ListOrdersByNextTokenRequest
                                                                                      {
                                                                                          SellerId = _amazonSellerSettings.SellerId,
                                                                                          NextToken = result.ListOrdersResult.NextToken
                                                                                      });
                if (response != null && response.IsSetListOrdersByNextTokenResult())
                {
                    if (response.ListOrdersByNextTokenResult.IsSetOrders() && response.ListOrdersByNextTokenResult.Orders.IsSetOrder())
                        orders.AddRange(response.ListOrdersByNextTokenResult.Orders.Order);
                    nextToken = response.ListOrdersByNextTokenResult.NextToken;
                }
                else nextToken = null;
            }

            return orders;
        }
        public IEnumerable<Order> ListUpdatedOrders(GetUpdatedOrdersRequest newOrdersRequest)
        {
            var request = new ListOrdersRequest
            {
                SellerId = _amazonSellerSettings.SellerId,
                MarketplaceId = new MarketplaceIdList().WithId(_amazonSellerSettings.MarketplaceId),
                LastUpdatedAfter = newOrdersRequest.LastUpdatedAfter,
                LastUpdatedBefore = newOrdersRequest.LastUpdatedBefore,
            };

            return ListOrders(request);
        }
        /**
         * Samples for Marketplace Web Service Orders functionality
         */
        public static void Main(string[] args)
        {
            Console.WriteLine("===========================================");
            Console.WriteLine("Welcome to Marketplace Web Service Orders Samples!");
            Console.WriteLine("===========================================");

            Console.WriteLine("To get started:");
            Console.WriteLine("===========================================");
            Console.WriteLine("  - Fill in your MWS credentials");
            Console.WriteLine("  - Uncomment sample you're interested in trying");
            Console.WriteLine("  - Set request with desired parameters");
            Console.WriteLine("  - Hit F5 to run!");
            Console.WriteLine();

            Console.WriteLine("===========================================");
            Console.WriteLine("Samples Output");
            Console.WriteLine("===========================================");
            Console.WriteLine();

            /************************************************************************
             * Access Key ID and Secret Access Key ID
             ***********************************************************************/
            String accessKeyId = "AKIAIZAIBEDEFFEWL3OA";
            String secretAccessKey = "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";
            String merchantId = "A3FFNVBB2U6OUI";
            String marketplaceId = "ATVPDKIKX0DER";

            /************************************************************************
             * The application name and version are included in each MWS call's
             * HTTP User-Agent field.
             ***********************************************************************/
            const string applicationName = "<Your Application Name>";
            const string applicationVersion = "<Your Application Version>";

            /************************************************************************
            * Uncomment to try advanced configuration options. Available options are:
            *
            *  - Signature Version
            *  - Proxy Host and Proxy Port
            *  - Service URL
            *  - User Agent String to be sent to Marketplace Web Service Orders  service
            *
            ***********************************************************************/
            MarketplaceWebServiceOrdersConfig config = new MarketplaceWebServiceOrdersConfig();
            //
            // IMPORTANT: Uncomment out the appropiate line for the country you wish
            // to sell in:
            //
            // United States:
            config.ServiceURL = "https://mws.amazonservices.com/Orders/2011-01-01";
            //
            // Canada:
            // config.ServiceURL = "https://mws.amazonservices.ca/Orders/2011-01-01";
            //
            // United Kingdom:
            // config.ServiceURL = "https://mws.amazonservices.co.uk/Orders/2011-01-01";
            //
            // Germany:
            // config.ServiceURL = "https://mws.amazonservices.de/Orders/2011-01-01";
            //
            // France:
            // config.ServiceURL = "https://mws.amazonservices.fr/Orders/2011-01-01";
            //
            // Italy:
            // config.ServiceURL = "https://mws.amazonservices.it/Orders/2011-01-01";
            //
            // Japan:
            // config.ServiceURL = "https://mws.amazonservices.jp/Orders/2011-01-01";
            //
            // China:
            // config.ServiceURL = "https://mws.amazonservices.com.cn/Orders/2011-01-01";
            //

            /************************************************************************
            * Instantiate  Implementation of Marketplace Web Service Orders
            ***********************************************************************/
            MarketplaceWebServiceOrders service = new MarketplaceWebServiceOrdersClient(
                applicationName, applicationVersion, accessKeyId, secretAccessKey, config);

            /************************************************************************
            * Uncomment to try out Mock Service that simulates Marketplace Web Service Orders
            * responses without calling Marketplace Web Service Orders  service.
            *
            * Responses are loaded from local XML files. You can tweak XML files to
            * experiment with various outputs during development
            *
            * XML files available under MarketplaceWebServiceOrders\Mock tree
            *
            ***********************************************************************/
            // MarketplaceWebServiceOrders service = new MarketplaceWebServiceOrdersMock();

            /************************************************************************
            * Uncomment to invoke List Orders By Next Token Action
            ***********************************************************************/
            //ListOrdersByNextTokenRequest request = new ListOrdersByNextTokenRequest();
            //// @TODO: set request parameters here
            //request.SellerId = merchantId;
            //request.NextToken = "NEXT_TOKEN";
            //ListOrdersByNextTokenSample.InvokeListOrdersByNextToken(service, request);

            /************************************************************************
            * Uncomment to invoke List Order Items By Next Token Action
            ***********************************************************************/
            //ListOrderItemsByNextTokenRequest request = new ListOrderItemsByNextTokenRequest();
            //// @TODO: set request parameters here
            //request.SellerId = merchantId;
            //request.NextToken = "NEXT_TOKEN";
            //ListOrderItemsByNextTokenSample.InvokeListOrderItemsByNextToken(service, request);

            /************************************************************************
            * Uncomment to invoke Get Order Action
            ***********************************************************************/
            //GetOrderRequest request = new GetOrderRequest();
            //// @TODO: set request parameters here
            //request.SellerId = merchantId;
            //request.AmazonOrderId = new OrderIdList();
            //request.AmazonOrderId.Id = new List<string>(new string[] { "ORDER_1", "ORDER_2" });
            //GetOrderSample.InvokeGetOrder(service, request);

            /************************************************************************
            * Uncomment to invoke List Order Items Action
            ***********************************************************************/
            //ListOrderItemsRequest request = new ListOrderItemsRequest();
            //// @TODO: set request parameters here
            //request.SellerId = merchantId;
            //request.AmazonOrderId = "ORDER_ID";
            // ListOrderItemsSample.InvokeListOrderItems(service, request);

            /************************************************************************
            * Uncomment to invoke List Orders Action
            ***********************************************************************/
            ListOrdersRequest request = new ListOrdersRequest();
            // @TODO: set request parameters here
            request.CreatedAfter = DateTime.Now.AddDays(-1);
            request.MarketplaceId = new MarketplaceIdList();
            request.MarketplaceId.Id = new List<string>(new string[] { marketplaceId });
            request.SellerId = merchantId;
            ListOrdersSample.InvokeListOrders(service, request);

            /************************************************************************
            * Uncomment to invoke Get Service Status Action
            ***********************************************************************/
            // GetServiceStatusRequest request = new GetServiceStatusRequest();
            // request.SellerId = merchantId;
            //// @TODO: set request parameters here
            // GetServiceStatusSample.InvokeGetServiceStatus(service, request);

            /************************************************************************
            * Uncomment to invoke OrderFetcher Sample
            ***********************************************************************/
            // OrderFetcherSample.InvokeOrderFetcherSample(service, merchantId, new string [] { marketplaceId } );

            /************************************************************************
            * Uncomment to invoke FetchOrderUpdatesJob Sample - A sample
            * implementation of continuously retrieving orders over a given
            * time interval.
            ***********************************************************************/
            // FetchOrderUpdatesJob.InvokeOrderFetcherSample(service, merchantId, new string[] { marketplaceId });

            Console.WriteLine();
            Console.WriteLine("===========================================");
            Console.WriteLine("End of output. You can close this window");
            Console.WriteLine("===========================================");

            System.Threading.Thread.Sleep(50000);
        }
 public ListOrdersResponse InvokeListOrders()
 {
     // Create a request.
     ListOrdersRequest request = new ListOrdersRequest();
     string sellerId = "A2J3O0BJ14F3AS";
     request.SellerId = sellerId;
     string mwsAuthToken = "example";
     request.MWSAuthToken = mwsAuthToken;
     DateTime createdAfter = new DateTime();
     request.CreatedAfter = DateTime.Now.AddMonths(-1);
     DateTime createdBefore = new DateTime();
     request.CreatedBefore = DateTime.Now.AddMinutes(-5);
     DateTime lastUpdatedAfter = new DateTime();
     //request.LastUpdatedAfter = lastUpdatedAfter;
     DateTime lastUpdatedBefore = new DateTime();
     //request.LastUpdatedBefore = lastUpdatedBefore;
     List<string> orderStatus = new List<string>();
     //request.OrderStatus = orderStatus;
     List<string> marketplaceId = new List<string>();
     marketplaceId.Add("ATVPDKIKX0DER");
     request.MarketplaceId = marketplaceId;
     List<string> fulfillmentChannel = new List<string>();
     //request.FulfillmentChannel = fulfillmentChannel;
     List<string> paymentMethod = new List<string>();
     //request.PaymentMethod = paymentMethod;
     string buyerEmail = "example";
     //request.BuyerEmail = buyerEmail;
     string sellerOrderId = "example";
     //request.SellerOrderId = sellerOrderId;
     decimal maxResultsPerPage = 1;
     request.MaxResultsPerPage = maxResultsPerPage;
     List<string> tfmShipmentStatus = new List<string>();
     //request.TFMShipmentStatus = tfmShipmentStatus;
     return this.client.ListOrders(request);
 }
 /// <summary>
 /// Creates a ListOrdersRequest object with the specified created after date.
 /// </summary>
 /// <param name="createdAfter">The date in which orders should have been created after.</param>
 /// <returns>A list orders request object.</returns>
 private ListOrdersRequest CreateListOrdersRequest(DateTime createdAfter)
 {
     var listOrdersRequest = new ListOrdersRequest()
     {
         SellerId = _MerchantId,
         MarketplaceId = new MarketplaceIdList() { Id = new List<string> { _MarketplaceId } },
         LastUpdatedAfter = createdAfter,
         // Only get those orders that have been paid, but haven't been shipped or only partially shipped.
         OrderStatus = new OrderStatusList()
         {
             Status = new List<OrderStatusEnum> { OrderStatusEnum.Unshipped, OrderStatusEnum.PartiallyShipped }
         }
     };
     return listOrdersRequest;
 }
        /// <summary>
        /// ListOrders can be used to find orders that meet the specified criteria.
        /// 
        /// </summary>
        /// <param name="service">Instance of MarketplaceWebServiceOrders service</param>
        /// <param name="request">ListOrdersRequest request</param>
        public static void InvokeListOrders(MarketplaceWebServiceOrders service, ListOrdersRequest request)
        {
            try
            {
                ListOrdersResponse response = service.ListOrders(request);

                Console.WriteLine ("Service Response");
                Console.WriteLine ("=============================================================================");
                Console.WriteLine ();

                Console.WriteLine("        ListOrdersResponse");
                if (response.IsSetListOrdersResult())
                {
                    Console.WriteLine("            ListOrdersResult");
                    ListOrdersResult  listOrdersResult = response.ListOrdersResult;
                    if (listOrdersResult.IsSetNextToken())
                    {
                        Console.WriteLine("                NextToken");
                        Console.WriteLine("                    {0}", listOrdersResult.NextToken);
                    }
                    if (listOrdersResult.IsSetCreatedBefore())
                    {
                        Console.WriteLine("                CreatedBefore");
                        Console.WriteLine("                    {0}", listOrdersResult.CreatedBefore);
                    }
                    if (listOrdersResult.IsSetLastUpdatedBefore())
                    {
                        Console.WriteLine("                LastUpdatedBefore");
                        Console.WriteLine("                    {0}", listOrdersResult.LastUpdatedBefore);
                    }
                    if (listOrdersResult.IsSetOrders())
                    {
                        Console.WriteLine("                Orders");
                        OrderList  orders = listOrdersResult.Orders;
                        List<Order> orderList = orders.Order;
                        foreach (Order order in orderList)
                        {
                            Console.WriteLine("                    Order");
                            if (order.IsSetAmazonOrderId())
                            {
                                Console.WriteLine("                        AmazonOrderId");
                                Console.WriteLine("                            {0}", order.AmazonOrderId);
                            }
                            if (order.IsSetSellerOrderId())
                            {
                                Console.WriteLine("                        SellerOrderId");
                                Console.WriteLine("                            {0}", order.SellerOrderId);
                            }
                            if (order.IsSetPurchaseDate())
                            {
                                Console.WriteLine("                        PurchaseDate");
                                Console.WriteLine("                            {0}", order.PurchaseDate);
                            }
                            if (order.IsSetLastUpdateDate())
                            {
                                Console.WriteLine("                        LastUpdateDate");
                                Console.WriteLine("                            {0}", order.LastUpdateDate);
                            }
                            if (order.IsSetOrderStatus())
                            {
                                Console.WriteLine("                        OrderStatus");
                                Console.WriteLine("                            {0}", order.OrderStatus);
                            }
                            if (order.IsSetFulfillmentChannel())
                            {
                                Console.WriteLine("                        FulfillmentChannel");
                                Console.WriteLine("                            {0}", order.FulfillmentChannel);
                            }
                            if (order.IsSetSalesChannel())
                            {
                                Console.WriteLine("                        SalesChannel");
                                Console.WriteLine("                            {0}", order.SalesChannel);
                            }
                            if (order.IsSetOrderChannel())
                            {
                                Console.WriteLine("                        OrderChannel");
                                Console.WriteLine("                            {0}", order.OrderChannel);
                            }
                            if (order.IsSetShipServiceLevel())
                            {
                                Console.WriteLine("                        ShipServiceLevel");
                                Console.WriteLine("                            {0}", order.ShipServiceLevel);
                            }
                            if (order.IsSetShippingAddress())
                            {
                                Console.WriteLine("                        ShippingAddress");
                                Address  shippingAddress = order.ShippingAddress;
                                if (shippingAddress.IsSetName())
                                {
                                    Console.WriteLine("                            Name");
                                    Console.WriteLine("                                {0}", shippingAddress.Name);
                                }
                                if (shippingAddress.IsSetAddressLine1())
                                {
                                    Console.WriteLine("                            AddressLine1");
                                    Console.WriteLine("                                {0}", shippingAddress.AddressLine1);
                                }
                                if (shippingAddress.IsSetAddressLine2())
                                {
                                    Console.WriteLine("                            AddressLine2");
                                    Console.WriteLine("                                {0}", shippingAddress.AddressLine2);
                                }
                                if (shippingAddress.IsSetAddressLine3())
                                {
                                    Console.WriteLine("                            AddressLine3");
                                    Console.WriteLine("                                {0}", shippingAddress.AddressLine3);
                                }
                                if (shippingAddress.IsSetCity())
                                {
                                    Console.WriteLine("                            City");
                                    Console.WriteLine("                                {0}", shippingAddress.City);
                                }
                                if (shippingAddress.IsSetCounty())
                                {
                                    Console.WriteLine("                            County");
                                    Console.WriteLine("                                {0}", shippingAddress.County);
                                }
                                if (shippingAddress.IsSetDistrict())
                                {
                                    Console.WriteLine("                            District");
                                    Console.WriteLine("                                {0}", shippingAddress.District);
                                }
                                if (shippingAddress.IsSetStateOrRegion())
                                {
                                    Console.WriteLine("                            StateOrRegion");
                                    Console.WriteLine("                                {0}", shippingAddress.StateOrRegion);
                                }
                                if (shippingAddress.IsSetPostalCode())
                                {
                                    Console.WriteLine("                            PostalCode");
                                    Console.WriteLine("                                {0}", shippingAddress.PostalCode);
                                }
                                if (shippingAddress.IsSetCountryCode())
                                {
                                    Console.WriteLine("                            CountryCode");
                                    Console.WriteLine("                                {0}", shippingAddress.CountryCode);
                                }
                                if (shippingAddress.IsSetPhone())
                                {
                                    Console.WriteLine("                            Phone");
                                    Console.WriteLine("                                {0}", shippingAddress.Phone);
                                }
                            }
                            if (order.IsSetOrderTotal())
                            {
                                Console.WriteLine("                        OrderTotal");
                                Money  orderTotal = order.OrderTotal;
                                if (orderTotal.IsSetCurrencyCode())
                                {
                                    Console.WriteLine("                            CurrencyCode");
                                    Console.WriteLine("                                {0}", orderTotal.CurrencyCode);
                                }
                                if (orderTotal.IsSetAmount())
                                {
                                    Console.WriteLine("                            Amount");
                                    Console.WriteLine("                                {0}", orderTotal.Amount);
                                }
                            }
                            if (order.IsSetNumberOfItemsShipped())
                            {
                                Console.WriteLine("                        NumberOfItemsShipped");
                                Console.WriteLine("                            {0}", order.NumberOfItemsShipped);
                            }
                            if (order.IsSetNumberOfItemsUnshipped())
                            {
                                Console.WriteLine("                        NumberOfItemsUnshipped");
                                Console.WriteLine("                            {0}", order.NumberOfItemsUnshipped);
                            }
                            if (order.IsSetMarketplaceId())
                            {
                                Console.WriteLine("                        MarketplaceId");
                                Console.WriteLine("                            {0}", order.MarketplaceId);
                            }
                            if (order.IsSetBuyerEmail())
                            {
                                Console.WriteLine("                        BuyerEmail");
                                Console.WriteLine("                            {0}", order.BuyerEmail);
                            }
                            if (order.IsSetBuyerName())
                            {
                                Console.WriteLine("                        BuyerName");
                                Console.WriteLine("                            {0}", order.BuyerName);
                            }
                            if (order.IsSetShipmentServiceLevelCategory())
                            {
                                Console.WriteLine("                        ShipmentServiceLevelCategory");
                                Console.WriteLine("                            {0}", order.ShipmentServiceLevelCategory);
                            }
                        }
                    }
                }
                if (response.IsSetResponseMetadata())
                {
                    Console.WriteLine("            ResponseMetadata");
                    ResponseMetadata  responseMetadata = response.ResponseMetadata;
                    if (responseMetadata.IsSetRequestId())
                    {
                        Console.WriteLine("                RequestId");
                        Console.WriteLine("                    {0}", responseMetadata.RequestId);
                    }
                }

            }
            catch (MarketplaceWebServiceOrdersException ex)
            {
                Console.WriteLine("Caught Exception: " + ex.Message);
                Console.WriteLine("Response Status Code: " + ex.StatusCode);
                Console.WriteLine("Error Code: " + ex.ErrorCode);
                Console.WriteLine("Error Type: " + ex.ErrorType);
                Console.WriteLine("Request ID: " + ex.RequestId);
                Console.WriteLine("XML: " + ex.XML);
            }
        }
 public ListOrdersResponse InvokeListOrders()
 {
     // Create a request.
     ListOrdersRequest request = new ListOrdersRequest();
     string sellerId = "example";
     request.SellerId = sellerId;
     DateTime createdAfter = new DateTime();
     request.CreatedAfter = createdAfter;
     DateTime createdBefore = new DateTime();
     request.CreatedBefore = createdBefore;
     DateTime lastUpdatedAfter = new DateTime();
     request.LastUpdatedAfter = lastUpdatedAfter;
     DateTime lastUpdatedBefore = new DateTime();
     request.LastUpdatedBefore = lastUpdatedBefore;
     OrderStatusList orderStatus = new OrderStatusList();
     request.OrderStatus = orderStatus;
     MarketplaceIdList marketplaceId = new MarketplaceIdList();
     request.MarketplaceId = marketplaceId;
     FulfillmentChannelList fulfillmentChannel = new FulfillmentChannelList();
     request.FulfillmentChannel = fulfillmentChannel;
     PaymentMethodList paymentMethod = new PaymentMethodList();
     request.PaymentMethod = paymentMethod;
     string buyerEmail = "example";
     request.BuyerEmail = buyerEmail;
     string sellerOrderId = "example";
     request.SellerOrderId = sellerOrderId;
     decimal maxResultsPerPage = 1;
     request.MaxResultsPerPage = maxResultsPerPage;
     TFMShipmentStatusList tfmShipmentStatus = new TFMShipmentStatusList();
     request.TFMShipmentStatus = tfmShipmentStatus;
     return this.client.ListOrders(request);
 }
        private ListOrdersResponse InvokeListOrders()
        {
            ListOrdersRequest request = new ListOrdersRequest();
            request.SellerId = SellerId;
            request.CreatedAfter = StartRange;
            request.CreatedBefore = EndRange;
            request.MarketplaceId = MarketplaceId;
            request.OrderStatus = new List<string>() { "Shipped" };

            return Client.ListOrders(request);
        }
        /// <summary>
        /// Fetches all orders created in the given time period and processes them locally.        
        /// <param name="startTime">The starting time period of orders to fetch.</param>
        /// <param name="endTime">The ending time period of orders to fetch.</param>
        public void FetchOrders(DateTime startTime, DateTime endTime)
        {
            ListOrdersRequest request = new ListOrdersRequest();
            request.CreatedAfter = startTime;
            if (endTime != DateTime.MinValue)
            {
                request.CreatedBefore = endTime;
            }
            request.SellerId = mwsSellerId;
            request.MarketplaceId = new MarketplaceIdList();
            request.MarketplaceId.Id = new List<string>();
            foreach (string marketplaceId in mwsMarketplaceIdList)
            {
                request.MarketplaceId.Id.Add(marketplaceId);
            }

            List<Order> orderList = new List<Order>();
            ListOrdersResponse response = null;
            OrderFetcher.InvokeRetriable(LIST_ORDERS_DEFAULT_THROTTLE_LIMIT, delegate()
            {
                response = mwsService.ListOrders(request);
                ProcessOrders(response.ListOrdersResult.Orders.Order);
            });

            String nextTokenString = response.ListOrdersResult.NextToken;

            while (!string.IsNullOrEmpty(nextTokenString))
            {
                // If NextToken is set, continue looping through the orders.
                ListOrdersByNextTokenRequest nextRequest = new ListOrdersByNextTokenRequest();
                nextRequest.NextToken = nextTokenString;
                nextRequest.SellerId = mwsSellerId;

                ListOrdersByNextTokenResponse nextResponse = null;
                OrderFetcher.InvokeRetriable(LIST_ORDERS_DEFAULT_THROTTLE_LIMIT, delegate()
                {
                    nextResponse = mwsService.ListOrdersByNextToken(nextRequest);
                    ProcessOrders(nextResponse.ListOrdersByNextTokenResult.Orders.Order);
                });

                nextTokenString = nextResponse.ListOrdersByNextTokenResult.NextToken;
            }
        }