dwolla-ruby 2.9.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +8 -8
- data/.travis.yml +11 -6
- data/Gemfile +1 -1
- data/README.md +225 -222
- data/Rakefile +8 -8
- data/dwolla-ruby.gemspec +27 -27
- data/examples/balance.rb +15 -15
- data/examples/contacts.rb +32 -32
- data/examples/fundingSources.rb +39 -39
- data/examples/oauth.rb +59 -59
- data/examples/offsiteGateway.rb +31 -31
- data/examples/transactions.rb +72 -72
- data/examples/users.rb +30 -30
- data/gemfiles/json.gemfile +2 -2
- data/lib/dwolla.rb +319 -327
- data/lib/dwolla/accounts.rb +27 -27
- data/lib/dwolla/balance.rb +15 -15
- data/lib/dwolla/contacts.rb +30 -30
- data/lib/dwolla/errors/api_connection_error.rb +3 -3
- data/lib/dwolla/errors/api_error.rb +3 -3
- data/lib/dwolla/errors/authentication_error.rb +3 -3
- data/lib/dwolla/errors/dwolla_error.rb +19 -19
- data/lib/dwolla/errors/invalid_request_error.rb +10 -10
- data/lib/dwolla/errors/missing_parameter_error.rb +3 -3
- data/lib/dwolla/exceptions.rb +4 -4
- data/lib/dwolla/funding_sources.rb +65 -65
- data/lib/dwolla/json.rb +20 -20
- data/lib/dwolla/masspay.rb +52 -52
- data/lib/dwolla/oauth.rb +84 -84
- data/lib/dwolla/offsite_gateway.rb +152 -152
- data/lib/dwolla/requests.rb +56 -56
- data/lib/dwolla/transactions.rb +108 -108
- data/lib/dwolla/users.rb +39 -39
- data/lib/dwolla/version.rb +3 -3
- data/test/test_accounts.rb +18 -18
- data/test/test_balance.rb +9 -9
- data/test/test_contacts.rb +19 -19
- data/test/test_dwolla.rb +62 -0
- data/test/test_funding_sources.rb +64 -64
- data/test/test_masspay.rb +47 -47
- data/test/test_oauth.rb +36 -36
- data/test/test_offsite_gateway.rb +57 -57
- data/test/test_requests.rb +29 -29
- data/test/test_transactions.rb +117 -117
- data/test/test_users.rb +33 -33
- metadata +5 -3
data/lib/dwolla/requests.rb
CHANGED
@@ -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
|
data/lib/dwolla/transactions.rb
CHANGED
@@ -1,108 +1,108 @@
|
|
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
|
-
end
|
10
|
-
|
11
|
-
url += id.to_s unless id.nil?
|
12
|
-
|
13
|
-
Dwolla.request(:get, url, filters, {}, token)
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.stats(filters={}, token=nil)
|
17
|
-
url = transactions_url + 'stats'
|
18
|
-
|
19
|
-
Dwolla.request(:get, url, filters, {}, token)
|
20
|
-
end
|
21
|
-
|
22
|
-
def self.create(params={}, token=nil)
|
23
|
-
raise MissingParameterError.new('No Destination ID Provided.') unless params[:destinationId]
|
24
|
-
raise MissingParameterError.new('No Amount Provided.') unless params[:amount]
|
25
|
-
|
26
|
-
url = transactions_url + 'send'
|
27
|
-
|
28
|
-
Dwolla.request(:post, url, params, {}, token)
|
29
|
-
end
|
30
|
-
|
31
|
-
def self.refund(params={}, token=nil)
|
32
|
-
raise MissingParameterError.new('No PIN Provided.') unless params[:pin]
|
33
|
-
raise MissingParameterError.new('No Funding Source Provided.') unless params[:fundsSource]
|
34
|
-
raise MissingParameterError.new('No Transaction ID Provided.') unless params[:transactionId]
|
35
|
-
raise MissingParameterError.new('No Amount Provided.') unless params[:amount]
|
36
|
-
|
37
|
-
url = transactions_url + 'refund'
|
38
|
-
|
39
|
-
Dwolla.request(:post, url, params, {}, token)
|
40
|
-
end
|
41
|
-
|
42
|
-
def self.schedule(params={}, token=nil)
|
43
|
-
raise MissingParameterError.new('No PIN Provided.') unless params[:pin]
|
44
|
-
raise MissingParameterError.new('No Destination ID Provided.') unless params[:destinationId]
|
45
|
-
raise MissingParameterError.new('No Amount Provided.') unless params[:amount]
|
46
|
-
raise MissingParameterError.new('No Scheduled Date Provided') unless params[:scheduleDate]
|
47
|
-
raise MissingParameterError.new('No Funds Source Provided.') unless params[:fundsSource]
|
48
|
-
|
49
|
-
url = transactions_url + 'scheduled'
|
50
|
-
|
51
|
-
Dwolla.request(:post, url, params, {}, token)
|
52
|
-
end
|
53
|
-
|
54
|
-
def self.scheduled(filters={}, token=nil)
|
55
|
-
url = transactions_url + 'scheduled'
|
56
|
-
|
57
|
-
Dwolla.request(:get, url, filters, {}, token)
|
58
|
-
end
|
59
|
-
|
60
|
-
def self.scheduled_by_id(id, token=nil)
|
61
|
-
raise MissingParameterError.new('No Scheduled Transaction ID Provided.') unless id
|
62
|
-
|
63
|
-
url = transactions_url + 'scheduled/'
|
64
|
-
url += id.to_s unless id.nil?
|
65
|
-
|
66
|
-
Dwolla.request(:get, url, {}, {}, token)
|
67
|
-
end
|
68
|
-
|
69
|
-
def self.edit_scheduled(id, params={}, token=nil)
|
70
|
-
raise MissingParameterError.new('No PIN Provided.') unless params[:pin]
|
71
|
-
raise MissingParameterError.new('No Scheduled Transaction ID Provided.') unless id
|
72
|
-
|
73
|
-
url = transactions_url + 'scheduled/'
|
74
|
-
url += id.to_s unless id.nil?
|
75
|
-
|
76
|
-
Dwolla.request(:put, url, params, {}, token)
|
77
|
-
end
|
78
|
-
|
79
|
-
def self.delete_scheduled_by_id(id, params={}, token=nil)
|
80
|
-
raise MissingParameterError.new('No PIN Provided.') unless params[:pin]
|
81
|
-
raise MissingParameterError.new('No Scheduled Transaction ID Provided.') unless id
|
82
|
-
|
83
|
-
url = transactions_url + 'scheduled/'
|
84
|
-
url += id.to_s unless id.nil?
|
85
|
-
|
86
|
-
Dwolla.request(:delete, url, params, {}, token)
|
87
|
-
end
|
88
|
-
|
89
|
-
def self.delete_all_scheduled(params={}, token=nil)
|
90
|
-
raise MissingParameterError.new('No PIN Provided.') unless params[:pin]
|
91
|
-
|
92
|
-
url = transactions_url + 'scheduled'
|
93
|
-
|
94
|
-
Dwolla.request(:delete, url, params, {}, token)
|
95
|
-
end
|
96
|
-
|
97
|
-
class << self
|
98
|
-
alias_method :listing, :get
|
99
|
-
alias_method :send, :create
|
100
|
-
end
|
101
|
-
|
102
|
-
private
|
103
|
-
|
104
|
-
def self.transactions_url
|
105
|
-
return '/transactions/'
|
106
|
-
end
|
107
|
-
end
|
108
|
-
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
|
+
end
|
10
|
+
|
11
|
+
url += id.to_s unless id.nil?
|
12
|
+
|
13
|
+
Dwolla.request(:get, url, filters, {}, token)
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.stats(filters={}, token=nil)
|
17
|
+
url = transactions_url + 'stats'
|
18
|
+
|
19
|
+
Dwolla.request(:get, url, filters, {}, token)
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.create(params={}, token=nil)
|
23
|
+
raise MissingParameterError.new('No Destination ID Provided.') unless params[:destinationId]
|
24
|
+
raise MissingParameterError.new('No Amount Provided.') unless params[:amount]
|
25
|
+
|
26
|
+
url = transactions_url + 'send'
|
27
|
+
|
28
|
+
Dwolla.request(:post, url, params, {}, token)
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.refund(params={}, token=nil)
|
32
|
+
raise MissingParameterError.new('No PIN Provided.') unless params[:pin]
|
33
|
+
raise MissingParameterError.new('No Funding Source Provided.') unless params[:fundsSource]
|
34
|
+
raise MissingParameterError.new('No Transaction ID Provided.') unless params[:transactionId]
|
35
|
+
raise MissingParameterError.new('No Amount Provided.') unless params[:amount]
|
36
|
+
|
37
|
+
url = transactions_url + 'refund'
|
38
|
+
|
39
|
+
Dwolla.request(:post, url, params, {}, token)
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.schedule(params={}, token=nil)
|
43
|
+
raise MissingParameterError.new('No PIN Provided.') unless params[:pin]
|
44
|
+
raise MissingParameterError.new('No Destination ID Provided.') unless params[:destinationId]
|
45
|
+
raise MissingParameterError.new('No Amount Provided.') unless params[:amount]
|
46
|
+
raise MissingParameterError.new('No Scheduled Date Provided') unless params[:scheduleDate]
|
47
|
+
raise MissingParameterError.new('No Funds Source Provided.') unless params[:fundsSource]
|
48
|
+
|
49
|
+
url = transactions_url + 'scheduled'
|
50
|
+
|
51
|
+
Dwolla.request(:post, url, params, {}, token)
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.scheduled(filters={}, token=nil)
|
55
|
+
url = transactions_url + 'scheduled'
|
56
|
+
|
57
|
+
Dwolla.request(:get, url, filters, {}, token)
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.scheduled_by_id(id, token=nil)
|
61
|
+
raise MissingParameterError.new('No Scheduled Transaction ID Provided.') unless id
|
62
|
+
|
63
|
+
url = transactions_url + 'scheduled/'
|
64
|
+
url += id.to_s unless id.nil?
|
65
|
+
|
66
|
+
Dwolla.request(:get, url, {}, {}, token)
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.edit_scheduled(id, params={}, token=nil)
|
70
|
+
raise MissingParameterError.new('No PIN Provided.') unless params[:pin]
|
71
|
+
raise MissingParameterError.new('No Scheduled Transaction ID Provided.') unless id
|
72
|
+
|
73
|
+
url = transactions_url + 'scheduled/'
|
74
|
+
url += id.to_s unless id.nil?
|
75
|
+
|
76
|
+
Dwolla.request(:put, url, params, {}, token)
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.delete_scheduled_by_id(id, params={}, token=nil)
|
80
|
+
raise MissingParameterError.new('No PIN Provided.') unless params[:pin]
|
81
|
+
raise MissingParameterError.new('No Scheduled Transaction ID Provided.') unless id
|
82
|
+
|
83
|
+
url = transactions_url + 'scheduled/'
|
84
|
+
url += id.to_s unless id.nil?
|
85
|
+
|
86
|
+
Dwolla.request(:delete, url, params, {}, token)
|
87
|
+
end
|
88
|
+
|
89
|
+
def self.delete_all_scheduled(params={}, token=nil)
|
90
|
+
raise MissingParameterError.new('No PIN Provided.') unless params[:pin]
|
91
|
+
|
92
|
+
url = transactions_url + 'scheduled'
|
93
|
+
|
94
|
+
Dwolla.request(:delete, url, params, {}, token)
|
95
|
+
end
|
96
|
+
|
97
|
+
class << self
|
98
|
+
alias_method :listing, :get
|
99
|
+
alias_method :send, :create
|
100
|
+
end
|
101
|
+
|
102
|
+
private
|
103
|
+
|
104
|
+
def self.transactions_url
|
105
|
+
return '/transactions/'
|
106
|
+
end
|
107
|
+
end
|
108
|
+
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
|
data/lib/dwolla/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module Dwolla
|
2
|
-
VERSION = "
|
3
|
-
end
|
1
|
+
module Dwolla
|
2
|
+
VERSION = "3.0.0"
|
3
|
+
end
|
data/test/test_accounts.rb
CHANGED
@@ -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
|