money_mover 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 00f83a02bf6fbc8289d72c49efb7317a2d0f2826
4
- data.tar.gz: f08ee651e612808e09e23d355df6182bd64f09b9
3
+ metadata.gz: c6381fecabe648a60a7a28e66f67582988c1645f
4
+ data.tar.gz: 585d5f5e065aafff7d61dc146dafa2d9196e912e
5
5
  SHA512:
6
- metadata.gz: 499c8c897ff246de0d6ad400f4ad7736868b8a735104c4a20872a4a3dea56a4313d0b56bb4dd6dbbd10186884c50facb739f5dd5104c17751688373be156a7ae
7
- data.tar.gz: 149b4ffec1177b88251b16a7730dd99dfd0eddc54dc38c12653a6d63e6e9a01493103b7ac5cf80d8b64ca4ba80bf9c969feec3e666d5c7f852acb9bfa758f102
6
+ metadata.gz: d453300e4eac7fc7d5f966d25697aaf2cf235b0d59906c55b7910df70d60eb9e954e3d937d84dbd352c1a3478ded530fb987a2a95b2aa2bde0131f7051a18131
7
+ data.tar.gz: d9595b26247a965c2603bff50f1583c0c2506572ae0fd456e26332deb9c881d99f2f5ff99178cf50f20aa75cc6cb7736d6520f4ee1db92d189e92ad6fcadbadf
@@ -5,9 +5,10 @@ module MoneyMover
5
5
 
6
6
  attr_accessor :id, :_links, :_embedded
7
7
 
8
- attr_reader :resource_location
8
+ attr_reader :resource_location, :attrs
9
9
 
10
10
  def initialize(attrs = {}, client = AccountClient.new)
11
+ @attrs = attrs
11
12
  @id = attrs[:id]
12
13
  @resource_location = attrs[:resource_location]
13
14
  @_links = attrs[:_links]
@@ -37,13 +37,13 @@ module MoneyMover
37
37
  doingBusinessAs: doingBusinessAs,
38
38
  website: website,
39
39
  type: 'business',
40
+ ipAddress: ipAddress
40
41
  }
41
42
 
42
43
  # hack to fix bug on dwolla's side with funding sources being removed if no dba is sent
43
44
  create_attrs[:doingBusinessAs] = businessName unless doingBusinessAs.present?
44
- create_attrs[:ipAddress] = ipAddress if ipAddress.present?
45
45
 
46
- create_attrs
46
+ create_attrs.reject{|_key, val| !val.present? }
47
47
  end
48
48
  end
49
49
  end
@@ -1,3 +1,3 @@
1
1
  module MoneyMover
2
- VERSION = '0.0.6'
2
+ VERSION = '0.0.7'
3
3
  end
@@ -27,14 +27,44 @@ describe MoneyMover::Dwolla::CustomerFundingSource do
27
27
  }}
28
28
 
29
29
  before do
30
- dwolla_helper.stub_create_customer_funding_source_request customer_token, create_params, dwolla_helper.customer_funding_source_created_response(customer_token, funding_source_token)
30
+ dwolla_helper.stub_create_customer_funding_source_request customer_token, create_params, create_response
31
31
  end
32
32
 
33
33
  describe '#save' do
34
- it 'creates new customer funding source in dwolla' do
35
- expect(subject.save).to eq(true)
36
- expect(subject.id).to eq(funding_source_token)
37
- expect(subject.resource_location).to eq(dwolla_helper.customer_funding_source_endpoint(customer_token, funding_source_token))
34
+ context 'valid' do
35
+ let(:create_response) { dwolla_helper.customer_funding_source_created_response customer_token, funding_source_token }
36
+
37
+ it 'creates new customer funding source in dwolla' do
38
+ expect(subject.save).to eq(true)
39
+ expect(subject.id).to eq(funding_source_token)
40
+ expect(subject.resource_location).to eq(dwolla_helper.customer_funding_source_endpoint(customer_token, funding_source_token))
41
+ end
42
+ end
43
+
44
+ context 'invalid' do
45
+ let(:create_response) do
46
+ dwolla_helper.error_response(
47
+ code: "ValidationError",
48
+ message: "Validation error(s) present. See embedded errors list for more details.",
49
+ _embedded: {
50
+ errors: [
51
+ {
52
+ code: "Invalid",
53
+ message: "Invalid parameter.",
54
+ path: "/routingNumber"
55
+ }
56
+ ]
57
+ }
58
+ )
59
+ end
60
+
61
+ it 'returns false and sets errors' do
62
+ expect(subject.save).to eq(false)
63
+ expect(subject.errors[:routingNumber]).to eq(['Invalid parameter.'])
64
+
65
+ expect(subject.id).to be_nil
66
+ expect(subject.resource_location).to be_nil
67
+ end
38
68
  end
39
69
  end
40
70
  end
@@ -0,0 +1,112 @@
1
+ require 'spec_helper'
2
+
3
+ describe MoneyMover::Dwolla::VerifiedBusinessCustomer do
4
+ let(:firstName) { 'first name' }
5
+ let(:lastName) { 'last name' }
6
+ let(:email) { 'some@example.com' }
7
+ let(:address1) { '123 Anywhere St.' }
8
+ let(:address2) { 'Suite 200' }
9
+ let(:city) { 'St. Louis' }
10
+ let(:state) { 'MO' }
11
+ let(:postalCode) { '63104' }
12
+ let(:dateOfBirth) { '01/28/1970' }
13
+ let(:ssn) { '123456789' }
14
+ let(:phone) { '636-333-3333' }
15
+ let(:businessClassification) { 'some-business-classification' }
16
+ let(:businessType) { 'llc' }
17
+ let(:businessName) { 'Some Company, LLC' }
18
+ let(:ein) { '987654321' }
19
+ let(:doingBusinessAs) { 'Alternate Company Name' }
20
+ let(:website) { 'http://website.com' }
21
+ let(:ipAddress) { '127.0.0.1' }
22
+
23
+ # TODO: add test for not being able to set type, status, created, etc. directly...
24
+
25
+ subject { described_class.new attrs }
26
+
27
+ describe '#save' do
28
+ let(:attrs) {{
29
+ firstName: firstName,
30
+ lastName: lastName,
31
+ email: email,
32
+ address1: address1,
33
+ address2: address2,
34
+ city: city,
35
+ state: state,
36
+ postalCode: postalCode,
37
+ dateOfBirth: dateOfBirth,
38
+ ssn: ssn,
39
+ phone: phone,
40
+ businessClassification: businessClassification,
41
+ businessType: businessType,
42
+ businessName: businessName,
43
+ ein: ein,
44
+ doingBusinessAs: doingBusinessAs,
45
+ website: website,
46
+ ipAddress: ipAddress
47
+ }}
48
+
49
+ let(:create_customer_params) {{
50
+ firstName: firstName,
51
+ lastName: lastName,
52
+ email: email,
53
+ address1: address1,
54
+ address2: address2,
55
+ city: city,
56
+ state: state,
57
+ postalCode: postalCode,
58
+ dateOfBirth: dateOfBirth,
59
+ ssn: ssn,
60
+ phone: phone,
61
+ businessClassification: businessClassification,
62
+ businessType: businessType,
63
+ businessName: businessName,
64
+ ein: ein,
65
+ doingBusinessAs: doingBusinessAs,
66
+ website: website,
67
+ ipAddress: ipAddress,
68
+ type: 'business'
69
+ }}
70
+
71
+ before do
72
+ dwolla_helper.stub_create_customer_request create_customer_params, create_response
73
+ end
74
+
75
+ context 'success' do
76
+ let(:customer_token) { '9481924a-6795-4e7a-b436-a7a48a4141ca' }
77
+
78
+ let(:create_response) { dwolla_helper.customer_created_response customer_token }
79
+
80
+ it 'creates new customer in dwolla' do
81
+ expect(subject.save).to eq(true)
82
+
83
+ expect(subject.id).to eq(customer_token)
84
+ expect(subject.resource_location).to eq(dwolla_helper.customer_endpoint(customer_token))
85
+ end
86
+ end
87
+
88
+ context 'fail' do
89
+ let(:create_response) { dwolla_helper.resource_create_error_response error_response }
90
+
91
+ let(:error_response) {{
92
+ code: "ValidationError",
93
+ message: "Validation error(s) present. See embedded errors list for more details.",
94
+ _embedded: {
95
+ errors: [
96
+ { code: "Duplicate", message: "A customer with the specified email already exists.", path: "/email"
97
+ }
98
+ ]
99
+ }
100
+ }}
101
+
102
+ it 'returns errors' do
103
+ expect(subject.save).to eq(false)
104
+
105
+ expect(subject.errors[:email]).to eq(['A customer with the specified email already exists.'])
106
+
107
+ expect(subject.id).to be_nil
108
+ expect(subject.resource_location).to be_nil
109
+ end
110
+ end
111
+ end
112
+ end
@@ -0,0 +1,201 @@
1
+ require 'spec_helper'
2
+
3
+ describe MoneyMover::Dwolla::VerifiedBusinessCustomer do
4
+ let(:firstName) { double 'first name' }
5
+ let(:lastName) { double 'last name' }
6
+ let(:email) { double 'email' }
7
+ let(:address1) { double 'address 1' }
8
+ let(:address2) { double 'address 2' }
9
+ let(:city) { double 'city' }
10
+ let(:state) { double 'state' }
11
+ let(:postalCode) { double 'postal code' }
12
+ let(:dateOfBirth) { double 'dob' }
13
+ let(:ssn) { double 'ssn' }
14
+ let(:phone) { double 'phone' }
15
+ let(:businessClassification) { double 'business classification' }
16
+ let(:businessType) { double 'business type' }
17
+ let(:businessName) { double 'business name' }
18
+ let(:ein) { double 'ein' }
19
+ let(:doingBusinessAs) { double 'dba' }
20
+ let(:website) { double 'website' }
21
+ let(:ipAddress) { double 'ip address' }
22
+
23
+ # TODO: add test for not being able to set type, status, created, etc. directly...
24
+
25
+ let(:account_client) { double 'account client' }
26
+
27
+ subject { described_class.new attrs, account_client }
28
+
29
+ describe '#save' do
30
+ let(:attrs) {{
31
+ firstName: firstName,
32
+ lastName: lastName,
33
+ email: email,
34
+ address1: address1,
35
+ address2: address2,
36
+ city: city,
37
+ state: state,
38
+ postalCode: postalCode,
39
+ dateOfBirth: dateOfBirth,
40
+ ssn: ssn,
41
+ phone: phone,
42
+ businessClassification: businessClassification,
43
+ businessType: businessType,
44
+ businessName: businessName,
45
+ ein: ein,
46
+ doingBusinessAs: doingBusinessAs,
47
+ website: website,
48
+ ipAddress: ipAddress
49
+ }}
50
+
51
+ let(:create_customer_params) {{
52
+ firstName: firstName,
53
+ lastName: lastName,
54
+ email: email,
55
+ address1: address1,
56
+ address2: address2,
57
+ city: city,
58
+ state: state,
59
+ postalCode: postalCode,
60
+ dateOfBirth: dateOfBirth,
61
+ ssn: ssn,
62
+ phone: phone,
63
+ businessClassification: businessClassification,
64
+ businessType: businessType,
65
+ businessName: businessName,
66
+ ein: ein,
67
+ doingBusinessAs: doingBusinessAs,
68
+ website: website,
69
+ ipAddress: ipAddress,
70
+ type: 'business'
71
+ }}
72
+
73
+ let(:dwolla_response) { double 'dwolla response', success?: success?, resource_id: resource_id, resource_location: resource_location, errors: dwolla_errors }
74
+ let(:resource_id) { double 'resource id' }
75
+ let(:resource_location) { double 'resource location' }
76
+ let(:dwolla_errors) {{
77
+ errorKey1: 'some error 1',
78
+ errorKey2: 'some error 2'
79
+ }}
80
+
81
+ let(:create_endpoint) { "/customers" }
82
+
83
+ before do
84
+ allow(account_client).to receive(:post).with(create_endpoint, create_customer_params) { dwolla_response }
85
+ end
86
+
87
+ shared_examples 'resource created successfully' do
88
+ it 'returns true' do
89
+ expect(subject.save).to eq(true)
90
+ expect(subject.errors.count).to eq(0)
91
+
92
+ expect(subject.id).to eq(resource_id)
93
+ expect(subject.resource_location).to eq(resource_location)
94
+ end
95
+ end
96
+
97
+ context 'success' do
98
+ let(:success?) { true }
99
+
100
+ it_behaves_like "resource created successfully"
101
+
102
+ context 'only required fields sent' do
103
+ let(:attrs) {{
104
+ firstName: firstName,
105
+ lastName: lastName,
106
+ email: email,
107
+ address1: address1,
108
+ city: city,
109
+ state: state,
110
+ postalCode: postalCode,
111
+ dateOfBirth: dateOfBirth,
112
+ ssn: ssn,
113
+ phone: phone,
114
+ businessClassification: businessClassification,
115
+ businessType: businessType,
116
+ businessName: businessName,
117
+ ein: ein
118
+ }}
119
+
120
+ let(:create_customer_params) {{
121
+ firstName: firstName,
122
+ lastName: lastName,
123
+ email: email,
124
+ address1: address1,
125
+ city: city,
126
+ state: state,
127
+ postalCode: postalCode,
128
+ dateOfBirth: dateOfBirth,
129
+ ssn: ssn,
130
+ phone: phone,
131
+ businessClassification: businessClassification,
132
+ businessType: businessType,
133
+ businessName: businessName,
134
+ ein: ein,
135
+ doingBusinessAs: businessName,
136
+ type: 'business'
137
+ }}
138
+
139
+ it_behaves_like "resource created successfully"
140
+ end
141
+
142
+ context 'sending empty strings for non-required fields' do
143
+ let(:attrs) {{
144
+ firstName: firstName,
145
+ lastName: lastName,
146
+ email: email,
147
+ address1: address1,
148
+ address2: "",
149
+ city: city,
150
+ state: state,
151
+ postalCode: postalCode,
152
+ dateOfBirth: dateOfBirth,
153
+ ssn: ssn,
154
+ phone: phone,
155
+ businessClassification: businessClassification,
156
+ businessType: businessType,
157
+ businessName: businessName,
158
+ ein: ein,
159
+ doingBusinessAs: "",
160
+ website: "",
161
+ ipAddress: ""
162
+ }}
163
+
164
+ let(:create_customer_params) {{
165
+ firstName: firstName,
166
+ lastName: lastName,
167
+ email: email,
168
+ address1: address1,
169
+ city: city,
170
+ state: state,
171
+ postalCode: postalCode,
172
+ dateOfBirth: dateOfBirth,
173
+ ssn: ssn,
174
+ phone: phone,
175
+ businessClassification: businessClassification,
176
+ businessType: businessType,
177
+ businessName: businessName,
178
+ ein: ein,
179
+ doingBusinessAs: businessName,
180
+ type: 'business'
181
+ }}
182
+
183
+ it_behaves_like "resource created successfully"
184
+ end
185
+ end
186
+
187
+ context 'fail' do
188
+ let(:success?) { false }
189
+
190
+ it 'returns errors' do
191
+ expect(subject.save).to eq(false)
192
+
193
+ expect(subject.errors[:errorKey1]).to eq(['some error 1'])
194
+ expect(subject.errors[:errorKey2]).to eq(['some error 2'])
195
+
196
+ expect(subject.id).to be_nil
197
+ expect(subject.resource_location).to be_nil
198
+ end
199
+ end
200
+ end
201
+ 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.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Errante
@@ -216,20 +216,22 @@ files:
216
216
  - spec/integration/money_mover/dwolla/documents/create_spec.rb
