I need to work with some payment gateway API. The API is divided into two parts. There are some methods based on REST and a few methods accessible through SOAP webservice. I would like to create some bridge to combine it into single API class in my application. However I am not sure it is a good choice. The question is.. is there any design pattern for this kind of situations?
Asked
Active
Viewed 905 times
4 Answers
2
As @user1172763 mentioned this is called a Facade. A facade is usually used to provide a simplified interface for a more complex system. But as the wiki link mentions, a Facade is also used to:
wrap a poorly designed collection of APIs with a single well-designed API.
In this case you hide two heterogenous APIs (one REST, one SOAP) behind a homogenous (facade) API.
Bogdan
- 3,650
1
And in addition to using the Facade pattern, and if you want to get more elegant and pure with your code, I would recommend using the Adapter pattern to cleanly convert the interface of the outer API classes to what is expected for the inner API classes.
David Spenard
- 289