Exemple #1
0
        /// <summary>Reads and parses response headers (pagination etc.)</summary>
        /// <param name="headers">The original response headers</param>
        /// <param name="listPaginated">The list</param>
        private ListPaginated <T> ReadResponseHeaders <T>(IList <Parameter> headers, ListPaginated <T> listPaginated)
        {
            headers = headers.Where(x => x.Name != null).ToList();
            foreach (var header in headers)
            {
                var value = header.Value.ToString();

                if (header.Name.ToLower().Contains(Constants.X_NUMBER_OF_PAGES.ToLower()))
                {
                    listPaginated.TotalPages = int.Parse(value);
                    continue;
                }

                if (header.Name.ToLower().Contains(Constants.X_NUMBER_OF_ITEMS.ToLower()))
                {
                    listPaginated.TotalItems = int.Parse(value);
                    continue;
                }

                if (header.Name.ToLower().Contains(Constants.LINK.ToLower()))
                {
                    var links = CustomSplit(value, ',');

                    if (links.Count <= 0)
                    {
                        continue;
                    }

                    SetLinksForList(listPaginated, links);
                }
            }

            return(listPaginated);
        }
Exemple #2
0
        /// <summary>
        /// Get a list of subscriptions
        /// </summary>
        /// <param name="subscriptions">The related subscriptions</param>
        /// <param name="referenceSegment">(optional) the related segment, if not provided and you have multiple segments, defaults on the first segment</param>
        /// <param name="referenceCustomer">(optional) Filter - returns only subscription where given customer is the recipient</param>
        /// <param name="referenceCustomerBuyer">(optional) Filter - returns only subscription where given customer is the buyer</param>
        /// <param name="html">(optional) true to have the localized text as HTML string, false for plain text. Default is true</param>
        /// <param name="page">(optional) Pagination : page index (starts from 1) </param>
        /// <param name="sizePage">(optional) Pagination : page size (default is 10) </param>
        public virtual RequestReport ListSubscriptions(out ListPaginated <Subscription> subscriptions, object referenceSegment, object referenceCustomer, object referenceCustomerBuyer, bool?html, int?page, int?sizePage)
        {
            subscriptions = null;

            // create the request
            RequestFluent request;
            var           result = this.CreateRequest(out request, EndpointsV1.Subscriptions);

            // if succeeded
            if (result.IsSuccess())
            {
                // append all parameters
                request
                .AddUrlParameter(EndpointParametersV1.ReferenceSegment, this.ToString(referenceSegment))
                .AddUrlParameter(EndpointParametersV1.ReferenceCustomer, this.ToString(referenceCustomer))
                .AddUrlParameter(EndpointParametersV1.ReferenceCustomerBuyer, this.ToString(referenceCustomerBuyer))
                .AddUrlParameter(EndpointParametersV1.Html, html)
                .AddUrlParameter(EndpointParametersV1.Page, page)
                .AddUrlParameter(EndpointParametersV1.SizePage, sizePage);

                // send the request
                var response = this.Send(request);

                // handle the response
                result = this.HandleResponse(out subscriptions, response);
            }
            return(result);
        }