217
217
  - spec/integration/money_mover/dwolla/funding-sources/micro-deposits/initiation_spec.rb
218
218
  - spec/integration/money_mover/dwolla/funding-sources/micro-deposits/verification_spec.rb
219
+ - spec/integration/money_mover/dwolla/models/verified_business_customer_spec.rb
219
220
  - spec/integration/money_mover/dwolla/request_signature_validator_spec.rb
220
221
  - spec/integration/money_mover/dwolla/transfers/create_spec.rb
221
- - spec/lib/money_mover/dwolla/client_spec.rb
222
- - spec/lib/money_mover/dwolla/config_spec.rb
223
- - spec/lib/money_mover/dwolla/error_handler_spec.rb
224
- - spec/lib/money_mover/dwolla/funding_source_spec.rb
225
- - spec/lib/money_mover/dwolla/microdeposits_initiation_spec.rb
226
- - spec/lib/money_mover/dwolla/root_account_spec.rb
227
- - spec/lib/money_mover/dwolla/token_spec.rb
228
- - spec/lib/money_mover/dwolla/transfer_spec.rb
229
- - spec/lib/money_mover/dwolla/webhook_subscription_spec.rb
230
222
  - spec/spec_helper.rb
231
223
  - spec/support/dwolla_helper.rb
