Skip to content

Commit d5bd818

Browse files
committed
Implement lists
1 parent 385f651 commit d5bd818

File tree

4 files changed

+86
-0
lines changed

4 files changed

+86
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
using FinancialModelingPrepApi.Model;
22
using FinancialModelingPrepApi.Model.CompanyValuation;
3+
using System.Collections.Generic;
34
using System.Threading.Tasks;
45

56
namespace FinancialModelingPrepApi.Abstractions.CompanyValuation
67
{
78
public interface ICompanyValuation
89
{
910
public Task<ApiResponse<CompanyProfileResponse>> GetCompanyProfileAsync(string symbol);
11+
public Task<ApiResponse<List<SymbolResponse>>> GetSymbolsListAsync();
12+
public Task<ApiResponse<List<SymbolResponse>>> GetTradableSymbolsListAsync();
13+
public Task<ApiResponse<List<SymbolResponse>>> GetETFListAsync();
1014
}
1115
}

FinancialModelingPrepApi/Core/CompanyValuation/CompanyValuation.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,41 @@ public async Task<ApiResponse<CompanyProfileResponse>> GetCompanyProfileAsync(st
3838

3939
return ApiResponse.FromSucces(result.Data.First());
4040
}
41+
42+
public Task<ApiResponse<List<SymbolResponse>>> GetETFListAsync()
43+
{
44+
const string url = "[version]/etf/list";
45+
46+
var pathParams = new NameValueCollection()
47+
{
48+
{ "version", ApiVersion.v3.ToString() }
49+
};
50+
51+
return client.GetAsync<List<SymbolResponse>>(url, pathParams, null);
52+
}
53+
54+
public Task<ApiResponse<List<SymbolResponse>>> GetSymbolsListAsync()
55+
{
56+
const string url = "[version]/stock/list";
57+
58+
var pathParams = new NameValueCollection()
59+
{
60+
{ "version", ApiVersion.v3.ToString() }
61+
};
62+
63+
return client.GetAsync<List<SymbolResponse>>(url, pathParams, null);
64+
}
65+
66+
public Task<ApiResponse<List<SymbolResponse>>> GetTradableSymbolsListAsync()
67+
{
68+
const string url = "[version]/available-traded/list";
69+
70+
var pathParams = new NameValueCollection()
71+
{
72+
{ "version", ApiVersion.v3.ToString() }
73+
};
74+
75+
return client.GetAsync<List<SymbolResponse>>(url, pathParams, null);
76+
}
4177
}
4278
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace FinancialModelingPrepApi.Model.CompanyValuation
2+
{
3+
public class SymbolResponse
4+
{
5+
public string symbol { get; set; }
6+
public string name { get; set; }
7+
public double price { get; set; }
8+
public string exchange { get; set; }
9+
}
10+
}

Tests/CompanyValuation/CompanyValuationTests.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,41 @@ public async Task GetCompanyProfile_Unknown_Symbol_Returns_HasError_True()
3535
Assert.NotNull(result);
3636
Assert.True(result.HasError);
3737
}
38+
39+
[Fact]
40+
public async Task GetSymbolsList()
41+
{
42+
var api = ServiceProvider.GetRequiredService<IFinancialModelingPrepApiClient>();
43+
44+
var result = await api.CompanyValuation.GetSymbolsListAsync();
45+
46+
Assert.NotNull(result);
47+
Assert.False(result.HasError);
48+
Assert.NotEmpty(result.Data);
49+
}
50+
51+
[Fact]
52+
public async Task GetETFList()
53+
{
54+
var api = ServiceProvider.GetRequiredService<IFinancialModelingPrepApiClient>();
55+
56+
var result = await api.CompanyValuation.GetETFListAsync();
57+
58+
Assert.NotNull(result);
59+
Assert.False(result.HasError);
60+
Assert.NotEmpty(result.Data);
61+
}
62+
63+
[Fact]
64+
public async Task GetTradableSymbolsList()
65+
{
66+
var api = ServiceProvider.GetRequiredService<IFinancialModelingPrepApiClient>();
67+
68+
var result = await api.CompanyValuation.GetTradableSymbolsListAsync();
69+
70+
Assert.NotNull(result);
71+
Assert.False(result.HasError);
72+
Assert.NotEmpty(result.Data);
73+
}
3874
}
3975
}

0 commit comments

Comments
 (0)