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,27 +1,27 @@
1
- module Dwolla
2
- class Accounts
3
- def self.get_auto_withdrawal_status(token=nil)
4
- url = accounts_url + 'features/auto_withdrawl'
5
-
6
- Dwolla.request(:get, url, {}, {}, token)
7
- end
8
-
9
- def self.toggle_auto_withdrawl(enabled=true, funding_id=nil, token=nil)
10
- raise MissingParameterError.new('No Funding ID Provided.') if funding_id.nil?
11
-
12
- url = accounts_url + 'features/auto_withdrawl'
13
- params = {
14
- :enabled => enabled,
15
- :fundingId => funding_id
16
- }
17
-
18
- Dwolla.request(:post, url, params, {}, token)
19
- end
20
-
21
- private
22
-
23
- def self.accounts_url
24
- return '/accounts/'
25
- end
26
- end
27
- end
1
+ module Dwolla
2
+ class Accounts
3
+ def self.get_auto_withdrawal_status(token=nil)
4
+ url = accounts_url + 'features/auto_withdrawl'
5
+
6
+ Dwolla.request(:get, url, {}, {}, token)
7
+ end
8
+
9
+ def self.toggle_auto_withdrawl(enabled=true, funding_id=nil, token=nil)
10
+ raise MissingParameterError.new('No Funding ID Provided.') if funding_id.nil?
11
+
12
+ url = accounts_url + 'features/auto_withdrawl'
13
+ params = {
14
+ :enabled => enabled,
15
+ :fundingId => funding_id
16
+ }
17
+
18
+ Dwolla.request(:post, url, params, {}, token)
19
+ end
20
+
21
+ private
22
+
23
+ def self.accounts_url
24
+ return '/accounts/'
25
+ end
26
+ end
27
+ end
@@ -1,15 +1,15 @@
1
- module Dwolla
2
- class Balance
3
- def self.get(token=nil)
4
- url = balance_url
5
-
6
- Dwolla.request(:get, url, {}, {}, token)
7
- end
8
-
9
- private
10
-
11
- def self.balance_url
12
- return '/balance/'
13
- end
14
- end
15
- end
1
+ module Dwolla
2
+ class Balance
3
+ def self.get(token=nil)
4
+ url = balance_url
5
+
6
+ Dwolla.request(:get, url, {}, {}, token)
7
+ end
8
+
9
+ private
10
+
11
+ def self.balance_url
12
+ return '/balance/'
13
+ end
14
+ end
15
+ end
@@ -1,30 +1,30 @@
1
- module Dwolla
2
- class Contacts
3
- def self.get(filters={}, token=nil)
4
- url = contacts_url
5
-
6
- Dwolla.request(:get, url, filters, {}, token)
7
- end
8
-
9
-
10
- def self.nearby(lat=nil, lon=nil, filters={})
11
- raise MissingParameterError.new('No Latitude Provided') unless lat
12
- raise MissingParameterError.new('No Longitude Provided.') unless lon
13
-
14
- url = contacts_url + 'nearby'
15
-
16
- params = {
17
- :latitude => lat,
18
- :longitude => lon
19
- }.merge(filters)
20
-
21
- Dwolla.request(:get, url, params, {}, false)
22
- end
23
-
24
- private
25
-
26
- def self.contacts_url
27
- return '/contacts/'
28
- end
29
- end
30
- end
1
+ module Dwolla
2
+ class Contacts
3
+ def self.get(filters={}, token=nil)
4
+ url = contacts_url
5
+
6
+ Dwolla.request(:get, url, filters, {}, token)
7
+ end
8
+
9
+
10
+ def self.nearby(lat=nil, lon=nil, filters={})
11
+ raise MissingParameterError.new('No Latitude Provided') unless lat
12
+ raise MissingParameterError.new('No Longitude Provided.') unless lon
13
+
14
+ url = contacts_url + 'nearby'
15
+
16
+ params = {
17
+ :latitude => lat,
18
+ :longitude => lon
19
+ }.merge(filters)
20
+
21
+ Dwolla.request(:get, url, params, {}, false)
22
+ end
23
+
24
+ private
25
+
26
+ def self.contacts_url
27
+ return '/contacts/'
28
+ end
29
+ end
30
+ end
@@ -1,4 +1,4 @@
1
- module Dwolla
2
- class APIConnectionError < DwollaError
3
- end
1
+ module Dwolla
2
+ class APIConnectionError < DwollaError
3
+ end
4
4
  end
