public async Task <Data> UpdateOrder(long orderId, UpdateOrderModel updateOrderModel) { var url = new Uri($"/api/orders/{orderId}", UriKind.Relative); var data = await _sveaHttpClient.HttpPut <Data>(url, updateOrderModel); return(data); }
public OrderActions(OrderResponseObject orderResponse, SveaHttpClient client) { foreach (var action in orderResponse.Actions) { switch (action) { case OrderActionType.CanCancelOrder: Cancel = async payload => await client.HttpPatch <object>( new Uri($"/api/v1/orders/{orderResponse.Id}/", UriKind.Relative), payload); break; case OrderActionType.CanCancelOrderRow: CancelOrderRows = async payload => await client.HttpPatch <object>( new Uri($"/api/v1/orders/{orderResponse.Id}/rows/cancelOrderRows", UriKind.Relative), payload); break; case OrderActionType.CanCancelAmount: CancelAmount = async payload => await client.HttpPatch <object>( new Uri($"/api/v1/orders/{orderResponse.Id}/", UriKind.Relative), payload); break; case OrderActionType.CanDeliverOrder: case OrderActionType.CanDeliverOrderPartially: DeliverOrder = async payload => { var response = await client.HttpPost <ResourceResponseObject <OrderResponseObject>, OrderResponseObject>( new Uri($"/api/v1/orders/{orderResponse.Id}/deliveries", UriKind.Relative), payload); var resource = new ResourceResponse <OrderResponseObject, Order>(response, () => new Order(response.Resource, client)); return(resource); }; break; case OrderActionType.CanAddOrderRow: AddOrderRow = async payload => { var response = await client.HttpPost <ResourceResponseObject <AddOrderRowResponseObject>, AddOrderRowResponseObject>( new Uri($"/api/v1/orders/{orderResponse.Id}/rows", UriKind.Relative), payload); var resource = new ResourceResponse <AddOrderRowResponseObject, AddOrderRowResponse>(response, () => new AddOrderRowResponse(response.Resource)); return(resource); }; AddOrderRows = async payload => await client.HttpPost <AddOrderRowsResponse>( new Uri($"/api/v1/orders/{orderResponse.Id}/rows/addOrderRows", UriKind.Relative), payload); break; case OrderActionType.CanUpdateOrderRow: UpdateOrderRows = async payload => await client.HttpPost <object>( new Uri($"/api/v1/orders/{orderResponse.Id}/rows/updateOrderRows", UriKind.Relative), payload); ReplaceOrderRows = async payload => await client.HttpPut <object>( new Uri($"/api/v1/orders/{orderResponse.Id}/rows/replaceOrderRows", UriKind.Relative), payload); break; } } }