Search code examples
c#wpftwittertwitter-oauthtwitter-rest-api

Web Data connector in WPF C#


I am in need to develop a application which is used to access(get data from) web accessible resources like twitter,facebook,linkedIn,Salesforce etc. by using their appropriate REST API's. Can anyone please suggest me the pattern and architecture to design the logic of the application?


Solution

  • Since you are coupling with many online providers, there's increased chance that their API implementation changes overtime.

    1. Think the API services as just any other Datasource. Implement the API service requester as a Provider class. Create an abstraction between this Provider and your actual process (where you use this data once you get it). This Provider will act as a source of data for the rest of the application. So any changes to API service will not affect your whole application.
    2. Create separate Provider classes for each Online Platform you need. Create Model that represents the data from API services and pass the Model object between Providers and Consumers.

    Something like this

    public interface IFBConnect {
        public FBData GetFBData();
        public bool PostFBData();
        //etc. etc
    }
    
    public class FacebookProvider : IFBConnect {
        public FBData GetFBData() {
            //call the webservice
            //parse the JSON to your model object
            return FBData
        }
    }