Last active
September 10, 2015 14:07
-
-
Save pwelter34/539e568d3b95f4071f08 to your computer and use it in GitHub Desktop.
Fluent Example
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 void HttpClientPost(){ | |
// post data | |
var post = new Dictionary<string, string>() | |
{ | |
{ "grant_type", "refresh_token" }, | |
{ "client_id", consumerkey }, | |
{ "client_secret", consumerSecret }, | |
{ "refresh_token", refreshToken } | |
}; | |
var content = new FormUrlEncodedContent(post); | |
var client = new HttpClient(); | |
var result = await client.PostAsync(tokenUrl, content).ConfigureAwait(false); | |
var json = await result.Content.ReadAsStringAsync().ConfigureAwait(false); | |
var tokenResult = JsonConvert.DeserializeObject<TokenResult>(json); | |
} | |
public void FluentPost(){ | |
var client = new FluentClient(tokenUrl) | |
var tokenResult = await client.PostAsync<TokenResult>(c => c | |
.Data("grant_type", "refresh_token") | |
.Data("client_id", consumerkey ) | |
.Data("client_secret", consumerSecret) | |
.Data("refresh_token", refreshToken) | |
) | |
} | |
public void FluentResponse() | |
{ | |
MemoryStore.Current.Register(r => r | |
.Url("http://blah.com") | |
.Header("", "") | |
.StatusCode(200) | |
.ReasonPhrase("OK") | |
.Content(c => c | |
.Header("", "") | |
.Data<T>(user) | |
) | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment