money_mover 0.0.9 → 0.0.10
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 010437904cafb2ca6c8793b9cf1a6f6f4544e785
|
4
|
+
data.tar.gz: 8a82210f6a88a6753fcd907e6c2e453a08bac09c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e294712b6bb300f17c4fcdf83c1bba845ca0502269b25ed8e035cd73b12222105eddfe3b905606316fbc0cf3265af55f1acf7d679f82a611c5e409398a9128cb
|
7
|
+
data.tar.gz: 57c09bfbb5845d1eaa039edc0bbffec11d108ecdb6ba94f4d1bc2ff9d16e4a07cc81b67e2cd54325c44ed5b80cccdb7291f5964d21de06c3a57d351d834c740d
|
data/Gemfile.lock
CHANGED
@@ -38,6 +38,26 @@ module MoneyMover
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
+
def save
|
42
|
+
return false unless valid?
|
43
|
+
|
44
|
+
if @id
|
45
|
+
response = @client.post self.class.fetch_endpoint(@id), create_params
|
46
|
+
add_errors_from response unless response.success?
|
47
|
+
else
|
48
|
+
response = @client.post create_endpoint, create_params
|
49
|
+
|
50
|
+
if response.success?
|
51
|
+
@resource_location = response.resource_location
|
52
|
+
@id = response.resource_id
|
53
|
+
else
|
54
|
+
add_errors_from response
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
errors.empty?
|
59
|
+
end
|
60
|
+
|
41
61
|
private
|
42
62
|
|
43
63
|
# dwolla doesnt accept urls without a scheme
|
data/lib/money_mover/version.rb
CHANGED
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe MoneyMover::Dwolla::UnverifiedCustomer do
|
4
|
+
let(:customer_token) { '9481924a-6795-4e7a-b436-a7a48a4141ca' }
|
5
|
+
let(:firstName) { 'first name' }
|
6
|
+
let(:lastName) { 'last name' }
|
7
|
+
let(:email) { 'some@example.com' }
|
8
|
+
let(:ipAddress) { '127.0.0.1' }
|
9
|
+
|
10
|
+
let(:attrs) {{
|
11
|
+
id: customer_token,
|
12
|
+
firstName: firstName,
|
13
|
+
lastName: lastName,
|
14
|
+
email: email,
|
15
|
+
ipAddress: ipAddress
|
16
|
+
}}
|
17
|
+
|
18
|
+
subject { described_class.new attrs }
|
19
|
+
|
20
|
+
let(:update_customer_params) {{
|
21
|
+
firstName: firstName,
|
22
|
+
lastName: lastName,
|
23
|
+
email: email,
|
24
|
+
ipAddress: ipAddress,
|
25
|
+
type: 'unverified'
|
26
|
+
}}
|
27
|
+
|
28
|
+
before do
|
29
|
+
dwolla_helper.stub_update_customer_request customer_token, update_customer_params, update_response
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#save' do
|
33
|
+
context 'success' do
|
34
|
+
let(:update_response) do
|
35
|
+
{
|
36
|
+
status: 200,
|
37
|
+
body: ""
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'creates new customer in dwolla' do
|
42
|
+
expect(subject.save).to eq(true)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'fail' do
|
47
|
+
let(:update_response) { dwolla_helper.resource_create_error_response error_response }
|
48
|
+
|
49
|
+
let(:error_response) {{
|
50
|
+
code: "ValidationError",
|
51
|
+
message: "Validation error(s) present. See embedded errors list for more details.",
|
52
|
+
_embedded: {
|
53
|
+
errors: [
|
54
|
+
{ code: "Duplicate", message: "A customer with the specified email already exists.", path: "/email"
|
55
|
+
}
|
56
|
+
]
|
57
|
+
}
|
58
|
+
}}
|
59
|
+
|
60
|
+
it 'returns errors' do
|
61
|
+
expect(subject.save).to eq(false)
|
62
|
+
expect(subject.errors[:email]).to eq(['A customer with the specified email already exists.'])
|
63
|
+
expect(subject.id).to eq(customer_token)
|
64
|
+
expect(subject.resource_location).to be_nil
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -34,7 +34,7 @@ class TestConfigProvider
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def account_token_provider
|
37
|
-
TestDwollaTokenProvider
|
37
|
+
TestDwollaTokenProvider.new
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
@@ -187,6 +187,10 @@ class DwollaHelper
|
|
187
187
|
stub_post_request customers_endpoint, params, response
|
188
188
|
end
|
189
189
|
|
190
|
+
def stub_update_customer_request(customer_token, params, response)
|
191
|
+
stub_post_request customer_endpoint(customer_token), params, response
|
192
|
+
end
|
193
|
+
|
190
194
|
def stub_create_customer_funding_source_request(customer_token, params, response)
|
191
195
|
stub_post_request customer_funding_sources_endpoint(customer_token), params, response
|
192
196
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: money_mover
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Errante
|
@@ -213,6 +213,7 @@ files:
|
|
213
213
|
- spec/integration/money_mover/dwolla/customers/create_spec.rb
|
214
214
|
- spec/integration/money_mover/dwolla/customers/find_spec.rb
|
215
215
|
- spec/integration/money_mover/dwolla/customers/funding-sources/create_spec.rb
|
216
|
+
- spec/integration/money_mover/dwolla/customers/update_spec.rb
|
216
217
|
- spec/integration/money_mover/dwolla/documents/create_spec.rb
|
217
218
|
- spec/integration/money_mover/dwolla/funding-sources/micro-deposits/initiation_spec.rb
|
218
219
|
- spec/integration/money_mover/dwolla/funding-sources/micro-deposits/verification_spec.rb
|
@@ -260,6 +261,7 @@ test_files:
|
|
260
261
|
- spec/integration/money_mover/dwolla/customers/create_spec.rb
|
261
262
|
- spec/integration/money_mover/dwolla/customers/find_spec.rb
|
262
263
|
- spec/integration/money_mover/dwolla/customers/funding-sources/create_spec.rb
|
264
|
+
- spec/integration/money_mover/dwolla/customers/update_spec.rb
|
263
265
|
- spec/integration/money_mover/dwolla/documents/create_spec.rb
|
264
266
|
- spec/integration/money_mover/dwolla/funding-sources/micro-deposits/initiation_spec.rb
|
265
267
|
- spec/integration/money_mover/dwolla/funding-sources/micro-deposits/verification_spec.rb
|