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?
Asked
Active
Viewed 144 times
1 Answers
1
Since you are coupling with many online providers, there's increased chance that their API implementation changes overtime.
- Think the API services as just any other Datasource. Implement the API service requester as a
Provider
class. Create an abstraction between thisProvider
and your actual process (where you use this data once you get it). ThisProvider
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. - Create separate Provider classes for each Online Platform you need. Create
Model
that represents the data from API services and pass theModel
object betweenProviders
andConsumers
.
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
}
}

Vishnu Prasad V
- 1,228
- 1
- 8
- 18
-
May i please know the common method to write webservice? if I have a API's ....For example i have a API to get timeline in Twitter. how to use this API in C#? – Vinod Kumar Jan 29 '16 at 11:38
-
@VinodKumar Are you asking how to send a request to twitter API service? or a skeleton method to call any webservice? – Vishnu Prasad V Jan 29 '16 at 13:59
-
Hi Vishnu, I am asking about a skeleton method to call any webservice. – Vinod Kumar Feb 01 '16 at 04:13
-
1@VinodKumar see a sample method here: http://www.c-sharpcorner.com/blogs/consuming-json-rest-or-restful-web-services-response-using-net-c-sharp-client1 . Remember this question is Off-topic with respect to SO. – Vishnu Prasad V Feb 01 '16 at 07:24
-
Thanks Vishnu.it helps me. – Vinod Kumar Feb 02 '16 at 06:53