c# - Best design pattern for integrating third-party api or services -
i integrating outside apis layered application. usual layered apps, has 3 layers , hooking apis business layer. "thrid party api , services", mean payment gateways, postcode ups, etc.
currently, each api, create service contract interface , api wrappers inherit interface class. , interface injected business classes' constructors , ioc container resolve @ entry point of application.
i decouple api layers business layers , make them re-usable in other projects well. question that, there better way or design pattern use integrating outside services. appreciate link guides or code snippets.
for each third party api create interface put in separate project. create new project implementation of each interface.
for example project structure like
yoursolution ... -company.interfaces.thridpartyapi1 -company.interfaces.thridpartyapi2 -company.interfaces.thridpartyapi3 -company.services.thridpartyapi1 -company.services.thridpartyapi2 -company.services.thridpartyapi3 ...
this decouples code api code , decouples api interfaces api code, means can mocked/stubbed out testing.
Comments
Post a Comment