dwolla-ruby 2.6.1 → 2.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. checksums.yaml +13 -5
  2. data/.gitignore +8 -8
  3. data/.travis.yml +6 -6
  4. data/Gemfile +1 -1
  5. data/README.md +171 -168
  6. data/Rakefile +8 -8
  7. data/dwolla-ruby.gemspec +27 -27
  8. data/examples/balance.rb +15 -15
  9. data/examples/contacts.rb +32 -32
  10. data/examples/fundingSources.rb +39 -39
  11. data/examples/oauth.rb +50 -50
  12. data/examples/offsiteGateway.rb +31 -31
  13. data/examples/transactions.rb +38 -38
  14. data/examples/users.rb +30 -30
  15. data/gemfiles/json.gemfile +2 -2
  16. data/lib/dwolla.rb +326 -326
  17. data/lib/dwolla/accounts.rb +27 -27
  18. data/lib/dwolla/balance.rb +15 -15
  19. data/lib/dwolla/contacts.rb +30 -30
  20. data/lib/dwolla/errors/api_connection_error.rb +3 -3
  21. data/lib/dwolla/errors/api_error.rb +3 -3
  22. data/lib/dwolla/errors/authentication_error.rb +3 -3
  23. data/lib/dwolla/errors/dwolla_error.rb +19 -19
  24. data/lib/dwolla/errors/invalid_request_error.rb +10 -10
  25. data/lib/dwolla/errors/missing_parameter_error.rb +3 -3
  26. data/lib/dwolla/exceptions.rb +4 -4
  27. data/lib/dwolla/funding_sources.rb +65 -65
  28. data/lib/dwolla/json.rb +20 -20
  29. data/lib/dwolla/masspay.rb +52 -52
  30. data/lib/dwolla/oauth.rb +75 -75
  31. data/lib/dwolla/offsite_gateway.rb +154 -154
  32. data/lib/dwolla/requests.rb +56 -56
  33. data/lib/dwolla/transactions.rb +56 -56
  34. data/lib/dwolla/users.rb +39 -39
  35. data/lib/dwolla/version.rb +3 -3
  36. data/test/test_accounts.rb +18 -18
  37. data/test/test_balance.rb +9 -9
  38. data/test/test_contacts.rb +19 -19
  39. data/test/test_funding_sources.rb +64 -64
  40. data/test/test_masspay.rb +47 -47
  41. data/test/test_oauth.rb +30 -30
  42. data/test/test_offsite_gateway.rb +57 -57
  43. data/test/test_requests.rb +29 -29
  44. data/test/test_transactions.rb +51 -51
  45. data/test/test_users.rb +33 -33
  46. metadata +15 -15
data/examples/balance.rb CHANGED
@@ -1,16 +1,16 @@
1
- # Include the Dwolla gem
2
- require 'rubygems'
3
- require 'pp'
4
- require 'dwolla'
5
-
6
- # Include any required keys
7
- require './_keys.rb'
8
-
9
- # Instantiate a new Dwolla User client
10
- # And, seed a previously generated access token
11
- Dwolla::token = @token
12
-
13
-
14
- # EXAMPLE 1:
15
- # Get the balance of the authenticated user
1
+ # Include the Dwolla gem
2
+ require 'rubygems'
3
+ require 'pp'
4
+ require 'dwolla'
5
+
6
+ # Include any required keys
7
+ require './_keys.rb'
8
+
9
+ # Instantiate a new Dwolla User client
10
+ # And, seed a previously generated access token
11
+ Dwolla::token = @token
12
+
13
+
14
+ # EXAMPLE 1:
15
+ # Get the balance of the authenticated user
16
16
  pp Dwolla::Balance.get
