public static ReportRequestTransportPostDTO CreateFromBusinessObject(ReportRequestPostDTO reportRequest)
        {
            ReportRequestTransportPostDTO result = new ReportRequestTransportPostDTO();

            result.CallbackURL = reportRequest.CallbackURL;
            result.Columns     = reportRequest.Columns != null?reportRequest.Columns.ToArray <string>() : null;

            result.DownloadFormat = reportRequest.DownloadFormat;
            result.Preview        = reportRequest.Preview;
            result.ReportType     = reportRequest.ReportType;
            result.Tag            = reportRequest.Tag;

            if (reportRequest.Filters != null)
            {
                result.Filters = FilterReportsTransport.CreateFromBusinessObject(reportRequest.Filters);
            }

            if (String.IsNullOrWhiteSpace(reportRequest.Sort))
            {
                result.Sort = "CreationDate:ASC";
            }
            else
            {
                result.Sort = reportRequest.Sort;
            }

            return(result);
        }
Пример #2
0
        /// <summary>Creates new report request.</summary>
        /// <param name="hook">Report request instance to be created.</param>
        /// <returns>Report request instance returned from API.</returns>
        public ReportRequestDTO Create(ReportRequestPostDTO reportRequest)
        {
            if (!reportRequest.ReportType.HasValue)
            {
                reportRequest.ReportType = ReportType.TRANSACTIONS;
            }

            return(Create(null, reportRequest));
        }
Пример #3
0
        /// <summary>Creates new report request.</summary>
        /// <param name="hook">Report request instance to be created.</param>
        /// <returns>Report request instance returned from API.</returns>
        public async Task <ReportRequestDTO> CreateAsync(ReportRequestPostDTO reportRequest)
        {
            if (!reportRequest.ReportType.HasValue)
            {
                reportRequest.ReportType = ReportType.TRANSACTIONS;
            }

            return(await CreateAsync(null, reportRequest));
        }
