Skip to content

Commit 85658dc

Browse files
authored
Add ESG Score (#33)
1 parent 06045c4 commit 85658dc

File tree

4 files changed

+67
-0
lines changed

4 files changed

+67
-0
lines changed

FinancialModelingPrepApi/Abstractions/AdvancedData/IAdvancedDataProvider.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,7 @@ public interface IAdvancedDataProvider
2323
Task<ApiResponse<List<IndustryPEResponse>>> GetIndustriesPriceEarningsRatioAsync(string date, string exchange);
2424

2525
Task<ApiResponse<SharesFloatResponse>> GetSharesFloatAsync(string symbol);
26+
27+
Task<ApiResponse<List<ESGScoreResponse>>> GetESGScoreAsync(string symbol);
2628
}
2729
}

FinancialModelingPrepApi/Core/AdvancedData/AdvancedDataProvider.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,5 +158,20 @@ public async Task<ApiResponse<SharesFloatResponse>> GetSharesFloatAsync(string s
158158

159159
return ApiResponse.FromSucces(result.Data.First());
160160
}
161+
162+
public Task<ApiResponse<List<ESGScoreResponse>>> GetESGScoreAsync(string symbol)
163+
{
164+
const string url = "[version]/esg-environmental-social-governance-data";
165+
166+
var pathParams = new NameValueCollection()
167+
{
168+
{ "version", ApiVersion.v4.ToString() }
169+
};
170+
171+
var queryString = new QueryStringBuilder();
172+
queryString.Add("symbol", symbol);
173+
174+
return client.GetJsonAsync<List<ESGScoreResponse>>(url, pathParams, queryString);
175+
}
161176
}
162177
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using System.Text.Json.Serialization;
2+
3+
namespace MatthiWare.FinancialModelingPrep.Model.AdvancedData
4+
{
5+
public class ESGScoreResponse
6+
{
7+
[JsonPropertyName("symbol")]
8+
public string Symbol { get; set; }
9+
10+
[JsonPropertyName("cik")]
11+
public string Cik { get; set; }
12+
13+
[JsonPropertyName("companyName")]
14+
public string CompanyName { get; set; }
15+
16+
[JsonPropertyName("formType")]
17+
public string FormType { get; set; }
18+
19+
[JsonPropertyName("acceptedDate")]
20+
public string AcceptedDate { get; set; }
21+
22+
[JsonPropertyName("date")]
23+
public string Date { get; set; }
24+
25+
[JsonPropertyName("environmentalScore")]
26+
public double EnvironmentalScore { get; set; }
27+
28+
[JsonPropertyName("socialScore")]
29+
public double SocialScore { get; set; }
30+
31+
[JsonPropertyName("governanceScore")]
32+
public double GovernanceScore { get; set; }
33+
34+
[JsonPropertyName("ESGScore")]
35+
public double ESGScore { get; set; }
36+
37+
[JsonPropertyName("url")]
38+
public string Url { get; set; }
39+
}
40+
}

Tests/AdvancedData/AdvancedDataTests.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,16 @@ public async Task GetSharesFloatAsync()
9191
Assert.True(result.Data.OutstandingShares > 0);
9292
}
9393

94+
[Fact]
95+
public async Task GetESGScoreAsync()
96+
{
97+
var result = await api.GetESGScoreAsync("AAPL");
98+
99+
result.AssertNoErrors();
100+
Assert.NotEmpty(result.Data);
101+
102+
}
103+
94104
private Task<ApiResponse<StandardIndustrialClassificationResponse>> GetStandardIndustrialClassSwitch(string by, string value)
95105
{
96106
return by switch

0 commit comments

Comments
 (0)