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/test/test_masspay.rb CHANGED
@@ -1,48 +1,48 @@
1
- require 'test/unit'
2
- require 'mocha/test_unit'
3
- require 'dwolla'
4
-
5
- class MassPayTest < Test::Unit::TestCase
6
- def test_get
7
- Dwolla.stubs(:request).with(:get, '/masspay/', {}, {}, 'abc')
8
- Dwolla::MassPay.get('abc')
9
- end
10
-
11
- def test_create
12
- Dwolla.stubs(:request).with(:post, '/masspay/',
13
- {
14
- :fundsSource => 'Balance',
15
- :pin => 1337,
16
- :items =>
17
- {
18
- :amount => 13.37,
19
- :destination => '812-111-1234'
20
- }
21
- }, {}, 'abc')
22
- Dwolla::MassPay.create(
23
- {
24
- :fundsSource => 'Balance',
25
- :pin => 1337,
26
- :items =>
27
- {
28
- :amount => 13.37,
29
- :destination => '812-111-1234'
30
- }
31
- }, 'abc')
32
- end
33
-
34
- def test_getItems
35
- Dwolla.stubs(:request).with(:get, '/masspay/123456/items', { :limit => 10 }, {}, 'abc')
36
- Dwolla::MassPay.getItems('123456', { :limit => 10 }, 'abc')
37
- end
38
-
39
- def test_getItem
40
- Dwolla.stubs(:request).with(:get, '/masspay/123456/items/654321', {}, {}, 'abc')
41
- Dwolla::MassPay.getItem('123456', '654321', 'abc')
42
- end
43
-
44
- def test_getJob
45
- Dwolla.stubs(:request).with(:get, '/masspay/123456', {}, {}, 'abc')
46
- Dwolla::MassPay.getJob('123456', 'abc')
47
- end
1
+ require 'test/unit'
2
+ require 'mocha/test_unit'
3
+ require 'dwolla'
4
+
5
+ class MassPayTest < Test::Unit::TestCase
6
+ def test_get
7
+ Dwolla.stubs(:request).with(:get, '/masspay/', {}, {}, 'abc')
8
+ Dwolla::MassPay.get('abc')
9
+ end
10
+
11
+ def test_create
12
+ Dwolla.stubs(:request).with(:post, '/masspay/',
13
+ {
14
+ :fundsSource => 'Balance',
15
+ :pin => 1337,
16
+ :items =>
17
+ {
18
+ :amount => 13.37,
19
+ :destination => '812-111-1234'
20
+ }
21
+ }, {}, 'abc')
22
+ Dwolla::MassPay.create(
23
+ {
24
+ :fundsSource => 'Balance',
25
+ :pin => 1337,
26
+ :items =>
27
+ {
28
+ :amount => 13.37,
29
+ :destination => '812-111-1234'
30
+ }
31
+ }, 'abc')
32
+ end
33
+
34
+ def test_getItems
35
+ Dwolla.stubs(:request).with(:get, '/masspay/123456/items', { :limit => 10 }, {}, 'abc')
36
+ Dwolla::MassPay.getItems('123456', { :limit => 10 }, 'abc')
37
+ end
38
+
39
+ def test_getItem
40
+ Dwolla.stubs(:request).with(:get, '/masspay/123456/items/654321', {}, {}, 'abc')
41
+ Dwolla::MassPay.getItem('123456', '654321', 'abc')
42
+ end
43
+
44
+ def test_getJob
45
+ Dwolla.stubs(:request).with(:get, '/masspay/123456', {}, {}, 'abc')
46
+ Dwolla::MassPay.getJob('123456', 'abc')
47
+ end
48
48
  end
