So I’m building a system that connects to multiple HR-applications. So I was thinking about using the Builder (Manager) pattern, like socialite is doing. So you can say this user is using HR-application AFAS so I new up a AFASProvider and do all my calls in there. And then I simply need to create a provider for each HR-application we support and I give them the same interface and make sure they all return the same information structure so I can work with that.
However the hard part here is that some HR-applications don’t support some functionalities that others do. So we were thinking about creating our own provider which can be used as well. So for example retrieve documents for a user is supported by AFAS but not by VISMA. So if the user is using the VISMA provider we need to make sure that for documents it’s using the local provider. Now that might not be that hard, but that means that the VISMA provider cannot use the normal interface, since the interface says it has a documents function.
So to fix that we can use multiple interfaces, like shown in the code examples. However this means that there are possibly around 20 interfaces and for each functionalty there needs to be a check on which provider should be used.
So what we really want is a flexible way to call a method on one of the providers if that provider is supporting the functionality. So my question is how can we make a good architecture that can manage this kind of behavior?