data/examples/contacts.rb CHANGED
@@ -1,33 +1,33 @@
1
- # Include the Dwolla gem
2
- require 'rubygems'
3
- require 'pp'
4
- require 'dwolla'
5
-
6
- # Include any required keys
7
- require './_keys.rb'
8
-
9
- # Instantiate a new Dwolla User client
10
- # And, seed a previously generated access token
11
- Dwolla::token = @token
12
- Dwolla::api_key = @api_key
13
- Dwolla::api_secret = @api_secret
14
-
15
-
16
- # EXAMPLE 1:
17
- # Fetch last 10 contacts from the
18
- # account associated with the provided
19
- # OAuth token
20
- pp Dwolla::Contacts.get
21
-
22
-
23
- # EXAMPLE 2:
24
- # Search through the contacts of the
25
- # account associated with the provided
26
- # OAuth token
27
- pp Dwolla::Contacts.get({:search => 'Ben'})
28
-
29
-
30
- # EXAMPLE 3:
31
- # Get a list of nearby Dwolla spots
32
- # for a given set of coordinates
1
+ # Include the Dwolla gem
2
+ require 'rubygems'
3
+ require 'pp'
4
+ require 'dwolla'
5
+
6
+ # Include any required keys
7
+ require './_keys.rb'
8
+
9
+ # Instantiate a new Dwolla User client
10
+ # And, seed a previously generated access token
11
+ Dwolla::token = @token
12
+ Dwolla::api_key = @api_key
13
+ Dwolla::api_secret = @api_secret
14
+
15
+
16
+ # EXAMPLE 1:
17
+ # Fetch last 10 contacts from the
18
+ # account associated with the provided
19
+ # OAuth token
20
+ pp Dwolla::Contacts.get
21
+
22
+
23
+ # EXAMPLE 2:
24
+ # Search through the contacts of the
25
+ # account associated with the provided
26
+ # OAuth token
27
+ pp Dwolla::Contacts.get({:search => 'Ben'})
28
+
29
+
30
+ # EXAMPLE 3:
31
+ # Get a list of nearby Dwolla spots
32
+ # for a given set of coordinates
33
33
  pp Dwolla::Contacts.nearby({:latitude => 1, :longitude => 2})
