public async Task <Data> CreateOrder(CreateOrderModel createOrderModel) { var url = new Uri("/api/orders", UriKind.Relative); var data = await _sveaHttpClient.HttpPost <Data>(url, createOrderModel); return(data); }
public DeliveryActions(long orderId, DeliveryResponseObject deliveryResponse, SveaHttpClient client) { foreach (var action in deliveryResponse.Actions) { switch (action) { case DeliveryActionType.CanCreditOrderRows: CreditOrderRows = async payload => { var response = await client .HttpPost <ResourceResponseObject <CreditResponseObject>, CreditResponseObject>( new Uri($"/api/v1/orders/{orderId}/deliveries/{deliveryResponse.Id}/credits", UriKind.Relative), payload); var resource = new ResourceResponse <CreditResponseObject, CreditResponse>(response, () => new CreditResponse(response.Resource)); return(resource); }; break; case DeliveryActionType.CanCreditNewRow: CreditNewRow = async payload => { var response = await client .HttpPost <ResourceResponseObject <CreditResponseObject>, CreditResponseObject>( new Uri($"/api/v1/orders/{orderId}/deliveries/{deliveryResponse.Id}/credits", UriKind.Relative), payload); var resource = new ResourceResponse <CreditResponseObject, CreditResponse>(response, () => new CreditResponse(response.Resource)); return(resource); }; break; case DeliveryActionType.CanCreditAmount: CreditAmount = async payload => { var response = await client.HttpPatch <CreditResponseObject>( new Uri($"/api/v1/orders/{orderId}/deliveries/{deliveryResponse.Id}", UriKind.Relative), payload); return(new CreditResponse(response)); }; break; } } }
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; } } }