data/test/test_oauth.rb CHANGED
@@ -1,31 +1,31 @@
1
- require 'test/unit'
2
- require 'mocha/test_unit'
3
- require 'dwolla'
4
-
5
- class OAuthTest < Test::Unit::TestCase
6
- def test_get_auth_url
7
- Dwolla::api_key = 'abcd'
8
- Dwolla::scope = 'efgh'
9
- assert Dwolla::OAuth.get_auth_url == "https://www.dwolla.com/oauth/v2/authenticate?client_id=abcd&response_type=code&scope=efgh"
10
- end
11
-
12
- def test_get_token
13
- Dwolla.stubs(:request).with(:get, 'https://www.dwolla.com/oauth/v2/token',
14
- {
15
- :grant_type => 'authorization_code',
16
- :code => 'abc',
17
- :redirect_uri => 'http://google.com'
18
- }, {}, false, false, true)
19
- Dwolla::OAuth.get_token('abc', 'http://google.com')
20
- end
21
-
22
- def test_refresh_auth
23
- Dwolla.stubs(:request).with(:get, 'https://www.dwolla.com/oauth/v2/token',
24
- {
25
- :grant_type => 'refresh_token',
26
- :refresh_token => 'abc'
27
- }, {}, false, false, true)
28
- Dwolla::OAuth.refresh_auth('abc')
29
- end
30
-
1
+ require 'test/unit'
2
+ require 'mocha/test_unit'
3
+ require 'dwolla'
4
+
5
+ class OAuthTest < Test::Unit::TestCase
6
+ def test_get_auth_url
7
+ Dwolla::api_key = 'abcd'
8
+ Dwolla::scope = 'efgh'
9
+ assert Dwolla::OAuth.get_auth_url == "https://www.dwolla.com/oauth/v2/authenticate?client_id=abcd&response_type=code&scope=efgh"
10
+ end
11
+
12
+ def test_get_token
13
+ Dwolla.stubs(:request).with(:get, 'https://www.dwolla.com/oauth/v2/token',
14
+ {
15
+ :grant_type => 'authorization_code',
16
+ :code => 'abc',
17
+ :redirect_uri => 'http://google.com'
18
+ }, {}, false, false, true)
19
+ Dwolla::OAuth.get_token('abc', 'http://google.com')
20
+ end
21
+
22
+ def test_refresh_auth
23
+ Dwolla.stubs(:request).with(:get, 'https://www.dwolla.com/oauth/v2/token',
24
+ {
25
+ :grant_type => 'refresh_token',
26
+ :refresh_token => 'abc'
27
+ }, {}, false, false, true)
28
+ Dwolla::OAuth.refresh_auth('abc')
29
+ end
30
+
31
31
  end
