private static async Task <QuoteRequest> ParseResponseAsync(string response) { QuoteRequest request = new QuoteRequest(); using (JsonTextReader jtr = new JsonTextReader(new StringReader(response))) { while (await jtr.ReadAsync().ConfigureAwait(false)) { if (jtr.Value == null) { continue; } else if (jtr.Value.ToString() == "pair") { await jtr.ReadAsync().ConfigureAwait(false); request.Pair = jtr.Value.ToString(); } else if (jtr.Value.ToString() == "withdrawalAmount") { await jtr.ReadAsync().ConfigureAwait(false); request.WithdrawalAmount = Convert.ToDouble(jtr.Value.ToString()); } else if (jtr.Value.ToString() == "depositAmount") { await jtr.ReadAsync().ConfigureAwait(false); request.DepositAmount = Convert.ToDouble(jtr.Value.ToString()); } else if (jtr.Value.ToString() == "expiration") { await jtr.ReadAsync().ConfigureAwait(false); request.Expiration = Convert.ToDouble(jtr.Value.ToString()); } else if (jtr.Value.ToString() == "quotedRate") { await jtr.ReadAsync().ConfigureAwait(false); request.QuotedRate = Convert.ToDouble(jtr.Value.ToString()); } else if (jtr.Value.ToString() == "minerFee") { await jtr.ReadAsync().ConfigureAwait(false); request.MinerFee = Convert.ToDouble(jtr.Value.ToString()); } else if (jtr.Value.ToString() == "error") { await jtr.ReadAsync().ConfigureAwait(false); request.Error = jtr.Value.ToString(); } else { continue; } } } return(request); }
/// <summary> /// Requests a quote for an exchange without exchanging. /// </summary> /// <param name="Pair">Coin pair to exchange between.</param> /// <param name="Amount">Amount of coin to be sent to withdrawal address.</param> /// <returns>Quote for exchange information.</returns> public static async Task <QuoteRequest> RequestQuoteAsync(string Pair, double Amount) => await QuoteRequest.RequestAsync(Pair, Amount).ConfigureAwait(false);