Skip to content

Instantly share code, notes, and snippets.

@pjmagee
Created May 25, 2012 23:00
Show Gist options
  • Select an option

  • Save pjmagee/2791057 to your computer and use it in GitHub Desktop.

Select an option

Save pjmagee/2791057 to your computer and use it in GitHub Desktop.
public class UrbanService : IUrbanService
{
private const string BaseUrl = "http://urbanscraper.herokuapp.com/";
public T Execute<T>(RestRequest request) where T : new()
{
var client = new RestClient() { BaseUrl = BaseUrl };
client.ClearHandlers();
client.AddHandler("text/plain", new JsonDeserializer());
request.RequestFormat = DataFormat.Json;
var restResponse = client.Execute<T>(request);
return restResponse.Data;
}
public UrbanResponse Search(UrbanRequest urbanRequest)
{
var request = new RestRequest {Resource = "define/{term}.json"};
request.AddParameter("term", urbanRequest.term, ParameterType.UrlSegment);
return Execute<UrbanResponse>(request);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment