dwolla-ruby 2.7.0 → 2.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +8 -8
  3. data/.travis.yml +6 -6
  4. data/Gemfile +1 -1
  5. data/README.md +222 -215
  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 +59 -59
  12. data/examples/offsiteGateway.rb +31 -31
  13. data/examples/transactions.rb +72 -72
  14. data/examples/users.rb +30 -30
  15. data/gemfiles/json.gemfile +2 -2
  16. data/lib/dwolla.rb +327 -327
  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 +84 -84
  31. data/lib/dwolla/offsite_gateway.rb +152 -152
  32. data/lib/dwolla/requests.rb +56 -56
  33. data/lib/dwolla/transactions.rb +108 -108
  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 +36 -36
  42. data/test/test_offsite_gateway.rb +57 -57
  43. data/test/test_requests.rb +29 -29
  44. data/test/test_transactions.rb +117 -117
  45. data/test/test_users.rb +33 -33
  46. metadata +25 -26
@@ -1,10 +1,10 @@
1
- require 'test/unit'
2
- require 'mocha/test_unit'
3
- require 'dwolla'
4
-
5
- class BalanceTest < Test::Unit::TestCase
6
- def test_balance
7
- Dwolla.stubs(:request).with(:get, '/balance/', {}, {}, 'abc')
8
- Dwolla::Balance.get('abc')
9
- end
1
+ require 'test/unit'
2
+ require 'mocha/test_unit'
3
+ require 'dwolla'
4
+
5
+ class BalanceTest < Test::Unit::TestCase
6
+ def test_balance
7
+ Dwolla.stubs(:request).with(:get, '/balance/', {}, {}, 'abc')
8
+ Dwolla::Balance.get('abc')
9
+ end
10
10
  end
@@ -1,20 +1,20 @@
1
- require 'test/unit'
2
- require 'mocha/test_unit'
3
- require 'dwolla'
4
-
5
- class ContactsTest < Test::Unit::TestCase
6
- def test_get
7
- Dwolla.stubs(:request).with(:get, '/contacts/', { :search => 'Test Parameter' }, {}, 'abc')
8
- Dwolla::Contacts.get({:search => 'Test Parameter'}, 'abc')
9
- end
10
-
11
- def test_nearby
12
- Dwolla.stubs(:request).with(:get, '/contacts/nearby',
13
- {
14
- :latitude => 35,
15
- :longitude => 45,
16
- :limit => 10
17
- }, {}, false)
18
- Dwolla::Contacts.nearby(35, 45, { :limit => 10 })
19
- end
1
+ require 'test/unit'
2
+ require 'mocha/test_unit'
3
+ require 'dwolla'
4
+
5
+ class ContactsTest < Test::Unit::TestCase
6
+ def test_get
7
+ Dwolla.stubs(:request).with(:get, '/contacts/', { :search => 'Test Parameter' }, {}, 'abc')
8
+ Dwolla::Contacts.get({:search => 'Test Parameter'}, 'abc')
9
+ end
10
+
11
+ def test_nearby
12
+ Dwolla.stubs(:request).with(:get, '/contacts/nearby',
13
+ {
14
+ :latitude => 35,
15
+ :longitude => 45,
16
+ :limit => 10
17
+ }, {}, false)
18
+ Dwolla::Contacts.nearby(35, 45, { :limit => 10 })
19
+ end
20
20
  end