@@ -1,4 +1,4 @@
1
- module Dwolla
2
- class APIError < DwollaError
3
- end
1
+ module Dwolla
2
+ class APIError < DwollaError
3
+ end
4
4
  end
@@ -1,4 +1,4 @@
1
- module Dwolla
2
- class AuthenticationError < DwollaError
3
- end
1
+ module Dwolla
2
+ class AuthenticationError < DwollaError
3
+ end
4
4
  end
@@ -1,20 +1,20 @@
1
- module Dwolla
2
- class DwollaError < StandardError
3
- attr_reader :message
4
- attr_reader :http_status
5
- attr_reader :http_body
6
- attr_reader :json_body
7
-
8
- def initialize(message=nil, http_status=nil, http_body=nil, json_body=nil)
9
- @message = message
10
- @http_status = http_status
11
- @http_body = http_body
12
- @json_body = json_body
13
- end
14
-
15
- def to_s
16
- status_string = @http_status.nil? ? "" : "(Status #{@http_status}) "
17
- "#{status_string}#{@message}"
18
- end
19
- end
1
+ module Dwolla
2
+ class DwollaError < StandardError
3
+ attr_reader :message
4
+ attr_reader :http_status
5
+ attr_reader :http_body
6
+ attr_reader :json_body
7
+
8
+ def initialize(message=nil, http_status=nil, http_body=nil, json_body=nil)
9
+ @message = message
10
+ @http_status = http_status
11
+ @http_body = http_body
12
+ @json_body = json_body
13
+ end
14
+
15
+ def to_s
16
+ status_string = @http_status.nil? ? "" : "(Status #{@http_status}) "
17
+ "#{status_string}#{@message}"
18
+ end
19
+ end
20
20
  end
@@ -1,10 +1,10 @@
1
- module Dwolla
2
- class InvalidRequestError < DwollaError
3
- attr_accessor :param
4
-
5
- def initialize(message, param, http_status=nil, http_body=nil, json_body=nil)
6
- super(message, http_status, http_body, json_body)
7
- @param = param
8
- end
9
- end
10
- end
1
+ module Dwolla
2
+ class InvalidRequestError < DwollaError
3
+ attr_accessor :param
4
+
5
+ def initialize(message, param, http_status=nil, http_body=nil, json_body=nil)
6
+ super(message, http_status, http_body, json_body)
7
+ @param = param
8
+ end
9
+ end
10
+ end
@@ -1,4 +1,4 @@
1
- module Dwolla
2
- class MissingParameterError < DwollaError
3
- end
1
+ module Dwolla
2
+ class MissingParameterError < DwollaError
3
+ end
4
4
  end
