synapsis 0.0.11 → 0.0.12

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: 88f25f31c347b1d5e1315a53f5f8b988bf36300d
4
- data.tar.gz: e057d3fa66b160ec82b589cdc38375a1d5810d45
3
+ metadata.gz: c4dba020d1db06c8514fcbd98c992fe177f30965
4
+ data.tar.gz: ae4bdaececc8d77fd3d9f8356d9b3c8f08f7f5ff
5
5
  SHA512:
6
- metadata.gz: d9236da172a713aa0c8aa9b70db0f711ef28230fa9d8ea2368010ade8239410534991af783c2dbac156db68d46b11dcee81b3ac2049e55eb1037d5012d982510
7
- data.tar.gz: c85014c085f84d63811d1d286b9612f84077c7b92f696c11636f34b4350b435a053040bf3531eba70970b1cf093440de16a3fd4ac82f7d4c62e90646277bdda8
6
+ metadata.gz: b095652236ee088bd5828fee5113638347ee053863962a932c5be0c5233ffe333787e65d78a1dda9df54bf20327d64a3572bd433dbd54cb8aa4b44413beeb369
7
+ data.tar.gz: 825c6e99316e02f09c84b46f8f9eb3a36c9335b8c497d262f29793e11d66cf5b9bdcb929b9a304d4e6788137fcea3637b2021a9621e35849df77bc42746134ac
data/lib/synapsis.rb CHANGED
@@ -31,6 +31,7 @@ module Synapsis
31
31
 
32
32
  def connection
33
33
  @connection ||= Faraday.new(url: synapse_url) do |faraday|
34
+ faraday.request :multipart # form-encode POST params
34
35
  faraday.request :url_encoded # form-encode POST params
35
36
  faraday.response :logger # log requests to STDOUT
36
37
  faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
data/lib/synapsis/bank.rb CHANGED
@@ -66,6 +66,11 @@ class Synapsis::Bank < Synapsis::APIResource
66
66
  return_response(response)
67
67
  end
68
68
 
69
+ def self.view_bank(oauth_token:, bank_id: )
70
+ response = view_request(oauth_consumer_key: oauth_token, id: bank_id)
71
+ return_response(response)
72
+ end
73
+
69
74
  def self.remove(bank_id, oauth_consumer_key)