Exemple #3
0
        /// <summary>
        /// Get a usages list with specified criteria
        /// </summary>
        /// <param name="usages">The related usages</param>
        /// <param name="referenceSegment">(optional) the related segment, if not provided and you have multiple segments, defaults on the first segment</param>
        /// <param name="referenceFeature">(optional) reference of related feature, required if idFeature is null</param>
        /// <param name="idFeature">(optional) ProAbono id of the related feature, required if referenceFeature is null</param>
        /// <param name="referenceCustomer">(optional) reference of related customer</param>
        /// <param name="idSubscription">(optional) reference of related subscription</param>
        /// <param name="aggregate">(optional) true to aggregate all usages of the same feature and the same customer. Default is false</param>
        /// <param name="page">(optional) Pagination : page index (starts from 1) </param>
        /// <param name="sizePage">(optional) Pagination : page size (default is 10) </param>
        public virtual RequestReport ListUsages(out ListPaginated <Usage> usages, object referenceSegment, object referenceFeature, long?idFeature, object referenceCustomer, long?idSubscription, bool?aggregate, int?page, int?sizePage)
        {
            usages = null;

            // create the request
            RequestFluent request;
            var           result = this.CreateRequest(out request, EndpointsV1.Usages);

            // if succeeded
            if (result.IsSuccess())
            {
                // append all parameters
                request
                .AddUrlParameter(EndpointParametersV1.ReferenceSegment, this.ToString(referenceSegment))
                .AddUrlParameter(EndpointParametersV1.ReferenceFeature, this.ToString(referenceFeature))
                .AddUrlParameter(EndpointParametersV1.IdFeature, idFeature)
                .AddUrlParameter(EndpointParametersV1.ReferenceCustomer, this.ToString(referenceCustomer))
                .AddUrlParameter(EndpointParametersV1.IdSubscription, idSubscription)
                .AddUrlParameter(EndpointParametersV1.Aggregate, aggregate)
                .AddUrlParameter(EndpointParametersV1.Page, page)
                .AddUrlParameter(EndpointParametersV1.SizePage, sizePage);

                // send the request
                var response = this.Send(request);

                // handle the response
                result = this.HandleResponse(out usages, response);
            }
            return(result);
        }
