Last active
May 6, 2016 07:58
-
-
Save michaelbramwell/5cf972b6f35cd3ae9982b8f5400609ab to your computer and use it in GitHub Desktop.
Generic Request with RestRequest lib
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static IRestResponse<T> MakeRequest(string relativeUrl, Func<RestClient, RestRequest, IRestResponse<T>> clientFunc) | |
{ | |
var client = new RestClient("https://someresource.com"); | |
var request = new RestSharp.RestRequest(relativeUrl); | |
return clientFunc(client, request); | |
} | |
// example call | |
var request = MakeRequest("/api/whatever", (c, r) => c.Execute<SomeType>(r)); | |
var deserializedSomeTypeData = request.Data; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment