public static async Task fetchdata(string pair) { var client = new HttpClient(); var fullurl = "https://www.btcturk.com/api/ticker"; var result = await client.GetStringAsync(fullurl); RootObject r = JsonConvert.DeserializeObject <RootObject>(result); double tryRate = Fixer.Convert("TRY", "USD", 1); if (pair == "fiat") { tryData.ask = r.ask.ToString(); tryData.bid = r.bid.ToString(); tryData.last = r.last.ToString(); tryData.volume = r.volume.ToString(); tryData.high = r.high.ToString(); tryData.low = r.low.ToString(); tryData.pair = "TRY"; } else { usdData.ask = toString(r.ask * tryRate); usdData.bid = toString(r.bid * tryRate); usdData.last = toString(r.last * tryRate); usdData.volume = r.volume.ToString(); usdData.high = toString(r.high * tryRate); usdData.low = toString(r.low * tryRate); usdData.pair = "USD"; } //System.Diagnostics.Debug.WriteLine(usdData); }
public Transaction Exchange(Transaction trans) { ExchangeRate excRate = Fixer.Rate(trans.Source_Currency, trans.Destination_Currency); trans.FX_Rate = excRate.Rate.ToString("0.00"); trans.Destination_Amount = Fixer.Convert(trans.Source_Currency, trans.Destination_Currency, Double.Parse(trans.Source_Amount)).ToString("0.00"); return(trans); }
public string valuta() { if (isNumeric == true) { exchangeResult = Fixer.Convert(curentCurrency, newCurrency, Convert.ToDouble(txtDeposit.Text)); } return($"{Math.Round(exchangeResult, 4)} {newCurrency}"); }
public static double?Calculate(CurrencyCalculationModel calculationModel) { if (calculationModel == null || calculationModel.CurrencyFrom == null || calculationModel.CurrencyTo == null) { return(null); } double result = Fixer.Convert(calculationModel.CurrencyFrom, calculationModel.CurrencyTo, calculationModel.ValueToCalc); return(result); }
protected override void Execute(CodeActivityContext context) { var aPIKey = APIKey.Get(context); Fixer.SetApiKey(aPIKey); var inputAmount = InputAmount.Get(context); var inputCurrency = InputCurrency.Get(context); var outputCurrency = OutputCurrency.Get(context); double outputAmount = Fixer.Convert(inputCurrency, outputCurrency, inputAmount); OutputAmount.Set(context, outputAmount); }
public void Conversion_With_String_Returns_Value() { double converted = Fixer.Convert("USD", "EUR", 100); Assert.AreNotEqual(converted, 0); }
public void Conversion_With_Symbol_Returns_Value() { double converted = Fixer.Convert(Symbols.GBP, Symbols.USD, 100); Assert.AreNotEqual(converted, 0); }
public void Invalid_To_Symbol_ThrowsException() { Fixer.Convert("GBP", "XYZ", 100); }
public void Invalid_From_Symbol_Throws_Exception() { Fixer.Convert("ABC", "USD", 100); }
public void Invalid_Api_Key_ThrowsException() { Fixer.SetApiKey(null); Fixer.Convert(Symbols.USD, Symbols.EUR, 100); }
public MainWindow() { Fixer.SetApiKey("ff3340ef6706308913308472e0fc7382"); double current1 = Fixer.Convert(Symbols.USD, Symbols.KZT, 1); double current2 = Fixer.Convert(Symbols.EUR, Symbols.KZT, 1); double current3 = Fixer.Convert(Symbols.KWD, Symbols.KZT, 1); double current4 = Fixer.Convert(Symbols.AUD, Symbols.KZT, 1); double current5 = Fixer.Convert(Symbols.ALL, Symbols.KZT, 1); double current6 = Fixer.Convert(Symbols.JPY, Symbols.KZT, 1); double current7 = Fixer.Convert(Symbols.KPW, Symbols.KZT, 1); double current8 = Fixer.Convert(Symbols.JOD, Symbols.KZT, 1); double current9 = Fixer.Convert(Symbols.RUB, Symbols.KZT, 1); double current10 = Fixer.Convert(Symbols.PKR, Symbols.KZT, 1); //List<CurrentInKzt> currents = new List<CurrentInKzt>() //{ // new CurrentInKzt() // { // Name="USD", // QuantityOfKzt = Fixer.Convert(Symbols.USD, Symbols.KZT, 1) // }, // new CurrentInKzt() // { // Name="EUR", // QuantityOfKzt = Fixer.Convert(Symbols.EUR, Symbols.KZT, 1) // }, // new CurrentInKzt() // { // Name="KWD", // QuantityOfKzt = Fixer.Convert(Symbols.KWD, Symbols.KZT, 1) // }, // new CurrentInKzt() // { // Name="AUD", // QuantityOfKzt = Fixer.Convert(Symbols.AUD, Symbols.KZT, 1) // }, // new CurrentInKzt() // { // Name="ALL", // QuantityOfKzt = Fixer.Convert(Symbols.ALL, Symbols.KZT, 1) // }, // new CurrentInKzt() // { // Name="JPY", // QuantityOfKzt = Fixer.Convert(Symbols.JPY, Symbols.KZT, 1) // }, // new CurrentInKzt() // { // Name="KPW", // QuantityOfKzt = Fixer.Convert(Symbols.KPW, Symbols.KZT, 1) // }, // new CurrentInKzt() // { // Name="JOD", // QuantityOfKzt = Fixer.Convert(Symbols.JOD, Symbols.KZT, 1) // }, // new CurrentInKzt() // { // Name="RUB", // QuantityOfKzt = Fixer.Convert(Symbols.RUB, Symbols.KZT, 1) // }, // new CurrentInKzt() // { // Name="PKR", // QuantityOfKzt = Fixer.Convert(Symbols.PKR, Symbols.KZT, 1) // } //}; InitializeComponent(); }