dwolla-ruby 2.6.4 → 2.6.5

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 +5 -13
  2. data/.gitignore +8 -8
  3. data/.travis.yml +6 -6
  4. data/Gemfile +1 -1
  5. data/README.md +198 -192
  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 -50
  12. data/examples/offsiteGateway.rb +31 -31
  13. data/examples/transactions.rb +72 -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 +83 -75
  31. data/lib/dwolla/offsite_gateway.rb +152 -152
  32. data/lib/dwolla/requests.rb +56 -56
  33. data/lib/dwolla/transactions.rb +111 -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 +36 -30
  42. data/test/test_offsite_gateway.rb +57 -57
  43. data/test/test_requests.rb +29 -29
  44. data/test/test_transactions.rb +117 -51
  45. data/test/test_users.rb +33 -33
  46. metadata +21 -21
@@ -1,56 +1,56 @@
1
- module Dwolla
2
- class Requests
3
- def self.get(id=nil, filters={}, token=nil)
4
- url = requests_url
5
-
6
- if id.is_a?(Hash)
7
- filters = id
8
- id = nil
9
- else
10
- filters = {}
11
- end
12
-
13
- url += id.to_s unless id.nil?
14
-
15
- Dwolla.request(:get, url, filters, {}, token)
16
- end
17
-
18
- def self.delete(id=nil, token=nil)
19
- raise MissingParameterError.new('No Request ID Provided.') if id.nil?
20
-
21
- url = requests_url + id.to_s + '/cancel'
22
-
23
- Dwolla.request(:post, url, {}, {}, token)
24
- end
25
-
26
- def self.create(params={}, token=nil)
27
- raise MissingParameterError.new('No Source ID Provided.') unless params[:sourceId]
28
- raise MissingParameterError.new('No Amount Provided.') unless params[:amount]
29
-
30
- url = requests_url
31
-
32
- Dwolla.request(:post, url, params, {}, token)
33
- end
34
-
35
- def self.fulfill(id=nil, params={}, token=nil)
36
- raise MissingParameterError.new('No Request ID Provided.') if id.nil?
37
- raise MissingParameterError.new('No PIN Provided.') unless params[:pin]
38
-
39
- url = requests_url + id.to_s + '/fulfill'
40
-
41
- Dwolla.request(:post, url, params, {}, token)
42
- end
43
-
44
- class << self
45
- alias_method :pending, :get
46
- alias_method :cancel, :delete
47
- alias_method :request, :create
48
- end
49
-
50
- private
51
-
52
- def self.requests_url
53
- return '/requests/'
54
- end
55
- end
56
- end
1
+ module Dwolla
2
+ class Requests
3
+ def self.get(id=nil, filters={}, token=nil)
4
+ url = requests_url
5
+
6
+ if id.is_a?(Hash)
7
+ filters = id
8
+ id = nil
9
+ else
10
+ filters = {}
11
+ end
12
+
13
+ url += id.to_s unless id.nil?
14
+
15
+ Dwolla.request(:get, url, filters, {}, token)
16
+ end
17
+
18
+ def self.delete(id=nil, token=nil)
19
+ raise MissingParameterError.new('No Request ID Provided.') if id.nil?
20
+
21
+ url = requests_url + id.to_s + '/cancel'
22
+
23
+ Dwolla.request(:post, url, {}, {}, token)
24
+ end
25
+
26
+ def self.create(params={}, token=nil)
27
+ raise MissingParameterError.new('No Source ID Provided.') unless params[:sourceId]
28
+ raise MissingParameterError.new('No Amount Provided.') unless params[:amount]
29
+
30
+ url = requests_url
31
+
32
+ Dwolla.request(:post, url, params, {}, token)
33
+ end
34
+
35
+ def self.fulfill(id=nil, params={}, token=nil)
36
+ raise MissingParameterError.new('No Request ID Provided.') if id.nil?
37
+ raise MissingParameterError.new('No PIN Provided.') unless params[:pin]
38
+
39
+ url = requests_url + id.to_s + '/fulfill'
40
+
41
+ Dwolla.request(:post, url, params, {}, token)
42
+ end
43
+
44
+ class << self
45
+ alias_method :pending, :get
46
+ alias_method :cancel, :delete
47
+ alias_method :request, :create
48
+ end
49
+
50
+ private
51
+
52
+ def self.requests_url
53
+ return '/requests/'
54
+ end
55
+ end
56
+ end
@@ -1,56 +1,111 @@
1
- module Dwolla
2
- class Transactions
3
- def self.get(id=nil, filters={}, token=nil)
4
- url = transactions_url
5
-
6
- if id.is_a?(Hash)
7
- filters = id
8
- id = nil
9
- else
10
- filters = {}
11
- end
12
-
13
- url += id.to_s unless id.nil?
14
-
15
- Dwolla.request(:get, url, filters, {}, token)
16
- end
17
-
18
- def self.stats(filters={}, token=nil)
19
- url = transactions_url + 'stats'
20
-
21
- Dwolla.request(:get, url, filters, {}, token)
22
- end
23
-
24
- def self.create(params={}, token=nil)
25
- raise MissingParameterError.new('No PIN Provided.') unless params[:pin]
26
- raise MissingParameterError.new('No Destination ID Provided.') unless params[:destinationId]
27
- raise MissingParameterError.new('No Amount Provided.') unless params[:amount]
28
-
29
- url = transactions_url + 'send'
30
-
31
- Dwolla.request(:post, url, params, {}, token)
32
- end
33
-
34
- def self.refund(params={}, token=nil)
35
- raise MissingParameterError.new('No PIN Provided.') unless params[:pin]
36
- raise MissingParameterError.new('No Funding Source Provided.') unless params[:fundsSource]
37
- raise MissingParameterError.new('No Transaction ID Provided.') unless params[:transactionId]
38
- raise MissingParameterError.new('No Amount Provided.') unless params[:amount]
39
-
40
- url = transactions_url + 'refund'
41
-
42
- Dwolla.request(:post, url, params, {}, token)
43
- end
44
-
45
- class << self
46
- alias_method :listing, :get
47
- alias_method :send, :create
48
- end
49
-
50
- private
51
-
52
- def self.transactions_url
53
- return '/transactions/'
54
- end
55
- end
56
- end
1
+ module Dwolla
2
+ class Transactions
3
+ def self.get(id=nil, filters={}, token=nil)
4
+ url = transactions_url
5
+
6
+ if id.is_a?(Hash)
7
+ filters = id
8
+ id = nil
9
+ else
10
+ filters = {}
11
+ end
12
+
13
+ url += id.to_s unless id.nil?
14
+
15
+ Dwolla.request(:get, url, filters, {}, token)
16
+ end
17
+
18
+ def self.stats(filters={}, token=nil)
19
+ url = transactions_url + 'stats'
20
+
21
+ Dwolla.request(:get, url, filters, {}, token)
22
+ end
23
+
24
+ def self.create(params={}, token=nil)
25
+ raise MissingParameterError.new('No PIN Provided.') unless params[:pin]
26
+ raise MissingParameterError.new('No Destination ID Provided.') unless params[:destinationId]
27
+ raise MissingParameterError.new('No Amount Provided.') unless params[:amount]
28
+
29
+ url = transactions_url + 'send'
30
+
31
+ Dwolla.request(:post, url, params, {}, token)
32
+ end
33
+
34
+ def self.refund(params={}, token=nil)
35
+ raise MissingParameterError.new('No PIN Provided.') unless params[:pin]
36
+ raise MissingParameterError.new('No Funding Source Provided.') unless params[:fundsSource]
37
+ raise MissingParameterError.new('No Transaction ID Provided.') unless params[:transactionId]
38
+ raise MissingParameterError.new('No Amount Provided.') unless params[:amount]
39
+
40
+ url = transactions_url + 'refund'
41
+
42
+ Dwolla.request(:post, url, params, {}, token)
43
+ end
44
+
45
+ def self.schedule(params={}, token=nil)
46
+ raise MissingParameterError.new('No PIN Provided.') unless params[:pin]
47
+ raise MissingParameterError.new('No Destination ID Provided.') unless params[:destinationId]
48
+ raise MissingParameterError.new('No Amount Provided.') unless params[:amount]
49
+ raise MissingParameterError.new('No Scheduled Date Provided') unless params[:scheduleDate]
50
+ raise MissingParameterError.new('No Funds Source Provided.') unless params[:fundsSource]
51
+
52
+ url = transactions_url + 'scheduled'
53
+
54
+ Dwolla.request(:post, url, params, {}, token)
55
+ end
56
+
57
+ def self.scheduled(filters={}, token=nil)
58
+ url = transactions_url + 'scheduled'
59
+
60
+ Dwolla.request(:get, url, filters, {}, token)
61
+ end
62
+
63
+ def self.scheduled_by_id(id, token=nil)
64
+ raise MissingParameterError.new('No Scheduled Transaction ID Provided.') unless id
65
+
66
+ url = transactions_url + 'scheduled/'
67
+ url += id.to_s unless id.nil?
68
+
69
+ Dwolla.request(:get, url, {}, {}, token)
70
+ end
71
+
72
+ def self.edit_scheduled(id, params={}, token=nil)
73
+ raise MissingParameterError.new('No PIN Provided.') unless params[:pin]
74
+ raise MissingParameterError.new('No Scheduled Transaction ID Provided.') unless id
75
+
76
+ url = transactions_url + 'scheduled/'
77
+ url += id.to_s unless id.nil?
78
+
79
+ Dwolla.request(:put, url, params, {}, token)
80
+ end
81
+
82
+ def self.delete_scheduled_by_id(id, params={}, token=nil)
83
+ raise MissingParameterError.new('No PIN Provided.') unless params[:pin]
84
+ raise MissingParameterError.new('No Scheduled Transaction ID Provided.') unless id
85
+
86
+ url = transactions_url + 'scheduled/'
87
+ url += id.to_s unless id.nil?
88
+
89
+ Dwolla.request(:delete, url, params, {}, token)
90
+ end
91
+
92
+ def self.delete_all_scheduled(params={}, token=nil)
93
+ raise MissingParameterError.new('No PIN Provided.') unless params[:pin]
94
+
95
+ url = transactions_url + 'scheduled'
96
+
97
+ Dwolla.request(:delete, url, params, {}, token)
98
+ end
99
+
100
+ class << self
101
+ alias_method :listing, :get
102
+ alias_method :send, :create
103
+ end
104
+
105
+ private
106
+
107
+ def self.transactions_url
108
+ return '/transactions/'
109
+ end
110
+ end
111
+ end
data/lib/dwolla/users.rb CHANGED
@@ -1,39 +1,39 @@
1
- module Dwolla
2
- class Users
3
- def self.get(id=nil, token=nil)
4
- url = users_url
5
-
6
- unless id.nil?
7
- url += id.to_s
8
- @oauth = false
9
- else
10
- @oauth = token.nil? ? true : token
11
- end
12
-
13
- Dwolla.request(:get, url, {}, {}, @oauth)
14
- end
15
-
16
- def self.me(token=nil)
17
- # I'm not using the 'alias_method' fn
18
- # because the .me method should not
19
- # honor any parameters (i.e. User IDs)
20
- # passed to it
21
- self.get(nil, token)
22
- end
23
-
24
- def self.nearby(params={})
25
- raise MissingParameterError.new('No Latitude Provided') unless params[:latitude]
26
- raise MissingParameterError.new('No Longitude Provided') unless params[:longitude]
27
-
28
- url = users_url + 'nearby'
29
-
30
- Dwolla.request(:get, url, params, {}, false)
31
- end
32
-
33
- private
34
-
35
- def self.users_url
36
- return '/users/'
37
- end
38
- end
39
- end
1
+ module Dwolla
2
+ class Users
3
+ def self.get(id=nil, token=nil)
4
+ url = users_url
5
+
6
+ unless id.nil?
7
+ url += id.to_s
8
+ @oauth = false
9
+ else
10
+ @oauth = token.nil? ? true : token
11
+ end
12
+
13
+ Dwolla.request(:get, url, {}, {}, @oauth)
14
+ end
15
+
16
+ def self.me(token=nil)
17
+ # I'm not using the 'alias_method' fn
18
+ # because the .me method should not
19
+ # honor any parameters (i.e. User IDs)
20
+ # passed to it
21
+ self.get(nil, token)
22
+ end
23
+
24
+ def self.nearby(params={})
25
+ raise MissingParameterError.new('No Latitude Provided') unless params[:latitude]
26
+ raise MissingParameterError.new('No Longitude Provided') unless params[:longitude]
27
+
28
+ url = users_url + 'nearby'
29
+
30
+ Dwolla.request(:get, url, params, {}, false)
31
+ end
32
+
33
+ private
34
+
35
+ def self.users_url
36
+ return '/users/'
37
+ end
38
+ end
39
+ end
@@ -1,3 +1,3 @@
1
- module Dwolla
2
- VERSION = "2.6.4"
3
- end
1
+ module Dwolla
2
+ VERSION = "2.6.5"
3
+ end
@@ -1,19 +1,19 @@
1
- require 'test/unit'
2
- require 'mocha/test_unit'
3
- require 'dwolla'
4
-
5
- class AccountsTest < Test::Unit::TestCase
6
- def test_get_auto_withdrawal_status
7
- Dwolla.stubs(:request).with(:get, '/accounts/features/auto_withdrawl', {}, {}, 'abc')
8
- Dwolla::Accounts.get_auto_withdrawal_status('abc')
9
- end
10
-
11
- def test_toggle_auto_withdrawl
12
- Dwolla.stubs(:request).with(:post, '/accounts/features/auto_withdrawl',
13
- {
14
- :enabled => true,
15
- :fundingId => '123456'
16
- }, {}, 'abc')
17
- Dwolla::Accounts.toggle_auto_withdrawl(true, '123456', 'abc')
18
- end
1
+ require 'test/unit'
2
+ require 'mocha/test_unit'
3
+ require 'dwolla'
4
+
5
+ class AccountsTest < Test::Unit::TestCase
6
+ def test_get_auto_withdrawal_status
7
+ Dwolla.stubs(:request).with(:get, '/accounts/features/auto_withdrawl', {}, {}, 'abc')
8
+ Dwolla::Accounts.get_auto_withdrawal_status('abc')
9
+ end
10
+
11
+ def test_toggle_auto_withdrawl
12
+ Dwolla.stubs(:request).with(:post, '/accounts/features/auto_withdrawl',
13
+ {
14
+ :enabled => true,
15
+ :fundingId => '123456'
16
+ }, {}, 'abc')
17
+ Dwolla::Accounts.toggle_auto_withdrawl(true, '123456', 'abc')
18
+ end
19
19
  end
data/test/test_balance.rb CHANGED
@@ -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