dwolla-ruby 2.5.5 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,55 +0,0 @@
1
- module Dwolla
2
- class Register
3
- def self.step(token=nil)
4
- url = register_url + 'step'
5
-
6
- Dwolla.request(:get, url, {}, {}, token)
7
- end
8
-
9
- def self.create(token=nil)
10
-
11
- end
12
-
13
- def self.resend_email(token=nil)
14
-
15
- end
16
-
17
- def self.verify_email(token=nil)
18
-
19
- end
20
-
21
- def self.add_phone(token=nil)
22
-
23
- end
24
-
25
- def self.resend_phone(token=nil)
26
-
27
- end
28
-
29
- def self.verify_phone(token=nil)
30
-
31
- end
32
-
33
- def self.set_address(token=nil)
34
-
35
- end
36
-
37
- def self.get_kba(token=nil)
38
-
39
- end
40
-
41
- def self.answer_kba(token=nil)
42
-
43
- end
44
-
45
- def self.set_general_info(token=nil)
46
-
47
- end
48
-
49
- private
50
-
51
- def self.register_url
52
- return '/register/'
53
- end
54
- end
55
- end
@@ -1,198 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- require File.expand_path('../test_helper', __FILE__)
3
- require 'test/unit'
4
- require 'shoulda'
5
- require 'mocha/setup'
6
- require 'pp'
7
- require 'rest-client'
8
- require 'cgi'
9
- require 'uri'
10
-
11
- class TestDwollaRuby < Test::Unit::TestCase
12
- include Mocha
13
-
14
- context "API Wrapper" do
15
- setup do
16
- @mock = mock
17
- Dwolla.mock_rest_client = @mock
18
- end
19
-
20
- teardown do
21
- Dwolla.mock_rest_client = nil
22
- end
23
-
24
- should "not specifying a token should raise an exception on user-centric calls" do
25
- Dwolla.token = nil
26
- assert_raises Dwolla::AuthenticationError do
27
- Dwolla::Balance.get
28
- end
29
- end
30
-
31
- should "not specifying api credentials should raise an exception on app-centric calls" do
32
- Dwolla.api_key = nil
33
- assert_raises Dwolla::AuthenticationError do
34
- Dwolla::Contacts.nearby
35
- end
36
- end
37
-
38
- context "with valid token" do
39
- setup do
40
- Dwolla.token="foo"
41
- end
42
-
43
- teardown do
44
- Dwolla.token=nil
45
- end
46
-
47
- context "balance tests" do
48
- should "balance should be retrievable" do
49
- @mock.expects(:get).once.returns(test_response(test_balance))
50
- balance = Dwolla::Balance.get
51
- assert balance.kind_of? Float
52
- end
53
- end
54
-
55
- context "contacts tests" do
56
- should "be able to get a user's contacts" do
57
- @mock.expects(:get).once.returns(test_response(test_contacts_array))
58
- contacts = Dwolla::Contacts.get
59
- assert contacts.kind_of? Array
60
- end
61
- end
62
-
63
- context "funding sources tests" do
64
- should "should be able to get a user's funding source by its id" do
65
- @mock.expects(:get).once.returns(test_response(test_fundingsource_byid))
66
- fundingsource = Dwolla::FundingSources.get('funding_source_id')
67
- assert fundingsource.kind_of? Object
68
- end
69
-
70
- should "should be able to get a user's funding sources" do
71
- @mock.expects(:get).once.returns(test_response(test_fundingsources_array))
72
- fundingsources = Dwolla::FundingSources.get
73
- assert fundingsources.kind_of? Array
74
- end
75
-
76
- should "should be able to withdraw to a user's funding source" do
77
- @mock.expects(:post).once.returns(test_response(test_fundingsource_withdraw))
78
- withdraw = Dwolla::FundingSources.withdraw('funding_source_id', {:pin => '0000', :amount => '1.00'})
79
- assert withdraw.kind_of? Object
80
- end
81
-
82
- should "should be able to deposit from a user's funding source" do
83
- @mock.expects(:post).once.returns(test_response(test_fundingsource_deposit))
84
- withdraw = Dwolla::FundingSources.withdraw('funding_source_id', {:pin => '0000', :amount => '1.00'})
85
- assert withdraw.kind_of? Object
86
- end
87
-
88
- should "should be able to add a funding source for a user" do
89
-
90
- end
91
-
92
- should "should be able to verify a user's funding source" do
93
-
94
- end
95
- end
96
-
97
- context "requests tests" do
98
- should "should be able to get a user's pending money requests" do
99
- @mock.expects(:get).once.returns(test_response(test_requests_array))
100
- requests = Dwolla::Requests.get
101
- assert requests.kind_of? Array
102
- end
103
-
104
- should "should be able to get a user's pending money request by its id" do
105
- @mock.expects(:get).once.returns(test_response(test_request_byid))
106
- request = Dwolla::Requests.get('request_id')
107
- assert request.kind_of? Object
108
- end
109
-
110
- should "should be able to cancel a user's pending money request" do
111
- @mock.expects(:post).once.returns(test_response(test_request_cancel))
112
- request = Dwolla::Requests.cancel('request_id')
113
- assert request.kind_of? String
114
- end
115
-
116
- should "should be able to create a new money request for a user" do
117
- @mock.expects(:post).once.returns(test_response(test_request))
118
- request = Dwolla::Requests.request({:pin => 1111, :amount => 0.01, :sourceId => 'alex@dwolla.com'})
119
- assert request.kind_of? Integer
120
- end
121
-
122
- should "should be a able to fulfill a user's pending money request" do
123
- @mock.expects(:post).once.returns(test_response(test_request_fulfill))
124
- request = Dwolla::Requests.fulfill('2219682', {:pin => 1111})
125
- assert request.kind_of? Object
126
- end
127
- end
128
-
129
- context "transactions tests" do
130
- should "should be able to get a user's transaction information by its id" do
131
- @mock.expects(:get).once.returns(test_response(test_transaction_byid))
132
- transactions = Dwolla::Transactions.get('transaction_id')
133
- assert transactions.kind_of? Object
134
- end
135
-
136
- should "should be able to get a user's transaction history" do
137
- @mock.expects(:get).once.returns(test_response(test_transactions_array))
138
- transactions = Dwolla::Transactions.get
139
- assert transactions.kind_of? Array
140
- end
141
-
142
- should "should be able to get a user's transaction statistics" do
143
- @mock.expects(:get).once.returns(test_response(test_transactions_stats))
144
- stats = Dwolla::Transactions.stats
145
- assert stats.kind_of? Object
146
- end
147
-
148
- should "should be able to send money from a user's account" do
149
- @mock.expects(:post).once.returns(test_response(test_send))
150
- send = Dwolla::Transactions.send({:pin => 1111, :destinationId => '812-734-7288', :amount => 0.01})
151
- assert send.kind_of? Integer
152
- end
153
- end
154
-
155
- context "users tests" do
156
- should "should be able to get a user's information" do
157
- @mock.expects(:get).once.returns(test_response(test_user_self))
158
- user = Dwolla::Users.me
159
- assert user.kind_of? Object
160
- end
161
- end
162
- end
163
-
164
- context "with valid app credentials" do
165
- setup do
166
- Dwolla.api_key="foo"
167
- Dwolla.api_secret="bar"
168
- end
169
-
170
- teardown do
171
- Dwolla.api_key=nil
172
- Dwolla.api_secret=nil
173
- end
174
-
175
- context "contacts tests" do
176
- should "be able to get a list of nearby spots" do
177
- @mock.expects(:get).once.returns(test_response(test_contacts_array))
178
- spots = Dwolla::Contacts.nearby
179
- assert spots.kind_of? Array
180
- end
181
- end
182
-
183
- context "users tests" do
184
- should "should be able to get any user's information" do
185
- @mock.expects(:get).once.returns(test_response(test_user_byid))
186
- user = Dwolla::Users.get('alex@dwolla.com')
187
- assert user.kind_of? Object
188
- end
189
-
190
- should "should be able to get a list of nearby users" do
191
- @mock.expects(:get).once.returns(test_response(test_users_array))
192
- users = Dwolla::Users.nearby
193
- assert users.kind_of? Array
194
- end
195
- end
196
- end
197
- end
198
- end
@@ -1,424 +0,0 @@
1
- require 'stringio'
2
- require 'test/unit'
3
- require 'dwolla'
4
- require 'mocha/setup'
5
- include Mocha
6
-
7
- #monkeypatch request methods
8
- module Dwolla
9
- @mock_rest_client = nil
10
-
11
- def self.mock_rest_client=(mock_client)
12
- @mock_rest_client = mock_client
13
- end
14
-
15
- def self.execute_request(opts)
16
- get_params = (opts[:headers] || {})[:params]
17
- post_params = opts[:payload]
18
-
19
- case opts[:method]
20
- when :get then @mock_rest_client.get opts[:url], get_params, post_params
21
- when :post then @mock_rest_client.post opts[:url], get_params, post_params
22
- end
23
- end
24
- end
25
-
26
- def test_response(body, code=200)
27
- # When an exception is raised, restclient clobbers method_missing. Hence we
28
- # can't just use the stubs interface.
29
- body = MultiJson.dump(body) if !(body.kind_of? String)
30
- m = mock
31
- m.instance_variable_set('@dwolla_values', { :body => body, :code => code })
32
- def m.body; @dwolla_values[:body]; end
33
- def m.code; @dwolla_values[:code]; end
34
- m
35
- end
36
-
37
- def test_transaction_byid(params={})
38
- {
39
- :Success => true,
40
- :Message => 'Success',
41
- :Response => {
42
- :Id => 2834469,
43
- :Amount => 1,
44
- :Date => "05/02/2013 17:18:09",
45
- :Type => "withdrawal",
46
- :UserType => "Dwolla",
47
- :DestinationId => "XXX80-1",
48
- :DestinationName => "Veridian Credit Union",
49
- :SourceId => "812-734-7288",
50
- :SourceName => "Michael Schonfeld",
51
- :ClearingDate => "5/2/2013",
52
- :Status => "processed",
53
- :Notes => nil,
54
- :Fees => nil
55
- }
56
- }.merge(params)
57
- end
58
-
59
- def test_transactions_array(params={})
60
- {
61
- :Success => true,
62
- :Message => 'Success',
63
- :Response => [
64
- {
65
- :Id => 2834469,
66
- :Amount => 1,
67
- :Date => "05/02/2013 17:18:09",
68
- :Type => "withdrawal",
69
- :UserType => "Dwolla",
70
- :DestinationId => "XXX80-1",
71
- :DestinationName => "Veridian Credit Union",
72
- :SourceId => "812-734-7288",
73
- :SourceName => "Michael Schonfeld",
74
- :ClearingDate => "5/2/2013",
75
- :Status => "processed",
76
- :Notes => nil,
77
- :Fees => nil
78
- },
79
- {
80
- :Id => 2834457,
81
- :Amount => 1,
82
- :Date => "05/02/2013 17:17:02",
83
- :Type => "deposit",
84
- :UserType => "Dwolla",
85
- :DestinationId => "812-734-7288",
86
- :DestinationName => "Michael Schonfeld",
87
- :SourceId => "XXX80-1",
88
- :SourceName => "Veridian Credit Union",
89
- :ClearingDate => "5/2/2013",
90
- :Status => "processed",
91
- :Notes => nil,
92
- :Fees => nil
93
- }
94
- ]
95
- }.merge(params)
96
- end
97
-
98
- def test_transactions_stats(params={})
99
- {
100
- :Success => true,
101
- :Message => 'Success',
102
- :Response => [
103
- {
104
- :TransactionsCount => 3,
105
- :TransactionsTotal => 0.03
106
- }
107
- ]
108
- }.merge(params)
109
- end
110
-
111
- def test_balance(params={})
112
- {
113
- :Success => true,
114
- :Message => 'Success',
115
- :Response => 10.00
116
- }.merge(params)
117
- end
118
-
119
- def test_send(params={})
120
- {
121
- :Success => true,
122
- :Message => 'Success',
123
- :Response => 2834853
124
- }.merge(params)
125
- end
126
-
127
- def test_request(params={})
128
- {
129
- :Success => true,
130
- :Message => 'Success',
131
- :Response => 2221134
132
- }.merge(params)
133
- end
134
-
135
- def test_request_byid(params={})
136
- {
137
- :Success => true,
138
- :Message => 'Success',
139
- :Response => {
140
- :Id => 2209516,
141
- :Source => {
142
- :Id => "812-734-7288",
143
- :Name => "Michael Schonfeld",
144
- :Type => "Dwolla",
145
- :Image => nil
146
- },
147
- :Destination => {
148
- :Id => "812-552-5325",
149
- :Name => "Mark Littlewood",
150
- :Type => "Dwolla",
151
- :Image => nil
152
- },
153
- :Amount => 8,
154
- :DateRequested => "8/15/2012 10:18:46 PM",
155
- :Status => "Pending",
156
- :Transaction => nil
157
- }
158
- }.merge(params)
159
- end
160
-
161
- def test_requests_array(params={})
162
- {
163
- :Success => true,
164
- :Message => 'Success',
165
- :Response => [
166
- {
167
- :Id => 2209516,
168
- :Source => {
169
- :Id => "812-734-7288",
170
- :Name => "Michael Schonfeld",
171
- :Type => "Dwolla",
172
- :Image => nil
173
- },
174
- :Destination => {
175
- :Id => "812-552-5325",
176
- :Name => "Mark Littlewood",
177
- :Type => "Dwolla",
178
- :Image => nil
179
- },
180
- :Amount => 8,
181
- :DateRequested => "8/15/2012 10:18:46 PM",
182
- :Status => "Pending",
183
- :Transaction => nil
184
- },
185
- {
186
- :Id => 2213417,
187
- :Source => {
188
- :Id => "812-713-9234",
189
- :Name => "Dwolla",
190
- :Type => "Dwolla",
191
- :Image => nil
192
- },
193
- :Destination => {
194
- :Id => "812-734-7288",
195
- :Name => "Michael Schonfeld",
196
- :Type => "Dwolla",
197
- :Image => nil
198
- },
199
- :Amount => 0.1,
200
- :DateRequested => "12/4/2012 5:20:38 PM",
201
- :Status => "Pending",
202
- :Transaction => nil
203
- }
204
- ]
205
- }.merge(params)
206
- end
207
-
208
- def test_request_cancel(params={})
209
- {
210
- :Success => true,
211
- :Message => 'Success',
212
- :Response => ''
213
- }.merge(params)
214
- end
215
-
216
- def test_request_fulfill(params={})
217
- {
218
- :Success => true,
219
- :Message => 'Success',
220
- :Response => {
221
- :Id => 2844131,
222
- :RequestId => 2219682,
223
- :Source => {
224
- :Id => "812-734-7288",
225
- :Name => "Michael Schonfeld",
226
- :Type => "Dwolla",
227
- :Image => nil
228
- },
229
- :Destination => {
230
- :Id => "812-726-8148",
231
- :Name => "Paul Liberman",
232
- :Type => "Dwolla",
233
- :Image => nil
234
- },
235
- :Amount => 1,
236
- :SentDate => "5/3/2013 10:55:56 AM",
237
- :ClearingDate => "5/3/2013 10:55:56 AM",
238
- :Status => "processed"
239
- }
240
- }.merge(params)
241
- end
242
-
243
- def test_fundingsource_byid(params={})
244
- {
245
- :Success => true,
246
- :Message => 'Success',
247
- :Response => {
248
- :Balance => 7.74,
249
- :Id => "a4946ae2d2b7f1f880790f31a36887f5",
250
- :Name => "Veridian Credit Union - Savings",
251
- :Type => "Savings",
252
- :Verified => true,
253
- :ProcessingType => "FiSync"
254
- }
255
- }.merge(params)
256
- end
257
-
258
- def test_fundingsources_array(params={})
259
- {
260
- :Success => true,
261
- :Message => 'Success',
262
- :Response => [
263
- {
264
- :Id => "a4946ae2d2b7f1f880790f31a36887f5",
265
- :Name => "Veridian Credit Union - Savings",
266
- :Type => "Savings",
267
- :Verified => true,
268
- :ProcessingType => "FiSync"
269
- },
270
- {
271
- :Id => "c21012f98742d4b0affcd8aeabefb369",
272
- :Name => "My Checking Account - Checking",
273
- :Type => "Checking",
274
- :Verified => true,
275
- :ProcessingType => "ACH"
276
- }
277
- ]
278
- }.merge(params)
279
- end
280
-
281
- def test_fundingsource_withdraw(params={})
282
- {
283
- :Success => true,
284
- :Message => 'Success',
285
- :Response => {
286
- :Id => 2834469,
287
- :Amount => 1,
288
- :Date => "5/2/2013 9:18:09 PM",
289
- :Type => "withdrawal",
290
- :UserType => "Dwolla",
291
- :DestinationId => "XXX80-1",
292
- :DestinationName => "Veridian Credit Union",
293
- :SourceId => "812-734-7288",
294
- :SourceName => "Michael Schonfeld",
295
- :ClearingDate => "5/2/2013",
296
- :Status => "pending",
297
- :Notes => nil,
298
- :Fees => nil
299
- }
300
- }.merge(params)
301
- end
302
-
303
- def test_fundingsource_deposit(params={})
304
- {
305
- :Success => true,
306
- :Message => 'Success',
307
- :Response => {
308
- :Id => 2834457,
309
- :Amount => 1,
310
- :Date => "5/2/2013 9:17:02 PM",
311
- :Type => "deposit",
312
- :UserType => "Dwolla",
313
- :DestinationId => "812-734-7288",
314
- :DestinationName => "Michael Schonfeld",
315
- :SourceId => "XXX80-1",
316
- :SourceName => "Veridian Credit Union",
317
- :ClearingDate => "5/2/2013",
318
- :Status => "pending",
319
- :Notes => nil,
320
- :Fees => nil
321
- }
322
- }.merge(params)
323
- end
324
-
325
- def test_user_self(params={})
326
- {
327
- :Success => true,
328
- :Message => 'Success',
329
- :Response => {
330
- :City => "Paris",
331
- :State => "TN",
332
- :Type => "Personal",
333
- :Id => "812-629-2658",
334
- :Name => "Codeacademy Course",
335
- :Latitude => 0,
336
- :Longitude => 0
337
- }
338
- }.merge(params)
339
- end
340
-
341
- def test_user_byid(params={})
342
- {
343
- :Success => true,
344
- :Message => 'Success',
345
- :Response => {
346
- :Name => "Alex Hart",
347
- :Id => "812-499-5823",
348
- :Type => "Dwolla",
349
- :Image => "https://www.dwolla.com/avatars/812-499-5823",
350
- :City => nil,
351
- :State => nil
352
- }
353
- }.merge(params)
354
- end
355
-
356
- def test_users_array(params={})
357
- {
358
- :Success => true,
359
- :Message => 'Success',
360
- :Response => [
361
- {
362
- :Name => "Alex Hart",
363
- :Id => "812-499-5823",
364
- :Type => "Dwolla",
365
- :Image => "https://www.dwolla.com/avatars/812-499-5823",
366
- :City => nil,
367
- :State => nil
368
- },
369
- {
370
- :Name => "Alexander Taub",
371
- :Id => "812-626-8794",
372
- :Type => "Dwolla",
373
- :Image => "https://www.dwolla.com/avatars/812-626-8794",
374
- :City => nil,
375
- :State => nil
376
- }
377
- ]
378
- }.merge(params)
379
- end
380
-
381
- def test_contacts_array(params={})
382
- {
383
- :Success => true,
384
- :Message => 'Success',
385
- :Response => [
386
- {
387
- :Name => "Pinnacle Marketing",
388
- :Id => "812-464-9495",
389
- :Type => "Dwolla",
390
- :Image => "https://www.dwolla.com/avatars/812-464-9495",
391
- :Latitude => 0,
392
- :Longitude => 0,
393
- :Address => "Box 311\n134 Moore Hill Road",
394
- :City => "Newbury",
395
- :State => "VT",
396
- :PostalCode => "05051",
397
- :Group => "812-534-7970,812-530-2592,812-451-7983,812-554-6122,812-499-3232,812-475-9151,812-568-7828,812-518-8055,812-514-9530",
398
- :Delta => 0
399
- },
400
- {
401
- :Name => "CMS Plus Hosting LLC",
402
- :Id => "812-534-7970",
403
- :Type => "Dwolla",
404
- :Image => "https://www.dwolla.com/avatars/812-534-7970",
405
- :Latitude => 0,
406
- :Longitude => 0,
407
- :Address => "20 E BEECH\nPO BOX 47",
408
- :City => "Cedar Springs",
409
- :State => "MI",
410
- :PostalCode => "49319",
411
- :Group => "812-464-9495,812-530-2592,812-451-7983,812-554-6122,812-499-3232,812-475-9151,812-568-7828,812-518-8055,812-514-9530",
412
- :Delta => 0
413
- }
414
- ]
415
- }.merge(params)
416
- end
417
-
418
- def test_api_error
419
- {
420
- :Success => false,
421
- :Message => 'Success',
422
- :Response => ''
423
- }
424
- end