public async Task HandlesCustomerNotification()
        {
            // given
            var creditor = await _resourceFactory.Creditor();

            var customer = await _resourceFactory.CreateLocalCustomer();

            var customerBankAccount = await _resourceFactory.CreateCustomerBankAccountFor(customer);

            await _resourceFactory.CreateMandateFor(creditor, customer, customerBankAccount);

            var subject = new CustomerNotificationsClient(_clientConfiguration);

            var id = "PCN0000DZ5X5BG0";

            // when
            var result = await subject.HandleAsync(id);

            // then
            Assert.That(result.Item, Is.Not.Null);
            Assert.That(result.Item.Id, Is.Not.Null.And.EqualTo(id));
            Assert.That(result.Item.ActionTaken, Is.Not.Null.And.EqualTo(ActionTaken.Handled));
            Assert.That(result.Item.ActionTakenAt, Is.Not.Null.And.Not.EqualTo(default(DateTimeOffset)));
            Assert.That(result.Item.ActionTakenBy, Is.Not.Null);
            Assert.That(result.Item.Links, Is.Not.Null);
            Assert.That(result.Item.Links.Customer, Is.Not.Null);
            Assert.That(result.Item.Links.Event, Is.Not.Null);
            Assert.That(result.Item.Links.Mandate, Is.Not.Null);
            Assert.That(result.Item.Type, Is.Not.Null);
        }
        public void IdIsNullOrWhiteSpaceThrows(string id)
        {
            // given
            var subject = new CustomerNotificationsClient(_clientConfiguration);

            // when
            AsyncTestDelegate test = () => subject.HandleAsync(id);

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

            Assert.That(ex.ParamName, Is.EqualTo(nameof(id)));
        }
        public async Task CallsHandleCustomerNotificationsEndpoint()
        {
            // given
            var subject = new CustomerNotificationsClient(_clientConfiguration);
            var id      = "PCN12345678";

            // when
            await subject.HandleAsync(id);

            // then
            _httpTest
            .ShouldHaveCalled("https://api.gocardless.com/customer_notifications")
            .WithVerb(HttpMethod.Post);
        }
Esempio n. 4
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);
        }