Skip to content

Commit 48aae63

Browse files
committed
Finish enterprise value call
1 parent d5bd818 commit 48aae63

File tree

6 files changed

+105
-1
lines changed

6 files changed

+105
-1
lines changed

FinancialModelingPrepApi/Abstractions/CompanyValuation/ICompanyValuation.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@ namespace FinancialModelingPrepApi.Abstractions.CompanyValuation
88
public interface ICompanyValuation
99
{
1010
public Task<ApiResponse<CompanyProfileResponse>> GetCompanyProfileAsync(string symbol);
11+
1112
public Task<ApiResponse<List<SymbolResponse>>> GetSymbolsListAsync();
1213
public Task<ApiResponse<List<SymbolResponse>>> GetTradableSymbolsListAsync();
1314
public Task<ApiResponse<List<SymbolResponse>>> GetETFListAsync();
15+
16+
public Task<ApiResponse<List<EnterpriseValueResponse>>> GetEnterpriseValueAsync(string symbol, Period period = Period.Quarter, int limit = 40);
1417
}
1518
}

FinancialModelingPrepApi/Core/CompanyValuation/CompanyValuation.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,27 @@ public Task<ApiResponse<List<SymbolResponse>>> GetTradableSymbolsListAsync()
7474

7575
return client.GetAsync<List<SymbolResponse>>(url, pathParams, null);
7676
}
77+
78+
public Task<ApiResponse<List<EnterpriseValueResponse>>> GetEnterpriseValueAsync(string symbol, Period period = Period.Quarter, int limit = 40)
79+
{
80+
const string url = "[version]/enterprise-values/[symbol]";
81+
82+
var pathParams = new NameValueCollection()
83+
{
84+
{ "version", ApiVersion.v3.ToString() },
85+
{ "symbol", symbol }
86+
};
87+
88+
var queryString = new QueryStringBuilder();
89+
90+
queryString.Add("limit", limit);
91+
92+
if (period != Period.Quarter)
93+
{
94+
queryString.Add("period", period.ToString().ToLower());
95+
}
96+
97+
return client.GetAsync<List<EnterpriseValueResponse>>(url, pathParams, queryString);
98+
}
7799
}
78100
}

FinancialModelingPrepApi/Abstractions/ApiVersion.cs renamed to FinancialModelingPrepApi/Model/ApiVersion.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace FinancialModelingPrepApi.Abstractions
1+
namespace FinancialModelingPrepApi.Model
22
{
33
public enum ApiVersion
44
{
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
namespace FinancialModelingPrepApi.Model.CompanyValuation
2+
{
3+
public class EnterpriseValueResponse
4+
{
5+
public string symbol { get; set; }
6+
public string date { get; set; }
7+
public double stockPrice { get; set; }
8+
public long numberOfShares { get; set; }
9+
public double marketCapitalization { get; set; }
10+
public long minusCashAndCashEquivalents { get; set; }
11+
public long addTotalDebt { get; set; }
12+
public double enterpriseValue { get; set; }
13+
}
14+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace FinancialModelingPrepApi.Model
2+
{
3+
public enum Period
4+
{
5+
Quarter,
6+
Annual,
7+
}
8+
}

Tests/CompanyValuation/CompanyValuationTests.cs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using FinancialModelingPrepApi;
22
using FinancialModelingPrepApi.Abstractions.CompanyValuation;
3+
using FinancialModelingPrepApi.Model;
34
using Microsoft.Extensions.DependencyInjection;
45
using System.Threading.Tasks;
56
using Xunit;
@@ -71,5 +72,61 @@ public async Task GetTradableSymbolsList()
7172
Assert.False(result.HasError);
7273
Assert.NotEmpty(result.Data);
7374
}
75+
76+
[Fact]
77+
public async Task GetEnterpriseValue()
78+
{
79+
var api = ServiceProvider.GetRequiredService<IFinancialModelingPrepApiClient>();
80+
81+
var result = await api.CompanyValuation.GetEnterpriseValueAsync("AAPL", Period.Annual, 5);
82+
83+
Assert.NotNull(result);
84+
Assert.False(result.HasError);
85+
Assert.NotEmpty(result.Data);
86+
Assert.Equal(5, result.Data.Count);
87+
Assert.All(result.Data, data => Assert.Equal("AAPL", data.symbol));
88+
}
89+
90+
[Fact]
91+
public async Task GetIncomeStatement()
92+
{
93+
var api = ServiceProvider.GetRequiredService<IFinancialModelingPrepApiClient>();
94+
95+
var result = await api.CompanyValuation.GetIncomeStatementAsync("AAPL", Period.Annual, 5);
96+
97+
Assert.NotNull(result);
98+
Assert.False(result.HasError);
99+
Assert.NotEmpty(result.Data);
100+
Assert.Equal(5, result.Data.Count);
101+
Assert.All(result.Data, data => Assert.Equal("AAPL", data.symbol));
102+
}
103+
104+
[Fact]
105+
public async Task GetCashFlowStatement()
106+
{
107+
var api = ServiceProvider.GetRequiredService<IFinancialModelingPrepApiClient>();
108+
109+
var result = await api.CompanyValuation.GetCashFlowStatementAsync("AAPL", Period.Annual, 5);
110+
111+
Assert.NotNull(result);
112+
Assert.False(result.HasError);
113+
Assert.NotEmpty(result.Data);
114+
Assert.Equal(5, result.Data.Count);
115+
Assert.All(result.Data, data => Assert.Equal("AAPL", data.symbol));
116+
}
117+
118+
[Fact]
119+
public async Task GetBalanceSheetStatement()
120+
{
121+
var api = ServiceProvider.GetRequiredService<IFinancialModelingPrepApiClient>();
122+
123+
var result = await api.CompanyValuation.GetBalanceSheetStatementAsync("AAPL", Period.Annual, 5);
124+
125+
Assert.NotNull(result);
126+
Assert.False(result.HasError);
127+
Assert.NotEmpty(result.Data);
128+
Assert.Equal(5, result.Data.Count);
129+
Assert.All(result.Data, data => Assert.Equal("AAPL", data.symbol));
130+
}
74131
}
75132
}

0 commit comments

Comments
 (0)