private async Task <HttpResult <AccessTokenResponse> > GetTokenAsync(IEnumerable <KeyValuePair <string, string> > values) { try { using (HttpResponseMessage response = await HttpClient.PostAsync(TokenUri, new FormUrlEncodedContent(values))) { HttpResult <AccessTokenResponse> result = new HttpResult <AccessTokenResponse>() { StatusCode = response.StatusCode }; if (response.Content != null) { result.Content = await response.Content.ReadAsAsync <AccessTokenResponse>(); } AccessTokenResponse tokenResponse = result.Content; if (tokenResponse != null && tokenResponse.Error != null) { result.Errors.Add(tokenResponse.ErrorDescription); } return(result); } } catch (HttpRequestException ex) { return(HttpResult <AccessTokenResponse> .Failure(ex.Message)); } }
public async Task <HttpResult <TodoList[]> > GetTodoListsAsync() { HttpResult <Wrapped <TodoList[]> > wrappedResult = await HttpClient.GetAsync <Wrapped <TodoList[]> >(TodoListsUri + "?$expand=Todos"); HttpResult <TodoList[]> result = wrappedResult.Succeeded ? new HttpResult <TodoList[]>(wrappedResult.Content.Value) : HttpResult <TodoList[]> .Failure(wrappedResult.Errors); result.StatusCode = wrappedResult.StatusCode; return(result); }