/// <summary> /// Lookup transactions and return response. /// </summary> /// <param name="accountId">the account id</param> /// <param name="limt">the limit</param> /// <param name="keyLevel">the level</param> /// <param name="offset">nullable offset to start at</param> /// <returns>a paged list of transactions</returns> /// <exception cref="StepUpRequiredException">if further authentication is required</exception> public Task <PagedList <Transaction> > GetTransactions( string accountId, int limt, Level keyLevel, string offset) { var request = new GetTransactionsRequest { AccountId = accountId, Page = new Page { Limit = limt } }; if (offset != null) { request.Page.Offset = offset; } return(gateway(authenticateOnBehalfOf(keyLevel)).GetTransactionsAsync(request) .ToTask(response => { if (response.Status.Equals(RequestStatus.SuccessfulRequest)) { return new PagedList <Transaction>(response.Transactions, response.Offset); } throw new StepUpRequiredException("Transactions step up required."); })); }
private async Task <List <Transaction> > GetAllTransactionsForPeriod(string userId, DateTime startDate, DateTime endDate) { int skip = 0; // API has no limit, this value equal value from coinkeeper web version const int STEP_SIZE = 20; List <Transaction> result = new List <Transaction>(); TransactionsResponse transactionsResponse; do { GetTransactionsRequest request = new GetTransactionsRequest(userId) { Take = STEP_SIZE, Skip = skip, Period = new Period { From = startDate, To = endDate } }; transactionsResponse = await _coinKeeperClient.GetTransactions(request); if (transactionsResponse?.Transactions.Count > 0) { result.AddRange(transactionsResponse.Transactions); } skip += STEP_SIZE; await Task.Delay(TimeSpan.FromSeconds(2)); } while (transactionsResponse != null && transactionsResponse.HasMoreData); return(result); }
public GetTransactionsResponse GetTransactions(GetTransactionsRequest request) { var response = new GetTransactionsResponse { Transactions = new Transactions(_domainActions).Get() }; if (string.IsNullOrEmpty(request.SkuId)) { return(response); } var finalCurrency = "EUR"; response.Transactions = response.Transactions.Where(x => x.Sku == request.SkuId). Select(x => new TransactionEquivalence { Sku = x.Sku, Currency = finalCurrency, Amount = decimal.Round(x.Amount * _transactionInternalService.ConvertFrom( new RateEquivalence { From = x.Currency, To = finalCurrency }).Rate, 2, MidpointRounding.AwayFromZero) }).ToList(); response.TotalAmount = response.Transactions.GroupBy(x => x.Sku).Select(x => x.Sum(y => y.Amount)).FirstOrDefault(); return(response); }
/// <summary> /// Lookup transactions and return response. /// </summary> /// <param name="accountId">the account id</param> /// <param name="limt">the limit</param> /// <param name="keyLevel">the level</param> /// <param name="offset">nullable offset to start at</param> /// <returns>a paged list of transactions</returns> /// <exception cref="StepUpRequiredException">if further authentication is required</exception> public Task <PagedList <Transaction> > GetTransactions( string accountId, int limt, Level keyLevel, string offset = null) { var request = new GetTransactionsRequest { AccountId = accountId, Page = PageBuilder(limt, offset) }; return(gateway(authenticateOnBehalfOf(keyLevel)).GetTransactionsAsync(request) .ToTask(response => { switch (response.Status) { case RequestStatus.SuccessfulRequest: return new PagedList <Transaction>(response.Transactions, response.Offset); case RequestStatus.MoreSignaturesNeeded: throw new StepUpRequiredException("Balance step up required."); default: throw new RequestException(response.Status); } })); }
public GetTransactionsResponse GetTransactions(GetTransactionsRequest request, IAuthContext authContext) { var transactionsRepo = _unitOfWork.GetRepository <Transaction>(); var transactions = transactionsRepo.GetList(x => x.AccountId.ToString() == request.AccountId); GetTransactionsResponse response = new GetTransactionsResponse(); response.Items = new List <GetTransactionsResponseItem>(); foreach (Transaction trn in transactions) { response.Items.Add(new GetTransactionsResponseItem() { Amount = trn.Amount, Date = trn.Date.ToString(), Description = trn.Description, MerchantCategory = MerchantCategory.GetInstance(trn.MerchantCategory).Text, ProviderTransactionId = trn.ProviderTransactionId, TransactionCategory = TransactionCategory.GetInstance(trn.TransactionCategory).Text, TransactionStatus = TransactionStatus.GetInstance(trn.TransactionStatus).Text, TransactionType = TransactionType.GetInstance(trn.TransactionType).Text }); } return(response); }
public async Task <IEnumerable <Transaction> > GetTransactionsAsync(GetTransactionsRequest request) { var query = DbContext.Transactions.AsQueryable(); if (request.WalletId.HasValue) { query = query.Where(t => t.WalletId.Equals(request.WalletId.Value)); } if (request.DatesRange != null) { query = query .Where(t => request.DatesRange.From <= t.RegisteredOn) .Where(t => t.RegisteredOn <= request.DatesRange.To); } query = query.OrderBy(t => t.RegisteredOn); if (request.Page > 0 && request.RecordsPerPage > 0) { query = query.Skip((request.Page - 1) * request.RecordsPerPage).Take(request.RecordsPerPage); } var entities = await query.ToArrayAsync(); return(entities.Select(e => _mapper.Map <Transaction>(e))); }
public async Task <TransactionSet> GetTransactionsAsync(int minRecentTransactions, int minRecentBlocks) { var client = new WalletService.WalletServiceClient(_channel); var request = new GetTransactionsRequest { // TODO: include these. With these uncommented, all transactions are loaded. //StartingBlockHeight = -minRecentBlocks, //MinimumRecentTransactions = minRecentTransactions }; var responseStream = client.GetTransactions(request, cancellationToken: _tokenSource.Token).ResponseStream; var minedTransactions = new List <Block>(); Dictionary <Blake256Hash, WalletTransaction> unminedTransactions = null; while (await responseStream.MoveNext()) { var msg = responseStream.Current; if (msg.MinedTransactions != null) { minedTransactions.Add(MarshalBlock(msg.MinedTransactions)); } else { unminedTransactions = msg.UnminedTransactions.Select(MarshalWalletTransaction).ToDictionary(tx => tx.Hash); } } return(new TransactionSet(minedTransactions, unminedTransactions ?? new Dictionary <Blake256Hash, WalletTransaction>())); }
public async Task <Types.TransactionListWithProof> GetTransactionsAsync( ulong startVersion, ulong limit) { var updateToLatestLedgerRequest = new Types.UpdateToLatestLedgerRequest(); var requestItem = new Types.RequestItem(); var tansactionRequest = new GetTransactionsRequest(); requestItem.GetTransactionsRequest = tansactionRequest; tansactionRequest.StartVersion = startVersion; tansactionRequest.Limit = limit; // tansactionRequest.FetchEvents = true; updateToLatestLedgerRequest.RequestedItems.Add(requestItem); var result = await _client.UpdateToLatestLedgerAsync( updateToLatestLedgerRequest, new Metadata()); //Console.WriteLine("result = " + result.ResponseItems.Count); //Console.WriteLine("result = " + result.ResponseItems.FirstOrDefault()); List <CustomRawTransaction> retList = new List <CustomRawTransaction>(); foreach (var item in result.ResponseItems) { return(item.GetTransactionsResponse.TxnListWithProof); } return(null); }
public async Task <IActionResult> Get([FromQuery] GetTransactionsRequest request) { var query = new GetTransactionListQuery() { BetweenAmount = request.BetweenAmount, CardHolder = request.CardHolder, CardNumber = request.CardNumber, ChargeDate = request.ChargeDate, Limit = request.Limit, Offset = request.Offset }; var result = await queryDispatcher.ExecuteAsync(query); if (!result.Any()) { return(NotFound(query)); } var response = result.Select(x => new GetTransactionsResponse() { Amount = x.Amount, CardHolder = x.CardHolder, CardNumber = x.CardNumber, ChargeDate = x.ChargeDate, CurrencyCode = x.CurrencyCode, UniqueId = x.UniqueId }); return(Ok(response)); }
public void GetTransactionById(NodeCoreAdminClient adminClient) { Console.WriteLine("GetTransactionById"); Console.WriteLine("NC_CLI command: gettransaction <txId> [searchLength]"); String txId = "DED0DB5035D90A756B6F5333157F13D55103C5F76378FD732809CDE27E6B57F3"; GetTransactionsRequest request = new GetTransactionsRequest(); request.Ids.Add(txId.ToByteString()); request.SearchLength = 2000; GetTransactionsReply reply = adminClient.AdminClient.GetTransactions(request); if (reply.Success) { if (reply.Transactions.Count > 0) { //Display info int iBlockIndex = reply.Transactions[0].BlockNumber; double sourceAmount = Utils.ConvertAtomicToVbkUnits(reply.Transactions[0].Transaction.SourceAmount); Console.WriteLine("BlockIndex={0}, sourceAmount={1}", iBlockIndex, sourceAmount); } } Console.WriteLine("--------------------"); Console.WriteLine(); }
public override async Task<GetTransactionsResponse> GetTransactions(GetTransactionsRequest request, ServerCallContext context) { var ids = request.Ids.Any() ? request.Ids.ToArray() : cardsRepository.GetIds(); var transactionsRequest = new FilterTransactionsRequest { Cards = { ids }, TimestampFrom = request.TimestampFrom, TimestampTo = request.TimestampTo }; var transactionsResponse = await transactionsClient.FilterAsync(transactionsRequest, context.RequestHeaders.SelectCustom()); return new GetTransactionsResponse { Transactions = { transactionsResponse.Transactions } }; }
public override Task <GetTransactionsResult> Get(GetTransactionsRequest request, ServerCallContext context) { var transactions = request.Ids.Select(id => transactionsRepository.Get(id)) .Where(transaction => transaction != null) .Select(transaction => mapper.Map <Transaction>(transaction)) .ToArray(); return(Task.FromResult(new GetTransactionsResult { Transactions = { transactions } })); }
public override async Task <GetTransactionsResponse> GetTransactions(GetTransactionsRequest request, ServerCallContext context) { var filters = new FilterTransactionsRequest { Senders = { request.Ids }, Recipients = { request.Ids }, TimestampFrom = request.TimestampFrom, TimestampTo = request.TimestampTo }; var response = await transactionsClient.FilterAsync(filters, context.RequestHeaders.SelectCustom()); return(new GetTransactionsResponse { Transactions = { response.Transactions } }); }
public static TransactionResult GetTransaction(string transactionGuidInput, string paymentGuidInput, string transactioGroupInput) { Guid transactionGuid = Guid.Empty; Guid paymentGuid = Guid.Empty; Guid transactionGroupGuid = Guid.Empty; if (!Guid.TryParse(transactionGuidInput, out transactionGuid) || !Guid.TryParse(paymentGuidInput, out paymentGuid) || !Guid.TryParse(transactioGroupInput, out transactionGroupGuid)) { return(null); } Payment payment = Payment.CreateManager().Load(paymentGuid, GuidType.Internal); if (payment == null) { return(null); } ServiceLookupMethodMap slmm = ServiceLookupMethodMap.CreateManager().Load(payment.ServiceOffer.Service, payment.PaymentRequest.Customer.Country, LookupMethod.Wap); TransactionClient transactionClient = new TransactionClient(); transactionClient.AttachLogWriter(new CashflowLog(payment.ServiceOffer.Service)); GetTransactionsRequest getTransactionRequest = new GetTransactionsRequest(RequestMode.Default, payment.ExternalPaymentGuid.ToString(), slmm.PaymentConfiguration.PaymentCredentials.Username, slmm.PaymentConfiguration.PaymentCredentials.Password, transactionGroupGuid, null); GetTransactionsResponse getTransactionResponse = transactionClient.GetTransactions(getTransactionRequest, null); foreach (Cashflow.Message.Data.Transaction transaction in getTransactionResponse.Transactions) { if (transaction.TransactionID == transactionGuid) { return new TransactionResult() { Transaction = transaction, Username = slmm.PaymentConfiguration.PaymentCredentials.Username, Password = slmm.PaymentConfiguration.PaymentCredentials.Password } } } ; return(null); }
public void RunIndefinitely() { var filter = new TransactionFilter(); filter.FiltersByParty.Add(_party, new Filters()); // we use the default filter since we don't want to filter out any contracts // assemble the request for the transaction stream GetTransactionsRequest transactionsRequest = new GetTransactionsRequest { LedgerId = _ledgerId, Begin = new LedgerOffset { Boundary = LedgerOffset.Types.LedgerBoundary.LedgerBegin }, Filter = filter, Verbose = true }; // this StreamObserver reacts to transactions and prints a message if an error occurs or the stream gets closed Console.WriteLine($"{_party} starts reading transactions."); AsyncServerStreamingCall <GetTransactionsResponse> transactionObserver = _transactionService.GetTransactions(transactionsRequest, null, null, _cancellationTokenSource.Token); Task.Run(async() => { try { while (await transactionObserver.ResponseStream.MoveNext(CancellationToken.None)) { foreach (var transaction in transactionObserver.ResponseStream.Current.Transactions) { ProcessTransaction(transaction); } } Console.WriteLine($"{_party}'s transactions stream completed."); } catch (RpcException ex) { if (ex.StatusCode != StatusCode.Cancelled) { Console.Error.WriteLine($"{_party} encountered an RpcException while processing transactions! {ex.Message}"); } } catch (Exception ex) { Console.Error.WriteLine($"{_party} encountered an error while processing transactions! {ex.Message}"); } }); }
public async Task <TransactionSet> GetTransactionsAsync(int minRecentTransactions, int minRecentBlocks) { var client = WalletService.NewClient(_channel); var request = new GetTransactionsRequest { // TODO: include these. With these uncommented, all transactions are loaded. //StartingBlockHeight = -minRecentBlocks, //MinimumRecentTransactions = minRecentTransactions }; var resp = await client.GetTransactionsAsync(request, cancellationToken : _tokenSource.Token); var minedTransactions = resp.MinedTransactions.Select(MarshalBlock); var unminedTransactions = resp.UnminedTransactions.Select(MarshalWalletTransaction); return(new TransactionSet(minedTransactions.ToList(), unminedTransactions.ToDictionary(tx => tx.Hash))); }
private IAsyncStreamReader <GetTransactionTreesResponse> GetTransactionTreesImpl(TransactionFilter transactionFilter, LedgerOffset beginOffset, LedgerOffset endOffset, bool verbose, string accessToken, TraceContext traceContext) { var request = new GetTransactionsRequest { LedgerId = LedgerId, Filter = transactionFilter, Begin = beginOffset, End = endOffset, Verbose = verbose, TraceContext = traceContext }; var response = _transactionsClient.WithAccess(accessToken).Dispatch(request, (c, r, co) => c.GetTransactionTrees(r, co)); return(response.ResponseStream); }
public async Task <TransactionsResponse> GetTransactions(GetTransactionsRequest request) { var message = CreateHttpRequest(HttpMethod.Post, $"{HOST}/api/transaction/get"); string postContent = JsonConvert.SerializeObject(request); message.Content = new StringContent(postContent, Encoding.UTF8, "application/json"); HttpResponseMessage response = await _httpClient.SendAsync(message); response.EnsureSuccessStatusCode(); string responseContent = await response.Content.ReadAsStringAsync(); TransactionsResponse result = JsonConvert.DeserializeObject <TransactionsResponse>(responseContent); return(result); }
public async Task FetchTransactionsAsync_should_retrieve_a_list_of_transactions() { // Arrange using PlaidClient client = new PlaidClient { Environment = Environment.Sandbox }; // Act GetTransactionsRequest request = new GetTransactionsRequest { }; GetTransactionsResponse result = await client.FetchTransactionsAsync(request); // Assert result.SuccessfulOutcome.ShouldBeTrue(); result.Request.ShouldNotBeNullOrEmpty(); result.TransactionsReturned.ShouldBeGreaterThan(0); result.Transactions.Length.ShouldBeGreaterThan(0); result.Transactions[0].Amount.ShouldBeGreaterThan(0); }
/// <inheritdoc /> public async Task <TransactionResult> GetTransactionsAsync(AccessToken accessToken, bool?includePending = null, string accountId = null, DateTimeOffset?greaterThanDate = null, DateTimeOffset?lessThanDate = null) { Condition.Requires(accessToken).IsNotNull(); GetTransactionsRequest transactionRequest = new GetTransactionsRequest(this.clientId, this.clientSecret, accessToken.Value); if (includePending.HasValue || !string.IsNullOrWhiteSpace(accountId) || greaterThanDate.HasValue || lessThanDate.HasValue) { transactionRequest.Options = new TransactionOptionsRequest { Account = accountId, GreaterThanDate = greaterThanDate, LessThanDate = lessThanDate, Pending = includePending }; } HttpResponseMessage response = await this.httpClient.PostAsJsonAsync(GetEndpoint(ApiType.Connect, "get"), transactionRequest); string responseJson = await response.Content.ReadAsStringAsync(); TransactionResult result = new TransactionResult(); // 200 OK indicates success, response includes access token and accounts/transactions if (response.StatusCode == HttpStatusCode.OK) { // Can just re-use the AddUserResponse since it contains account and transaction objects AddUserResponse userResponse = JsonConvert.DeserializeObject <AddUserResponse>(responseJson); if (userResponse.Accounts != null) { result.Accounts = userResponse.Accounts.Select(x => x.ToAccount()).ToList(); } if (userResponse.Transactions != null) { result.Transactions = userResponse.Transactions.Select(x => x.ToTransaction()).ToList(); } return(result); } result.Exception = await this.ParseException(response, responseJson); return(result); }
/// <summary> /// Export transactions history for period from <paramref name="from"/> to <paramref name="to"/> /// </summary> /// <param name="from">Date from</param> /// <param name="to">date to</param> /// <returns></returns> public async Task <List <Transaction> > ExportData(DateTime from, DateTime to) { PingResponse pingResponse = await _coinKeeperClient.Ping(); string userId = pingResponse.UserInfo.UserId; GetTransactionsRequest request = new GetTransactionsRequest(userId) { Take = 20, Skip = 0, Period = new Period { From = from, To = to, } }; List <Transaction> result = await GetAllTransactionsForPeriod(userId, from, to); return(result); }
public async void SubscribeTransactions() { var request = new GetTransactionsRequest(); try { using (_transactionStream = lndClient.SubscribeTransactions(request)) { while (await _transactionStream.ResponseStream.MoveNext()) { var e = new NewTransactionEventArgs(); e.Transaction = _transactionStream.ResponseStream.Current; OnNewTransaction(this, e); } } }catch (Exception e) { Debug.Log(e); } }
public static bool TryReadTransactionHashes(GetTransactionsRequest request, out List <TransactionHash> hashes) { hashes = new List <TransactionHash>(); foreach (var hash in request.Hashes) { try { using (var stream = new ByteStream(Convert.FromBase64String(hash))) { hashes.Add(stream.ReadTransactionHash()); } } catch { hashes = null; return(false); } } return(true); }
public IAsyncEnumerator <GetTransactionsResponse> GetTransactions( TransactionFilter transactionFilter, LedgerOffset beginOffset, LedgerOffset endOffset = null, bool verbose = true, string accessToken = null, TraceContext traceContext = null) { var request = new GetTransactionsRequest { LedgerId = LedgerId, Filter = transactionFilter, Begin = beginOffset, End = endOffset, Verbose = verbose, TraceContext = traceContext }; var response = _transactionsClient.WithAccess(accessToken).Dispatch(request, (c, r, co) => c.GetTransactions(r, co)); return(response.ResponseStream); }
public override async Task <GetTransactionsReply> GetTransactions(GetTransactionsRequest request, ServerCallContext context) { var resp = new GetTransactionsReply { }; try { var client = LyraRestClient.Create(_config["network"], Environment.OSVersion.ToString(), "LyraBroker", "1.0"); var result = await client.SearchTransactionsAsync(request.AccountId, request.StartTime.ToDateTime().Ticks, request.EndTime.ToDateTime().Ticks, request.Count); if (result.ResultCode == APIResultCodes.Success) { for (int i = 0; i < result.Transactions.Count; i++) { var txDesc = result.Transactions[i]; var tx = new LyraTransaction { Height = txDesc.Height, Time = Timestamp.FromDateTime(txDesc.TimeStamp), IsReceive = txDesc.IsReceive, SendAccountId = txDesc.SendAccountId ?? "", SendHash = txDesc.SendHash ?? "", RecvAccountId = txDesc.RecvAccountId, RecvHash = txDesc.RecvHash ?? "" // protobuf not like null }; if (txDesc.Changes == null || !txDesc.Changes.ContainsKey(LyraGlobal.OFFICIALTICKERCODE)) { tx.BalanceChange = 0; } else { tx.BalanceChange = txDesc.Changes[LyraGlobal.OFFICIALTICKERCODE] / LyraGlobal.TOKENSTORAGERITO; } if (txDesc.Balances == null || !txDesc.Balances.ContainsKey(LyraGlobal.OFFICIALTICKERCODE)) { tx.Balance = 0; } else { tx.Balance = txDesc.Balances[LyraGlobal.OFFICIALTICKERCODE] / LyraGlobal.TOKENSTORAGERITO; } resp.Transactions.Add(tx); } } } catch (Exception ex) { _logger.LogWarning("In OpenWallet: " + ex.ToString()); } return(resp); }
public async Task<TransactionSet> GetTransactionsAsync(int minRecentTransactions, int minRecentBlocks) { var client = new WalletService.WalletServiceClient(_channel); var request = new GetTransactionsRequest { // TODO: include these. With these uncommented, all transactions are loaded. //StartingBlockHeight = -minRecentBlocks, //MinimumRecentTransactions = minRecentTransactions }; var responseStream = client.GetTransactions(request, cancellationToken: _tokenSource.Token).ResponseStream; var minedTransactions = new List<Block>(); Dictionary<Blake256Hash, WalletTransaction> unminedTransactions = null; while (await responseStream.MoveNext()) { var msg = responseStream.Current; if (msg.MinedTransactions != null) minedTransactions.Add(MarshalBlock(msg.MinedTransactions)); else unminedTransactions = msg.UnminedTransactions.Select(MarshalWalletTransaction).ToDictionary(tx => tx.Hash); } return new TransactionSet(minedTransactions, unminedTransactions ?? new Dictionary<Blake256Hash, WalletTransaction>()); }
public async Task<TransactionSet> GetTransactionsAsync(int minRecentTransactions, int minRecentBlocks) { var client = WalletService.NewClient(_channel); var request = new GetTransactionsRequest { // TODO: include these. With these uncommented, all transactions are loaded. //StartingBlockHeight = -minRecentBlocks, //MinimumRecentTransactions = minRecentTransactions }; var resp = await client.GetTransactionsAsync(request, cancellationToken: _tokenSource.Token); var minedTransactions = resp.MinedTransactions.Select(MarshalBlock); var unminedTransactions = resp.UnminedTransactions.Select(MarshalWalletTransaction); return new TransactionSet(minedTransactions.ToList(), unminedTransactions.ToDictionary(tx => tx.Hash)); }
public GetTransactionsResponse GetTransactionsFromRemoteAPI(GetTransactionsRequest request) { return(GetTransactionRESTAPI(Constants.GET_TRANSACTIONS_URL, request).GetAwaiter().GetResult()); }
public ApiResponse <List <Transaction> > GetTransactions(GetTransactionsRequest request) { return(SendApiRequest <GetTransactionsRequest, List <Transaction> >(request)); }
public ActionResult <GetTransactionsResponse> GetTransactions([FromQuery] GetTransactionsRequest request) { GetTransactionsResponse response = _accountDataService.GetTransactions(request, _authContext); return(Ok(response)); }
public async Task <IActionResult> GetTransactions(GetTransactionsRequest request) { var viewModel = await _service.GetTransactionsAsync(request); return(PartialView("_Transactions", viewModel)); }
private async Task <GetTransactionsResponse> GetTransactionRESTAPI(string url, GetTransactionsRequest request) { HttpClient client = new HttpClient(); var requestBody = new StringContent(JsonConvert.SerializeObject(request), Encoding.UTF8, "application/json"); HttpResponseMessage response = await client.GetAsync(url + "/" + request.CustomerID); response.EnsureSuccessStatusCode(); var responseBody = response.Content.ReadAsStringAsync().Result; return(JsonConvert.DeserializeObject <GetTransactionsResponse>(responseBody)); }