232
224
  - spec/support/fixtures/sample.jpg
225
+ - spec/unit/money_mover/dwolla/client_spec.rb
226
+ - spec/unit/money_mover/dwolla/config_spec.rb
227
+ - spec/unit/money_mover/dwolla/error_handler_spec.rb
228
+ - spec/unit/money_mover/dwolla/funding_source_spec.rb
229
+ - spec/unit/money_mover/dwolla/microdeposits_initiation_spec.rb
230
+ - spec/unit/money_mover/dwolla/models/verified_business_customer_spec.rb
231
+ - spec/unit/money_mover/dwolla/root_account_spec.rb
232
+ - spec/unit/money_mover/dwolla/token_spec.rb
233
+ - spec/unit/money_mover/dwolla/transfer_spec.rb
234
+ - spec/unit/money_mover/dwolla/webhook_subscription_spec.rb
233
235
  homepage: https://github.com/danoph/money_mover
234
236
  licenses:
235
237
  - MIT
@@ -261,17 +263,19 @@ test_files:
261
263
  - spec/integration/money_mover/dwolla/documents/create_spec.rb
262
264
  - spec/integration/money_mover/dwolla/funding-sources/micro-deposits/initiation_spec.rb
263
265
  - spec/integration/money_mover/dwolla/funding-sources/micro-deposits/verification_spec.rb
