Beispiel #1
0
        public async Task CreatesMandateImportEntries()
        {
            // given
            var subject       = new MandateImportEntriesClient(_clientConfiguration);
            var mandateImport = await _resourceFactory.CreateMandateImport();

            var request = new AddMandateImportEntryRequest
            {
                BankAccount = new BankAccount
                {
                    AccountHolderName = "Joe Bloggs",
                    AccountNumber     = "55666666",
                    BranchCode        = "200000",
                    CountryCode       = "GB"
                },
                Customer = new Customer
                {
                    AddressLine1          = "Address Line 1",
                    AddressLine2          = "Address Line 2",
                    AddressLine3          = "Address Line 3",
                    City                  = "London",
                    CompanyName           = "Company Name",
                    CountryCode           = "DK",
                    DanishIdentityNumber  = "2205506218",
                    Email                 = "*****@*****.**",
                    FamilyName            = "Family Name",
                    GivenName             = "Given Name",
                    Language              = "da",
                    PhoneNumber           = "+44 1234 567890",
                    PostalCode            = "SW1A 1AA",
                    Region                = "Essex",
                    SwedishIdentityNumber = "5302256218",
                },
                Links = new AddMandateImportEntryLinks
                {
                    MandateImport = mandateImport.Id
                },
                RecordIdentifier = $"import-{DateTime.Now:yyyyMMddhhssmmfff}"
            };

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

            var actual = result.Item;

            // then
            Assert.That(actual, Is.Not.Null);
            Assert.That(actual.CreatedAt, Is.Not.Null.And.Not.EqualTo(default(DateTimeOffset)));
            Assert.That(actual.Links, Is.Not.Null);
            Assert.That(actual.Links.MandateImport, Is.Not.Null.And.EqualTo(mandateImport.Id));
            Assert.That(actual.RecordIdentifier, Is.Not.Null);
        }
        public async Task CallsAddMandateImportEntryEndpoint()
        {
            // given
            var subject = new MandateImportEntriesClient(_clientConfiguration);
            var request = new AddMandateImportEntryRequest();

            // when
            await subject.AddAsync(request);

            // then
            _httpTest
            .ShouldHaveCalled("https://api.gocardless.com/mandate_import_entries")
            .WithVerb(HttpMethod.Post);
        }
        public void AddMandateImportEntryRequestIsNullThrows()
        {
            // given
            var subject = new MandateImportEntriesClient(_clientConfiguration);
            AddMandateImportEntryRequest request = null;

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

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

            Assert.That(ex.ParamName, Is.EqualTo(nameof(request)));
        }
        internal async Task <MandateImportEntry> CreateMandateImportEntryFor(
            MandateImport mandateImport,
            string recordIdentifier)
        {
            var request = new AddMandateImportEntryRequest
            {
                BankAccount = new BankAccount
                {
                    AccountHolderName = "Joe Bloggs",
                    AccountNumber     = "55666666",
                    BranchCode        = "200000",
                    CountryCode       = "GB"
                },
                Customer = new MandateImportEntries.Customer
                {
                    AddressLine1          = "Address Line 1",
                    AddressLine2          = "Address Line 2",
                    AddressLine3          = "Address Line 3",
                    City                  = "London",
                    CompanyName           = "Company Name",
                    CountryCode           = "DK",
                    DanishIdentityNumber  = "2205506218",
                    Email                 = "*****@*****.**",
                    FamilyName            = "Family Name",
                    GivenName             = "Given Name",
                    Language              = "da",
                    PostalCode            = "SW1A 1AA",
                    Region                = "Essex",
                    SwedishIdentityNumber = "5302256218",
                },
                Links = new AddMandateImportEntryLinks
                {
                    MandateImport = mandateImport.Id
                },
                RecordIdentifier = recordIdentifier
            };

            var mandateImportEntriesClient = new MandateImportEntriesClient(_clientConfiguration);

            return((await mandateImportEntriesClient.AddAsync(request)).Item);
        }