I have to implement a REST API endpoint for resource update. But there are two possibilities of update - with and without additional operations. How to handle it?
My API (name it just "API") is going to call a "System" where resource is located. API should handle two kinds of an update call: A) with check-out/check-in B) without check-out/check-in
(check-out and check-in are operation which setups/tears Documents during update)
For A) it should look like this:
- User calls an API with "update with check-out/check-in"
- API calls System with check-out request
- API calls System with update data
- API calls with check-in request.
For B) it should look like this:
- User calls an API with "update without check-out/check-in"
- API calls system with update data.
How should I design my API? My idea is to user PATCH method, because only changed data will be sent:
PATCH: /documents/{documentId}
But how to pass information defining if check-out/check-in should be run or not?
I was thinking about query param, like this:
PATCH: /documents/{documentId}&checkOut=true
But as far I know query params should be used to pass more details defining resource.
Or should I implement two endpoints? Like this:
For A): PATCH: /documents/{documentId}
For B): PATCH: /documents/{documentId}/withoutCheckOut