Skip to content

Commit 4ffbb66

Browse files
committed
Initial commit of the application.
- working network call to Coingecko API to fetch basic market info - unit testing setup done - MatBlazor template initialized to be used as the frontend of the application
1 parent 527ba0f commit 4ffbb66

37 files changed

+1281
-3
lines changed

.gitignore

Lines changed: 449 additions & 0 deletions
Large diffs are not rendered by default.

.idea/.idea.CryptoTracker/.idea/.gitignore

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/.idea.CryptoTracker/.idea/.name

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/.idea.CryptoTracker/.idea/encodings.xml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/.idea.CryptoTracker/.idea/indexLayout.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/.idea.CryptoTracker/.idea/riderModule.iml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/.idea.CryptoTracker/.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CryptoStatsSource/CoingeckoSource.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Net.Http;
5+
using System.Threading.Tasks;
6+
using CryptoStatsSource.model;
7+
using Tiny.RestClient;
8+
9+
namespace CryptoStatsSource
10+
{
11+
public class CoingeckoSource : ICryptoStatsSource
12+
{
13+
private const string BaseUrl = "https://api.coingecko.com/api/";
14+
private const string ApiVersion = "v3";
15+
16+
private readonly TinyRestClient _client = new(new HttpClient(), $"{BaseUrl}{ApiVersion}/");
17+
18+
public CoingeckoSource()
19+
{
20+
_client.Settings.Formatters.OfType<JsonFormatter>().First().UseSnakeCase();
21+
}
22+
23+
public async Task<List<MarketEntry>> GetMarketEntries(string currency, params string[] ids) => await _client
24+
.GetRequest("coins/markets").AddQueryParameter("vs_currency", currency)
25+
.AddQueryParameter("ids", String.Join(",", ids)).ExecuteAsync<List<MarketEntry>>();
26+
}
27+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using System.Collections.Generic;
2+
using System.Threading.Tasks;
3+
using CryptoStatsSource.model;
4+
5+
namespace CryptoStatsSource
6+
{
7+
public interface ICryptoStatsSource
8+
{
9+
public Task<List<MarketEntry>> GetMarketEntries(string currency, params string[] ids);
10+
}
11+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net5.0</TargetFramework>
5+
<AssemblyName>CryptoStatsSource</AssemblyName>
6+
<RootNamespace>CryptoStatsSource</RootNamespace>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
11+
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
12+
<PackageReference Include="SimpleInjector" Version="5.3.0" />
13+
<PackageReference Include="Tiny.RestClient" Version="1.7.1" />
14+
<PackageReference Include="xunit.assert" Version="2.4.1" />
15+
<PackageReference Include="xunit.core" Version="2.4.1" />
16+
</ItemGroup>
17+
18+
</Project>

0 commit comments

Comments
 (0)