public async System.Threading.Tasks.Task <BalanceResponse> GetBalanceAsync() { String url = $"{Host}/getBalance"; String postData = $"{{\"clientKey\":\"{ClientKey}\"}}"; Http.Request request = new Http.Request() { Url = url, Method = "POST", PostData = postData, ContentType = "application/json" }; Http.Response response = await Client.ExecuteAsync(request); if (response.StatusCode == 200) { BalanceResponse balanceResponse = BalanceResponse.ParseFromJson(response.Body); return(balanceResponse); } else { throw new Exception(response.ToString()); } }
public double?GetBalance() { var jsonPostData = new JObject(); jsonPostData["clientKey"] = ClientKey; dynamic postResult = JsonPostRequest(ApiMethod.GetBalance, jsonPostData); if (postResult == null || postResult.Equals(false)) { DebugHelper.Out("API error", DebugHelper.Type.Error); return(null); } var balanceResponse = new BalanceResponse(postResult); if (!balanceResponse.ErrorId.Equals(0)) { ErrorMessage = balanceResponse.ErrorDescription; DebugHelper.Out( "API error " + balanceResponse.ErrorId + ": " + balanceResponse.ErrorDescription, DebugHelper.Type.Error ); return(null); } return(balanceResponse.Balance); }
public double?GetBalance() { var jsonPostData = new JObject { ["clientKey"] = ClientKey }; dynamic postResult = JsonPostRequest(ApiMethod.GetBalance, jsonPostData); if (postResult?.Equals(false) != false) { DebugHelper.Out(DebugHelper.Severity.Error, "API error"); return(null); } var balanceResponse = new BalanceResponse(postResult); if (!balanceResponse.ErrorId.Equals(0)) { ErrorMessage = balanceResponse.ErrorDescription; DebugHelper.Out( DebugHelper.Severity.Error , "API error " + balanceResponse.ErrorId + ": " + balanceResponse.ErrorDescription); return(null); } return(balanceResponse.Balance); }