synapsis 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/synapsis/bank.rb +58 -33
- data/lib/synapsis/error.rb +7 -0
- data/lib/synapsis/version.rb +1 -1
- data/lib/synapsis.rb +1 -0
- data/spec/synapsis/bank_spec.rb +70 -3
- data/spec/synapsis/user_spec.rb +4 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a010707a291ff524db1960a548b8352e09c234ca
|
4
|
+
data.tar.gz: b3ade5344af580ff5b097de89de7a8b87ccf3541
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: adcc1e4086f5fa54e6ea20b5057ea6ffe8cf7cc4d4c145f5e1bebfc8840e424cc17e5e916031e97d513bc5c673d932f99e023a9e5137130d8875fdd56a4ec71d
|
7
|
+
data.tar.gz: 39b71f8973a2e3b7b928967c65509f4270c5cc8af10900131dc3407a4823a941de52b0fd27c0ddc11c9a7beb7d61cbcfb5ab605cf84881bfa17f0cd8fa54d033
|
data/lib/synapsis/bank.rb
CHANGED
@@ -1,6 +1,16 @@
|
|
1
1
|
class Synapsis::Bank
|
2
2
|
include Synapsis::Utilities
|
3
3
|
|
4
|
+
module AccountClass
|
5
|
+
PERSONAL = 1
|
6
|
+
BUSINESS = 2
|
7
|
+
end
|
8
|
+
|
9
|
+
module AccountType
|
10
|
+
CHECKING = 1
|
11
|
+
SAVINGS = 2
|
12
|
+
end
|
13
|
+
|
4
14
|
attr_accessor :account_class,
|
5
15
|
:account_num,
|
6
16
|
:account_type,
|
@@ -40,7 +50,11 @@ class Synapsis::Bank
|
|
40
50
|
req.body = build_json_from_variable_hash
|
41
51
|
end
|
42
52
|
|
43
|
-
|
53
|
+
if JSON.parse(added_bank.body)['success']
|
54
|
+
Synapsis::RetrievedBank.new(added_bank)
|
55
|
+
else
|
56
|
+
Synapsis::Error.new(JSON.parse(added_bank.body))
|
57
|
+
end
|
44
58
|
end
|
45
59
|
|
46
60
|
def link
|
@@ -61,6 +75,17 @@ class Synapsis::Bank
|
|
61
75
|
return Synapsis::RetrievedBank.new(new_bank)
|
62
76
|
end
|
63
77
|
|
78
|
+
def self.remove(bank_id, oauth_consumer_key)
|
79
|
+
return Synapsis.connection.post do |req|
|
80
|
+
req.headers['Content-Type'] = 'application/json'
|
81
|
+
req.url "#{API_V2_PATH}bank/delete/"
|
82
|
+
req.body = JSON.generate(
|
83
|
+
bank_id: bank_id,
|
84
|
+
oauth_consumer_key: oauth_consumer_key
|
85
|
+
)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
64
89
|
def view_linked_banks
|
65
90
|
Synapsis.connection.post do |req|
|
66
91
|
req.headers['Content-Type'] = 'application/json'
|
@@ -68,39 +93,39 @@ class Synapsis::Bank
|
|
68
93
|
req.body = build_json_from_variable_hash
|
69
94
|
end
|
70
95
|
end
|
96
|
+
end
|
97
|
+
|
98
|
+
class Synapsis::RetrievedBank
|
99
|
+
attr_accessor :account_class,
|
100
|
+
:account_number_string,
|
101
|
+
:account_type,
|
102
|
+
:address,
|
103
|
+
:balance,
|
104
|
+
:bank_name,
|
105
|
+
:date,
|
106
|
+
:email,
|
107
|
+
:id,
|
108
|
+
:is_active,
|
109
|
+
:is_buyer_default,
|
110
|
+
:is_seller_default,
|
111
|
+
:is_verified,
|
112
|
+
:mfa_verifed,
|
113
|
+
:name_on_account,
|
114
|
+
:nickname,
|
115
|
+
:phone_number,
|
116
|
+
:resource_uri,
|
117
|
+
:routing_number_string
|
71
118
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
:is_active,
|
83
|
-
:is_buyer_default,
|
84
|
-
:is_seller_default,
|
85
|
-
:is_verified,
|
86
|
-
:mfa_verifed,
|
87
|
-
:name_on_account,
|
88
|
-
:nickname,
|
89
|
-
:phone_number,
|
90
|
-
:resource_uri,
|
91
|
-
:routing_number_string
|
92
|
-
|
93
|
-
def initialize(synapse_response)
|
94
|
-
parsed_response = JSON.parse(synapse_response.body)
|
95
|
-
|
96
|
-
if parsed_response['banks']
|
97
|
-
parsed_response['banks'].first.each do |k, v|
|
98
|
-
send("#{k}=", v)
|
99
|
-
end
|
100
|
-
elsif parsed_response['bank']
|
101
|
-
parsed_response['bank'].each do |k, v|
|
102
|
-
send("#{k}=", v)
|
103
|
-
end
|
119
|
+
def initialize(synapse_response)
|
120
|
+
parsed_response = JSON.parse(synapse_response.body)
|
121
|
+
|
122
|
+
if parsed_response['banks']
|
123
|
+
parsed_response['banks'].first.each do |k, v|
|
124
|
+
send("#{k}=", v)
|
125
|
+
end
|
126
|
+
elsif parsed_response['bank']
|
127
|
+
parsed_response['bank'].each do |k, v|
|
128
|
+
send("#{k}=", v)
|
104
129
|
end
|
105
130
|
end
|
106
131
|
end
|
data/lib/synapsis/version.rb
CHANGED
data/lib/synapsis.rb
CHANGED
data/spec/synapsis/bank_spec.rb
CHANGED
@@ -1,9 +1,18 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
RSpec.describe Synapsis::Bank do
|
4
|
+
context 'namespacing' do
|
5
|
+
it 'has a namespace for both AccountClass and AccountType' do
|
6
|
+
expect(Synapsis::Bank::AccountClass::PERSONAL).to eq 1
|
7
|
+
expect(Synapsis::Bank::AccountClass::BUSINESS).to eq 2
|
8
|
+
|
9
|
+
expect(Synapsis::Bank::AccountType::CHECKING).to eq 1
|
10
|
+
expect(Synapsis::Bank::AccountType::SAVINGS).to eq 2
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
4
14
|
context '#add' do
|
5
15
|
it 'adds a bank account' do
|
6
|
-
|
7
16
|
# We need to create a user because Synapse limits bank accounts to 5 per user.
|
8
17
|
user_params = {
|
9
18
|
email: Faker::Internet.email,
|
@@ -21,8 +30,8 @@ RSpec.describe Synapsis::Bank do
|
|
21
30
|
routing_num: '121000358',
|
22
31
|
nickname: 'Sourcepad Bank',
|
23
32
|
oauth_consumer_key: new_user.access_token,
|
24
|
-
account_type:
|
25
|
-
account_class:
|
33
|
+
account_type: Synapsis::Bank::AccountType::CHECKING,
|
34
|
+
account_class: Synapsis::Bank::AccountClass::PERSONAL
|
26
35
|
}
|
27
36
|
|
28
37
|
new_bank = Synapsis::Bank.add(bank_params)
|
@@ -31,6 +40,34 @@ RSpec.describe Synapsis::Bank do
|
|
31
40
|
expect(new_bank.name_on_account).to eq user_params[:fullname]
|
32
41
|
expect(new_bank.nickname).to eq bank_params[:nickname]
|
33
42
|
end
|
43
|
+
|
44
|
+
it 'adds a bank account (errors)' do
|
45
|
+
# We need to create a user because Synapse limits bank accounts to 5 per user.
|
46
|
+
user_params = {
|
47
|
+
email: Faker::Internet.email,
|
48
|
+
fullname: Faker::Name.name,
|
49
|
+
phonenumber: Faker::PhoneNumber.phone_number,
|
50
|
+
password: '5ourcep4d',
|
51
|
+
ip_address: '8.8.8.8'
|
52
|
+
}
|
53
|
+
|
54
|
+
new_user = Synapsis::User.create(user_params)
|
55
|
+
|
56
|
+
bank_params = {
|
57
|
+
fullname: 'NOT THE GUY',
|
58
|
+
account_num: '1111111112',
|
59
|
+
routing_num: '121000358',
|
60
|
+
nickname: 'Sourcepad Bank',
|
61
|
+
oauth_consumer_key: new_user.access_token,
|
62
|
+
account_type: Synapsis::Bank::AccountType::CHECKING,
|
63
|
+
account_class: Synapsis::Bank::AccountClass::PERSONAL
|
64
|
+
}
|
65
|
+
|
66
|
+
new_bank = Synapsis::Bank.add(bank_params)
|
67
|
+
|
68
|
+
expect(new_bank.class).to eq Synapsis::Error
|
69
|
+
expect(new_bank.reason).to be_a_kind_of String
|
70
|
+
end
|
34
71
|
end
|
35
72
|
|
36
73
|
context '#link' do
|
@@ -61,4 +98,34 @@ RSpec.describe Synapsis::Bank do
|
|
61
98
|
expect(new_bank.bank_name).to eq bank_params[:bank]
|
62
99
|
end
|
63
100
|
end
|
101
|
+
|
102
|
+
context '#remove' do
|
103
|
+
it 'removes the bank' do
|
104
|
+
user_params = {
|
105
|
+
email: Faker::Internet.email,
|
106
|
+
fullname: Faker::Name.name,
|
107
|
+
phonenumber: Faker::PhoneNumber.phone_number,
|
108
|
+
password: '5ourcep4d',
|
109
|
+
ip_address: '8.8.8.8'
|
110
|
+
}
|
111
|
+
|
112
|
+
new_user = Synapsis::User.create(user_params)
|
113
|
+
|
114
|
+
bank_params = {
|
115
|
+
fullname: new_user.fullname,
|
116
|
+
account_num: '1111111112',
|
117
|
+
routing_num: '121000358',
|
118
|
+
nickname: 'Sourcepad Bank',
|
119
|
+
oauth_consumer_key: new_user.access_token,
|
120
|
+
account_type: Synapsis::Bank::AccountType::CHECKING,
|
121
|
+
account_class: Synapsis::Bank::AccountClass::PERSONAL
|
122
|
+
}
|
123
|
+
|
124
|
+
new_bank = Synapsis::Bank.add(bank_params)
|
125
|
+
|
126
|
+
removed_bank = Synapsis::Bank.remove(new_bank.id, new_user.access_token)
|
127
|
+
|
128
|
+
expect(JSON.parse(removed_bank.body)['success']).to eq true
|
129
|
+
end
|
130
|
+
end
|
64
131
|
end
|
data/spec/synapsis/user_spec.rb
CHANGED
@@ -3,9 +3,11 @@ require 'spec_helper'
|
|
3
3
|
RSpec.describe Synapsis::User do
|
4
4
|
describe '#create' do
|
5
5
|
it 'creates a user account and returns the SynapsePay username, access_token and refresh_token' do
|
6
|
+
user_email = Faker::Internet.email
|
7
|
+
|
6
8
|
user_params = {
|
7
|
-
email:
|
8
|
-
fullname:
|
9
|
+
email: user_email,
|
10
|
+
fullname: user_email,
|
9
11
|
phonenumber: Faker::PhoneNumber.phone_number,
|
10
12
|
password: '5ourcep4d',
|
11
13
|
ip_address: '8.8.8.8'
|
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.
|
4
|
+
version: 0.0.4
|
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-04-
|
11
|
+
date: 2015-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -111,6 +111,7 @@ files:
|
|
111
111
|
- lib/synapsis.rb
|
112
112
|
- lib/synapsis/authentication.rb
|
113
113
|
- lib/synapsis/bank.rb
|
114
|
+
- lib/synapsis/error.rb
|
114
115
|
- lib/synapsis/user.rb
|
115
116
|
- lib/synapsis/utilities.rb
|
116
117
|
- lib/synapsis/version.rb
|