@@ -1,39 +1,39 @@
1
- # Include the Dwolla gem
2
- require 'rubygems'
3
- require 'pp'
4
- require 'dwolla'
5
-
6
- # Include any required keys
7
- require './_keys.rb'
8
-
9
- # Instantiate a new Dwolla User client
10
- # And, seed a previously generated access token
11
- Dwolla::token = @token
12
-
13
-
14
- # EXAMPLE 1:
15
- # Fetch all funding sources for the
16
- # account associated with the provided
17
- # OAuth token
18
- pp Dwolla::FundingSources.get
19
-
20
-
21
- # EXAMPLE 2:
22
- # Fetch detailed information for the
23
- # funding source with a specific ID
24
- pp Dwolla::FundingSources.get('funding_source_id')
25
-
26
- # EXAMPLE 3:
27
- # Deposit funds from a funding source (bank account)
28
- # into the Dwolla account balance.
29
- pp Dwolla::FundingSources.deposit('funding_source_id', {:amount => 12.95, :pin => @pin})
30
-
31
- # EXAMPLE 4:
32
- # Withdraw funds from a Dwolla account balance into
33
- # a funding source (bank account)
34
- pp Dwolla::FundingSources.withdraw('funding_source_id', {:amount => 12.95, :pin => @pin})
35
-
36
- # EXAMPLE 5:
37
- # Add a new funding source (bank account).
38
- # Possible values for account_type: "Checking" and "Savings"
39
- pp Dwolla::FundingSources.add({:routing_number => 99999999, :account_number => 99999999, :account_type => "Checking", :name => "Some Nickname"})
1
+ # Include the Dwolla gem
2
+ require 'rubygems'
3
+ require 'pp'
4
+ require 'dwolla'
5
+
6
+ # Include any required keys
7
+ require './_keys.rb'
8
+
9
+ # Instantiate a new Dwolla User client
10
+ # And, seed a previously generated access token
11
+ Dwolla::token = @token
12
+
13
+
14
+ # EXAMPLE 1:
15
+ # Fetch all funding sources for the
16
+ # account associated with the provided
17
+ # OAuth token
18
+ pp Dwolla::FundingSources.get
19
+
20
+
21
+ # EXAMPLE 2:
22
+ # Fetch detailed information for the
23
+ # funding source with a specific ID
24
+ pp Dwolla::FundingSources.get('funding_source_id')
25
+
26
+ # EXAMPLE 3:
27
+ # Deposit funds from a funding source (bank account)
28
+ # into the Dwolla account balance.
29
+ pp Dwolla::FundingSources.deposit('funding_source_id', {:amount => 12.95, :pin => @pin})
30
+
31
+ # EXAMPLE 4:
32
+ # Withdraw funds from a Dwolla account balance into
33
+ # a funding source (bank account)
34
+ pp Dwolla::FundingSources.withdraw('funding_source_id', {:amount => 12.95, :pin => @pin})
35
+
36
+ # EXAMPLE 5:
37
+ # Add a new funding source (bank account).
38
+ # Possible values for account_type: "Checking" and "Savings"
39
+ pp Dwolla::FundingSources.add({:routing_number => 99999999, :account_number => 99999999, :account_type => "Checking", :name => "Some Nickname"})
data/examples/oauth.rb CHANGED
@@ -1,51 +1,51 @@
1
- # Include the Dwolla gem
2
- require 'rubygems'
3
- require 'pp'
4
- require 'sinatra'
5
- require 'dwolla'
6
-
7
- # Include any required keys
8
- require './_keys.rb'
9
-
10
- # Instantiate a new Dwolla User client
11
- Dwolla::api_key = @api_key
12
- Dwolla::api_secret = @api_secret
13
-
14
- # Constants...
15
- redirect_uri = 'http://localhost:4567/oauth_return'
16
-
17
- # STEP 1:
18
- # Create an authentication URL
19
- # that the user will be redirected to
20
- get '/' do
21
- authUrl = Dwolla::OAuth.get_auth_url(redirect_uri)
22
- "To begin the OAuth process, send the user off to <a href=\"#{authUrl}\">#{authUrl}</a>"
23
- end
24
-
25
-
26
- # STEP 2:
27
- # Exchange the temporary code given
28
- # to us in the querystring, for
29
- # an expiring OAuth access token and refresh token pair.
30
- get '/oauth_return' do
31
- code = params['code']
32
- info = Dwolla::OAuth.get_token(code, redirect_uri)
33
- token = info['access_token']
34
- refresh_token = info['refresh_token']
35
- "Your expiring OAuth access token is: <b>#{token}</b>, and your refresh token is <b>#{refresh_token}</b>"
36
- end
37
-
38
- # STEP 3:
39
- #
40
- # The array returned in step 2 as 'info' also contains
41
- # expiration times for when the OAuth token will become
42
- # invalid. Use this method to refresh your token with
43
- # the provided refresh token.
44
- #
45
- get '/oauth_refresh' do
46
- refresh_token = params['refresh_token']
47
- info = Dwolla::OAuth.refresh_auth(refresh_token)
48
- token = info['access_token']
49
- refresh_token = info['refresh_token']
50
- "Your expiring OAuth access token is: <b>#{token}</b>, and your refresh token is <b>#{refresh_token}</b>"
1
+ # Include the Dwolla gem
2
+ require 'rubygems'
3
+ require 'pp'
4
+ require 'sinatra'
5
+ require 'dwolla'
6
+
7
+ # Include any required keys
8
+ require './_keys.rb'
9
+
10
+ # Instantiate a new Dwolla User client
11
+ Dwolla::api_key = @api_key
12
+ Dwolla::api_secret = @api_secret
13
+
14
+ # Constants...
15
+ redirect_uri = 'http://localhost:4567/oauth_return'
16
+
17
+ # STEP 1:
18
+ # Create an authentication URL
19
+ # that the user will be redirected to
20
+ get '/' do
21
+ authUrl = Dwolla::OAuth.get_auth_url(redirect_uri)
22
+ "To begin the OAuth process, send the user off to <a href=\"#{authUrl}\">#{authUrl}</a>"
23
+ end
24
+
25
+
26
+ # STEP 2:
27
+ # Exchange the temporary code given
28
+ # to us in the querystring, for
29
+ # an expiring OAuth access token and refresh token pair.
30
+ get '/oauth_return' do
31
+ code = params['code']
32
+ info = Dwolla::OAuth.get_token(code, redirect_uri)
33
+ token = info['access_token']
34
+ refresh_token = info['refresh_token']
35
+ "Your expiring OAuth access token is: <b>#{token}</b>, and your refresh token is <b>#{refresh_token}</b>"
36
+ end
37
+
38
+ # STEP 3:
39
+ #
40
+ # The array returned in step 2 as 'info' also contains
41
+ # expiration times for when the OAuth token will become
42
+ # invalid. Use this method to refresh your token with
43
+ # the provided refresh token.
44
+ #
45
+ get '/oauth_refresh' do
46
+ refresh_token = params['refresh_token']
47
+ info = Dwolla::OAuth.refresh_auth(refresh_token)
48
+ token = info['access_token']
49
+ refresh_token = info['refresh_token']
50
+ "Your expiring OAuth access token is: <b>#{token}</b>, and your refresh token is <b>#{refresh_token}</b>"
51
51
  end
