dwolla-ruby 2.5.5 → 2.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -3
- data/README.md +17 -6
- data/dwolla-ruby.gemspec +1 -1
- data/examples/oauth.rb +23 -6
- data/lib/dwolla.rb +18 -18
- data/lib/dwolla/accounts.rb +7 -1
- data/lib/dwolla/contacts.rb +11 -3
- data/lib/dwolla/masspay.rb +53 -0
- data/lib/dwolla/oauth.rb +60 -35
- data/lib/dwolla/offsite_gateway.rb +2 -0
- data/lib/dwolla/transactions.rb +0 -15
- data/lib/dwolla/users.rb +6 -3
- data/lib/dwolla/version.rb +1 -1
- data/test/test_accounts.rb +19 -0
- data/test/test_balance.rb +10 -0
- data/test/test_contacts.rb +20 -0
- data/test/test_funding_sources.rb +65 -0
- data/test/test_masspay.rb +48 -0
- data/test/test_oauth.rb +31 -0
- data/test/test_offsite_gateway.rb +58 -0
- data/test/test_requests.rb +30 -0
- data/test/test_transactions.rb +52 -0
- data/test/test_users.rb +34 -0
- metadata +26 -23
- data/lib/dwolla/register.rb +0 -55
- data/test/test_dwolla.rb +0 -198
- data/test/test_helper.rb +0 -424
@@ -0,0 +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
|
19
|
+
end
|
@@ -0,0 +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
|
20
|
+
end
|
@@ -0,0 +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
|
65
|
+
end
|
@@ -0,0 +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
|
48
|
+
end
|
data/test/test_oauth.rb
ADDED
@@ -0,0 +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
|
+
|
31
|
+
end
|
@@ -0,0 +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
|
+
|
58
|
+
end
|
@@ -0,0 +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
|
30
|
+
end
|
@@ -0,0 +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
|
52
|
+
end
|
data/test/test_users.rb
ADDED
@@ -0,0 +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
|
34
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dwolla-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Schonfeld
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06
|
11
|
+
date: 2014-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -72,20 +72,6 @@ dependencies:
|
|
72
72
|
- - '>='
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '0'
|
75
|
-
- !ruby/object:Gem::Dependency
|
76
|
-
name: shoulda
|
77
|
-
requirement: !ruby/object:Gem::Requirement
|
78
|
-
requirements:
|
79
|
-
- - '>='
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
version: '0'
|
82
|
-
type: :development
|
83
|
-
prerelease: false
|
84
|
-
version_requirements: !ruby/object:Gem::Requirement
|
85
|
-
requirements:
|
86
|
-
- - '>='
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
version: '0'
|
89
75
|
- !ruby/object:Gem::Dependency
|
90
76
|
name: test-unit
|
91
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -150,17 +136,26 @@ files:
|
|
150
136
|
- lib/dwolla/exceptions.rb
|
151
137
|
- lib/dwolla/funding_sources.rb
|
152
138
|
- lib/dwolla/json.rb
|
139
|
+
- lib/dwolla/masspay.rb
|
153
140
|
- lib/dwolla/oauth.rb
|
154
141
|
- lib/dwolla/offsite_gateway.rb
|
155
|
-
- lib/dwolla/register.rb
|
156
142
|
- lib/dwolla/requests.rb
|
157
143
|
- lib/dwolla/transactions.rb
|
158
144
|
- lib/dwolla/users.rb
|
159
145
|
- lib/dwolla/version.rb
|
160
|
-
- test/
|
161
|
-
- test/
|
146
|
+
- test/test_accounts.rb
|
147
|
+
- test/test_balance.rb
|
148
|
+
- test/test_contacts.rb
|
149
|
+
- test/test_funding_sources.rb
|
150
|
+
- test/test_masspay.rb
|
151
|
+
- test/test_oauth.rb
|
152
|
+
- test/test_offsite_gateway.rb
|
153
|
+
- test/test_requests.rb
|
154
|
+
- test/test_transactions.rb
|
155
|
+
- test/test_users.rb
|
162
156
|
homepage: https://github.com/dwolla/dwolla-ruby
|
163
|
-
licenses:
|
157
|
+
licenses:
|
158
|
+
- MIT
|
164
159
|
metadata: {}
|
165
160
|
post_install_message:
|
166
161
|
rdoc_options: []
|
@@ -178,10 +173,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
178
173
|
version: '0'
|
179
174
|
requirements: []
|
180
175
|
rubyforge_project: dwolla-ruby
|
181
|
-
rubygems_version: 2.
|
176
|
+
rubygems_version: 2.2.2
|
182
177
|
signing_key:
|
183
178
|
specification_version: 4
|
184
179
|
summary: Official Ruby Wrapper for Dwolla's API
|
185
180
|
test_files:
|
186
|
-
- test/
|
187
|
-
- test/
|
181
|
+
- test/test_accounts.rb
|
182
|
+
- test/test_balance.rb
|
183
|
+
- test/test_contacts.rb
|
184
|
+
- test/test_funding_sources.rb
|
185
|
+
- test/test_masspay.rb
|
186
|
+
- test/test_oauth.rb
|
187
|
+
- test/test_offsite_gateway.rb
|
188
|
+
- test/test_requests.rb
|
189
|
+
- test/test_transactions.rb
|
190
|
+
- test/test_users.rb
|