Accepting a proposal five times should have the same effect as accepting it once. This is idempotent. Therefore, it must be PUT.
You might want to choose a different name for your "requests." When I do GET /requests/123 , I request a response, which is a request? This can be a bit confusing for customers.
Also, try to avoid nesting resource identifiers. This may create problems for you later. The offer really should not be βunderβ the corresponding request. What happens when you later want to offer offers that match multiple requests?
A good rule of thumb is that if you consider a Gizmo object as an entity in the entity-relationship model , it must be the -level URI root, as in GET /gizmos/17 , and not GET /widgets/54/gizmos/17 . A common mistake is to say: "Each Gizmo has exactly one related widget, so I have to embed the Gizmo URIs as extensions of the Widget URIs."
Below I suggest what the operations will look like. You might want to replace some of the identification links with a URI, but that is up to you.
POST /requests ---> 201 Created Location: /requests/123 GET /requests ---> 200 OK [ { "requestId": 123, "offersUri": "/offers?requestId=123", ... }, ... ] POST /offers ---> 201 Created { Location: /offers/456 "requestId": 123, "amount": 300, ... } GET /offers?requestId=123 ---> 200 OK [ { "requestId": 123, "amount": 300, ... } ] PUT /offers/456/approval ---> 204 No Content PUT /offers/456/approval ---> 204 No Content PUT /offers/456/approval ---> 204 No Content
source share