public async Task Delete <T>(string id) where T : ResourceItem <T> { using (var request = new HttpRequestMessage(HttpMethod.Delete, ResourceItem <T> .CreatePathWithId(id))) { using (var response = await _httpClient .SendAsync(request, HttpCompletionOption.ResponseHeadersRead) .ConfigureAwait(false)) { response.EnsureSuccessStatusCode(); } } }
public async Task <T> Get <T>(string id) where T : ResourceItem <T> { var request = new HttpRequestMessage(HttpMethod.Get, ResourceItem <T> .CreatePathWithId(id)); using (var result = await _httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead).ConfigureAwait(false)) { result.EnsureSuccessStatusCode(); using (var responseStream = await result.Content.ReadAsStreamAsync()) { using (var streamReader = new StreamReader(responseStream)) using (var jsonTextReader = new JsonTextReader(streamReader)) { return(_jsonSerializer.Deserialize <T>(jsonTextReader)); } } } }