Пример #4
0
        public void Test_Report_Transactions_Filtered_Create()
        {
            try
            {
                ReportRequestPostDTO reportPost = new ReportRequestPostDTO(ReportType.TRANSACTIONS);
                string johnsId         = this.GetJohn().Id;
                string walletId        = this.GetJohnsWallet().Id;
                var    minDebitedFunds = new Money()
                {
                    Amount = 111, Currency = CurrencyIso.EUR
                };
                var maxDebitedFunds = new Money()
                {
                    Amount = 222, Currency = CurrencyIso.EUR
                };
                var minFees = new Money()
                {
                    Amount = 3, Currency = CurrencyIso.JPY
                };
                var maxFees = new Money()
                {
                    Amount = 4, Currency = CurrencyIso.JPY
                };
                reportPost.Filters.AuthorId = johnsId;
                reportPost.Filters.WalletId = walletId;
                reportPost.Filters.MinDebitedFundsAmount   = minDebitedFunds.Amount;
                reportPost.Filters.MinDebitedFundsCurrency = minDebitedFunds.Currency;
                reportPost.Filters.MaxDebitedFundsAmount   = maxDebitedFunds.Amount;
                reportPost.Filters.MaxDebitedFundsCurrency = maxDebitedFunds.Currency;
                reportPost.Filters.MinFeesAmount           = minFees.Amount;
                reportPost.Filters.MinFeesCurrency         = minFees.Currency;
                reportPost.Filters.MaxFeesAmount           = maxFees.Amount;
                reportPost.Filters.MaxFeesCurrency         = maxFees.Currency;

                ReportRequestDTO report = this.Api.Reports.Create(reportPost);
                Assert.IsNotNull(report);
                Assert.AreEqual(ReportType.TRANSACTIONS, report.ReportType);
                Assert.IsNotNull(report.Filters);
                Assert.IsNotNull(report.Filters.AuthorId);
                Assert.AreEqual(johnsId, report.Filters.AuthorId);
                Assert.IsNotNull(report.Filters.WalletId);
                Assert.AreEqual(walletId, report.Filters.WalletId);
                Assert.AreEqual(minDebitedFunds.Amount, reportPost.Filters.MinDebitedFundsAmount);
                Assert.AreEqual(minDebitedFunds.Currency, reportPost.Filters.MinDebitedFundsCurrency);
                Assert.AreEqual(maxDebitedFunds.Amount, reportPost.Filters.MaxDebitedFundsAmount);
                Assert.AreEqual(maxDebitedFunds.Currency, reportPost.Filters.MaxDebitedFundsCurrency);
                Assert.AreEqual(minFees.Amount, reportPost.Filters.MinFeesAmount);
                Assert.AreEqual(minFees.Currency, reportPost.Filters.MinFeesCurrency);
                Assert.AreEqual(maxFees.Amount, reportPost.Filters.MaxFeesAmount);
                Assert.AreEqual(maxFees.Currency, reportPost.Filters.MaxFeesCurrency);
                Assert.IsTrue(report.Id.Length > 0);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
Пример #5
0
        protected ReportRequestDTO GetJohnsReport(ReportType reportType)
        {
            if (!BaseTest._johnsReports.ContainsKey(reportType))
            {
                ReportRequestPostDTO reportPost = new ReportRequestPostDTO(ReportType.TRANSACTIONS);
                BaseTest._johnsReports.Add(reportType, this.Api.Reports.Create(reportPost));
            }

            return(BaseTest._johnsReports[reportType]);
        }
Пример #6
0
        /// <summary>Creates new report request.</summary>
        /// <param name="idempotencyKey">Idempotency key for this request.</param>
        /// <param name="hook">Report request instance to be created.</param>
        /// <returns>Report request instance returned from API.</returns>
        public ReportRequestDTO Create(String idempotencyKey, ReportRequestPostDTO reportRequest)
        {
            if (!reportRequest.ReportType.HasValue)
            {
                reportRequest.ReportType = ReportType.TRANSACTIONS;
            }

            ReportRequestTransportPostDTO reportRequestTransport = ReportRequestTransportPostDTO.CreateFromBusinessObject(reportRequest);

            return(this.CreateObject <ReportRequestTransportDTO, ReportRequestTransportPostDTO>(idempotencyKey, MethodKey.ReportRequest, reportRequestTransport, reportRequestTransport.ReportType.ToString().ToLower()).GetBusinessObject());
        }
Пример #7
0
        protected async Task <ReportRequestDTO> GetJohnsReport(ReportType reportType)
        {
            if (!BaseTest._johnsReports.ContainsKey(reportType))
            {
                ReportRequestPostDTO reportPost = new ReportRequestPostDTO(ReportType.TRANSACTIONS);
                var reportRequest = await this.Api.Reports.CreateAsync(reportPost);

                BaseTest._johnsReports.Add(reportType, reportRequest);
            }

            return(BaseTest._johnsReports[reportType]);
        }
Пример #8
0
        /// <summary>Creates new report request.</summary>
        /// <param name="idempotencyKey">Idempotency key for this request.</param>
        /// <param name="hook">Report request instance to be created.</param>
        /// <returns>Report request instance returned from API.</returns>
        public async Task <ReportRequestDTO> CreateAsync(String idempotencyKey, ReportRequestPostDTO reportRequest)
        {
            if (!reportRequest.ReportType.HasValue)
            {
                reportRequest.ReportType = ReportType.TRANSACTIONS;
            }

            var reportRequestTransport = ReportRequestTransportPostDTO.CreateFromBusinessObject(reportRequest);

            var reportRequestTransportDTO = await this.CreateObjectAsync <ReportRequestTransportDTO, ReportRequestTransportPostDTO>(idempotencyKey, MethodKey.ReportRequest, reportRequestTransport, reportRequestTransport.ReportType.ToString().ToLower());

            return(reportRequestTransportDTO.GetBusinessObject());
        }
Пример #9
0
        public async Task <ReportRequestDTO> Create(string idempotencyKey, ReportRequestPostDTO reportRequest)
        {
            if (!reportRequest.ReportType.HasValue)
            {
                reportRequest.ReportType = ReportType.TRANSACTIONS;
            }

            ReportRequestTransportPostDTO reportRequestTransport = ReportRequestTransportPostDTO.CreateFromBusinessObject(reportRequest);

            var targetUrl = $"{_baseUrl}/reports/{reportRequestTransport.ReportType.ToString().ToLower()}";

            var result = await CreateEntity <ReportRequestTransportDTO, ReportRequestTransportPostDTO>(targetUrl, reportRequestTransport, idempotencyKey);

            return(result.GetBusinessObject());
        }
Пример #10
0
        public void Test_Report_Transactions_Create()
        {
            try
            {
                ReportRequestPostDTO reportPost = new ReportRequestPostDTO(ReportType.TRANSACTIONS);

                ReportRequestDTO report = this.Api.Reports.Create(reportPost);
                Assert.IsNotNull(report);
                Assert.AreEqual(ReportType.TRANSACTIONS, report.ReportType);
                Assert.IsTrue(report.Id.Length > 0);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
Пример #11
0
        public async Task Test_Report_Wallets_Create()
        {
            try
            {
                ReportRequestPostDTO reportPost = new ReportRequestPostDTO(ReportType.WALLETS);

                ReportRequestDTO report = await this.Api.Reports.Create(reportPost);

                Assert.IsNotNull(report);
                Assert.AreEqual(ReportType.WALLETS, report.ReportType);
                Assert.IsTrue(report.Id.Length > 0);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
Пример #12
0
        public async Task Test_Report_Wallets_Filtered_Create()
        {
            try
            {
                ReportRequestPostDTO reportPost = new ReportRequestPostDTO(ReportType.WALLETS);
                var temp = await this.GetJohn();

                string johnsId    = temp.Id;
                var    minBalance = new Money()
                {
                    Amount = 1, Currency = CurrencyIso.EUR
                };
                var maxBalance = new Money()
                {
                    Amount = 1000, Currency = CurrencyIso.EUR
                };
                var currency = CurrencyIso.EUR;
                reportPost.Filters.OwnerId            = johnsId;
                reportPost.Filters.MinBalanceAmount   = minBalance.Amount;
                reportPost.Filters.MinBalanceCurrency = minBalance.Currency;
                reportPost.Filters.MaxBalanceAmount   = maxBalance.Amount;
                reportPost.Filters.MaxBalanceCurrency = maxBalance.Currency;
                reportPost.Filters.Currency           = currency;
                ReportRequestDTO report = await this.Api.Reports.Create(reportPost);

                Assert.IsNotNull(report);
                Assert.AreEqual(ReportType.WALLETS, report.ReportType);
                Assert.IsNotNull(report.Filters);
                Assert.IsNotNull(report.Filters.OwnerId);
                Assert.AreEqual(johnsId, report.Filters.OwnerId);
                Assert.AreEqual(minBalance.Amount, reportPost.Filters.MinBalanceAmount);
                Assert.AreEqual(minBalance.Currency, reportPost.Filters.MinBalanceCurrency);
                Assert.AreEqual(maxBalance.Amount, reportPost.Filters.MaxBalanceAmount);
                Assert.AreEqual(maxBalance.Currency, reportPost.Filters.MaxBalanceCurrency);
                Assert.AreEqual(currency, reportPost.Filters.Currency);
                Assert.IsTrue(report.Id.Length > 0);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
        public ReportRequestPostDTO GetBusinessObject()
        {
            ReportRequestPostDTO result = new ReportRequestPostDTO(this.ReportType ?? Core.Enumerations.ReportType.TRANSACTIONS);

            result.CallbackURL = this.CallbackURL;
            result.Columns     = this.Columns != null?this.Columns.ToList <string>() : null;

            result.DownloadFormat = this.DownloadFormat;
            result.Preview        = this.Preview;
            result.ReportType     = this.ReportType;
            result.Sort           = this.Sort;
            result.Tag            = this.Tag;

            if (this.Filters != null)
            {
                result.Filters = this.Filters.GetBusinessObject();
            }

            return(result);
        }