70
75
  params = {
71
76
  bank_id: bank_id,
data/lib/synapsis/card.rb CHANGED
@@ -11,5 +11,7 @@ class Synapsis::Card < Synapsis::APIResource
11
11
  def self.show(params)
12
12
  view(params)
13
13
  end
14
+
15
+ # self.edit parameters: oauth_consumer_key, id, legal_name, account_number, routing_number, account_class, account_type
14
16
  end
15
17
 
@@ -21,6 +21,12 @@ class Synapsis::Order < Synapsis::APIResource
21
21
  return_response(response)
22
22
  end
23
23
 
24
+ # oauth_consumer_key (required):, order_id:, supp_id:
25
+ def self.view_recent(params)
26
+ response = request(:post, view_recent_url, params)
27
+ return_response(response)
28
+ end
29
+
24
30
  # Consumer key of the seller
25
31
  def self.void(order_id:, oauth_consumer_key:)
26
32
  params = {
@@ -49,5 +55,9 @@ class Synapsis::Order < Synapsis::APIResource
49
55
  def self.void_url
50
56
  "#{API_V2_PATH}order/void"
51
57
  end
58
+
59
+ def self.view_recent_url
60
+ "#{API_V2_PATH}order/recent"
61
+ end
52
62
  end
53
63
 
data/lib/synapsis/user.rb CHANGED
@@ -23,10 +23,41 @@ class Synapsis::User < Synapsis::APIResource
23
23
  return_response(response)
24
24
  end
25
25
 
26
+ def self.add_ssn(params)
27
+ response = request(:post, add_ssn_url, params)
28
+
29
+ # Synapse incorrectly returns SSN validation fails as 200. Thus we have to override default return_reponse behavior
30
+ if parse_as_synapse_resource(response).success
31
+ return_response(response)
32
+ else
33
+ raise Synapsis::Error, parse_as_synapse_resource(response).reason
34
+ end
35
+ end
36
+
37
+ def self.verify(params)
38
+ response = request(:post, verify_ssn_url, params)
39
+
40
+ # Synapse incorrectly returns SSN validation fails as 200. Thus we have to override default return_reponse behavior
41
+ if parse_as_synapse_resource(response).success
42
+ return_response(response)
43
+ else
44
+ raise Synapsis::Error, parse_as_synapse_resource(response).reason
45
+ end
46
+ end
47
+
48
+ def self.add_document(params)
49
+ response = request(:post, add_document_url, params.merge(attachment: Faraday::UploadIO.new(params[:attachment], 'image/jpeg')))
50
+ return_response(response)
51
+ end
52
+
26
53
  def self.view_linked_banks(oauth_token)
27
54
  Synapsis::Bank.view_linked_banks(oauth_token)
28
55
  end
29
56
 
57
+ def self.view_recent_orders(params)
58
+ Synapsis::Order.view_recent_orders(params)
59
+ end
60
+
30
61
  private
31
62
 
32
63
  def self.client_credentials
@@ -43,5 +74,17 @@ class Synapsis::User < Synapsis::APIResource
43
74
  def self.refresh_url
44
75
  "#{API_V2_PATH}user/refresh"
45
76
  end
77
+
78
+ def self.add_ssn_url
79
+ "#{API_V2_PATH}user/ssn/add"
80
+ end
81
+
82
+ def self.verify_ssn_url
83
+ "#{API_V2_PATH}user/ssn/answer"
84
+ end
85
+
86
+ def self.add_document_url
87
+ "#{API_V2_PATH}user/doc/add"
88
+ end
46
89
  end
47
90
 
@@ -1,3 +1,3 @@
1
1
  module Synapsis
2
- VERSION = "0.0.11"
2
+ VERSION = "0.0.12"
3
3
  end
@@ -0,0 +1,14 @@
1
+ def create_user
2
+ user_email = Faker::Internet.email[0, 29] # Limit 30 characters
3
+
4
+ user_params = {
5
+ email: user_email,
6
+ fullname: user_email,
7
+ phonenumber: Faker::PhoneNumber.phone_number,
8
+ password: '5ourcep4d',
9
+ ip_address: '8.8.8.8'
10
+ }
11
+
12
+ return Synapsis::User.create(user_params)
13
+ end
14
+
@@ -99,7 +99,22 @@ RSpec.describe Synapsis::Bank do
99
99
  end
100
100
 
101
101
  context 'errors' do
102
- it 'bad username returns a SynapsisError' do
102
+ it 'bad username returns a SynapsisError--generic error (used Chase as an example)' do
103
+ new_user = Synapsis::User.create(user_params)
104
+
105
+ bank_params = {
106
+ username: 'WRONG USERNAME',
107
+ password: 'test1234',
108
+ pin: '1234',
109
+ oauth_consumer_key: new_user.access_token,
110
+ bank: 'Chase',
111
+ mfa: 'test_answer'
112
+ }
113
+
114
+ expect { Synapsis::Bank.link(bank_params) }.to raise_error(Synapsis::Error).with_message('The username or password provided were not correct.')
115
+ end
116
+
117
+ it 'bad username returns a SynapsisError--Ally bank specific error message' do
103
118
  new_user = Synapsis::User.create(user_params)
104
119
 
105
120
  bank_params = {
@@ -111,7 +126,7 @@ RSpec.describe Synapsis::Bank do
111
126
  mfa: 'test_answer'
112
127
  }
113
128
 
114
- expect { Synapsis::Bank.link(bank_params) }.to raise_error(Synapsis::Error).with_message('Please Enter the Correct Username and Password')
129
+ expect { Synapsis::Bank.link(bank_params) }.to raise_error(Synapsis::Error).with_message('Problems logging in? You can go to the online banking login page at allybank.com and select Forgot Your Username or call us 24/7 for help. Mobile banking is not available to Ally Auto or Mortgage customers at this time.')
115
130
  end
116
131
 
117
132
  it 'bad mfa answer returns a SynapsisError' do
@@ -11,7 +11,7 @@ RSpec.describe Synapsis::Bank do
11
11
  end
12
12
  end
13
13
 
14
- context '.add/#remove' do
14
+ context '.add/.view_bank/#remove' do
15
15
  it 'adds and removes a bank account' do
16
16
  random_persons_access_token = 'dcd234d9d9fb55ad9711c4c41e254868ef3768d4'
17
17
 
@@ -31,6 +31,8 @@ RSpec.describe Synapsis::Bank do
31
31
  expect(new_bank.bank.name_on_account).to eq viewed_user.user.fullname
32
32
  expect(new_bank.bank.nickname.downcase).to eq bank_params[:nickname].downcase
33
33
 
34
+ viewed_bank = Synapsis::Bank.view_bank(oauth_token: random_persons_access_token, bank_id: new_bank.bank.id)
35
+
34
36
  removed_bank = Synapsis::Bank.remove(new_bank.bank.id, random_persons_access_token)
35
37
 
36
38
  expect(removed_bank.success).to eq true
@@ -80,7 +82,7 @@ RSpec.describe Synapsis::Bank do
80
82
  account_num: '1111111112',
81
83
  routing_num: '121000358',
82
84
  nickname: 'Sourcepad Bank',
83
- oauth_consumer_key: new_user_response.access_token,
85
+ oauth_consumer_key: new_user_response.oauth_consumer_key,
84
86
  account_type: Synapsis::Bank::AccountType::CHECKING,
85
87
  account_class: Synapsis::Bank::AccountClass::PERSONAL
86
88
  }
@@ -89,7 +91,7 @@ RSpec.describe Synapsis::Bank do
89
91
  second_bank_response = Synapsis::Bank.add(bank_params)
90
92
  third_bank_response = Synapsis::Bank.add(bank_params)
91
93
 
92
- set_bank_primary_response = Synapsis::Bank.set_as_primary(bank_id: second_bank_response.bank.id, oauth_consumer_key: new_user_response.access_token)
94
+ set_bank_primary_response = Synapsis::Bank.set_as_primary(bank_id: second_bank_response.bank.id, oauth_consumer_key: new_user_response.oauth_consumer_key)
93
95
 
94
96
  expect(set_bank_primary_response.success).to be_truthy
95
97
  end
@@ -118,19 +118,16 @@ RSpec.describe Synapsis::MassPay do
118
118
  expect { Synapsis::MassPay.show(mass_pay_id: 721, oauth_consumer_key: 'WRONG KEY') }.to raise_error(Synapsis::Error).with_message('Error in OAuth Authentication.')
119
119
 
120
120
  # Bad ID
121
- expect { Synapsis::MassPay.show(mass_pay_id: 'a', oauth_consumer_key: users_consumer_key) }.to raise_error(Synapsis::Error).with_message('Sorry, this request could not be processed. Please try again later.')
121
+ expect { Synapsis::MassPay.show(mass_pay_id: 'a', oauth_consumer_key: users_consumer_key) }.to raise_error(Synapsis::Error).with_message('id not formatted correctly.')
122
122
 
123
- # If mass_pay_id isn't owned by the user, then return all the mass_pays of the user
124
- expect(Synapsis::MassPay.show(mass_pay_id: 200, oauth_consumer_key: users_consumer_key)).to respond_to(:obj_count)
125
- end
126
- end
127
- end
123
+ # No mass_pay_id argument: fails
124
+ expect { Synapsis::MassPay.show(oauth_consumer_key: users_consumer_key) }.to raise_error(Synapsis::Error).with_message('id not formatted correctly.')
128
125
 
129
- context 'without mass_pay_id argument' do
130
- it 'returns all the user\'s mass_pays' do
131
- mass_pay_response = Synapsis::MassPay.show(oauth_consumer_key: users_consumer_key)
126
+ # If mass_pay_id isn't owned by the user, Synapse's behavior is to return an array of empty mass_pays.
127
+ mass_pay_with_bad_id_but_is_integer = Synapsis::MassPay.show(mass_pay_id: 99999, oauth_consumer_key: users_consumer_key)
132
128
 
133
- expect(mass_pay_response.obj_count).to be > 1
129
+ expect(mass_pay_with_bad_id_but_is_integer.mass_pays.count).to eq 0
130
+ end
134
131
  end
135
132
  end
136
133
  end
@@ -29,7 +29,7 @@ RSpec.describe Synapsis::Order do
29
29
  end
30
30
  end
31
31
 
32
- xit 'pending due to a bug wherein the buyer\'s balance does not get decremented--subtracts the money from the consumer\'s account and adds to the seller\'s account' do
32
+ it 'pending due to a bug wherein the buyer\'s balance does not get decremented--subtracts the money from the consumer\'s account and adds to the seller\'s account' do
33
33
  buyer_account_balance = Synapsis::User.view(buyer_consumer_key).user.balance
34
34
  seller_account_balance = Synapsis::User.view(seller_consumer_key).user.balance
35
35
 
@@ -107,4 +107,14 @@ RSpec.describe Synapsis::Order do
107
107
  end
108
108
  end
109
109
  end
110
+
111
+ describe '.view_recent_orders' do
112
+ it 'views the recent orders' do
113
+ token = 'M9Ned3lWBokYMsdZcDLUBIFuOOmCyG1fYauuNpzT'
114
+ order_response = Synapsis::Order.view_recent(oauth_consumer_key: token)
115
+
116
+ expect(order_response.success).to be_truthy
117
+ expect(order_response).to respond_to(:orders)
118
+ end
119
+ end
110
120
  end
@@ -16,7 +16,7 @@ RSpec.describe Synapsis::User do
16
16
  new_synapse_user = Synapsis::User.create(user_params)
17
17
 
18
18
  ['access_token', 'oauth_consumer_key', 'expires_in',
19
- 'reason', 'refresh_token', 'success', 'username', 'user_id'].each do |k|
19
+ 'refresh_token', 'success', 'username', 'user_id'].each do |k|
20
20
  expect(new_synapse_user.send(k)).not_to be_nil
