I need to call multiple services having multiple APIs. Few of them are mostly read (they return some data to me), and few of them change the state of several objects (they basically update the state of several objects).
I am looking for a design pattern that can be applied to the scenario described above.
Code example
Let's look at a small example of service A
AccountInfo A.getAccountInfo() void A.setAccountData(AccountInfo) AccountStatus A.getStatusForAccount
...
I was thinking about having a universal interface
interface CallAPI<Input , Output> { public Output execute(Input) }
Each API call will implement this interface, and I can use the Factory pattern to get instances of the API.
I would like to know if there is a better template for the same or whether it can be reorganized differently. APIs and services will only grow, and it will be easier for them to configure new APIs, and clients should not have additional overhead for writing adapters for new APIs.
Shari source share