/// <summary> /// Returns how many RAW is owned and how many have not yet been received by account. /// </summary> /// <param name="acc">The account to get balance for.</param> /// <returns>Balance of <paramref name="acc"/> in RAW.</returns> public async Task <BalanceResult> GetBalanceAsync(RaiAddress acc) { var action = new GetBalance(acc); var handler = new ActionHandler <GetBalance, BalanceResult>(_node); return(await handler.Handle(action)); }
public override async Task <SpeechletResponse> OnIntentAsync(IntentRequest intentRequest, Session session) { if (AlexaUtils.IsRequestInvalid(session)) { return(await Task.FromResult <SpeechletResponse>(InvalidApplicationId(session))); } var intent = intentRequest.Intent; var intentName = intent?.Name; switch (intentName.ToUpper()) { case "BALANCE": return(await GetBalance.GetResults(session)); case "TRANSACTIONS": return(await GetTransactions.GetResults(session, intentRequest.Intent.Slots["date"].Value)); case "PAYMENT": return(await MakePayment.GetResults(session, decimal.Parse(intentRequest.Intent.Slots["amount"].Value), intentRequest.Intent.Slots["account"].Value)); case "WINNERS": return(await Winners.GetResults()); case "MORTGAGE": return(await Mortgage.GetResults(session)); case "SAVINGS": return(await Insights.GetResults(session)); default: return(await Task.FromResult <SpeechletResponse>(GetOnLaunchAsyncResult(session))); } }
async Task <GetBalanceResponse> ICommonGameActionsProvider.GetBalanceAsync(GetBalance request) { if (_useRealUgs) { var client = _flycowApiClientProvider.GetApiClient(); var token = await _flycowApiClientProvider.GetApiToken(client); var balanceResponse = await client.GetBalanceAsync(new GetBalanceRequest { authtoken = request.AuthToken }, token); return(new GetBalanceResponse { Balance = balanceResponse.bal, CurrencyCode = balanceResponse.cur, }); } var playerId = GetPlayerIdFromToken(request); var balance = await _gameQueries.GetPlayableBalanceAsync(playerId); return(new GetBalanceResponse { Balance = balance.Balance, CurrencyCode = balance.CurrencyCode, }); }
public async Task Test_GetBalance() { var GetBalance = new GetBalance(API_URL); var balance = await GetBalance.Invoke("hx0000000000000000000000000000000000000000"); Console.WriteLine($"Treasury : {balance.ToString()}"); }
public async Task Test_GetBalance2() { var getBalance = GetBalance.Create(Consts.ApiUrl.TestNet); var balance = await getBalance("hx0000000000000000000000000000000000000000"); Console.WriteLine($"Treasury : {balance.ToString()}"); }
public static void DisplayBalance() { var wallet = WalletHelper.LoadWallet(); var getBalance = GetBalance.Create(WalletHelper.TestNetUrl); var balance = getBalance.Invoke(wallet.Address).Result; Console.WriteLine($"Your current ICX balance for {wallet.Address} is : {Utils.Loop2ICX(balance)} ICX"); }
public void Test_RPCMethodNotFoundException() { var getBalance = new GetBalance(Consts.ApiUrl.TestNet); GetBalanceRequestMessage requestMessage = new GetBalanceRequestMessage("hx0000000000000000000000000000000000000000"); FieldInfo methodFieldInfo = typeof(GetBalanceRequestMessage).GetField("Method"); methodFieldInfo.SetValue(requestMessage, "icx_GetBalance"); // 'icx_getBalance' is correct Assert.ThrowsAsync(typeof(RPCMethodNotFoundException), async() => await getBalance.Invoke(requestMessage)); }
async Task <GetBalanceResponse> ICommonGameActionsProvider.GetBalanceAsync(GetBalance request) { var playerId = GetPlayerIdFromToken(request); var balance = await _gameQueries.GetPlayableBalanceAsync(playerId); return(new GetBalanceResponse { Balance = balance.Balance, CurrencyCode = balance.CurrencyCode, }); }
public void Test_RPCInvalidParamsException() { var getBalance = new GetBalance(Consts.ApiUrl.TestNet); GetBalanceRequestMessage requestMessage = new GetBalanceRequestMessage("hx0000000000000000000000000000000000000000"); FieldInfo addressFieldInfo = requestMessage.Parameters.GetType().GetField("Address"); addressFieldInfo.SetValue(requestMessage.Parameters, "hxz000000000000000000000000000000000000000"); // 'hx0000000000000000000000000000000000000000' is correct Assert.ThrowsAsync(typeof(RPCInvalidParamsException), async() => await getBalance.Invoke(requestMessage)); }
/// <summary> /// Get anticaptcha balance. /// </summary> /// <returns>Returns anticaptcha balance.</returns> public float GetBalance() { var req = new GetBalance { ClientKey = AnticaptchaKey }; var reqJson = JsonConvert.SerializeObject(req); var response = (BalanceResult)ExecuteRequest <BalanceResult>(ApiMethodUrl.GetBalance, reqJson, "POST"); if (response.ErrorId != 0) { throw new Exception($"{response.ErrorCode} #{response.ErrorId}:\n {response.ErrorDescription}"); } return(response.Balance); }
public void CreditCardPaymentHandler() { //init var dalMock = new Mock <IPaymentAccessLayer>(); var getBalance = new GetBalance(); //act new GetBalanceHandler(dalMock.Object).Read(getBalance); //assert dalMock.Verify(layer => layer.GetCashBalance(), Times.Once); dalMock.Verify(layer => layer.GetCreditBalance(), Times.Once); }
private void AddPSinhCongNoToDKy(List <GetBalance> dkData, DateTime balanceDate, DateTime fromDate) { List <GetBalance> psNotDk = new List <GetBalance>(); // TH ngày đầu kỳ nhỏ hơn ngày bắt đầu thì đi lấy tất cả phát sinh trước ngày bắt đầu var psDKData = this.ReportDAO.GetSoTongHopNo(balanceDate, fromDate.AddDays(-1)); // tính lại đầu kỳ ( đầu kỳ = đầu kỳ + phát sinh) if (psDKData != null) { foreach (var psdk in psDKData) { GetBalance item = dkData.Find(o => o.AccountID == psdk.AccountID && o.AccountDetailID == psdk.AccountDetailID && o.CustomerID == psdk.CustomerID); if (item != null) { item.DebitBalance += psdk.PSNo; item.CreditBalance += psdk.PSCo; } else { psNotDk.Add(new GetBalance { AccountID = psdk.AccountID, AccountDetailID = psdk.AccountDetailID, CustomerID = psdk.CustomerID, CustomerSName = psdk.CustomerSName, CustomerName = psdk.CustomerName, BalanceDate = fromDate, DebitBalance = psdk.PSNo, CreditBalance = psdk.PSCo }); } } } // Thêm phát sinh mà không có đầu kỳ vào list đầu kỳ if (psNotDk.Count > 0) { dkData.AddRange(psNotDk); } }
public string GetBalanceAvailable(string accountno) { var balance = GetBalance.Get(accountno); return(balance); }
public CheckBalance(GetBalance getBalance, ILoggerFactory loggerFactory) { _getBalance = getBalance; _logger = loggerFactory.CreateLogger <CheckBalance>(); }
public async Task <GetBalanceResponse> Get([FromUri] GetBalance request) { return(await GameActions.GetBalanceAsync(request)); }
public CreateFakeDatabaseContext() { string databaseName = Guid.NewGuid().ToString(); _context = TestContextCreater.Create(databaseName); _context.Employees.Add(new Employee() { CardUid = "04346C824D5380", Balance = 10, Email = "*****@*****.**" }); _context.Employees.Add(new Employee() { CardUid = "99999999999999", Balance = 0, Email = "*****@*****.**" }); var terminals = new Faker <Terminal>() .RuleFor(x => x.TerminalId, x => Guid.NewGuid().ToString()) .Generate(10); _context.Terminals.Add(new Terminal() { TerminalId = "04346C824D538012", ProductId = 1 }); _context.Terminals.AddRange(terminals); var products = new Faker <Product>() .RuleFor(x => x.ProductId, x => x.IndexFaker + 1) .RuleFor(x => x.Productname, x => x.Commerce.ProductName()) .RuleFor(x => x.ProductDescription, x => x.Lorem.Sentence()) .RuleFor(x => x.ProductPrice, x => Convert.ToDecimal((x.Commerce.Price(0.5m, 2m)))) .RuleFor(x => x.Terminal, x => x.PickRandom(terminals)) .Generate(10); _context.Products.AddRange(products); var loggerFactory = new LoggerFactory(); var getBalance = new GetBalance(_context); _checkBalance = new CheckBalance(getBalance, loggerFactory); var getProduct = new GetProduct(_context); _checkTerminal = new CheckTerminal(getProduct, loggerFactory); var writeTransaction = new WriteTransaction(_context, loggerFactory); _processPayment = new ProcessPayment(writeTransaction); var writeNewcard = new WriteNewCard(_context, loggerFactory); _newCardScanned = new NewCardScanned(writeNewcard, getProduct); _context.SaveChanges(); }
public async Task <BigInteger> GetBalance() { var getBalance = new GetBalance(ApiUrl); return(await getBalance.Invoke(Address)); }
public async Task <GetBalanceResponse> Get([FromUri] GetBalance request) { await ValidateTokenData(request); return(await GameActions.GetBalanceAsync(request)); }