public async void TestTransactionRequest() { IContainer container = InitContainer(typeof(YodleeService)); YodleeService yodleeService = container.GetInstance <YodleeService>(); YCobrandLoginRequest cobrandLoginRequest = new YCobrandLoginRequest().SetCobrandUserName(CoBrandUserName) .SetCobrandPassword(CoBrandPassword); YCobrandLoginResponse yCobrandLoginResponse = await yodleeService.LoginCobrand(cobrandLoginRequest); YUserLoginRequest userLoginRequest = new YUserLoginRequest() .SetCobrandSessionToken(yCobrandLoginResponse.cobrandConversationCredentials.sessionToken) .SetUserName(UserName) .SetUserPassword(UserPassword); YUserLoginResponse yUserLoginResponse = await yodleeService.LoginUser(userLoginRequest); YTransactionsSearchRequest transactionsSearchRequest = new YTransactionsSearchRequest() .SetCoBrandToken(yCobrandLoginResponse.cobrandConversationCredentials.sessionToken) .SetUserSessionToken(yUserLoginResponse.userContext.conversationCredentials.sessionToken) .SetContainerType(EContainerType.bank) .SetPageSize(1, 10); YTransactionsSearchResponse t = await yodleeService.GetTransactions2(transactionsSearchRequest); YTransactionsSearchResponse tt = yodleeService.GetTransactions3(transactionsSearchRequest); YTransactionsSearchResponse transactions = yodleeService.GetTransactions(transactionsSearchRequest).First(); Assert.AreEqual(transactions.searchResult.Transactions.Count, 10); }
internal YTransactionsSearchResponse GetTransactions3(YTransactionsSearchRequest request) { HttpContent content = CreateHttpContent(request); var task = Browser.PostAsyncAndGetJsonReponseAs <YTransactionsSearchResponse>(YodleeCommands.EXECUTE_USER_SEARCH_REQUEST, content); return(task.Result); }
/// <summary> /// Handles the specified command. /// </summary> /// <param name="cmd">The command.</param> public async void Handle(YodleeGetTransactionsCommand cmd) { YCobrandLoginRequest cobrandLoginRequest = new YCobrandLoginRequest().SetCobrandUserName(cmd.CobrandUserName) .SetCobrandPassword(cmd.CobrandPassword); YCobrandLoginResponse yCobrandLoginResponse = await Yodlee.LoginCobrand(cobrandLoginRequest); YUserLoginRequest userLoginRequest = new YUserLoginRequest() .SetCobrandSessionToken(yCobrandLoginResponse.cobrandConversationCredentials.sessionToken) .SetUserName(cmd.UserName) .SetUserPassword(cmd.UserPassword); YUserLoginResponse yUserLoginResponse = await Yodlee.LoginUser(userLoginRequest); YTransactionsSearchRequest transactionsSearchRequest = new YTransactionsSearchRequest() .SetCoBrandToken(yCobrandLoginResponse.cobrandConversationCredentials.sessionToken) .SetUserSessionToken(yUserLoginResponse.userContext.conversationCredentials.sessionToken) .SetContainerType(EContainerType.bank); var lookup = cmd.AccountsNumbers.ToLookup(o => o); IEnumerable <YTransactionsSearchResponse> transactions = Yodlee.GetTransactions(transactionsSearchRequest); foreach (var transaction in transactions) { var currentTransation = transaction; SendReply(new InfoAccumulator(), cmd, reply => { reply.HitsCount = currentTransation.numberOfHits; reply.TotalTransactionsCount = currentTransation.countOfAllTransaction; reply.Transactions = currentTransation.searchResult.Transactions.Where(t => !lookup.Contains(t.account.itemAccountId)) .Select(ConvertToApiTransaction); reply.AccountNumbers = cmd.AccountsNumbers; }); } }
/// <summary> /// Gets the transactions. /// </summary> /// <param name="request">The request.</param> /// <returns></returns> internal IEnumerable <YTransactionsSearchResponse> GetTransactions(YTransactionsSearchRequest request) { int startIdx = 1; int pageSize = 1000; request.SetPageSize(startIdx, pageSize); HttpContent content = CreateHttpContent(request); while (true) { var yTransactionsSearchResponse = Browser.PostAsyncAndGetJsonReponseAs <YTransactionsSearchResponse>(YodleeCommands.EXECUTE_USER_SEARCH_REQUEST, content).Result; if (yTransactionsSearchResponse.numberOfHits < 1) { break; } startIdx += pageSize; request.SetPageSize(startIdx, pageSize); content = CreateHttpContent(request); yield return(yTransactionsSearchResponse); } }