示例#1
0
        public void ShouldGetDepositsByTransferIds()
        {
            // Arrange
            var transferIds = new List <string>
            {
                "111aaa222bbb",
                "333ccc444ddd"
            };

            var filter = $"Processor_Transfer_ID IN (" + string.Join(',', transferIds) + ")";

            _apiUserRepository.Setup(r => r.GetDefaultApiUserToken()).Returns(token);
            _restRequestBuilder.Setup(m => m.NewRequestBuilder()).Returns(_restRequest.Object);
            _restRequest.Setup(m => m.WithAuthenticationToken(token)).Returns(_restRequest.Object);
            _restRequest.Setup(m => m.WithFilter(filter)).Returns(_restRequest.Object);
            _restRequest.Setup(m => m.Build()).Returns(_request.Object);

            _request.Setup(m => m.Search <MpDeposit>()).Returns(new List <MpDeposit>());

            // Act
            var result = _fixture.GetDepositsByTransferIds(transferIds);

            // Assert
            Assert.NotNull(result);
        }
示例#2
0
        public List <SettlementEventDto> GetDepositsForSync(DateTime startDate, DateTime endDate)
        {
            var deposits = _pushpayService.GetDepositsByDateRange(startDate, endDate);

            if (!deposits.Any())
            {
                return(null);
            }

            var transferIds = deposits.Select(r => "'" + r.Key + "'").ToList();

            // check to see if any of the deposits we're pulling over have already been deposited
            var existingDeposits   = _depositRepository.GetDepositsByTransferIds(transferIds);
            var existingDepositIds = existingDeposits.Select(r => r.ProcessorTransferId).ToList();

            var depositsToProcess = new List <SettlementEventDto>();

            foreach (var deposit in deposits)
            {
                if (!existingDepositIds.Contains(deposit.Key))
                {
                    depositsToProcess.Add(deposit);
                }
            }

            return(depositsToProcess);
        }