private static async Task <List <RecentTx> > ParseResponseAsync(string response) { List <RecentTx> TxList = new List <RecentTx>(); RecentTx NewTx = new RecentTx(); using (JsonTextReader jtr = new JsonTextReader(new StringReader(response))) { while (await jtr.ReadAsync().ConfigureAwait(false)) { if (jtr.TokenType.ToString() == "StartObject") { if (!string.IsNullOrEmpty(NewTx.CurrencyInput)) { TxList.Add(NewTx); } NewTx = new RecentTx(); } else if (jtr.Value == null) { continue; } else if (jtr.Value.ToString() == "curIn") { await jtr.ReadAsync().ConfigureAwait(false); NewTx.CurrencyInput = jtr.Value.ToString(); } else if (jtr.Value.ToString() == "curOut") { await jtr.ReadAsync().ConfigureAwait(false); NewTx.CurrencyOutput = jtr.Value.ToString(); } else if (jtr.Value.ToString() == "amount") { await jtr.ReadAsync().ConfigureAwait(false); NewTx.Amount = Convert.ToDouble(jtr.Value.ToString()); } else if (jtr.Value.ToString() == "timestamp") { await jtr.ReadAsync().ConfigureAwait(false); NewTx.TimeStamp = Convert.ToDouble(jtr.Value.ToString()); } else { continue; } } } if (!string.IsNullOrEmpty(NewTx.CurrencyInput)) { TxList.Add(NewTx); } return(TxList); }
/// <summary> /// Gets information on recent transactions completed by ShapeShift. /// </summary> /// <param name="Max">Maximum number of transactions to return. Must be betweeen 1 and 50, inclusive.</param> /// <returns>List of recent transactions.</returns> public static async Task <List <RecentTx> > GetRecentTransactionsAsync(int Max = 5) => await RecentTx.GetRecentTransactionsAsync(Max).ConfigureAwait(false);