@@ -1,65 +1,65 @@
1
- require 'test/unit'
2
- require 'mocha/test_unit'
3
- require 'dwolla'
4
-
5
- class FundingSourcesTest < Test::Unit::TestCase
6
- def test_get
7
- Dwolla.stubs(:request).with(:get, '/fundingsources/123456', {}, {}, 'abc')
8
- Dwolla::FundingSources.get('123456', 'abc')
9
- end
10
-
11
- def test_withdraw
12
- Dwolla.stubs(:request).with(:post, '/fundingsources/123456/withdraw',
13
- {
14
- :pin => 1337,
15
- :amount => 13.37
16
- }, {}, 'abc')
17
- Dwolla::FundingSources.withdraw('123456',
18
- {
19
- :pin => 1337,
20
- :amount => 13.37
21
- }, 'abc')
22
- end
23
-
24
- def test_deposit
25
- Dwolla.stubs(:request).with(:post, '/fundingsources/123456/deposit',
26
- {
27
- :pin => 1337,
28
- :amount => 13.37
29
- }, {}, 'abc')
30
- Dwolla::FundingSources.deposit('123456',
31
- {
32
- :pin => 1337,
33
- :amount => 13.37
34
- }, 'abc')
35
- end
36
-
37
- def test_add
38
- Dwolla.stubs(:request).with(:post, '/fundingsources/',
39
- {
40
- :account_number => '123456',
41
- :routing_number => '654321',
42
- :account_type => 'Checking',
43
- :name => 'My Unit Testing Account'
44
- }, {}, 'abc')
45
- Dwolla::FundingSources.add({
46
- :account_number => '123456',
47
- :routing_number => '654321',
48
- :account_type => 'Checking',
49
- :name => 'My Unit Testing Account'
50
- }, 'abc')
51
- end
52
-
53
- def test_verify
54
- Dwolla.stubs(:request).with(:post, '/fundingsources/123456/verify',
55
- {
56
- :deposit1 => 0.05,
57
- :deposit2 => 0.08
58
- }, {}, 'abc')
59
- Dwolla::FundingSources.verify('123456',
60
- {
61
- :deposit1 => 0.05,
62
- :deposit2 => 0.08
63
- }, 'abc')
64
- end
1
+ require 'test/unit'
2
+ require 'mocha/test_unit'
3
+ require 'dwolla'
4
+
5
+ class FundingSourcesTest < Test::Unit::TestCase
6
+ def test_get
7
+ Dwolla.stubs(:request).with(:get, '/fundingsources/123456', {}, {}, 'abc')
8
+ Dwolla::FundingSources.get('123456', 'abc')
9
+ end
10
+
11
+ def test_withdraw
12
+ Dwolla.stubs(:request).with(:post, '/fundingsources/123456/withdraw',
13
+ {
14
+ :pin => 1337,
15
+ :amount => 13.37
16
+ }, {}, 'abc')
17
+ Dwolla::FundingSources.withdraw('123456',
18
+ {
19
+ :pin => 1337,
20
+ :amount => 13.37
21
+ }, 'abc')
22
+ end
23
+
24
+ def test_deposit
25
+ Dwolla.stubs(:request).with(:post, '/fundingsources/123456/deposit',
26
+ {
27
+ :pin => 1337,
28
+ :amount => 13.37
29
+ }, {}, 'abc')
30
+ Dwolla::FundingSources.deposit('123456',
31
+ {
32
+ :pin => 1337,
33
+ :amount => 13.37
34
+ }, 'abc')
35
+ end
36
+
37
+ def test_add
38
+ Dwolla.stubs(:request).with(:post, '/fundingsources/',
39
+ {
40
+ :account_number => '123456',
41
+ :routing_number => '654321',
42
+ :account_type => 'Checking',
43
+ :name => 'My Unit Testing Account'
44
+ }, {}, 'abc')
45
+ Dwolla::FundingSources.add({
46
+ :account_number => '123456',
47
+ :routing_number => '654321',
48
+ :account_type => 'Checking',
49
+ :name => 'My Unit Testing Account'
50
+ }, 'abc')
51
+ end
52
+
53
+ def test_verify
54
+ Dwolla.stubs(:request).with(:post, '/fundingsources/123456/verify',
55
+ {
56
+ :deposit1 => 0.05,
57
+ :deposit2 => 0.08
58
+ }, {}, 'abc')
59
+ Dwolla::FundingSources.verify('123456',
60
+ {
61
+ :deposit1 => 0.05,
62
+ :deposit2 => 0.08
63
+ }, 'abc')
64
+ end
65
65
  end
@@ -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
@@ -1,37 +1,37 @@
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&verified_account=false"
10
- end
11
-
12
- def test_get_token
13
- Dwolla.stubs(:request).with(:post, '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(:post, '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
- def test_catalog
32
- Dwolla.stubs(:request).with(:get, '/catalog',
33
- {}, {}, 'abc', false, false)
34
- Dwolla::OAuth.catalog('abc')
35
- end
36
-
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&verified_account=false"
10
+ end
11
+
12
+ def test_get_token
13
+ Dwolla.stubs(:request).with(:post, '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(:post, '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
+ def test_catalog
32
+ Dwolla.stubs(:request).with(:get, '/catalog',
33
+ {}, {}, 'abc', false, false)
34
+ Dwolla::OAuth.catalog('abc')
35
+ end
36
+
37
37
  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