public async Task <Response> ParseMarsRoverPhotosOfTheDayAsync(HttpResponseMessage httpResponse) { Dto.Root photos = null; /* * var responseContent = string.Empty; * * var responseStream = await httpResponse.Content.ReadAsStreamAsync().ConfigureAwait(false); * var encoding = Encoding.UTF8; * * using (var sr = new StreamReader(responseStream, encoding)) * { * responseContent = await sr.ReadToEndAsync().ConfigureAwait(false); * } */ using (var responseStream = await httpResponse.Content.ReadAsStreamAsync().ConfigureAwait(false)) { photos = await JsonSerializer.DeserializeAsync <Dto.Root>(responseStream, _jsonSerializerOptions).ConfigureAwait(false); } httpResponse.Dispose(); return(new Response(StatusCode.OK, photos)); }
public Response(StatusCode statusCode, Dto.Root photos = null, Error error = null) { StatusCode = statusCode; Photos = photos; Error = error; }