public void GetCurrencyBalance(string key, Action <bool, float> callBack) { StartCoroutine( SendRequest( null, Method.GET, $"contracts/currency/balances", new Dictionary <string, string> { { "key", key } }, null, (string json, bool callCompleted) => { if (callCompleted) { try { if (json.Contains("_fixed_")) { callBack?.Invoke(true, CurrencyBalanceFloatData.GetValue(json)); } else { callBack?.Invoke(true, CurrencyBalanceIntData.GetValue(json)); } } catch (Exception ex) { Debug.LogError($"GetCurrencyBalance: Failed json string: {json}, ex: {ex.Message}"); callBack?.Invoke(false, -1); } } else { callBack?.Invoke(false, -1); }; })); }
public static float GetValue(string json) { CurrencyBalanceFloatData currencyBalance = JsonUtility.FromJson <CurrencyBalanceFloatData>(json); return(float.Parse(currencyBalance.value.__fixed__)); }