A little bit of clean up

This commit is contained in:
Robert Marshall 2021-07-23 22:05:29 +01:00
parent f79cd3dad4
commit 8b5185847d
4 changed files with 5 additions and 5 deletions

View file

@ -4,7 +4,6 @@ using System.Threading.Tasks;
using FluentAssertions;
using Microsoft.Extensions.Caching.Memory;
using NSubstitute;
using Robware.Lib.ApiClient;
using Xunit;
namespace Robware.Lib.ApiClient.Tests {

View file

@ -1,6 +1,5 @@
using System.Collections.Generic;
using FluentAssertions;
using Robware.Lib.ApiClient;
using Xunit;
namespace Robware.Lib.ApiClient.Tests {

View file

@ -3,7 +3,9 @@ using System.Net.Http;
namespace Robware.Lib.ApiClient {
public class ApiCallException : Exception {
private readonly HttpResponseMessage Response;
// ReSharper disable once NotAccessedField.Local
// ReSharper disable once MemberCanBePrivate.Global
public readonly HttpResponseMessage Response;
public ApiCallException(HttpResponseMessage response):base($"Error calling API {response.RequestMessage.RequestUri}: {(int)response.StatusCode}, {response.ReasonPhrase}") {
Response = response;

View file

@ -21,10 +21,10 @@ namespace Robware.Lib.ApiClient {
_cacheDurations = cacheDurations;
}
private IDictionary<string, string> ParseQueryParameters(object query) {
private static IDictionary<string, string> ParseQueryParameters(object query) {
var type = query.GetType();
var props = type.GetProperties();
return props.ToDictionary(info => info.Name, info => info.GetValue(query, null).ToString());
return props.ToDictionary(info => info.Name, info => info.GetValue(query, null)?.ToString());
}
private async Task<TResult> DoCachedCall<TResult>(string callerName, string url, bool skipCache, Func<Task<TResult>> call) {