I need some guidance in designing an API wrapper for my backend APIs. I have tried to keep it as specific as possible.
Context: We have a project which supports certain file operations like edit, create, merge etc.
All the services are exposed as rest APIs. Now I have to create an API wrapper over this (client library) in Java. I've been reading about DDD and trying to approach the problem using that.
- As per my thinking, the core object in my project would be File, along with some minor DTOs for talking to the backend.
- Edit, create, and merge will be the verbs here acting on my domain object. I want to make it as easy as possible for the external developer to integrate the API.
I would like the design to be something like this:
For Creating a file :
For Editing :
Same for other operations
Also, I want to have the capability of chaining operations (along the lines of fluent interfaces) for readability
For. eg. if you want to create a file and then convert it, it should be something like
My problem is each of the operations is bulky and async. I don't wanna write all the async error-handling logic in the File class. Chaining the methods like those above wont be easy as well if they return CompletableFuture objects, and this will be harder to maintain.
Question: What is a better way of solving this problem?
I am not looking for a spoonfed design. I just want to be guided to a design approach that fits the scenario. Feel free to point out if I am understanding DDD wrong.