Пример #1
0
        public static WexCurrency FromString(string s)
        {
            WexCurrency ret = WexCurrency.Unknown;

            Enum.TryParse <WexCurrency>(s.ToLowerInvariant(), out ret);
            return(ret);
        }
Пример #2
0
        static SortedSet <string> GetDeletedCurrencies(IEnumerable <string> resp_pairs)
        {
            var our_currencies = WexCurrencyHelper.GetAllCurrencies();

            foreach (string s_pair in resp_pairs)
            {
                string[] two_currs_arr = s_pair.Split(WexPairHelper.PAIR_TO_CURR_SPLIT_CHARS);
                if (two_currs_arr.Count() != 2)
                {
                    throw new Exception("Strange pair " + s_pair);
                }

                foreach (string s_curr in two_currs_arr)
                {
                    WexCurrency wex_curr = WexCurrencyHelper.FromString(s_curr);
                    if (wex_curr != WexCurrency.Unknown)
                    {
                        our_currencies.Remove(wex_curr);
                    }
                }
            }

            SortedSet <string> deleted_currencies = new SortedSet <string>();

            foreach (WexCurrency curr in our_currencies)
            {
                deleted_currencies.Add(WexCurrencyHelper.ToString(curr));
            }
            return(deleted_currencies);
        }
Пример #3
0
        /// <summary>
        /// This method can be used to retrieve the address for depositing crypto-currency.
        /// See https://github.com/wex-exchange/api-doc/blob/master/trade-api.md#CoinDepositAddress
        /// </summary>
        /// <param name="crypto_currency">Crypto currency</param>
        /// <returns>address for deposits</returns>
        public string CoinDepositAddress(WexCurrency crypto_currency)
        {
            var args = new Dictionary <string, string>()
            {
                { "method", "CoinDepositAddress" },
                { "coinName", WexCurrencyHelper.ToString(crypto_currency).ToUpperInvariant() }
            };

            string query_answer = QueryExec(args);
            var    json_result  = ParseAnswer(query_answer);

            return(json_result.Value <string>("address"));
        }
Пример #4
0
        public decimal GetAmount(WexCurrency curr)
        {
            if (Amounts == null)
            {
                return(0m);
            }

            decimal val;

            if (Amounts.TryGetValue(curr, out val))
            {
                return(val);
            }

            return(0m);
        }
Пример #5
0
        public static CurrencyType GetCurrencyType(WexCurrency v)
        {
            int key = (int)v;

            if (key > (int)WexCurrency.CRYPTO_BEGIN && key < (int)WexCurrency.CRYPTO_END)
            {
                return(CurrencyType.Crypto);
            }
            else if (key > (int)WexCurrency.FIAT_BEGIN && key < (int)WexCurrency.FIAT_END)
            {
                return(CurrencyType.Fiat);
            }
            else if (key > (int)WexCurrency.TOKENS_BEGIN && key < (int)WexCurrency.TOKENS_END)
            {
                return(CurrencyType.Token);
            }

            return(CurrencyType.Unknown);
        }
Пример #6
0
        static SortedSet <string> GetAddedCurrencies(List <string> resp_pairs)
        {
            SortedSet <string> added_currencies = new SortedSet <string>();

            foreach (string s_pair in resp_pairs)
            {
                string[] two_currs_arr = s_pair.Split(WexPairHelper.PAIR_TO_CURR_SPLIT_CHARS);
                if (two_currs_arr.Count() != 2)
                {
                    throw new Exception("Strange pair " + s_pair);
                }

                foreach (string s_curr in two_currs_arr)
                {
                    WexCurrency wex_curr = WexCurrencyHelper.FromString(s_curr);
                    if (wex_curr == WexCurrency.Unknown)
                    {
                        added_currencies.Add(s_curr.ToLowerInvariant());
                    }
                }
            }

            return(added_currencies);
        }
Пример #7
0
 public static string ToString(WexCurrency v)
 {
     return(Enum.GetName(typeof(WexCurrency), v));
 }