@@ -1,4 +1,4 @@
1
- module Dwolla
2
- class RequestException < Exception
3
- end
4
- end
1
+ module Dwolla
2
+ class RequestException < Exception
3
+ end
4
+ end
@@ -1,65 +1,65 @@
1
- module Dwolla
2
- class FundingSources
3
- def self.get(id=nil, token=nil)
4
- url = funding_sources_url
5
-
6
- url += id.to_s unless id.nil?
7
-
8
- Dwolla.request(:get, url, {}, {}, token)
9
- end
10
-
11
- def self.withdraw(id=nil, params={}, token=nil)
12
- raise MissingParameterError.new('No Funding Source ID Provided.') if id.nil?
13
- raise MissingParameterError.new('No PIN Provided.') unless params[:pin]
14
- raise MissingParameterError.new('No Amount Provided.') unless params[:amount]
15
-
16
- url = funding_sources_url
17
- url += id.to_s + '/withdraw'
18
-
19
- Dwolla.request(:post, url, params, {}, token)
20
- end
21
-
22
- def self.deposit(id=nil, params={}, token=nil)
23
- raise MissingParameterError.new('No Funding Source ID Provided.') if id.nil?
24
- raise MissingParameterError.new('No PIN Provided.') unless params[:pin]
25
- raise MissingParameterError.new('No Amount Provided.') unless params[:amount]
26
-
27
- url = funding_sources_url
28
- url += id.to_s + '/deposit'
29
-
30
- Dwolla.request(:post, url, params, {}, token)
31
- end
32
-
33
- def self.add(params={}, token=nil)
34
- raise MissingParameterError.new('No Account Number Provided.') unless params[:account_number]
35
- raise MissingParameterError.new('No Routing Number (ABA) Provided.') unless params[:routing_number]
36
- raise MissingParameterError.new('No Account Type Provided.') unless params[:account_type]
37
- raise MissingParameterError.new('No Account Name Provided.') unless params[:name]
38
-
39
- url = funding_sources_url
40
-
41
- Dwolla.request(:post, url, params, {}, token)
42
- end
43
-
44
- def self.verify(id=nil, params={}, token=nil)
45
- raise MissingParameterError.new('No Funding Source ID Provided.') if id.nil?
46
- raise MissingParameterError.new('No Deposit 1 Amount Provided.') unless params[:deposit1]
47
- raise MissingParameterError.new('No Deposit 2 Amount Provided.') unless params[:deposit2]
48
-
49
- url = funding_sources_url
50
- url += id.to_s + '/verify'
51
-
52
- Dwolla.request(:post, url, params, {}, token)
53
- end
54
-
55
- class << self
56
- alias_method :listing, :get
57
- end
58
-
59
- private
60
-
61
- def self.funding_sources_url
62
- return '/fundingsources/'
63
- end
64
- end
65
- end
1
+ module Dwolla
2
+ class FundingSources
3
+ def self.get(id=nil, token=nil)
4
+ url = funding_sources_url
5
+
6
+ url += id.to_s unless id.nil?
7
+
8
+ Dwolla.request(:get, url, {}, {}, token)
9
+ end
10
+
11
+ def self.withdraw(id=nil, params={}, token=nil)
12
+ raise MissingParameterError.new('No Funding Source ID Provided.') if id.nil?
13
+ raise MissingParameterError.new('No PIN Provided.') unless params[:pin]
14
+ raise MissingParameterError.new('No Amount Provided.') unless params[:amount]
15
+
16
+ url = funding_sources_url
17
+ url += id.to_s + '/withdraw'
18
+
19
+ Dwolla.request(:post, url, params, {}, token)
20
+ end
21
+
22
+ def self.deposit(id=nil, params={}, token=nil)
23
+ raise MissingParameterError.new('No Funding Source ID Provided.') if id.nil?
24
+ raise MissingParameterError.new('No PIN Provided.') unless params[:pin]
25
+ raise MissingParameterError.new('No Amount Provided.') unless params[:amount]
26
+
27
+ url = funding_sources_url
28
+ url += id.to_s + '/deposit'
29
+
30
+ Dwolla.request(:post, url, params, {}, token)
31
+ end
32
+
33
+ def self.add(params={}, token=nil)
34
+ raise MissingParameterError.new('No Account Number Provided.') unless params[:account_number]
35
+ raise MissingParameterError.new('No Routing Number (ABA) Provided.') unless params[:routing_number]
36
+ raise MissingParameterError.new('No Account Type Provided.') unless params[:account_type]
37
+ raise MissingParameterError.new('No Account Name Provided.') unless params[:name]
38
+
39
+ url = funding_sources_url
40
+
41
+ Dwolla.request(:post, url, params, {}, token)
42
+ end
43
+
44
+ def self.verify(id=nil, params={}, token=nil)
45
+ raise MissingParameterError.new('No Funding Source ID Provided.') if id.nil?
46
+ raise MissingParameterError.new('No Deposit 1 Amount Provided.') unless params[:deposit1]
47
+ raise MissingParameterError.new('No Deposit 2 Amount Provided.') unless params[:deposit2]
48
+
49
+ url = funding_sources_url
50
+ url += id.to_s + '/verify'
51
+
52
+ Dwolla.request(:post, url, params, {}, token)
53
+ end
54
+
55
+ class << self
56
+ alias_method :listing, :get
57
+ end
58
+
59
+ private
60
+
61
+ def self.funding_sources_url
62
+ return '/fundingsources/'
63
+ end
64
+ end
65
+ end
data/lib/dwolla/json.rb CHANGED
@@ -1,21 +1,21 @@
1
- module Dwolla
2
- module JSON
3
- if MultiJson.respond_to?(:dump)
4
- def self.dump(*args)
5
- MultiJson.dump(*args)
6
- end
7
-
8
- def self.load(*args)
9
- MultiJson.load(*args)
10
- end
11
- else
12
- def self.dump(*args)
13
- MultiJson.encode(*args)
14
- end
15
-
16
- def self.load(*args)
17
- MultiJson.decode(*args)
18
- end
19
- end
20
- end
1
+ module Dwolla
2
+ module JSON
3
+ if MultiJson.respond_to?(:dump)
4
+ def self.dump(*args)
5
+ MultiJson.dump(*args)
6
+ end
7
+
8
+ def self.load(*args)
9
+ MultiJson.load(*args)
10
+ end
11
+ else
12
+ def self.dump(*args)
13
+ MultiJson.encode(*args)
14
+ end
15
+
16
+ def self.load(*args)
17
+ MultiJson.decode(*args)
18
+ end
19
+ end
20
+ end
21
21
  end
