I’m working on a wrapper for a REST API at the moment and curious to know what the best practices are for the following situation. I have several resource objects which contain methods for performing CRUD operations on that resource, however the API i’m wrapping returns empty response bodies for PUT requests.
What’s generally the best thing to be returning in this situation? It feels wrong to return
"" for a successful request. Would it make more sense to return the instance of that resource, i.e.
self? I was also considering maybe returning
true but it also felt weird since unsuccessful requests raise an exception, which is caught elsewhere. So my code would look like:
def update(attributes) http_client.put(url, attributes) true end
I may be overthinking this and maybe they’re all valid options but i’m interested to hear what people think is the best approach. (And apologies for the awful topic name )