21
21
  end
22
22
  end
@@ -81,6 +81,88 @@ RSpec.describe Synapsis::User do
81
81
  end
82
82
  end
83
83
 
84
+ describe '.add_ssn and .verify_ssn' do
85
+ let!(:ssn_information) {{
86
+ birth_day: 23,
87
+ birth_month: 8,
88
+ birth_year: 1980,
89
+ name_first: 'Jon',
90
+ name_last: 'Doe',
91
+ ssn: '1111',
92
+ address_street1: '1 Infinite Loop',
93
+ address_postal_code: '95014',
94
+ address_country_code: 'US'
95
+ }}
96
+
97
+ context 'happy path' do
98
+ it 'SSN validations fails: return a Synapsis error' do
99
+ new_synapse_user = create_user
100
+
101
+ SYNAPSE_SANDBOX_SSN_VALIDATION_SUCCEEDS_VALUE = '0000'
102
+
103
+ ssn_validation_succeeds_params = ssn_information.merge(oauth_consumer_key: new_synapse_user.oauth_consumer_key, ssn: SYNAPSE_SANDBOX_SSN_VALIDATION_SUCCEEDS_VALUE)
104
+
105
+ successful_add_ssn_response = Synapsis::User.add_ssn(ssn_validation_succeeds_params)
106
+
107
+ expect(successful_add_ssn_response.success).to eq true
108
+ end
109
+ end
110
+
111
+ context 'errors' do
112
+ it 'SSN validations fails: return a Synapsis error' do
113
+ user_email = Faker::Internet.email[0, 29] # Limit 30 characters
114
+
115
+ user_params = {
116
+ email: user_email,
117
+ fullname: user_email,
118
+ phonenumber: Faker::PhoneNumber.phone_number,
119
+ password: '5ourcep4d',
120
+ ip_address: '8.8.8.8'
121
+ }
122
+
123
+ new_synapse_user = Synapsis::User.create(user_params)
124
+
125
+ SYNAPSE_SANDBOX_SSN_VALIDATION_FAILS_VALUE = '1111'
126
+
127
+ ssn_validation_fails_params = ssn_information.merge(oauth_consumer_key: new_synapse_user.oauth_consumer_key, ssn: SYNAPSE_SANDBOX_SSN_VALIDATION_FAILS_VALUE)
128
+
129
+ expect { Synapsis::User.add_ssn(ssn_validation_fails_params) }.to raise_error(Synapsis::Error).with_message('Invalid SSN information supplied')
130
+ end
131
+ end
132
+
133
+ context 'verify ssn' do
134
+ xit 'need to consult with synapse re: verify SSN intended results' do
135
+ new_synapse_user = create_user
136
+
137
+ SYNAPSE_SANDBOX_SSN_VALIDATION_NEEDS_TO_BE_VERIFIED_VALUE = '3333'
138
+
139
+ ssn_validation_succeeds_params = ssn_information.merge(oauth_consumer_key: new_synapse_user.oauth_consumer_key, ssn: SYNAPSE_SANDBOX_SSN_VALIDATION_NEEDS_TO_BE_VERIFIED_VALUE)
140
+
141
+ successful_add_ssn_response = Synapsis::User.add_ssn(ssn_validation_succeeds_params)
142
+
143
+ expect(successful_add_ssn_response.success).to eq true
144
+ end
145
+ end
146
+ end
147
+
148
+ describe '.add_document' do
149
+ context 'happy path' do
150
+ it 'shows the user\'s balance and linked banks' do
151
+ token = 'da2e45d5665551667ba6e08292407b56daa6ea43'
152
+
153
+ doc_params = {
154
+ attachment: 'spec/test_file.txt',
155
+ is_base_64: true,
156
+ oauth_consumer_key: token
157
+ }
158
+
159
+ successful_add_document_response = Synapsis::User.add_document(doc_params)
160
+
161
+ expect(successful_add_document_response.success).to eq true
162
+ end
163
+ end
164
+ end
165
+
84
166
  describe '.view_linked_banks' do
