Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions GradDemo.Api/Controllers/CryptoController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,14 @@ public async Task<Response<CryptoCoinResponse>> GetCoin(string coinId, string cu

return Response<CryptoCoinResponse>.Error("Something went wrong");
}

[HttpGet("available/currencies")]
public async Task<string?[]> GetCurrencies()
{

var res = await _coinGeckoProvider.GetAllCurrencies();

return res;
}
}
}
21 changes: 20 additions & 1 deletion GradDemo.Api/Providers/CoinGeckoProvider.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using GradDemo.Api.Models.CoinGecko;
using GradDemo.Api.Models;
using GradDemo.Api.Models.CoinGecko;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -43,5 +44,23 @@ public CoinGeckoProvider(string baseUrl)

return null;
}

public async Task<string?[]> GetAllCurrencies()
{

string url = "api/v3/simple/supported_vs_currencies";
HttpResponseMessage response = await client.GetAsync(url);
if (response.IsSuccessStatusCode)
{
string res = await response.Content.ReadAsStringAsync();

var coinGeckoResult = JsonConvert.DeserializeObject<string?[]>(res);


return coinGeckoResult;
}

return null;
}
}
}