Exemplo n.º 1
0
        public void It_should_register_a_new_dwolla_user()
        {
            // arrange
            var registerService = new DwollaRegisterService();

            var options = new RegisterOptions {
                ClientId = TestAppKey,
                ClientSecret = TestAppSecret,
                Email = TestEmail,
                Password = "******",
                Pin = "1111",
                FirstName = "TestFirst",
                LastName = "TestLast",
                Address = "555 Not Real",
                City = "Seattle",
                State = "WA",
                Zip = "98119",
                Phone = "2065551234",
                DateOfBirth = new DateTime(1980, 1, 1),
                AccountType = "Personal",
                AcceptTerms = true
            };

            // act
            DwollaResponse<DwollaUser> response = registerService.RegisterUser(options);

            // assert
            response.Success.ShouldBeTrue();
        }
        public DwollaResponse <DwollaUser> RegisterUser(RegisterOptions options)
        {
            var url = Urls.Register;

            var client = new RestClient();

            var data = new {
                client_id     = options.ClientId,
                client_secret = options.ClientSecret,
                email         = options.Email,
                password      = options.Password,
                pin           = options.Pin,
                firstName     = options.FirstName,
                lastName      = options.LastName,
                address       = options.Address,
                address2      = options.Address2,
                city          = options.City,
                state         = options.State,
                zip           = options.Zip,
                phone         = options.Phone,
                dateOfBirth   = options.DateOfBirth,
                type          = options.AccountType,
                organization  = options.Organization,
                ein           = options.Ein,
                acceptTerms   = options.AcceptTerms
            };

            var request = new RestRequest(url, Method.POST)
            {
                RequestFormat = DataFormat.Json
            };

            request.AddBody(data);

            var response = client.Execute(request);

            return(Mapper <DwollaResponse <DwollaUser> > .MapFromJson(response.Content));
        }
        public DwollaResponse<DwollaUser> RegisterUser(RegisterOptions options)
        {
            var url = Urls.Register;

            var client = new RestClient();

            var data = new {
                client_id = options.ClientId,
                client_secret = options.ClientSecret,
                email = options.Email,
                password = options.Password,
                pin = options.Pin,
                firstName = options.FirstName,
                lastName = options.LastName,
                address = options.Address,
                address2 = options.Address2,
                city = options.City,
                state = options.State,
                zip = options.Zip,
                phone = options.Phone,
                dateOfBirth = options.DateOfBirth,
                type = options.AccountType,
                organization = options.Organization,
                ein = options.Ein,
                acceptTerms = options.AcceptTerms
            };

            var request = new RestRequest(url, Method.POST) {
                RequestFormat = DataFormat.Json
            };

            request.AddBody(data);

            var response = client.Execute(request);

            return Mapper<DwollaResponse<DwollaUser>>.MapFromJson(response.Content);
        }