Beispiel #1
0
        private static async Task <TxStatus> ParseResponseAsync(string response)
        {
            TxStatus status = new TxStatus();

            using (JsonTextReader jtr = new JsonTextReader(new StringReader(response)))
            {
                while (await jtr.ReadAsync().ConfigureAwait(false))
                {
                    if (jtr.Value == null)
                    {
                        continue;
                    }
                    else if (jtr.Value.ToString() == "status")
                    {
                        await jtr.ReadAsync().ConfigureAwait(false);

                        status.Status =
                            jtr.Value.ToString() == "no_deposits" ? TxStatuses.NoDeposits :
                            jtr.Value.ToString() == "received" ? TxStatuses.Received :
                            jtr.Value.ToString() == "complete" ? TxStatuses.Complete :
                            jtr.Value.ToString() == "failed" ? TxStatuses.Failed : TxStatuses.Returned;
                    }
                    else if (jtr.Value.ToString() == "address")
                    {
                        await jtr.ReadAsync().ConfigureAwait(false);

                        status.Address = jtr.Value.ToString();
                    }
                    else if (jtr.Value.ToString() == "withdraw")
                    {
                        await jtr.ReadAsync().ConfigureAwait(false);

                        status.WithdrawalAddress = jtr.Value.ToString();
                    }
                    else if (jtr.Value.ToString() == "incomingCoin")
                    {
                        await jtr.ReadAsync().ConfigureAwait(false);

                        status.IncomingAmount = Convert.ToDouble(jtr.Value.ToString());
                    }
                    else if (jtr.Value.ToString() == "incomingType")
                    {
                        await jtr.ReadAsync().ConfigureAwait(false);

                        status.IncomingCoin = jtr.Value.ToString();
                    }
                    else if (jtr.Value.ToString() == "outgoingCoin")
                    {
                        await jtr.ReadAsync().ConfigureAwait(false);

                        status.OutgoingAmount = Convert.ToDouble(jtr.Value.ToString());
                    }
                    else if (jtr.Value.ToString() == "outgoingType")
                    {
                        await jtr.ReadAsync().ConfigureAwait(false);

                        status.OutgoingCoin = jtr.Value.ToString();
                    }
                    else if (jtr.Value.ToString() == "transaction")
                    {
                        await jtr.ReadAsync().ConfigureAwait(false);

                        status.TxID = jtr.Value.ToString();
                    }
                    else if (jtr.Value.ToString() == "error")
                    {
                        await jtr.ReadAsync().ConfigureAwait(false);

                        status.Error = jtr.Value.ToString();
                    }
                    else
                    {
                        continue;
                    }
                }
            }
            return(status);
        }
Beispiel #2
0
 /// <summary>
 /// Gets status of transaction (to be) deposited to supplied address.
 /// </summary>
 /// <param name="Address">Deposit address.</param>
 /// <returns>Transaction status.</returns>
 public static async Task <TxStatus> GetTransactionStatusAsync(string Address) =>
 await TxStatus.GetStatusAsync(Address).ConfigureAwait(false);