@@ -1,31 +1,31 @@
1
- # Include the Dwolla gem
2
- require 'rubygems'
3
- require 'pp'
4
- require 'dwolla'
5
-
6
- # Include any required keys
7
- require './_keys.rb'
8
-
9
- # Instantiate a new Dwolla User client
10
- Dwolla::api_key = @api_key
11
- Dwolla::api_secret = @api_secret
12
-
13
- # Clear out any previous session data
14
- Dwolla::OffsiteGateway.clear_session
15
-
16
- # Optional Settings
17
- Dwolla::OffsiteGateway.redirect = 'http://dwolla.com/payment_redirect'
18
- Dwolla::OffsiteGateway.callback = 'http://dwolla.com/payment_callback'
19
- Dwolla::OffsiteGateway.set_customer_info('Michael', 'Schonfeld', 'michael@dwolla.com', 'New York', 'NY', '10001')
20
- Dwolla::OffsiteGateway.discount = 4.95
21
- Dwolla::OffsiteGateway.notes = 'This is just an offsite gateway test...'
22
-
23
- # Add products
24
- Dwolla::OffsiteGateway.add_product('Macbook Air', '13" Macbook Air; Model #0001', 499.99, 1)
25
-
26
- # Generate a checkout sesssion
27
- pp Dwolla::OffsiteGateway.get_checkout_url('812-734-7288')
28
-
29
- # Verify and parse gateway callback
30
- data = Dwolla::OffsiteGateway.read_callback('{"Amount":0.01,"OrderId":null,"Status":"Completed","Error":null,"TransactionId":3396300,"CheckoutId":"51f9dfaa-20ed-41a7-8874-00a47c19c655","Signature":"8be03dfd0e95c567b2855f5876acfc98992f6402","TestMode":"false","ClearingDate":"7/22/2013 8:42:18 PM"}')
31
- pp data
1
+ # Include the Dwolla gem
2
+ require 'rubygems'
3
+ require 'pp'
4
+ require 'dwolla'
5
+
6
+ # Include any required keys
7
+ require './_keys.rb'
8
+
9
+ # Instantiate a new Dwolla User client
10
+ Dwolla::api_key = @api_key
11
+ Dwolla::api_secret = @api_secret
12
+
13
+ # Clear out any previous session data
14
+ Dwolla::OffsiteGateway.clear_session
15
+
16
+ # Optional Settings
17
+ Dwolla::OffsiteGateway.redirect = 'http://dwolla.com/payment_redirect'
18
+ Dwolla::OffsiteGateway.callback = 'http://dwolla.com/payment_callback'
19
+ Dwolla::OffsiteGateway.set_customer_info('Michael', 'Schonfeld', 'michael@dwolla.com', 'New York', 'NY', '10001')
20
+ Dwolla::OffsiteGateway.discount = 4.95
21
+ Dwolla::OffsiteGateway.notes = 'This is just an offsite gateway test...'
22
+
23
+ # Add products
24
+ Dwolla::OffsiteGateway.add_product('Macbook Air', '13" Macbook Air; Model #0001', 499.99, 1)
25
+
26
+ # Generate a checkout sesssion
27
+ pp Dwolla::OffsiteGateway.get_checkout_url('812-734-7288')
28
+
29
+ # Verify and parse gateway callback
30
+ data = Dwolla::OffsiteGateway.read_callback('{"Amount":0.01,"OrderId":null,"Status":"Completed","Error":null,"TransactionId":3396300,"CheckoutId":"51f9dfaa-20ed-41a7-8874-00a47c19c655","Signature":"8be03dfd0e95c567b2855f5876acfc98992f6402","TestMode":"false","ClearingDate":"7/22/2013 8:42:18 PM"}')
31
+ pp data
@@ -1,38 +1,38 @@
1
- # Include the Dwolla gem
2
- require 'rubygems'
3
- require 'pp'
4
- require '../lib/dwolla'
5
-
6
- # Include any required keys
7
- require './_keys.rb'
8
-
9
- # Instantiate a new Dwolla User client
10
- # And, seed a previously generated access token
11
- Dwolla::token = @token
12
- Dwolla::debug = true
13
-
14
- # EXAMPLE 1:
15
- # Send money ($1.00) to a Dwolla ID
16
- transactionId = Dwolla::Transactions.send({:destinationId => '812-626-8794', :amount => 1.00, :pin => @pin})
17
- pp transactionId
18
-
19
- # EXAMPLE 2:
20
- # Send money ($1.00) to an email address, with a note
21
- transactionId = Dwolla::Transactions.send({:destinationId => '812-626-8794', :destinationType => 'Email', :amount => 1.00, :pin => @pin, :notes => 'Everyone loves getting money'})
22
- pp transactionId
23
-
24
- # EXAMPLE 3:
25
- # Get details about all recent transactions
26
- pp Dwolla::Transactions.get
27
-
28
- # EXAMPLE 4:
29
- # Get details about a certain Transaction
30
- pp Dwolla::Transactions.get(transactionId)
31
-
32
- # EXAMPLE 4:
33
- # Get details about a certain Transaction
34
- # using the API key & secret
35
- Dwolla::token = ''
36
- Dwolla::api_key = @api_key
37
- Dwolla::api_secret = @api_secret
38
- pp Dwolla::Transactions.get(transactionId, {}, false)
1
+ # Include the Dwolla gem
2
+ require 'rubygems'
3
+ require 'pp'
4
+ require '../lib/dwolla'
5
+
6
+ # Include any required keys
7
+ require './_keys.rb'
8
+
9
+ # Instantiate a new Dwolla User client
10
+ # And, seed a previously generated access token
11
+ Dwolla::token = @token
12
+ Dwolla::debug = true
13
+
14
+ # EXAMPLE 1:
15
+ # Send money ($1.00) to a Dwolla ID
16
+ transactionId = Dwolla::Transactions.send({:destinationId => '812-626-8794', :amount => 1.00, :pin => @pin})
17
+ pp transactionId
18
+
19
+ # EXAMPLE 2:
20
+ # Send money ($1.00) to an email address, with a note
21
+ transactionId = Dwolla::Transactions.send({:destinationId => '812-626-8794', :destinationType => 'Email', :amount => 1.00, :pin => @pin, :notes => 'Everyone loves getting money'})
22
+ pp transactionId
23
+
24
+ # EXAMPLE 3:
25
+ # Get details about all recent transactions
26
+ pp Dwolla::Transactions.get
27
+
28
+ # EXAMPLE 4:
29
+ # Get details about a certain Transaction
30
+ pp Dwolla::Transactions.get(transactionId)
31
+
32
+ # EXAMPLE 4:
33
+ # Get details about a certain Transaction
34
+ # using the API key & secret
35
+ Dwolla::token = ''
36
+ Dwolla::api_key = @api_key
37
+ Dwolla::api_secret = @api_secret
38
+ pp Dwolla::Transactions.get(transactionId, {}, false)
data/examples/users.rb CHANGED
@@ -1,31 +1,31 @@
1
- # Include the Dwolla gem
2
- require 'rubygems'
3
- require 'pp'
4
- require 'dwolla'
5
-
6
- # Include any required keys
7
- require '_keys.rb'
8
-
9
- # Instantiate a new Dwolla User client
10
- # And, seed a previously generated access token
11
- Dwolla::token = @token
12
- Dwolla::api_key = @api_key
13
- Dwolla::api_secret = @api_secret
14
-
15
- # EXAMPLE 1:
16
- # Fetch account information for the
17
- # account associated with the provided
18
- # OAuth token
19
- pp Dwolla::Users.get
20
-
21
-
22
- # EXAMPLE 2:
23
- # Fetch basic account information
24
- # for a given Dwolla ID
25
- pp Dwolla::Users.get('812-626-8794')
26
-
27
-
28
- # EXAMPLE 3:
29
- # Fetch basic account information
30
- # for a given Email address
1
+ # Include the Dwolla gem
2
+ require 'rubygems'
3
+ require 'pp'
4
+ require 'dwolla'
5
+
6
+ # Include any required keys
7
+ require '_keys.rb'
8
+
9
+ # Instantiate a new Dwolla User client
10
+ # And, seed a previously generated access token
11
+ Dwolla::token = @token
12
+ Dwolla::api_key = @api_key
13
+ Dwolla::api_secret = @api_secret
14
+
15
+ # EXAMPLE 1:
16
+ # Fetch account information for the
17
+ # account associated with the provided
18
+ # OAuth token
19
+ pp Dwolla::Users.get
20
+
21
+
22
+ # EXAMPLE 2:
23
+ # Fetch basic account information
24
+ # for a given Dwolla ID
25
+ pp Dwolla::Users.get('812-626-8794')
26
+
27
+
28
+ # EXAMPLE 3:
29
+ # Fetch basic account information
30
+ # for a given Email address
31
31
  pp Dwolla::Users.get('michael@dwolla.com')