Couple of things: With the class
https://github.com/Coding-Enthusiast/Watch-Only-Bitcoin-Wallet/blob/MVVM/WalletServices/PriceServices.csIf you have an enum, use it instead of a string in the get method. Thats what its for.
public static async Task<decimal> GetPrice(ServiceNames serviceName)
Doing that will prevent the need for this.
default:
price = 0;
break;
You shouldn't really do that anyway. The caller should be treating your method as a black box. If the service doesnt exist, throw an exception. Don't give the user a heart attack and return a 0 price!
Using a switch statement also means you violate the open closed principal. You should really use an Interface and have concrete types of "BitFinex" ect. Which will enable you to mock the call in your unit tests. Also, the convention is to name async method with async.
public interface IPriceClient
{
Task<Decimal> GetPriceAsync();
}
namespace WalletServices
{
public class BitfinexService : ApiCall, IPriceClient
{
public async Task<decimal> GetPriceAsync()
{
JObject jResult = await GetApiResponse("https://api.bitfinex.com/v1/pubticker/btcusd");
decimal price = (decimal)jResult["last_price"];
return price;
}
}
}