266
+ - spec/integration/money_mover/dwolla/models/verified_business_customer_spec.rb
264
267
  - spec/integration/money_mover/dwolla/request_signature_validator_spec.rb
265
268
  - spec/integration/money_mover/dwolla/transfers/create_spec.rb
266
- - spec/lib/money_mover/dwolla/client_spec.rb
267
- - spec/lib/money_mover/dwolla/config_spec.rb
268
- - spec/lib/money_mover/dwolla/error_handler_spec.rb
269
- - spec/lib/money_mover/dwolla/funding_source_spec.rb
270
- - spec/lib/money_mover/dwolla/microdeposits_initiation_spec.rb
271
- - spec/lib/money_mover/dwolla/root_account_spec.rb
272
- - spec/lib/money_mover/dwolla/token_spec.rb
273
- - spec/lib/money_mover/dwolla/transfer_spec.rb
274
- - spec/lib/money_mover/dwolla/webhook_subscription_spec.rb
275
269
  - spec/spec_helper.rb
276
270
  - spec/support/dwolla_helper.rb
277
271
  - spec/support/fixtures/sample.jpg
272
+ - spec/unit/money_mover/dwolla/client_spec.rb
273
+ - spec/unit/money_mover/dwolla/config_spec.rb
274
+ - spec/unit/money_mover/dwolla/error_handler_spec.rb
275
+ - spec/unit/money_mover/dwolla/funding_source_spec.rb
276
+ - spec/unit/money_mover/dwolla/microdeposits_initiation_spec.rb
277
+ - spec/unit/money_mover/dwolla/models/verified_business_customer_spec.rb
278
+ - spec/unit/money_mover/dwolla/root_account_spec.rb
279
+ - spec/unit/money_mover/dwolla/token_spec.rb
280
+ - spec/unit/money_mover/dwolla/transfer_spec.rb
281
+ - spec/unit/money_mover/dwolla/webhook_subscription_spec.rb