@@ -1,58 +1,58 @@
1
- require 'test/unit'
2
- require 'mocha/test_unit'
3
- require 'dwolla'
4
-
5
- class OffsiteGatewayTest < Test::Unit::TestCase
6
- def test_add_product
7
- Dwolla::OffsiteGateway.add_product("Test", "Desc", 1.50, 2)
8
- assert Dwolla::OffsiteGateway.instance_variable_get(:@products) == [{:name => 'Test', :description => 'Desc', :price => 1.50, :quantity => 2}]
9
- end
10
-
11
- def test_set_customer_info
12
- Dwolla::OffsiteGateway.set_customer_info("First", "Last", "Em@i.l", "City", "State", "90210")
13
- assert Dwolla::OffsiteGateway.instance_variable_get(:@customerInfo) == {
14
- :firstName => "First",
15
- :lastName => "Last",
16
- :email => "Em@i.l",
17
- :city => "City",
18
- :state => "State",
19
- :zip => "90210"
20
- }
21
- end
22
-
23
- def test_discount
24
- Dwolla::OffsiteGateway.discount = 1
25
- assert Dwolla::OffsiteGateway.instance_variable_get(:@discount) == -1
26
- end
27
-
28
- def test_get_checkout_url
29
- Dwolla.stubs(:request).with(:post, 'https://www.dwolla.com/payment/request',
30
- {
31
- :key => 'abc',
32
- :secret => 'def',
33
- :allowFundingSources => true,
34
- :additionalFundingSources => true,
35
- :test => false,
36
- :callback => nil,
37
- :redirect => nil,
38
- :orderId => nil,
39
- :notes => nil,
40
- :purchaseOrder => {
41
- :customerInfo => @customerInfo,
42
- :destinationId => '812-111-1234',
43
- :orderItems => [{:name => 'Test', :description => 'Desc', :price => 1.50, :quantity => 2}],
44
- :facilitatorAmount => nil,
45
- :discount => -1,
46
- :shipping => 0,
47
- :tax => 0,
48
- :total => 2.00
49
- }
50
- }, {}, false, false, true)
51
- Dwolla::api_key = 'abc'
52
- Dwolla::api_secret = 'def'
53
- Dwolla::OffsiteGateway.get_checkout_url('812-111-1234')
54
- end
55
-
56
- ## TODO: Tests to validate OpenSSL digest functionality.
57
-
1
+ require 'test/unit'
2
+ require 'mocha/test_unit'
3
+ require 'dwolla'
4
+
5
+ class OffsiteGatewayTest < Test::Unit::TestCase
6
+ def test_add_product
7
+ Dwolla::OffsiteGateway.add_product("Test", "Desc", 1.50, 2)
8
+ assert Dwolla::OffsiteGateway.instance_variable_get(:@products) == [{:name => 'Test', :description => 'Desc', :price => 1.50, :quantity => 2}]
9
+ end
10
+
11
+ def test_set_customer_info
12
+ Dwolla::OffsiteGateway.set_customer_info("First", "Last", "Em@i.l", "City", "State", "90210")
13
+ assert Dwolla::OffsiteGateway.instance_variable_get(:@customerInfo) == {
14
+ :firstName => "First",
15
+ :lastName => "Last",
16
+ :email => "Em@i.l",
17
+ :city => "City",
18
+ :state => "State",
19
+ :zip => "90210"
20
+ }
21
+ end
22
+
23
+ def test_discount
24
+ Dwolla::OffsiteGateway.discount = 1
25
+ assert Dwolla::OffsiteGateway.instance_variable_get(:@discount) == -1
26
+ end
27
+
28
+ def test_get_checkout_url
29
+ Dwolla.stubs(:request).with(:post, 'https://www.dwolla.com/payment/request',
30
+ {
31
+ :key => 'abc',
32
+ :secret => 'def',
33
+ :allowFundingSources => true,
34
+ :additionalFundingSources => true,
35
+ :test => false,
36
+ :callback => nil,
37
+ :redirect => nil,
38
+ :orderId => nil,
39
+ :notes => nil,
40
+ :purchaseOrder => {
41
+ :customerInfo => @customerInfo,
42
+ :destinationId => '812-111-1234',
43
+ :orderItems => [{:name => 'Test', :description => 'Desc', :price => 1.50, :quantity => 2}],
44
+ :facilitatorAmount => nil,
45
+ :discount => -1,
46
+ :shipping => 0,
47
+ :tax => 0,
48
+ :total => 2.00
49
+ }
50
+ }, {}, false, false, true)
51
+ Dwolla::api_key = 'abc'
52
+ Dwolla::api_secret = 'def'
53
+ Dwolla::OffsiteGateway.get_checkout_url('812-111-1234')
54
+ end
55
+
56
+ ## TODO: Tests to validate OpenSSL digest functionality.
57
+
58
58
  end
