Skip to content

Commit 6cae2e7

Browse files
committed
Add Press Releases Endpoint
1 parent 6a53fd2 commit 6cae2e7

File tree

4 files changed

+53
-0
lines changed

4 files changed

+53
-0
lines changed

FinancialModelingPrepApi/Abstractions/CompanyValuation/ICompanyValuationProvider.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,7 @@ public interface ICompanyValuationProvider
3838

3939
public Task<ApiResponse<CompanyRatingResponse>> GetCompanyRatingAsync(string symbol);
4040
public Task<ApiResponse<List<CompanyRatingResponse>>> GetHistoricalCompanyRatingAsync(string symbol, int? limit = 140);
41+
42+
public Task<ApiResponse<List<PressReleasesResponse>>> GetPressReleasesAsync(string symbol, int? limit = null);
4143
}
4244
}

FinancialModelingPrepApi/Core/CompanyValuation/CompanyValuationProvider.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,5 +439,25 @@ private Task<ApiResponse<List<TickerSearchResponse>>> SearchInternalAsync(string
439439

440440
return client.GetJsonAsync<List<TickerSearchResponse>>(byTicker ? urlByTicker : url, pathParams, queryString);
441441
}
442+
443+
public Task<ApiResponse<List<PressReleasesResponse>>> GetPressReleasesAsync(string symbol, int? limit = null)
444+
{
445+
const string url = "[version]/press-releases/[symbol]";
446+
447+
var pathParams = new NameValueCollection()
448+
{
449+
{ "version", ApiVersion.v3.ToString() },
450+
{ "symbol", symbol},
451+
};
452+
453+
var queryString = new QueryStringBuilder();
454+
455+
if (limit != null)
456+
{
457+
queryString.Add("limit", limit);
458+
}
459+
460+
return client.GetJsonAsync<List<PressReleasesResponse>>(url, pathParams, queryString);
461+
}
442462
}
443463
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System.Text.Json.Serialization;
2+
3+
namespace MatthiWare.FinancialModelingPrep.Model.CompanyValuation
4+
{
5+
public class PressReleasesResponse
6+
{
7+
[JsonPropertyName("symbol")]
8+
public string Symbol { get; set; }
9+
10+
[JsonPropertyName("date")]
11+
public string Date { get; set; }
12+
13+
[JsonPropertyName("title")]
14+
public string Title { get; set; }
15+
16+
[JsonPropertyName("text")]
17+
public string Text { get; set; }
18+
}
19+
}

Tests/CompanyValuation/CompanyValuationTests.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,18 @@ public async Task GetMarketCapAsync()
255255
Assert.Equal("AAPL", result.Data.Symbol);
256256
}
257257

258+
[Fact]
259+
public async Task GetPressReleasesAsync()
260+
{
261+
var result = await api.GetPressReleasesAsync("AAPL", 2);
262+
263+
result.AssertNoErrors();
264+
Assert.NotEmpty(result.Data);
265+
Assert.Equal(2, result.Data.Count);
266+
Assert.All(result.Data, data => Assert.False(string.IsNullOrEmpty(data.Title)));
267+
Assert.All(result.Data, data => Assert.False(string.IsNullOrEmpty(data.Text)));
268+
}
269+
258270
public static IEnumerable<object[]> AvailableExchanges
259271
{
260272
get

0 commit comments

Comments
 (0)