From f34af7c29d19649ee4b7867e481416d474c3d5ea Mon Sep 17 00:00:00 2001 From: Matthias Beerens <3512339+Matthiee@users.noreply.github.com> Date: Fri, 20 Jan 2023 11:07:48 +0100 Subject: [PATCH] Make `timestamp`, `price` nullable (#77) * Make properties nullable * Fix failing tests * Make avg volume also double * Fix different error handling on FMP --- .../Core/Http/FinancialModelingPrepHttpClient.cs | 4 +++- .../Model/CompanyValuation/QuoteResponse.cs | 8 ++++---- .../Model/CompanyValuation/SymbolResponse.cs | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/FinancialModelingPrepApi/Core/Http/FinancialModelingPrepHttpClient.cs b/FinancialModelingPrepApi/Core/Http/FinancialModelingPrepHttpClient.cs index fb63a7f..d08db61 100644 --- a/FinancialModelingPrepApi/Core/Http/FinancialModelingPrepHttpClient.cs +++ b/FinancialModelingPrepApi/Core/Http/FinancialModelingPrepHttpClient.cs @@ -18,6 +18,7 @@ public class FinancialModelingPrepHttpClient private readonly ILogger logger; private readonly JsonSerializerOptions jsonSerializerOptions; private const string EmptyArrayResponse = "[ ]"; + private const string EmptyArrayResponse2 = "[]"; private const string ErrorMessageResponse = "Error Message"; public FinancialModelingPrepHttpClient(HttpClient client, FinancialModelingPrepOptions options, @@ -64,7 +65,8 @@ public async Task> GetStringAsync(string urlPattern, NameVal return ApiResponse.FromError(errorData.ErrorMessage); } - if (response.Data.Equals(EmptyArrayResponse, StringComparison.OrdinalIgnoreCase)) + if (response.Data.Equals(EmptyArrayResponse, StringComparison.OrdinalIgnoreCase) || + response.Data.Equals(EmptyArrayResponse2, StringComparison.OrdinalIgnoreCase)) { return ApiResponse.FromError("Invalid parameters"); } diff --git a/FinancialModelingPrepApi/Model/CompanyValuation/QuoteResponse.cs b/FinancialModelingPrepApi/Model/CompanyValuation/QuoteResponse.cs index cf9035a..d13d6fc 100644 --- a/FinancialModelingPrepApi/Model/CompanyValuation/QuoteResponse.cs +++ b/FinancialModelingPrepApi/Model/CompanyValuation/QuoteResponse.cs @@ -42,10 +42,10 @@ public class QuoteResponse public double? PriceAvg200 { get; set; } [JsonPropertyName("volume")] - public long? Volume { get; set; } + public double? Volume { get; set; } [JsonPropertyName("avgVolume")] - public long? AvgVolume { get; set; } + public double? AvgVolume { get; set; } [JsonPropertyName("exchange")] public string Exchange { get; set; } @@ -66,9 +66,9 @@ public class QuoteResponse public string EarningsAnnouncement { get; set; } [JsonPropertyName("sharesOutstanding")] - public long? SharesOutstanding { get; set; } + public double? SharesOutstanding { get; set; } [JsonPropertyName("timestamp")] - public int Timestamp { get; set; } + public int? Timestamp { get; set; } } } diff --git a/FinancialModelingPrepApi/Model/CompanyValuation/SymbolResponse.cs b/FinancialModelingPrepApi/Model/CompanyValuation/SymbolResponse.cs index bc59b9b..bbee702 100644 --- a/FinancialModelingPrepApi/Model/CompanyValuation/SymbolResponse.cs +++ b/FinancialModelingPrepApi/Model/CompanyValuation/SymbolResponse.cs @@ -11,7 +11,7 @@ public class SymbolResponse public string Name { get; set; } [JsonPropertyName("price")] - public double Price { get; set; } + public double? Price { get; set; } [JsonPropertyName("exchange")] public string Exchange { get; set; }