@@ -1,53 +1,53 @@
1
- module Dwolla
2
- class MassPay
3
-
4
- def self.get(token=nil)
5
- Dwolla.request(:get, masspay_url, {}, {}, token);
6
- end
7
-
8
- def self.create(params={}, token=nil)
9
- raise MissingParameterError.new('No fundsSource ID Provided.') unless params[:fundsSource]
10
- raise MissingParameterError.new('No PIN Provided.') unless params[:pin]
11
- raise MissingParameterError.new('No Items Provided.') unless params[:items]
12
-
13
- Dwolla.request(:post, masspay_url, params, {}, token)
14
- end
15
-
16
- def self.getItems(id=nil, params={}, token=nil)
17
- raise MissingParameterError.new('No MassPay Job ID Provided.') if id.nil?
18
- url = masspay_url
19
- url += id.to_s unless id.nil?
20
- url += '/items'
21
-
22
- Dwolla.request(:get, url, params, {}, token)
23
- end
24
-
25
- def self.getItem(jobId=nil, itemId=nil, token=nil)
26
- raise MissingParameterError.new('No MassPay Job ID Provided.') if jobId.nil?
27
- raise MissingParameterError.new('No Item ID Provided.') if itemId.nil?
28
-
29
- url = masspay_url
30
- url += jobId.to_s unless jobId.nil?
31
- url += '/items/'
32
- url += itemId.to_s unless itemId.nil?
33
-
34
- Dwolla.request(:get, url, {}, {}, token)
35
- end
36
-
37
- def self.getJob(id=nil, token=nil)
38
- raise MissingParameterError.new('No MassPay Job ID Provided.') if id.nil?
39
-
40
- url = masspay_url
41
- url += id.to_s unless id.nil?
42
-
43
- Dwolla.request(:get, url, {}, {}, token)
44
- end
45
-
46
- private
47
-
48
- def self.masspay_url
49
- return '/masspay/'
50
- end
51
-
52
- end
1
+ module Dwolla
2
+ class MassPay
3
+
4
+ def self.get(token=nil)
5
+ Dwolla.request(:get, masspay_url, {}, {}, token);
6
+ end
7
+
8
+ def self.create(params={}, token=nil)
9
+ raise MissingParameterError.new('No fundsSource ID Provided.') unless params[:fundsSource]
10
+ raise MissingParameterError.new('No PIN Provided.') unless params[:pin]
11
+ raise MissingParameterError.new('No Items Provided.') unless params[:items]
12
+
13
+ Dwolla.request(:post, masspay_url, params, {}, token)
14
+ end
15
+
16
+ def self.getItems(id=nil, params={}, token=nil)
17
+ raise MissingParameterError.new('No MassPay Job ID Provided.') if id.nil?
18
+ url = masspay_url
19
+ url += id.to_s unless id.nil?
20
+ url += '/items'
21
+
22
+ Dwolla.request(:get, url, params, {}, token)
23
+ end
24
+
25
+ def self.getItem(jobId=nil, itemId=nil, token=nil)
26
+ raise MissingParameterError.new('No MassPay Job ID Provided.') if jobId.nil?
27
+ raise MissingParameterError.new('No Item ID Provided.') if itemId.nil?
28
+
29
+ url = masspay_url
30
+ url += jobId.to_s unless jobId.nil?
31
+ url += '/items/'
32
+ url += itemId.to_s unless itemId.nil?
33
+
34
+ Dwolla.request(:get, url, {}, {}, token)
35
+ end
36
+
37
+ def self.getJob(id=nil, token=nil)
38
+ raise MissingParameterError.new('No MassPay Job ID Provided.') if id.nil?
39
+
40
+ url = masspay_url
41
+ url += id.to_s unless id.nil?
42
+
43
+ Dwolla.request(:get, url, {}, {}, token)
44
+ end
45
+
46
+ private
47
+
48
+ def self.masspay_url
49
+ return '/masspay/'
50
+ end
51
+
52
+ end
53
53
  end