@@ -1,30 +1,30 @@
1
- require 'test/unit'
2
- require 'mocha/test_unit'
3
- require 'dwolla'
4
-
5
- class RequestsTest < Test::Unit::TestCase
6
- def test_get
7
- Dwolla.stubs(:request).with(:get, '/requests/', {:limit => 10}, {}, 'abc')
8
- Dwolla::Requests.get({:limit => 10}, {}, 'abc')
9
- end
10
-
11
- def test_get_by_id
12
- Dwolla.stubs(:request).with(:get, '/requests/123456', {}, {}, 'abc')
13
- Dwolla::Requests.get('123456', {}, 'abc')
14
- end
15
-
16
- def test_create
17
- Dwolla.stubs(:request).with(:post, '/requests/', {:sourceId => '812-111-1234', :amount => 5.00}, {}, 'abc')
18
- Dwolla::Requests.create({:sourceId => '812-111-1234', :amount => 5.00}, 'abc')
19
- end
20
-
21
- def test_delete
22
- Dwolla.stubs(:request).with(:post, '/requests/123456/cancel', {}, {}, 'abc')
23
- Dwolla::Requests.delete('123456', 'abc')
24
- end
25
-
26
- def test_fulfill
27
- Dwolla.stubs(:request).with(:post, '/requests/123456/fulfill', {:pin => 1337}, {}, 'abc')
28
- Dwolla::Requests.fulfill('123456', {:pin => 1337}, 'abc')
29
- end
1
+ require 'test/unit'
2
+ require 'mocha/test_unit'
3
+ require 'dwolla'
4
+
5
+ class RequestsTest < Test::Unit::TestCase
6
+ def test_get
7
+ Dwolla.stubs(:request).with(:get, '/requests/', {:limit => 10}, {}, 'abc')
8
+ Dwolla::Requests.get({:limit => 10}, {}, 'abc')
9
+ end
10
+
11
+ def test_get_by_id
12
+ Dwolla.stubs(:request).with(:get, '/requests/123456', {}, {}, 'abc')
13
+ Dwolla::Requests.get('123456', {}, 'abc')
14
+ end
15
+
16
+ def test_create
17
+ Dwolla.stubs(:request).with(:post, '/requests/', {:sourceId => '812-111-1234', :amount => 5.00}, {}, 'abc')
18
+ Dwolla::Requests.create({:sourceId => '812-111-1234', :amount => 5.00}, 'abc')
19
+ end
20
+
21
+ def test_delete
22
+ Dwolla.stubs(:request).with(:post, '/requests/123456/cancel', {}, {}, 'abc')
23
+ Dwolla::Requests.delete('123456', 'abc')
24
+ end
25
+
26
+ def test_fulfill
27
+ Dwolla.stubs(:request).with(:post, '/requests/123456/fulfill', {:pin => 1337}, {}, 'abc')
28
+ Dwolla::Requests.fulfill('123456', {:pin => 1337}, 'abc')
29
+ end
30
30
  end
@@ -1,52 +1,52 @@
1
- require 'test/unit'
2
- require 'mocha/test_unit'
3
- require 'dwolla'
4
-
5
- class TransactionsTest < Test::Unit::TestCase
6
- def test_get
7
- Dwolla.stubs(:request).with(:get, '/transactions/', {:limit => 10}, {}, 'abc')
8
- Dwolla::Transactions.get({:limit => 10}, {}, 'abc')
9
- end
10
-
11
- def test_get_by_id
12
- Dwolla.stubs(:request).with(:get, '/transactions/123456', {}, {}, 'abc')
13
- Dwolla::Transactions.get('123456', {}, 'abc')
14
- end
15
-
16
- def test_stats
17
- Dwolla.stubs(:request).with(:get, '/transactions/stats', {:types => 'TransactionsCount'}, {}, 'abc')
18
- Dwolla::Transactions.stats({:types => 'TransactionsCount'}, 'abc')
19
- end
20
-
21
- def test_send
22
- Dwolla.stubs(:request).with(:post, '/transactions/send',
23
- {
24
- :pin => 1337,
25
- :amount => 15.00,
26
- :destinationId => '812-111-1111'
27
- }, {}, 'abc')
28
-
29
- # Send is also an alias but is not tested since it is redundant
30
- Dwolla::Transactions.create({
31
- :pin => 1337,
32
- :amount => 15.00,
33
- :destinationId => '812-111-1111'
34
- }, 'abc')
35
- end
36
-
37
- def test_refund
38
- Dwolla.stubs(:request).with(:post, '/transactions/refund',
39
- {
40
- :pin => 1337,
41
- :fundsSource => 'Balance',
42
- :transactionId => '123456',
43
- :amount => 15.00
44
- }, {}, 'abc')
45
- Dwolla::Transactions.refund({
46
- :pin => 1337,
47
- :fundsSource => 'Balance',
48
- :transactionId => '123456',
49
- :amount => 15.00
50
- }, 'abc')
51
- end
1
+ require 'test/unit'
2
+ require 'mocha/test_unit'
3
+ require 'dwolla'
4
+
5
+ class TransactionsTest < Test::Unit::TestCase
6
+ def test_get
7
+ Dwolla.stubs(:request).with(:get, '/transactions/', {:limit => 10}, {}, 'abc')
8
+ Dwolla::Transactions.get({:limit => 10}, {}, 'abc')
9
+ end
10
+
11
+ def test_get_by_id
12
+ Dwolla.stubs(:request).with(:get, '/transactions/123456', {}, {}, 'abc')
13
+ Dwolla::Transactions.get('123456', {}, 'abc')
14
+ end
15
+
16
+ def test_stats
17
+ Dwolla.stubs(:request).with(:get, '/transactions/stats', {:types => 'TransactionsCount'}, {}, 'abc')
18
+ Dwolla::Transactions.stats({:types => 'TransactionsCount'}, 'abc')
19
+ end
20
+
21
+ def test_send
22
+ Dwolla.stubs(:request).with(:post, '/transactions/send',
23
+ {
24
+ :pin => 1337,
25
+ :amount => 15.00,
26
+ :destinationId => '812-111-1111'
27
+ }, {}, 'abc')
28
+
29
+ # Send is also an alias but is not tested since it is redundant
30
+ Dwolla::Transactions.create({
31
+ :pin => 1337,
32
+ :amount => 15.00,
33
+ :destinationId => '812-111-1111'
34
+ }, 'abc')
35
+ end
36
+
37
+ def test_refund
38
+ Dwolla.stubs(:request).with(:post, '/transactions/refund',
39
+ {
40
+ :pin => 1337,
41
+ :fundsSource => 'Balance',
42
+ :transactionId => '123456',
43
+ :amount => 15.00
44
+ }, {}, 'abc')
45
+ Dwolla::Transactions.refund({
46
+ :pin => 1337,
47
+ :fundsSource => 'Balance',
48
+ :transactionId => '123456',
49
+ :amount => 15.00
50
+ }, 'abc')
51
+ end
52
52
  end
