/// <summary> /// This endpoint can be used to either confirm a cancellation request by the customer or to cancel an order you yourself are unable to fulfil. /// </summary> /// <param name="orderItems">Items to cancel (use CancelReason enum)</param> /// <returns></returns> public async Task <StatusResponse> CancelOrderByOrderItemId(OrderItemCancellationContainer orderItemsContainer) { using (var content = BolApiHelper.BuildContentFromObject(orderItemsContainer)) { var response = await Put($"/orders/cancellation", content).ConfigureAwait(false); return(await BolApiHelper.GetContentFromResponse <StatusResponse>(response).ConfigureAwait(false)); } }
public async Task CancelOrder() { var bolApiCaller = new BolApiCaller(testClientId, testClientSecret, true); var response = await bolApiCaller.Orders.GetOpenOrders(1, FulFilmentMethod.FBR); var orderItemsContainer = new OrderItemCancellationContainer(); foreach (var order in response.Orders) { orderItemsContainer.OrderItems = new List <OrderItemCancellation>(); var orderItem = new OrderItemCancellation() { OrderItemId = order.OrderId, ReasonCode = CancelReason.TECH_ISSUE.ToString() }; orderItemsContainer.OrderItems.Add(orderItem); await bolApiCaller.Orders.CancelOrderByOrderItemId(orderItemsContainer); } Assert.IsTrue(response.Orders.Length > 0); }