Example #1
0
        public async Task CreateCustomerWithSdk()
        {
            var client = DwollaClient.Create(isSandbox: true);

            var tokenRes = await client.PostAuthAsync <AppTokenRequest, TokenResponse>(
                new Uri($"{client.AuthBaseAddress}/token"),
                new AppTokenRequest { Key = Client, Secret = Key });

            var headers = new Headers();

            headers.Add("Authorization", $"Bearer {tokenRes.Content.Token}");
            var rootRes   = (await client.GetAsync <RootResponse>(new Uri(client.ApiBaseAddress), headers)).Content;
            var customers = await client.PostAsync(rootRes.Links["customers"].Href, new CreateCustomerRequest
            {
                FirstName   = "Ricardino",
                LastName    = "Flores",
                Email       = "*****@*****.**",
                Type        = "personal",
                Address1    = "Default Location 777",
                City        = "Existing City",
                State       = "WA",
                PostalCode  = "12345",
                DateOfBirth = DateTime.Today.AddYears(-20),
                Ssn         = "1234"
            }, headers);
        }
        public void ConfigureHttpClient()
        {
            var client = DwollaClient.CreateHttpClient();

            Assert.Equal(UserAgent, client.DefaultRequestHeaders.UserAgent.ToString());
            Assert.Equal(JsonV1, client.DefaultRequestHeaders.Accept.ToString());
        }
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            services.AddHttpClient();
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
            services.AddScoped <IxCompanyRepository, xCompanyRepository>();
            services.AddScoped <IDwollaService, DwollaService>();
            services.AddScoped <IDwollaClient>(op => DwollaClient.Create(true));
        }
Example #4
0
        public async Task ListCustomers()
        {
            var client = DwollaClient.Create(isSandbox: true);

            var token = await client.PostAuthAsync <AppTokenRequest, TokenResponse>(
                new Uri("https://sandbox.dwolla.com/oauth/v2/token"),
                new AppTokenRequest { Key = Client, Secret = Key });

            var headers = new Headers {
                { "Authorization", $"Bearer {token.Content.Token}" }
            };
            var rootRes = (await client.GetAsync <RootResponse>(new Uri(client.ApiBaseAddress), headers)).Content;

            var customers = await client.GetAsync <GetCustomersResponse>(rootRes.Links["customers"].Href, headers);
        }
Example #5
0
        private static void Main()
        {
            var key    = Environment.GetEnvironmentVariable("DWOLLA_APP_KEY");
            var secret = Environment.GetEnvironmentVariable("DWOLLA_APP_SECRET");

            if (string.IsNullOrWhiteSpace(key) || string.IsNullOrWhiteSpace(secret))
            {
                WriteLine("Set DWOLLA_APP_KEY and DWOLLA_APP_SECRET env vars and restart IDE. Press any key to exit..");
                ReadLine();
            }
            else
            {
                var running = true;
                var broker  = new DwollaBroker(DwollaClient.Create(true));

                Task.Run(async() => await broker.SetAuthorizationHeader(key, secret)).Wait();

                WriteHelp();

                while (running)
                {
                    Write("What would you like to do? (Press ? for options): ");
                    var i     = ReadLine();
                    var input = i == null ? "" : i.ToLower().Trim();

                    switch (input)
                    {
                    case "?":
                        WriteHelp();
                        break;

                    case "quit":
                    case "q":
                    case "exit":
                        running = false;
                        break;

                    default:
                        BeginTask(input, broker);
                        break;
                    }
                }
            }
        }
Example #6
0
 public DwollaClientShould()
 {
     messageHandler = new Mock <HttpMessageHandler>(MockBehavior.Strict);
     _client        = new DwollaClient(new HttpClient(messageHandler.Object));
 }
 public DwollaClientShould()
 {
     _restClient = new Mock <IRestClient>();
     _client     = new DwollaClient(_restClient.Object, true);
 }