Exemple #4
0
        private void SetLinksForList <T>(ListPaginated <T> listPaginated, List <string> links)
        {
            foreach (var l in links)
            {
                var oneLink = CustomSplit(l, ';');
                oneLink[1] = SubstractFromRel(oneLink[1], '"');

                if (oneLink[0] != null && oneLink[1] != null)
                {
                    if (oneLink[1] == Constants.LINKS_FIRST_ITEM)
                    {
                        listPaginated.Links[0] = oneLink[0];
                    }
                    if (oneLink[1] == Constants.LINKS_PREVIOUS_ITEM)
                    {
                        listPaginated.Links[1] = oneLink[0];
                    }
                    if (oneLink[1] == Constants.LINKS_NEXT_ITEM)
                    {
                        listPaginated.Links[2] = oneLink[0];
                    }
                    if (oneLink[1] == Constants.LINKS_LAST_ITEM)
                    {
                        listPaginated.Links[3] = oneLink[0];
                    }
                }
            }
        }
        public void Test_Users_GetAll()
        {
            try
            {
                ListPaginated <UserDTO> users = this.Api.Users.GetAll();

                Assert.IsNotNull(users);
                Assert.IsTrue(users.Count > 0);


                // test sorting
                ListPaginated <UserDTO> result  = null;
                ListPaginated <UserDTO> result2 = null;

                Pagination pagination = new Pagination(1, 2);
                Sort       sort       = new Sort();
                sort.AddField("CreationDate", SortDirection.asc);
                result = this.Api.Users.GetAll(pagination, sort);
                Assert.IsNotNull(result);
                Assert.IsTrue(result.Count > 0);

                sort = new Sort();
                sort.AddField("CreationDate", SortDirection.desc);
                result2 = this.Api.Users.GetAll(pagination, sort);
                Assert.IsNotNull(result2);
                Assert.IsTrue(result2.Count > 0);

                Assert.IsTrue(result[0].Id != result2[0].Id);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
Exemple #6
0
        public async Task Test_GetDisputesForWallet()
        {
            DisputeDTO dispute = _clientDisputes.FirstOrDefault(x => x.InitialTransactionId != null);

            if (dispute == null)
            {
                Assert.Fail("Cannot test getting disputes for wallet because there's no disputes with transaction ID in the disputes list.");
            }

            ListPaginated <DisputeDTO> result = null;

            try
            {
                var temp = await Api.PayIns.Get(dispute.InitialTransactionId);

                string walletId = temp.CreditedWalletId;

                result = await Api.Disputes.GetDisputesForWallet(walletId, new Pagination(1, 10), null);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }

            Assert.IsNotNull(result);
        }
        public void Test_Client_GetKycDocuments()
        {
            ListPaginated <KycDocumentDTO> result  = null;
            ListPaginated <KycDocumentDTO> result2 = null;

            result = _objectToTest.GetKycDocuments(null, null).Result;
            Assert.NotNull(result);
            Assert.True(result.Count > 0);

            Pagination pagination = new Pagination(1, 2);
            Sort       sort       = new Sort();

            sort.AddField("CreationDate", SortDirection.asc);
            result = _objectToTest.GetKycDocuments(pagination, null, sort).Result;
            Assert.NotNull(result);
            Assert.True(result.Count > 0);

            sort = new Sort();
            sort.AddField("CreationDate", SortDirection.desc);
            result2 = _objectToTest.GetKycDocuments(pagination, null, sort).Result;
            Assert.NotNull(result2);
            Assert.True(result2.Count > 0);

            Assert.True(result[0].Id != result2[0].Id);
        }
        public void Test_GetDisputesForUser()
        {
            ListPaginated <DisputeDTO> result = null;

            DisputeDTO dispute = _clientDisputes.FirstOrDefault(x => x.DisputeType.HasValue && x.DisputeType.Value == DisputeType.NOT_CONTESTABLE);

            if (dispute == null)
            {
                Assert.Fail("Cannot test getting disputes for user because there's no not contestable disputes in the disputes list.");
            }

            try
            {
                string userId = Api.Disputes.GetTransactions(dispute.Id, new Pagination(1, 1), null)[0].AuthorId;

                result = Api.Disputes.GetDisputesForUser(userId, new Pagination(1, 20), null);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Count > 0);
        }
        /// <summary>
        /// Get an offer
        /// </summary>
        /// <param name="offers">The related offers</param>
        /// <param name="referenceSegment">(optional) the related segment, if not provided and you have multiple segments, defaults on the first segment</param>
        /// <param name="prefixReferenceOffer">(optional) filter - get only offers whose reference start with given prefix</param>
        /// <param name="language">(optional) language of the localized texts</param>
        /// <param name="referenceCustomer">(optional) multiple purposes :
        /// adds a customer-specific 'subscribe' links in each offer to allow the customer to subscribe to the offer,
        /// determining the language of the localized texts (if language not provided),
        /// performing an upgrade (if upgrade requested and idSubscription not provided)</param>
        /// <param name="upgrade">(optional) ignored if referenceCustomer has not been provided. Adds a customer-specific 'upgrade' links, allowing given customer to subscribe to that offer</param>
        /// <param name="idSubscription">(optional) if provided, adds a customer-specific 'upgrade' links, allowing the customer to upgrade given subscription to the new offer</param>
        /// <param name="isVisible">(optional) filter - get only visible offers and their visible features. Default is null</param>
        /// <param name="ignoreFeatures">(optional) true to prevent returning contained. Faster call. Default is false</param>
        /// <param name="html">(optional) true to have the localized text as HTML string, false for plain text. Default is true</param>
        /// <param name="page">(optional) Pagination : page index (starts from 1) </param>
        /// <param name="sizePage">(optional) Pagination : page size (default is 10) </param>
        public virtual RequestReport ListOffers(out ListPaginated <Offer> offers, object referenceSegment, string prefixReferenceOffer, string language, object referenceCustomer, bool?upgrade, long?idSubscription, bool?isVisible, bool?ignoreFeatures, bool?html, int?page, int?sizePage)
        {
            offers = null;

            // create the request
            RequestFluent request;
            var           result = this.CreateRequest(out request, EndpointsV1.Offers);

            // if succeeded
            if (result.IsSuccess())
            {
                // append all parameters
                request
                .AddUrlParameter(EndpointParametersV1.ReferenceSegment, this.ToString(referenceSegment))
                .AddUrlParameter(EndpointParametersV1.PrefixReferenceOffer, prefixReferenceOffer)
                .AddUrlParameter(EndpointParametersV1.Language, language)
                .AddUrlParameter(EndpointParametersV1.ReferenceCustomer, this.ToString(referenceCustomer))
                .AddUrlParameter(EndpointParametersV1.IdSubscription, idSubscription)
                .AddUrlParameter(EndpointParametersV1.Upgrade, upgrade)
                .AddUrlParameter(EndpointParametersV1.IsVisible, isVisible)
                .AddUrlParameter(EndpointParametersV1.IgnoreFeatures, ignoreFeatures)
                .AddUrlParameter(EndpointParametersV1.Html, html)
                .AddUrlParameter(EndpointParametersV1.Page, page)
                .AddUrlParameter(EndpointParametersV1.SizePage, sizePage);

                // send the request
                var response = this.Send(request);

                // handle the response
                result = this.HandleResponse(out offers, response);
            }
            return(result);
        }
        public void Test_GetDocumentsForDispute()
        {
            DisputeDTO dispute = _clientDisputes.FirstOrDefault(x => x.Status == DisputeStatus.SUBMITTED);

            if (dispute == null)
            {
                Test_ContestDispute();
                Initialize();

                dispute = _clientDisputes.FirstOrDefault(x => x.Status == DisputeStatus.SUBMITTED);

                if (dispute == null)
                {
                    Assert.Fail("Cannot test getting dispute's documents because there's no available disputes with SUBMITTED status in the disputes list.");
                }
            }

            ListPaginated <DisputeDocumentDTO> result = null;

            try
            {
                result = Api.Disputes.GetDocumentsForDispute(dispute.Id, new Pagination(1, 1), null);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }

            Assert.IsNotNull(result);
        }
        public async Task Test_Events_GetAll_SortByCreationDate()
        {
            try
            {
                PayInCardWebDTO payIn1 = await GetJohnsNewPayInCardWeb();

                PayInCardWebDTO payIn2 = await GetJohnsNewPayInCardWeb();

                FilterEvents eventsFilter = new FilterEvents();
                eventsFilter.BeforeDate = payIn2.CreationDate.AddSeconds(1);
                eventsFilter.AfterDate  = payIn1.CreationDate;
                eventsFilter.Type       = EventType.PAYIN_NORMAL_CREATED;

                Sort sort = new Sort();
                sort.AddField("Date", SortDirection.desc);

                Pagination pagination = new Pagination();

                ListPaginated <EventDTO> result = await this.Api.Events.GetAllAsync(pagination, eventsFilter, sort);

                Assert.IsNotNull(result);
                Assert.IsTrue(result.Count > 1);
                Assert.IsTrue(result[0].Date >= result[1].Date);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
        /// <summary>
        /// List all customers
        /// </summary>
        /// <param name="customers">the customers paginated list</param>
        /// <param name="referenceSegment">(optional) the related segment, if not provided and you have multiple segments, defaults on the first segment</param>
        /// <param name="referenceFeature">(optional) if provided, get only customers having access to given feature. Adds the current usage in the returned object</param>
        /// <param name="page">(optional) Pagination : page index (starts from 1) </param>
        /// <param name="sizePage">(optional) Pagination : page size (default is 10) </param>
        public virtual RequestReport ListCustomers(out ListPaginated <Customer> customers, object referenceSegment, object referenceFeature, int?page, int?sizePage)
        {
            customers = null;

            // create the request
            RequestFluent request;
            var           result = this.CreateRequest(out request, EndpointsV1.Customers);

            // if succeeded
            if (result.IsSuccess())
            {
                // append all parameters
                request
                .AddUrlParameter(EndpointParametersV1.ReferenceSegment, this.ToString(referenceSegment))
                .AddUrlParameter(EndpointParametersV1.PrefixReferenceOffer, this.ToString(referenceFeature))
                .AddUrlParameter(EndpointParametersV1.ReferenceFeature, this.ToString(referenceFeature))
                .AddUrlParameter(EndpointParametersV1.Page, page)
                .AddUrlParameter(EndpointParametersV1.SizePage, sizePage);

                // send the request
                var response = this.Send(request);

                // handle the response
                result = this.HandleResponse(out customers, response);
            }
            return(result);
        }
Exemple #13
0
        public void Test_Client_GetKycDocuments()
        {
            ListPaginated <KycDocumentDTO> result  = null;
            ListPaginated <KycDocumentDTO> result2 = null;

            try
            {
                result = this.Api.Clients.GetKycDocuments(null, null);
                Assert.IsNotNull(result);
                Assert.IsTrue(result.Count > 0);

                Pagination pagination = new Pagination(1, 2);
                Sort       sort       = new Sort();
                sort.AddField("CreationDate", SortDirection.asc);
                result = this.Api.Clients.GetKycDocuments(pagination, null, sort);
                Assert.IsNotNull(result);
                Assert.IsTrue(result.Count > 0);

                sort = new Sort();
                sort.AddField("CreationDate", SortDirection.desc);
                result2 = this.Api.Clients.GetKycDocuments(pagination, null, sort);
                Assert.IsNotNull(result2);
                Assert.IsTrue(result2.Count > 0);

                Assert.IsTrue(result[0].Id != result2[0].Id);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
        public void Test_Mandate_GetForBankAccount()
        {
            try
            {
                UserNaturalDTO user          = this.GetJohn(true);
                string         bankAccountId = this.GetJohnsAccount(true).Id;
                string         returnUrl     = "http://test.test";
                MandatePostDTO mandatePost   = new MandatePostDTO(bankAccountId, CultureCode.EN, returnUrl);

                MandateDTO mandateCreated = this.Api.Mandates.Create(mandatePost);

                ListPaginated <MandateDTO> mandates = this.Api.Mandates.GetForBankAccount(user.Id, bankAccountId, new Pagination(1, 1), null);

                Assert.IsNotNull(mandateCreated);
                Assert.IsNotNull(mandates);
                Assert.IsTrue(mandates.Count > 0);

                Assert.IsNotNull(mandates[0]);
                Assert.IsFalse(String.IsNullOrEmpty(mandates[0].Id));
                Assert.AreEqual(mandateCreated.Id, mandates[0].Id);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
Exemple #15
0
        /// <summary>
        /// Get a list of features
        /// </summary>
        /// <param name="features">The related features</param>
        /// <param name="referenceSegment">(optional) the related segment, if not provided and you have multiple segments, defaults on the first segment</param>
        /// <param name="referenceCustomer">(optional) filter - return only features available to given customer. Adds the current usage of the features for given user (aggregated among its subscriptions)</param>
        /// <param name="isVisible">(optional) filter - get only visible features. Default is null</param>
        /// <param name="language">(optional) language of the localized texts</param>
        /// <param name="html">(optional) true to have the localized text as HTML string, false for plain text. Default is true</param>
        /// <param name="page">(optional) Pagination : page index (starts from 1) </param>
        /// <param name="sizePage">(optional) Pagination : page size (default is 10) </param>
        public virtual RequestReport ListFeatures(out ListPaginated <Feature> features, object referenceSegment, object referenceCustomer, bool?isVisible, string language, bool?html, int?page, int?sizePage)
        {
            features = null;

            // create the request
            RequestFluent request;
            var           result = this.CreateRequest(out request, EndpointsV1.Features);

            // if succeeded
            if (result.IsSuccess())
            {
                // append all parameters
                request
                .AddUrlParameter(EndpointParametersV1.ReferenceSegment, this.ToString(referenceSegment))
                .AddUrlParameter(EndpointParametersV1.ReferenceCustomer, this.ToString(referenceCustomer))
                .AddUrlParameter(EndpointParametersV1.IsVisible, isVisible)
                .AddUrlParameter(EndpointParametersV1.Language, language)
                .AddUrlParameter(EndpointParametersV1.Html, html)
                .AddUrlParameter(EndpointParametersV1.Page, page)
                .AddUrlParameter(EndpointParametersV1.SizePage, sizePage);

                // send the request
                var response = this.Send(request);

                // handle the response
                result = this.HandleResponse(out features, response);
            }
            return(result);
        }
        public void Test_Users_BankAccounts()
        {
            try
            {
                UserNaturalDTO     john       = this.GetJohn();
                BankAccountIbanDTO account    = this.GetJohnsAccount();
                Pagination         pagination = new Pagination(1, 12);

                ListPaginated <BankAccountDTO> list = this.Api.Users.GetBankAccounts(john.Id, pagination);

                int listIndex;
                for (listIndex = 0; listIndex < list.Count; listIndex++)
                {
                    if (list[listIndex].Id == account.Id)
                    {
                        break;
                    }
                }

                Assert.IsTrue(list[listIndex] is BankAccountDTO);

                BankAccountIbanDTO castedBankAccount = this.Api.Users.GetBankAccountIban(john.Id, list[listIndex].Id);

                Assert.IsTrue(account.Id == castedBankAccount.Id);
                AssertEqualInputProps(account, castedBankAccount);
                Assert.IsTrue(pagination.Page == 1);
                Assert.IsTrue(pagination.ItemsPerPage == 12);


                // test sorting
                ListPaginated <BankAccountDTO> result  = null;
                ListPaginated <BankAccountDTO> result2 = null;

                BankAccountOtherPostDTO account2 = new BankAccountOtherPostDTO(john.FirstName + " " + john.LastName, john.Address, "234234234234", "BINAADADXXX");
                account2.Type    = BankAccountType.OTHER;
                account2.Country = CountryIso.FR;

                this.Api.Users.CreateBankAccountOther(john.Id, account2);

                pagination = new Pagination(1, 2);
                Sort sort = new Sort();
                sort.AddField("CreationDate", SortDirection.asc);
                result = this.Api.Users.GetBankAccounts(john.Id, pagination, sort);
                Assert.IsNotNull(result);
                Assert.IsTrue(result.Count > 0);

                sort = new Sort();
                sort.AddField("CreationDate", SortDirection.desc);
                result2 = this.Api.Users.GetBankAccounts(john.Id, pagination, sort);
                Assert.IsNotNull(result2);
                Assert.IsTrue(result2.Count > 0);

                Assert.IsTrue(result[0].Id != result2[0].Id);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
        public void Initialize()
        {
            Sort sort = new Sort();
            sort.AddField("CreationDate", SortDirection.desc);

            _clientDisputes = Api.Disputes.GetAll(new Pagination(1, 100), null, sort);

            if (_clientDisputes == null || _clientDisputes.Count == 0)
                Assert.Fail("INITIALIZATION FAILURE - cannot test disputes");
        }
Exemple #18
0
        /// <summary>Makes a call to the MangoPay API.
        /// This generic method handles calls targeting collections of
        /// DTO instances. In order to process single objects,
        /// use <code>Request</code> method instead.
        /// </summary>
        /// <typeparam name="T">Type on behalf of which the request is being called.</typeparam>
        /// <param name="urlMethod">Relevant method key.</param>
        /// <param name="requestType">HTTP request term. For lists should be always GET.</param>
        /// <param name="requestData">Collection of key-value pairs of request parameters.</param>
        /// <param name="pagination">Pagination object.</param>
        /// <param name="additionalUrlParams"></param>
        /// <returns>Collection of DTO instances returned from API.</returns>
        public ListPaginated <T> RequestList <T>(String urlMethod, String requestType, Dictionary <String, String> requestData, Pagination pagination, Dictionary <String, String> additionalUrlParams)
            where T : new()
        {
            this._requestType = requestType;
            this._requestData = requestData;

            ListPaginated <T> responseResult = this.DoRequestList <T>(urlMethod, pagination, additionalUrlParams);

            return(responseResult);
        }
        public void Test_Client_GetWallets()
        {
            ListPaginated <WalletDTO> feesWallets   = null;
            ListPaginated <WalletDTO> creditWallets = null;

            feesWallets   = _objectToTest.GetWallets(FundsType.FEES, new Pagination(1, 100)).Result;
            creditWallets = _objectToTest.GetWallets(FundsType.CREDIT, new Pagination(1, 100)).Result;

            Assert.NotNull(feesWallets);
            Assert.NotNull(creditWallets);
        }
        /// <summary>Makes a call to the MangoPay API.
        /// This generic method handles calls targeting collections of
        /// DTO instances. In order to process single objects,
        /// use <code>Request</code> method instead.
        /// </summary>
        /// <typeparam name="T">Type on behalf of which the request is being called.</typeparam>
        /// <param name="endPoint">An instance of <see cref="ApiEndPoint"/> that specifies API url and method to call</param>
        /// <param name="requestData">Collection of key-value pairs of request parameters.</param>
        /// <param name="pagination">Pagination object.</param>
        /// <param name="additionalUrlParams"></param>
        /// <returns>Collection of DTO instances returned from API.</returns>
        public async Task <ListPaginated <T> > RequestList <T>(ApiEndPoint endPoint, Dictionary <String, String> requestData, Pagination pagination, Dictionary <String, String> additionalUrlParams)
            where T : new()
        {
            this._requestType     = endPoint.RequestType;
            this._includeClientId = endPoint.IncludeClientId;
            this._requestData     = requestData;

            ListPaginated <T> responseResult = await this.DoRequestList <T>(endPoint.GetUrl(), pagination, additionalUrlParams);

            return(responseResult);
        }
        public void Initialize()
        {
            Sort sort = new Sort();

            sort.AddField("CreationDate", SortDirection.desc);

            _clientDisputes = Api.Disputes.GetAll(new Pagination(1, 100), null, sort);

            if (_clientDisputes == null || _clientDisputes.Count == 0)
            {
                Assert.Fail("INITIALIZATION FAILURE - cannot test disputes");
            }
        }
Exemple #22
0
        public void ApiUboDeclaration_GetAll_UboDeclaration_Valid()
        {
            var userLegal         = Api.Users.Create(CreateUserLegalPost());
            var uboDeclarationDto = Api.UboDeclarations.Create(userLegal.Id);

            ListPaginated <UboDeclarationDTO> result = null;
            Pagination pagination = new Pagination(1, 1);

            Assert.DoesNotThrow(() => result = Api.UboDeclarations.GetUboDeclarationByUserId(userLegal.Id, pagination));
            Assert.NotNull(result);
            Assert.IsTrue(result.Count > 0);
            Assert.AreEqual(uboDeclarationDto.Id, result[0].Id);
        }
        public void Test_Mandates_GetAll()
        {
            try
            {
                ListPaginated <MandateDTO> mandates = this.Api.Mandates.GetAll();

                Assert.IsNotNull(mandates);
                Assert.IsTrue(mandates.Count > 0);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
Exemple #24
0
        public async Task Test_Reports_All()
        {
            try
            {
                ReportRequestDTO report = await this.GetJohnsReport(ReportType.TRANSACTIONS);

                Pagination pagination = new Pagination(1, 10);
                Sort       sort       = new Sort();
                sort.AddField("CreationDate", SortDirection.desc);

                ListPaginated <ReportRequestDTO> list = await this.Api.Reports.GetAllAsync(pagination, null, sort);

                var exist = false;
                for (int i = 0; i < pagination.ItemsPerPage; i++)
                {
                    if (report.Id == list[i].Id)
                    {
                        exist = true;
                        break;
                    }
                }

                Assert.IsNotNull(list[0]);
                Assert.IsTrue(exist);
                Assert.AreEqual(pagination.Page, 1);
                Assert.IsTrue(pagination.ItemsPerPage <= 10);

                FilterReportsList filters = new FilterReportsList();
                filters.AfterDate  = list[0].CreationDate;
                filters.BeforeDate = DateTime.Today;

                list = await this.Api.Reports.GetAllAsync(pagination, filters, sort);

                Assert.IsNotNull(list);
                Assert.IsTrue(list.Count == 0);

                filters.BeforeDate = filters.AfterDate;
                filters.AfterDate  = DateTime.Today.AddYears(-10);

                list = await this.Api.Reports.GetAllAsync(pagination, filters, sort);

                Assert.IsNotNull(list);
                Assert.IsTrue(list.Count > 0);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
Exemple #25
0
        public void Test_Client_GetTransactions()
        {
            ListPaginated <TransactionDTO> result = null;

            try
            {
                result = this.Api.Clients.GetTransactions(null, null);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }

            Assert.IsNotNull(result);
        }
Exemple #26
0
        public async Task Test_GetDisputesPendingSettlement()
        {
            ListPaginated <DisputeDTO> result = null;

            try
            {
                result = await Api.Disputes.GetDisputesPendingSettlement(new Pagination(1, 10), null);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }

            Assert.IsNotNull(result);
        }
        public void Test_Client_GetTransactions()
        {
            ListPaginated <TransactionDTO> result = null;

            try
            {
                result = _objectToTest.GetTransactions(null, null).Result;
            }
            catch (Exception ex)
            {
                Assert.True(false, ex.Message);
            }

            Assert.NotNull(result);
        }
        public void Test_GetDocumentsForClient()
        {
            ListPaginated <DisputeDocumentDTO> result = null;

            try
            {
                result = Api.Disputes.GetDocumentsForClient(new Pagination(1, 1), null);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }

            Assert.IsNotNull(result);
        }
        public void Test_GetFilteredDisputes()
        {
            ListPaginated <DisputeDTO> result1 = null;
            ListPaginated <DisputeDTO> result2 = null;
            ListPaginated <DisputeDTO> result3 = null;
            ListPaginated <DisputeDTO> result4 = null;

            try
            {
                result1 = Api.Disputes.GetAll(new Pagination(1, 100), new FilterDisputes {
                    AfterDate = DateTime.Now
                });
                result2 = Api.Disputes.GetAll(new Pagination(1, 100), new FilterDisputes {
                    BeforeDate = DateTime.Now
                });
                result3 = Api.Disputes.GetAll(new Pagination(1, 100), new FilterDisputes {
                    Type = DisputeType.CONTESTABLE
                });
                result4 = Api.Disputes.GetAll(new Pagination(1, 100), new FilterDisputes {
                    Status = DisputeStatus.SUBMITTED
                });
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }

            Assert.IsNotNull(result1);
            Assert.IsNotNull(result2);
            Assert.IsNotNull(result3);
            Assert.IsNotNull(result4);
            Assert.IsTrue(result1.Count == 0);
            Assert.IsTrue(result2.Count > 0);
            Assert.IsTrue(result3.Count > 0);
            Assert.IsTrue(result4.Count > 0);

            foreach (DisputeDTO dispute in result3)
            {
                Assert.AreEqual(dispute.DisputeType, DisputeType.CONTESTABLE);
            }

            foreach (DisputeDTO dispute in result4)
            {
                Assert.AreEqual(dispute.Status, DisputeStatus.SUBMITTED);
            }
        }
Exemple #30
0
        public void Test_Client_GetWallet()
        {
            ListPaginated <WalletDTO> feesWallets    = null;
            ListPaginated <WalletDTO> creditWallets  = null;
            ListPaginated <WalletDTO> defaultWallets = null;

            try
            {
                feesWallets    = this.Api.Clients.GetWallets(FundsType.FEES, new Pagination(1, 1));
                creditWallets  = this.Api.Clients.GetWallets(FundsType.CREDIT, new Pagination(1, 1));
                defaultWallets = this.Api.Clients.GetWallets(FundsType.DEFAULT, new Pagination(1, 1));
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }

            if ((feesWallets == null || feesWallets.Count == 0) ||
                (creditWallets == null || creditWallets.Count == 0) ||
                (defaultWallets == null || defaultWallets.Count == 0))
            {
                Assert.Fail("Cannot test getting client's wallet because there is no any wallet for client.");
            }

            WalletDTO wallet = null;
            WalletDTO result = null;

            if (feesWallets != null && feesWallets.Count > 0)
            {
                wallet = feesWallets[0];
            }
            else if (creditWallets != null && creditWallets.Count > 0)
            {
                wallet = creditWallets[0];
            }
            else
            {
                wallet = defaultWallets[0];
            }

            result = this.Api.Clients.GetWallet(wallet.FundsType, wallet.Currency);

            Assert.IsNotNull(result);
            Assert.IsTrue(result.FundsType == wallet.FundsType);
            Assert.IsTrue(result.Currency == wallet.Currency);
        }
Exemple #31
0
        public void Test_Client_GetWallets()
        {
            ListPaginated <WalletDTO> feesWallets   = null;
            ListPaginated <WalletDTO> creditWallets = null;

            try
            {
                feesWallets   = this.Api.Clients.GetWallets(FundsType.FEES, new Pagination(1, 100));
                creditWallets = this.Api.Clients.GetWallets(FundsType.CREDIT, new Pagination(1, 100));
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
            Assert.IsNotNull(feesWallets);
            Assert.IsNotNull(creditWallets);
        }