85
167
  context 'happy path' do
86
168
  it 'shows the user\'s balance and linked banks' do
@@ -0,0 +1 @@
1
+ Hello
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: synapsis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daryll Santos
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-25 00:00:00.000000000 Z
11
+ date: 2015-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -125,6 +125,7 @@ files:
125
125
  - lib/synapsis/withdrawal.rb
126
126
  - spec/config.yml
127
127
  - spec/spec_helper.rb
128
+ - spec/support/create_user_helper.rb
128
129
  - spec/support/routing_number_helpers.rb
129
130
  - spec/synapsis/api_resource_spec.rb
130
131
  - spec/synapsis/bank_link_spec.rb
@@ -136,6 +137,7 @@ files:
136
137
  - spec/synapsis/order_spec.rb
137
138
  - spec/synapsis/user_spec.rb
138
139
  - spec/synapsis/withdrawal_spec.rb
140
+ - spec/test_file.txt
139
141
  - synapsis.gemspec
140
142
  homepage: ''
141
143
  licenses:
@@ -164,6 +166,7 @@ summary: Ruby wrapper to the SynapsePay API
164
166
  test_files:
165
167
  - spec/config.yml
166
168
  - spec/spec_helper.rb
169
+ - spec/support/create_user_helper.rb
167
170
  - spec/support/routing_number_helpers.rb
168
171
  - spec/synapsis/api_resource_spec.rb
169
172
  - spec/synapsis/bank_link_spec.rb
@@ -175,3 +178,4 @@ test_files:
175
178
  - spec/synapsis/order_spec.rb
176
179
  - spec/synapsis/user_spec.rb
177
180
  - spec/synapsis/withdrawal_spec.rb
181
+ - spec/test_file.txt