Beispiel #1
0
        public async Task MapsPagingProperties()
        {
            // given
            var subject = new PayoutItemsClient(_clientConfiguration);

            var firstPageRequest = new GetPayoutItemsRequest
            {
                Limit  = 1,
                Payout = _payout.Id
            };

            // when
            var firstPageResult = await subject.GetPageAsync(firstPageRequest);

            var secondPageRequest = new GetPayoutItemsRequest
            {
                After  = firstPageResult.Meta.Cursors.After,
                Limit  = 1,
                Payout = _payout.Id
            };

            var secondPageResult = await subject.GetPageAsync(secondPageRequest);

            // then
            Assert.That(firstPageResult.Items.Count(), Is.EqualTo(firstPageRequest.Limit));
            Assert.That(firstPageResult.Meta.Limit, Is.EqualTo(firstPageRequest.Limit));
            Assert.That(firstPageResult.Meta.Cursors.Before, Is.Null);
            Assert.That(firstPageResult.Meta.Cursors.After, Is.Not.Null);

            Assert.That(secondPageResult.Items.Count(), Is.EqualTo(secondPageRequest.Limit));
            Assert.That(secondPageResult.Meta.Limit, Is.EqualTo(secondPageRequest.Limit));
            Assert.That(secondPageResult.Meta.Cursors.Before, Is.Not.Null);
            Assert.That(secondPageResult.Meta.Cursors.After, Is.Null);
        }
        public void GetPayoutItemRequestIsNullThrows()
        {
            // given
            var subject = new PayoutItemsClient(_clientConfiguration);

            GetPayoutItemsRequest request = null;

            // when
            AsyncTestDelegate test = () => subject.GetPageAsync(request);

            // then
            var ex = Assert.ThrowsAsync <ArgumentNullException>(test);

            Assert.That(ex.ParamName, Is.EqualTo(nameof(request)));
        }
        public void PayoutIdIsNullOrWhiteSpaceThrows(string payoutId)
        {
            // given
            var subject = new PayoutItemsClient(_clientConfiguration);

            var request = new GetPayoutItemsRequest
            {
                Payout = payoutId
            };

            // when
            AsyncTestDelegate test = () => subject.GetPageAsync(request);

            // then
            var ex = Assert.ThrowsAsync <ArgumentException>(test);

            Assert.That(ex.Message, Is.Not.Null);
            Assert.That(ex.ParamName, Is.EqualTo(nameof(request.Payout)));
        }
Beispiel #4
0
        public async Task ReturnsPagesIncludingAndAfterInitialRequest()
        {
            // given
            var subject = new PayoutItemsClient(_clientConfiguration);

            var initialRequest = new GetPayoutItemsRequest
            {
                Payout = _payout.Id
            };

            // when
            var result = await subject
                         .BuildPager()
                         .StartFrom(initialRequest)
                         .AndGetAllAfterAsync();

            // then
            Assert.That(result.Count, Is.GreaterThan(1));
        }
        public async Task CallsGetPayoutItemsEndpointUsingRequest()
        {
            // given
            var subject = new PayoutItemsClient(_clientConfiguration);

            var request = new GetPayoutItemsRequest
            {
                Before = "before test",
                After  = "after test",
                Limit  = 5,
                Payout = "PO12345678"
            };

            // when
            await subject.GetPageAsync(request);

            // then
            _httpTest
            .ShouldHaveCalled("https://api.gocardless.com/payout_items?before=before%20test&after=after%20test&limit=5&payout=PO12345678")
            .WithVerb(HttpMethod.Get);
        }
Beispiel #6
0
        public async Task ReturnsPayoutItems()
        {
            // given
            var subject = new PayoutItemsClient(_clientConfiguration);

            var request = new GetPayoutItemsRequest
            {
                Payout = _payout.Id
            };

            // when
            var result = await subject.GetPageAsync(request);

            var actual = result.Items.ToList();

            // then
            Assert.That(actual[0].Amount, Is.Not.Null);
            Assert.That(actual[0].Links, Is.Not.Null);
            Assert.That(actual[0].Links.Payment, Is.Not.Null);
            Assert.That(actual[0].Type, Is.Not.Null);
        }
Beispiel #7
0
        public GoCardlessClient(ClientConfiguration configuration)
        {
            _configuration = configuration;

            BankDetailsLookups    = new BankDetailsLookupsClient(configuration);
            CreditorBankAccounts  = new CreditorBankAccountsClient(configuration);
            Creditors             = new CreditorsClient(configuration);
            CustomerBankAccounts  = new CustomerBankAccountsClient(configuration);
            CustomerNotifications = new CustomerNotificationsClient(configuration);
            Customers             = new CustomersClient(configuration);
            Events = new EventsClient(configuration);
            MandateImportEntries = new MandateImportEntriesClient(configuration);
            MandateImports       = new MandateImportsClient(configuration);
            MandatePdfs          = new MandatePdfsClient(configuration);
            Mandates             = new MandatesClient(configuration);
            Payments             = new PaymentsClient(configuration);
            PayoutItems          = new PayoutItemsClient(configuration);
            Payouts       = new PayoutsClient(configuration);
            RedirectFlows = new RedirectFlowsClient(configuration);
            Refunds       = new RefundsClient(configuration);
            Subscriptions = new SubscriptionsClient(configuration);
        }