public Task <GetBalanceResponse> GetBalance(GetBalanceRequest request) { var response = new GetBalanceResponse(); try { var wallet = (from p in _context.WalletType join c in _context.Wallets on p.WalletTypeId equals c.WalletTypeId where p.WalletTypeName == request.AccountType select new { Balance = c.Balance, }).FirstOrDefault(); response.Data.Balance = wallet.Balance; } catch (Exception ex) { response.Code = ErrorCode.GetError(ErrorCode.SystemError).Key; response.Message = ErrorCode.GetError(ErrorCode.SystemError).Value; Logger.Error(ex); } return(Task.FromResult(response)); }
private static async Task <GetBalanceResponse> GetKeyBalance(string clientKey) { string request = JsonConvert.SerializeObject(new GetBalanceRequest(clientKey)); using (HttpRequestMessage httpRequest = new HttpRequestMessage(HttpMethod.Post, AntiCaptchaEndpoints.GetBalanceUrl)) { httpRequest.Content = new StringContent(request, Encoding.UTF8, "application/json"); using (HttpResponseMessage httpResponse = await AntiCaptchaGlobals.HttpClient.SendAsync(httpRequest)) { httpResponse.EnsureSuccessStatusCode(); string value = await httpResponse.Content.ReadAsStringAsync(); GetBalanceResponse ret = JsonConvert.DeserializeObject <GetBalanceResponse>(value); if (ret.ErrorId > 0) { throw new AntiCaptchaException($"{ret.ErrorCode}:{ret.ErrorDescription}"); } return(ret); } } }
public static async Task <GetBalanceResponse> GetBalance(string curr) { //Get nonce: TimeSpan t = DateTime.UtcNow - new DateTime(1970, 1, 1); double timeUnix = t.TotalSeconds; //Form request Uri: string uri = string.Format("account/getbalance?apikey={0}&nonce={1}¤cy={2}", API_KEY, timeUnix, curr); HttpRequestMessage mesg = new HttpRequestMessage() { RequestUri = new Uri(uri, UriKind.Relative), Method = HttpMethod.Get }; //Compute Signature and add to request header: string sign = GetSignature(new Uri(client.BaseAddress, mesg.RequestUri)); mesg.Headers.Add("apisign", sign); //SendAsync request and await response object: GetBalanceResponse balanceResponse = null; HttpResponseMessage response = await client.SendAsync(mesg); if (response.IsSuccessStatusCode) { balanceResponse = await response.Content.ReadAsAsync <GetBalanceResponse>(); } return(balanceResponse); }
public async Task <GetBalanceResponse> GetBalance(string address) { var request = new RestRequest(Consts.GetBalanceUri, Method.GET); request.AddUrlSegment("id", address); var response = await _client.ExecuteTaskAsync(request); if (!response.IsSuccessful) { return(new GetBalanceResponse() { Error = response.ErrorMessage }); } // Successful response returns String Value with HttpCode 200, // Unsuccessful response return Json with HttpCode 200, so there are no correct way to detect error if (response.Content.Contains("\"error\"")) { return(GetBalanceResponse.FromJson(response.Content)); } if (double.TryParse(response.Content, out double balance)) { return(new GetBalanceResponse(balance)); } return(new GetBalanceResponse() { Error = "Failed to parse balance" }); }
public async Task GetBalanceSuccess() { GetBalanceResponse response = await GetExplorer().GetBalance(_wallet); Assert.True(response.Success); Assert.True(response.Balance > 0); }
public GetBalanceResponse GetWalletBalance(GetBalanceRequest getBalanceRequest) { string content = JsonConvert.SerializeObject(getBalanceRequest); string path = "/vendorwallet/GetBalance"; string response = Post(content, path); GetBalanceResponse balanceResponse = JsonConvert.DeserializeObject <GetBalanceResponse>(response); return(balanceResponse); }
public GetBalanceResponse GetVendorBalance(GetBalanceRequest getBalanceRequest) { string content = JsonConvert.SerializeObject(getBalanceRequest); string path = string.Format("/vendorwallet/{0}/GetBalance", _vendorName); string response = Post(content, path); GetBalanceResponse balanceResponse = JsonConvert.DeserializeObject <GetBalanceResponse>(response); return(balanceResponse); }
async void BalanceTimer_Tick(object sender) { if (_model.Session != null) { GetBalanceResponse response = await DiceWebAPI.GetBalanceAsync(_model.Session, _model.Currency); if (response.Success) { _model.InitModel(); } } }
public override async Task <GetBalanceResponse> GetBalance(GetBalanceRequest request, ServerCallContext context) { var balances = await _b2C2RestClient.BalanceAsync(context.CancellationToken); var result = new GetBalanceResponse { Timestamp = DateTime.UtcNow.ToTimestamp() }; result.AssetBalances.AddRange(Map(balances)); return(result); }
public async Task FetchAccountBalanceAsync_should_retrieve_the_account_balances_of_an_user() { // Arrange using PlaidClient client = new PlaidClient { Environment = Environment.Sandbox }; // Act GetBalanceRequest request = new GetBalanceRequest { }; GetBalanceResponse result = await client.FetchAccountBalanceAsync(request); // Assert result.Request.ShouldNotBeNullOrEmpty(); result.Accounts.Length.ShouldBeGreaterThanOrEqualTo(1); result.Accounts[0].Balance.Current.ShouldBeGreaterThanOrEqualTo(1); }
private GetBalanceResponse CreateGetBalanceResponse(GetBalanceResponse response, List <Limit> limit) { foreach (Limit value in limit) { if (value.TransactionCategory == "1" && value.TransactionDate == DateTimeOffset.Now.Date) { response.Ecommerce += value.Amount; } if (value.TransactionCategory == "0" && value.TransactionDate == DateTimeOffset.Now.Date) { response.CardPresent += value.Amount; } } return(response); }
public void GetBalanceResponse() { var responseXml = File.ReadAllText(@"TestData\GetBalance\GetBalanceResponseReply1.xml"); var response = new GetBalanceResponse(responseXml); Assert.AreEqual("XCP", response.Protocol); Assert.AreEqual("REPLY", response.Action); Assert.AreEqual("BALANCE", response.Object); Assert.AreEqual("Command successful", response.ResponseText); Assert.True(response.IsSuccess); Assert.AreEqual(200, response.ResponseCode); Assert.AreEqual(8549.18, response.balance); Assert.AreEqual(1676.05, response.hold_balance); }
private List <VendorBalance> GetWalletBalances() { GetBalanceResponse response = _vendorApi.GetWalletBalance(new GetBalanceRequest { UserId = _userSession.UserID, DomainId = _domainId, UserName = _userSession.Username }); if (!response.Success) { throw new CeException(String.Format("Cant get wallet balances, vendorId: {0}, domainId: {1}, UserId: {2}", _vendor, _domainId, _userSession.UserID)); } return(response.VendorBalances); }
public async Task <IActionResult> GetBalance(GetBalanceRequest request) { var response = new GetBalanceResponse(); try { response = await _accountQueries.GetBalance(request); } catch (Exception ex) { response.Code = ErrorCode.GetError(ErrorCode.SystemError).Key; response.Message = ErrorCode.GetError(ErrorCode.SystemError).Value; Logger.Error($"Exception: {ex} , Method:GetBalance"); } return(Ok(response)); }
public void GetBalanceResponse_Error() { var responseXml = File.ReadAllText(@"TestData\GetBalance\GetBalanceResponseReply2.xml"); var response = new GetBalanceResponse(responseXml); Assert.AreEqual("XCP", response.Protocol); Assert.AreEqual("REPLY", response.Action); Assert.AreEqual("BALANCE", response.Object); Assert.AreEqual("An error occurred", response.ResponseText); Assert.False(response.IsSuccess); Assert.AreEqual(500, response.ResponseCode); Assert.AreEqual(0, response.balance); Assert.AreEqual(0, response.hold_balance); }
/// <inheritdoc /> public override double GetBalance() { using (CWebClient client = new CWebClient()) { if (Timeout > 0) { client.Timeout = Timeout; } client.Headers.Add(HttpRequestHeader.ContentType, "application/json"); var response = client.UploadString("https://api.anti-captcha.com/getBalance", JsonConvert.SerializeObject(new GetBalanceRequest(ApiKey))); GetBalanceResponse gbr = JsonConvert.DeserializeObject <GetBalanceResponse>(response); if (gbr.errorId > 0) { throw new Exception(gbr.errorCode); } return(gbr.balance); } }
/// <inheritdoc /> public override double GetBalance() { using (CWebClient client = new CWebClient()) { if (Timeout > 0) { client.Timeout = Timeout; } client.Headers.Add(HttpRequestHeader.Accept, "application/json"); client.Headers.Add(HttpRequestHeader.ContentType, "application/x-www-form-urlencoded"); var response = client.UploadString("http://api.dbcapi.me/api/user", $"username={User}&password={Pass}"); GetBalanceResponse gbr = JsonConvert.DeserializeObject <GetBalanceResponse>(response); if (gbr.status != 0) { throw new Exception("Invalid Credentials"); } return(gbr.balance / 100); } }
public ActionResult GetBalanceRequest() { GetBalanceRequest getRequest = new GetBalanceRequest(); acctRepository acctRepo = new acctRepository(); GetBalanceResponse response = new GetBalanceResponse(); //Input stream using (Stream stream = Request.InputStream) { using (StreamReader reader = new StreamReader(stream)) { getRequest = JsonConvert.DeserializeObject <GetBalanceRequest>(reader.ReadToEnd()); } } //end of Input stream var balance = acctRepo.GetBalanceRequest(getRequest); //validation if (balance == null) { response.merchantCode = getRequest.MerchantCode; response.serialNo = getRequest.SerialNo; response.msg = "Account Not Found "; response.code = 50100; return(Json(response)); } response.acctInfo = balance; response.merchantCode = getRequest.MerchantCode; response.serialNo = getRequest.SerialNo; response.msg = "Success"; response.code = 0; //end of validation return(Json(response)); }
public async Task <Result <GetBalanceResponse> > GetBalanceSrvAsync(GetBalanceRequest request) { Result <GetBalanceResponse> result = new Result <GetBalanceResponse>(); GetBalanceResponse response = new GetBalanceResponse(); List <Limit> limit = new List <Limit>(); try { ValidategetBalanceRequest(request); limit = await RetrieveLimitFromDb(request); response = CreateGetBalanceResponse(response, limit); result.Payload = response; } catch (Exception ex) { logger.LogError(ex.Message); GetExeptionResult(result, ex.Message); } return(result); }
static public void GetBalance(BitcoinAddress address, NBitcoin.Network network, GetBalanceResponse response, bool includeImmature = false, bool unspentOnly = false, bool colored = true) { ObservableWWW.Get(URL(network, "balances/" + EscapeUrlPart(address.ToString()) + CreateParameters("includeImmature", includeImmature, "unspentOnly", unspentOnly, "colored", colored))). Subscribe(x => response(JsonUtility.FromJson <Models.BalanceModel>(x).Result(), network), ex => Debug.Log("error : " + ex.Message)); }