data/test/test_users.rb CHANGED
@@ -1,34 +1,34 @@
1
- require 'test/unit'
2
- require 'mocha/test_unit'
3
- require 'dwolla'
4
-
5
- class UsersTest < Test::Unit::TestCase
6
- def test_get_oauth
7
- Dwolla.stubs(:request).with(:get, '/users/', {}, {}, 'abc')
8
- Dwolla::Users.get(nil, 'abc')
9
- end
10
-
11
- def test_get_id
12
- Dwolla.stubs(:request).with(:get, '/users/812-111-1111', {}, {}, false)
13
- Dwolla::Users.get('812-111-1111')
14
- end
15
-
16
- # This test is redundant, however it is a different function and therefore
17
- # I'm going to test it anyway.
18
- def test_me
19
- Dwolla.stubs(:request).with(:get, '/users/', {}, {}, 'abc')
20
- Dwolla::Users.me('abc')
21
- end
22
-
23
- def test_nearby
24
- Dwolla.stubs(:request).with(:get, '/users/nearby',
25
- {
26
- :latitude => 45,
27
- :longitude => 50
28
- }, {}, false)
29
- Dwolla::Users.nearby({
30
- :latitude => 45,
31
- :longitude => 50
32
- })
33
- end
1
+ require 'test/unit'
2
+ require 'mocha/test_unit'
3
+ require 'dwolla'
4
+
5
+ class UsersTest < Test::Unit::TestCase
6
+ def test_get_oauth
7
+ Dwolla.stubs(:request).with(:get, '/users/', {}, {}, 'abc')
8
+ Dwolla::Users.get(nil, 'abc')
9
+ end
10
+
11
+ def test_get_id
12
+ Dwolla.stubs(:request).with(:get, '/users/812-111-1111', {}, {}, false)
13
+ Dwolla::Users.get('812-111-1111')
14
+ end
15
+
16
+ # This test is redundant, however it is a different function and therefore
17
+ # I'm going to test it anyway.
18
+ def test_me
19
+ Dwolla.stubs(:request).with(:get, '/users/', {}, {}, 'abc')
20
+ Dwolla::Users.me('abc')
21
+ end
22
+
23
+ def test_nearby
24
+ Dwolla.stubs(:request).with(:get, '/users/nearby',
25
+ {
26
+ :latitude => 45,
27
+ :longitude => 50
28
+ }, {}, false)
29
+ Dwolla::Users.nearby({
30
+ :latitude => 45,
31
+ :longitude => 50
32
+ })
33
+ end
34
34
  end