protected virtual async Task DoSingleUserWorkAsync(CancellationToken cancellationToken) { int iteration = 0; var random = new Random(); var customers = await customersClient.GetCustomersAsync(); var customer = customers.ElementAt(random.Next(1, customers.Count())); Interlocked.Increment(ref totalRequests); while (!cancellationToken.IsCancellationRequested) { try { var products5 = await productsClient.GetProductsAsync("for testing 5", true, cancellationToken); var products4 = await productsClient.GetProductsAsync("for testing 4", true, cancellationToken); var products6 = await productsClient.GetProductsAsync("for testing 6", true, cancellationToken); var orderItems = products4.Take(1) .Concat(products5.Take(1)) .Concat(products6.Take(1)) .Select(x => new ApiModel.Order.NewOrderItemInfo() { ProductId = x.Id, Quantity = 4 }) .ToList(); bool shouldAddOrder = (iteration++) % 4 == 0; if (shouldAddOrder) { await ordersClient.AddNewOrderAsync(new ApiModel.Order.Request.AddOrderRequest() { CustomerId = customer.Id, EmployeeId = 2, Freight = 1, RequiredDate = DateTime.Now.AddDays(3), ShipAddress = "Test address", ShipCity = "Never", ShipCountry = "Neverland", ShipName = "Test ship name", ShipPostalCode = "12345", ShipRegion = "Test region", OrderItems = orderItems }, cancellationToken); Interlocked.Increment(ref totalRequests); } var orders = await ordersClient.GetOrdersAsync(customerId : customer.Id, cancellationToken : cancellationToken); Interlocked.Increment(ref totalRequests); Interlocked.Increment(ref totalRequests); Interlocked.Increment(ref totalRequests); Interlocked.Increment(ref totalRequests); } catch (Exception ex) when(ex is IOException || ex is TaskCanceledException) { ; } } }
/// <summary> /// Returns orders created or updated during the time frame indicated by the /// specified parameters. You can also apply a range of filtering criteria to /// narrow the list of orders returned. If NextToken is present, that will be /// used to retrieve the orders instead of other criteria. /// /// **Usage Plans:** /// /// | Plan type | Rate (requests per second) | Burst | /// | ---- | ---- | ---- | /// |Default| 0.0055 | 20 | /// |Selling partner specific| Variable | Variable | /// /// The x-amzn-RateLimit-Limit response header returns the usage plan rate /// limits that were applied to the requested operation. Rate limits for some /// selling partners will vary from the default rate and burst shown in the /// table above. For more information, see "Usage Plans and Rate Limits" in the /// Selling Partner API documentation. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='marketplaceIds'> /// A list of MarketplaceId values. Used to select orders that were placed in /// the specified marketplaces. /// /// See the [Selling Partner API Developer /// Guide](https://github.com/amzn/selling-partner-api-docs/blob/main/guides/en-US/developer-guide/SellingPartnerApiDeveloperGuide.md#marketplaceid-values) /// for a complete list of marketplaceId values. /// </param> /// <param name='createdAfter'> /// A date used for selecting orders created after (or at) a specified time. /// Only orders placed after the specified time are returned. Either the /// CreatedAfter parameter or the LastUpdatedAfter parameter is required. Both /// cannot be empty. The date must be in ISO 8601 format. /// </param> /// <param name='createdBefore'> /// A date used for selecting orders created before (or at) a specified time. /// Only orders placed before the specified time are returned. The date must be /// in ISO 8601 format. /// </param> /// <param name='lastUpdatedAfter'> /// A date used for selecting orders that were last updated after (or at) a /// specified time. An update is defined as any change in order status, /// including the creation of a new order. Includes updates made by Amazon and /// by the seller. The date must be in ISO 8601 format. /// </param> /// <param name='lastUpdatedBefore'> /// A date used for selecting orders that were last updated before (or at) a /// specified time. An update is defined as any change in order status, /// including the creation of a new order. Includes updates made by Amazon and /// by the seller. The date must be in ISO 8601 format. /// </param> /// <param name='orderStatuses'> /// A list of OrderStatus values used to filter the results. Possible values: /// PendingAvailability (This status is available for pre-orders only. The /// order has been placed, payment has not been authorized, and the release /// date of the item is in the future.); Pending (The order has been placed but /// payment has not been authorized); Unshipped (Payment has been authorized /// and the order is ready for shipment, but no items in the order have been /// shipped); PartiallyShipped (One or more, but not all, items in the order /// have been shipped); Shipped (All items in the order have been shipped); /// InvoiceUnconfirmed (All items in the order have been shipped. The seller /// has not yet given confirmation to Amazon that the invoice has been shipped /// to the buyer.); Canceled (The order has been canceled); and Unfulfillable /// (The order cannot be fulfilled. This state applies only to Multi-Channel /// Fulfillment orders.). /// </param> /// <param name='fulfillmentChannels'> /// A list that indicates how an order was fulfilled. Filters the results by /// fulfillment channel. Possible values: FBA (Fulfillment by Amazon); /// SellerFulfilled (Fulfilled by the seller). /// </param> /// <param name='paymentMethods'> /// A list of payment method values. Used to select orders paid using the /// specified payment methods. Possible values: COD (Cash on delivery); CVS /// (Convenience store payment); Other (Any payment method other than COD or /// CVS). /// </param> /// <param name='buyerEmail'> /// The email address of a buyer. Used to select orders that contain the /// specified email address. /// </param> /// <param name='sellerOrderId'> /// An order identifier that is specified by the seller. Used to select only /// the orders that match the order identifier. If SellerOrderId is specified, /// then FulfillmentChannels, OrderStatuses, PaymentMethod, LastUpdatedAfter, /// LastUpdatedBefore, and BuyerEmail cannot be specified. /// </param> /// <param name='maxResultsPerPage'> /// A number that indicates the maximum number of orders that can be returned /// per page. Value must be 1 - 100. Default 100. /// </param> /// <param name='easyShipShipmentStatuses'> /// A list of EasyShipShipmentStatus values. Used to select Easy Ship orders /// with statuses that match the specified values. If EasyShipShipmentStatus /// is specified, only Amazon Easy Ship orders are returned.Possible values: /// PendingPickUp (Amazon has not yet picked up the package from the seller). /// LabelCanceled (The seller canceled the pickup). PickedUp (Amazon has picked /// up the package from the seller). AtOriginFC (The packaged is at the origin /// fulfillment center). AtDestinationFC (The package is at the destination /// fulfillment center). OutForDelivery (The package is out for delivery). /// Damaged (The package was damaged by the carrier). Delivered (The package /// has been delivered to the buyer). RejectedByBuyer (The package has been /// rejected by the buyer). Undeliverable (The package cannot be delivered). /// ReturnedToSeller (The package was not delivered to the buyer and was /// returned to the seller). ReturningToSeller (The package was not delivered /// to the buyer and is being returned to the seller). /// </param> /// <param name='nextToken'> /// A string token returned in the response of your previous request. /// </param> /// <param name='amazonOrderIds'> /// A list of AmazonOrderId values. An AmazonOrderId is an Amazon-defined order /// identifier, in 3-7-7 format. /// </param> /// <param name='actualFulfillmentSupplySourceId'> /// Denotes the recommended sourceId where the order should be fulfilled from. /// </param> /// <param name='isISPU'> /// When true, this order is marked to be picked up from a store rather than /// delivered. /// </param> /// <param name='storeChainStoreId'> /// The store chain store identifier. Linked to a specific store in a store /// chain. /// </param> public static GetOrdersResponse GetOrders(this IOrdersClient operations, IList <string> marketplaceIds, string createdAfter = default(string), string createdBefore = default(string), string lastUpdatedAfter = default(string), string lastUpdatedBefore = default(string), IList <string> orderStatuses = default(IList <string>), IList <string> fulfillmentChannels = default(IList <string>), IList <string> paymentMethods = default(IList <string>), string buyerEmail = default(string), string sellerOrderId = default(string), int?maxResultsPerPage = default(int?), IList <string> easyShipShipmentStatuses = default(IList <string>), string nextToken = default(string), IList <string> amazonOrderIds = default(IList <string>), string actualFulfillmentSupplySourceId = default(string), bool?isISPU = default(bool?), string storeChainStoreId = default(string)) { return(operations.GetOrdersAsync(marketplaceIds, createdAfter, createdBefore, lastUpdatedAfter, lastUpdatedBefore, orderStatuses, fulfillmentChannels, paymentMethods, buyerEmail, sellerOrderId, maxResultsPerPage, easyShipShipmentStatuses, nextToken, amazonOrderIds, actualFulfillmentSupplySourceId, isISPU, storeChainStoreId).GetAwaiter().GetResult()); }