I am trying to integrate social media APIs into my application as seperate modules. Each module will be implemented on its own, but I want another module that pulls in each of the social media integrations. I want each module to implement an interface like this
Social = (function(){
var expose = {};
expose.FACEBOOK = 'facebook';
expose.YOUTUBE = 'youtube';
expose.TWITTER = 'twitter';
expose.like = function(type, data) {
};
expose.unlike = function(type, data) {
};
expose.post = function(type, data) {
};
expose.remove = function(type, data) {
};
expose.reply = function(type, data) {
};
return expose;
})();
I then want to be able to call something like
Social.post(Social.YOUTUBE, data) or Social.like(Social.FACEBOOK, data)
To which the correct integration is invoked. What is the best way to accomplish this, and can it be achieved without using a lot of switch statements?