Answer the question
In order to leave comments, you need to log in
How to change data via API?
There is an entity - an order that has a delivery address and goods (with a quantity)
In the database, something like this:
orders: [id, address]
order_products: [order_id, product_id, count]
Any field can be changed from the client. This includes deleting the items in the order
Calling the server only via API
Questions:
1) Suppose there were 2 different items (x,y)
The client changed the address, changed the quantity of item "x", deleted item "y", and added item "z" "
3 options for possible requests come to mind:
A) Send 1 request with a changed address and goods "x", "z". The server must determine which product to delete.
B)Send 1 request with a changed address and all 3 products, one of which will have a delete flag.
C ) Send 4 requests (creepy, but for RestFul api it seems the only right solution):
I) to change the address of the order
II) to change the quantity in product "x"
III) to remove product "y"
IV) to add product "z"
2) Are options A, B simple RestFul [PUT] requests?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question