synapsis 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 +4 -4
- data/README.md +4 -0
- data/lib/synapsis/api_operations/create.rb +14 -0
- data/lib/synapsis/api_operations/edit.rb +14 -0
- data/lib/synapsis/api_operations/view.rb +13 -0
- data/lib/synapsis/api_resource.rb +23 -0
- data/lib/synapsis/bank.rb +40 -93
- data/lib/synapsis/deposit.rb +10 -0
- data/lib/synapsis/error.rb +1 -7
- data/lib/synapsis/order.rb +18 -0
- data/lib/synapsis/user.rb +18 -96
- data/lib/synapsis/utilities.rb +0 -2
- data/lib/synapsis/version.rb +1 -1
- data/lib/synapsis/withdrawal.rb +25 -0
- data/lib/synapsis.rb +17 -1
- data/spec/synapsis/api_resource_spec.rb +11 -0
- data/spec/synapsis/bank_link_spec.rb +59 -83
- data/spec/synapsis/bank_spec.rb +12 -49
- data/spec/synapsis/deposit_spec.rb +36 -0
- data/spec/synapsis/order_spec.rb +60 -0
- data/spec/synapsis/user_spec.rb +21 -37
- data/spec/synapsis/withdrawal_spec.rb +64 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14bcbb633ac4588d0c5c2aec128086bc1a76ec6a
|
4
|
+
data.tar.gz: 161ed76607fc6fe4a5336e23423f1e2d3f894d8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51b3daec18b29486ea45dd9b66b90cf73e6b88ec644ff8872eec042af25efc21b63558ce1c50ea3ffcce64d14bbf021faaa925fad6d7c2496d75738784df4d60
|
7
|
+
data.tar.gz: 55c997216c62ec91e687c59bcd651e6aca46e9d080e094a2a45706a160b481f64f76491bdb1fc6888562ee4dbacd9a61b551866708a5ec36a67fd32a46d73599
|
data/README.md
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
module Synapsis::APIOperations::Create
|
2
|
+
def create_request(params)
|
3
|
+
Synapsis.connection.post do |req|
|
4
|
+
req.headers['Content-Type'] = 'application/json'
|
5
|
+
req.url create_url
|
6
|
+
req.body = JSON.generate(params)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def create_url
|
11
|
+
"#{API_V2_PATH}#{class_name}/add"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Synapsis::APIOperations::Edit
|
2
|
+
def edit_request(params)
|
3
|
+
Synapsis.connection.post do |req|
|
4
|
+
req.headers['Content-Type'] = 'application/json'
|
5
|
+
req.url edit_url
|
6
|
+
req.body = JSON.generate(params)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def edit_url
|
11
|
+
"#{API_V2_PATH}#{class_name}/edit/"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Synapsis::APIOperations::View
|
2
|
+
def view_request(params)
|
3
|
+
Synapsis.connection.post do |req|
|
4
|
+
req.headers['Content-Type'] = 'application/json'
|
5
|
+
req.url view_url
|
6
|
+
req.body = JSON.generate(params)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def view_url
|
11
|
+
"#{API_V2_PATH}#{class_name}/show"
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class Synapsis::APIResource
|
2
|
+
def self.class_name
|
3
|
+
name.partition('::').last.downcase
|
4
|
+
end
|
5
|
+
|
6
|
+
def class_name
|
7
|
+
self.class.name.partition('::').last.downcase
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.return_response(response)
|
11
|
+
parsed_response = JSON.parse(response.body, object_class: Synapsis::Response)
|
12
|
+
|
13
|
+
if response.success?
|
14
|
+
return parsed_response
|
15
|
+
else
|
16
|
+
raise Synapsis::Error, parsed_response['reason']
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.parse_as_synapse_resource(response)
|
21
|
+
return JSON.parse(response.body, object_class: Synapsis::Response)
|
22
|
+
end
|
23
|
+
end
|
data/lib/synapsis/bank.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
class Synapsis::Bank
|
1
|
+
class Synapsis::Bank < Synapsis::APIResource
|
2
2
|
include Synapsis::Utilities
|
3
|
+
extend Synapsis::APIOperations::Create
|
3
4
|
|
4
5
|
module AccountClass
|
5
6
|
PERSONAL = 1
|
@@ -12,90 +13,70 @@ class Synapsis::Bank
|
|
12
13
|
end
|
13
14
|
|
14
15
|
attr_accessor :account_class,
|
15
|
-
:
|
16
|
+
:account_number_string,
|
16
17
|
:account_type,
|
17
|
-
:
|
18
|
-
:
|
19
|
-
:
|
18
|
+
:address,
|
19
|
+
:balance,
|
20
|
+
:bank_name,
|
21
|
+
:date,
|
22
|
+
:email,
|
23
|
+
:id,
|
24
|
+
:is_active,
|
25
|
+
:is_buyer_default,
|
26
|
+
:is_seller_default,
|
27
|
+
:is_verified,
|
28
|
+
:mfa_verifed,
|
29
|
+
:name_on_account,
|
20
30
|
:nickname,
|
21
|
-
:
|
22
|
-
:
|
23
|
-
:
|
24
|
-
:routing_num,
|
25
|
-
:username,
|
26
|
-
:access_token
|
31
|
+
:phone_number,
|
32
|
+
:resource_uri,
|
33
|
+
:routing_number_string
|
27
34
|
|
28
35
|
def self.add(params)
|
29
|
-
|
36
|
+
added_bank = create_request(params)
|
37
|
+
return_response(added_bank)
|
30
38
|
end
|
31
39
|
|
32
40
|
def self.link(params)
|
33
|
-
self.new(params).link
|
34
|
-
end
|
35
|
-
|
36
|
-
def self.view_linked_banks(params)
|
37
|
-
self.new(params).view_linked_banks
|
38
|
-
end
|
39
|
-
|
40
|
-
def initialize(params)
|
41
|
-
params.each do |k, v|
|
42
|
-
send("#{k}=", v)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def add
|
47
|
-
added_bank = Synapsis.connection.post do |req|
|
48
|
-
req.headers['Content-Type'] = 'application/json'
|
49
|
-
req.url "#{API_V2_PATH}bank/add/"
|
50
|
-
req.body = build_json_from_variable_hash
|
51
|
-
end
|
52
|
-
|
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
|
58
|
-
end
|
59
|
-
|
60
|
-
def link
|
61
41
|
partially_linked_bank = Synapsis.connection.post do |req|
|
62
42
|
req.headers['Content-Type'] = 'application/json'
|
63
43
|
req.url "#{API_V2_PATH}bank/login/?is_dev=yes"
|
64
|
-
req.body =
|
44
|
+
req.body = JSON.generate(params)
|
65
45
|
end
|
66
46
|
|
67
|
-
parsed_partially_linked_bank =
|
47
|
+
parsed_partially_linked_bank = parse_as_synapse_resource(partially_linked_bank)
|
68
48
|
|
69
|
-
if parsed_partially_linked_bank
|
70
|
-
if parsed_partially_linked_bank
|
71
|
-
return
|
49
|
+
if parsed_partially_linked_bank.success
|
50
|
+
if parsed_partially_linked_bank.banks # This happens if the added bank has no MFA
|
51
|
+
return parsed_partially_linked_bank
|
72
52
|
end
|
73
53
|
|
74
|
-
@access_token = parsed_partially_linked_bank
|
54
|
+
@access_token = parsed_partially_linked_bank.response.access_token
|
75
55
|
|
76
56
|
new_bank = Synapsis.connection.post do |req|
|
77
57
|
req.headers['Content-Type'] = 'application/json'
|
78
58
|
req.url "#{API_V2_PATH}bank/mfa/?is_dev=yes"
|
79
|
-
req.body =
|
59
|
+
req.body = JSON.generate(params.merge(access_token: @access_token))
|
80
60
|
end
|
81
61
|
|
82
|
-
|
83
|
-
|
62
|
+
parsed_new_bank = parse_as_synapse_resource(new_bank)
|
63
|
+
|
64
|
+
if parsed_new_bank.banks
|
65
|
+
return parsed_new_bank
|
84
66
|
else
|
85
|
-
Synapsis::Error.
|
86
|
-
"reason" => "Wrong MFA answer."
|
87
|
-
})
|
67
|
+
raise Synapsis::Error, 'Wrong MFA answer.'
|
88
68
|
end
|
89
69
|
else
|
90
|
-
|
91
|
-
Synapsis::Error.new({
|
92
|
-
"reason" => JSON.parse(partially_linked_bank.body)['message']
|
93
|
-
})
|
70
|
+
raise Synapsis::Error, JSON.parse(partially_linked_bank.body)['message']
|
94
71
|
end
|
95
72
|
end
|
96
73
|
|
74
|
+
def self.view_linked_banks(params)
|
75
|
+
self.new(params).view_linked_banks
|
76
|
+
end
|
77
|
+
|
97
78
|
def self.remove(bank_id, oauth_consumer_key)
|
98
|
-
|
79
|
+
response = Synapsis.connection.post do |req|
|
99
80
|
req.headers['Content-Type'] = 'application/json'
|
100
81
|
req.url "#{API_V2_PATH}bank/delete/"
|
101
82
|
req.body = JSON.generate(
|
@@ -103,6 +84,8 @@ class Synapsis::Bank
|
|
103
84
|
oauth_consumer_key: oauth_consumer_key
|
104
85
|
)
|
105
86
|
end
|
87
|
+
|
88
|
+
return_response(response)
|
106
89
|
end
|
107
90
|
|
108
91
|
def view_linked_banks
|
@@ -113,39 +96,3 @@ class Synapsis::Bank
|
|
113
96
|
end
|
114
97
|
end
|
115
98
|
end
|
116
|
-
|
117
|
-
class Synapsis::RetrievedBank
|
118
|
-
attr_accessor :account_class,
|
119
|
-
:account_number_string,
|
120
|
-
:account_type,
|
121
|
-
:address,
|
122
|
-
:balance,
|
123
|
-
:bank_name,
|
124
|
-
:date,
|
125
|
-
:email,
|
126
|
-
:id,
|
127
|
-
:is_active,
|
128
|
-
:is_buyer_default,
|
129
|
-
:is_seller_default,
|
130
|
-
:is_verified,
|
131
|
-
:mfa_verifed,
|
132
|
-
:name_on_account,
|
133
|
-
:nickname,
|
134
|
-
:phone_number,
|
135
|
-
:resource_uri,
|
136
|
-
:routing_number_string
|
137
|
-
|
138
|
-
def initialize(synapse_response)
|
139
|
-
parsed_response = JSON.parse(synapse_response.body)
|
140
|
-
|
141
|
-
if parsed_response['banks']
|
142
|
-
parsed_response['banks'].first.each do |k, v|
|
143
|
-
send("#{k}=", v)
|
144
|
-
end
|
145
|
-
elsif parsed_response['bank']
|
146
|
-
parsed_response['bank'].each do |k, v|
|
147
|
-
send("#{k}=", v)
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|
151
|
-
end
|
data/lib/synapsis/error.rb
CHANGED
@@ -0,0 +1,18 @@
|
|
1
|
+
class Synapsis::Order < Synapsis::APIResource
|
2
|
+
include Synapsis::Utilities
|
3
|
+
extend Synapsis::APIOperations::Create
|
4
|
+
|
5
|
+
def self.add(params)
|
6
|
+
response = create_request(params)
|
7
|
+
return_response(response)
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.synapse_fee(transaction_amount)
|
11
|
+
if transaction_amount > 10
|
12
|
+
0.25
|
13
|
+
else
|
14
|
+
0.1
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
data/lib/synapsis/user.rb
CHANGED
@@ -1,113 +1,35 @@
|
|
1
|
-
class Synapsis::User
|
1
|
+
class Synapsis::User < Synapsis::APIResource
|
2
2
|
include Synapsis::Utilities
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
:password,
|
7
|
-
:ip_address,
|
8
|
-
:phonenumber,
|
9
|
-
:access_token,
|
10
|
-
:refresh_token,
|
11
|
-
:username
|
3
|
+
extend Synapsis::APIOperations::Create
|
4
|
+
extend Synapsis::APIOperations::Edit
|
5
|
+
extend Synapsis::APIOperations::View
|
12
6
|
|
13
7
|
def self.create(params)
|
14
|
-
|
8
|
+
response = create_request(params.merge(client_credentials))
|
9
|
+
return_response(response)
|
15
10
|
end
|
16
11
|
|
17
12
|
def self.edit(params)
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
def self.view(params)
|
22
|
-
self.new({}).view(params)
|
23
|
-
end
|
24
|
-
|
25
|
-
def initialize(params)
|
26
|
-
params.each do |k, v|
|
27
|
-
send("#{k}=", v)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def create
|
32
|
-
response = Synapsis.connection.post do |req|
|
33
|
-
req.headers['Content-Type'] = 'application/json'
|
34
|
-
req.url "#{API_V2_PATH}user/create/"
|
35
|
-
req.body = build_json_from_params
|
36
|
-
end
|
37
|
-
|
38
|
-
if JSON.parse(response.body)['success']
|
39
|
-
update_attributes(response)
|
40
|
-
return self
|
41
|
-
else
|
42
|
-
return Synapsis::Error.new(JSON.parse(response.body))
|
43
|
-
end
|
13
|
+
response = edit_request(params)
|
14
|
+
return_response(response)
|
44
15
|
end
|
45
16
|
|
46
|
-
def
|
47
|
-
response =
|
48
|
-
|
49
|
-
req.url "#{API_V2_PATH}user/edit/"
|
50
|
-
req.body = JSON.generate(params)
|
51
|
-
end
|
52
|
-
|
53
|
-
|
54
|
-
if JSON.parse(response.body)['success']
|
55
|
-
update_attributes(response)
|
56
|
-
return self
|
57
|
-
else
|
58
|
-
return Synapsis::Error.new(JSON.parse(response.body))
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
def view(oauth_token = @access_token)
|
63
|
-
response = Synapsis.connection.post do |req|
|
64
|
-
req.headers['Content-Type'] = 'application/json'
|
65
|
-
req.url "#{API_V2_PATH}user/show/"
|
66
|
-
req.body = JSON.generate({ 'oauth_consumer_key' => oauth_token})
|
67
|
-
end
|
68
|
-
|
69
|
-
if response.success?
|
70
|
-
return Synapsis::RetrievedUser.new(response)
|
71
|
-
else
|
72
|
-
return response
|
73
|
-
end
|
17
|
+
def self.view(oauth_token)
|
18
|
+
response = view_request('oauth_consumer_key' => oauth_token)
|
19
|
+
return_response(response)
|
74
20
|
end
|
75
21
|
|
76
22
|
private
|
77
23
|
|
78
|
-
def
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
if parsed_response['user']
|
85
|
-
@fullname = parsed_response['user']['fullname']
|
86
|
-
end
|
24
|
+
def self.client_credentials
|
25
|
+
{
|
26
|
+
client_id: Synapsis.client_id,
|
27
|
+
client_secret: Synapsis.client_secret
|
28
|
+
}
|
87
29
|
end
|
88
30
|
|
89
|
-
|
90
|
-
|
91
|
-
:accept_gratuity,
|
92
|
-
:balance,
|
93
|
-
:email,
|
94
|
-
:fullname,
|
95
|
-
:has_avatar,
|
96
|
-
:phone_number,
|
97
|
-
:resource_uri,
|
98
|
-
:seller_details,
|
99
|
-
:user_id,
|
100
|
-
:username,
|
101
|
-
:visit_count,
|
102
|
-
:visit_message
|
103
|
-
|
104
|
-
def initialize(synapse_response)
|
105
|
-
parsed_response = JSON.parse(synapse_response.body)
|
106
|
-
|
107
|
-
parsed_response['user'].each do |k, v|
|
108
|
-
send("#{k}=", v)
|
109
|
-
end
|
110
|
-
end
|
31
|
+
def self.create_url
|
32
|
+
"#{API_V2_PATH}user/create/"
|
111
33
|
end
|
112
34
|
end
|
113
35
|
|
data/lib/synapsis/utilities.rb
CHANGED
data/lib/synapsis/version.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
class Synapsis::Withdrawal < Synapsis::APIResource
|
2
|
+
include Synapsis::Utilities
|
3
|
+
extend Synapsis::APIOperations::Create
|
4
|
+
extend Synapsis::APIOperations::View
|
5
|
+
|
6
|
+
# Note: If you do not supply the bank_id, Synapse will attempt to withdraw from the primary bank.
|
7
|
+
def self.create(params)
|
8
|
+
response = create_request(params)
|
9
|
+
|
10
|
+
return_response(response)
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.view(params)
|
14
|
+
response = view_request(params)
|
15
|
+
|
16
|
+
return_response(response)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
# SynapseAPI's URI for withdrawals is /withdraw, not /withdrawal
|
22
|
+
def self.class_name
|
23
|
+
'withdraw'
|
24
|
+
end
|
25
|
+
end
|
data/lib/synapsis.rb
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
# External dependencies
|
2
2
|
require "faraday"
|
3
3
|
|
4
|
-
#
|
4
|
+
# Namespacing
|
5
|
+
|
6
|
+
module Synapsis
|
7
|
+
module APIOperations; end
|
8
|
+
end
|
5
9
|
|
10
|
+
# Internal dependencies
|
6
11
|
require "synapsis/version"
|
7
12
|
require "synapsis/utilities"
|
13
|
+
require "synapsis/api_resource"
|
14
|
+
require "synapsis/api_operations/create"
|
15
|
+
require "synapsis/api_operations/edit"
|
16
|
+
require "synapsis/api_operations/view"
|
8
17
|
require "synapsis/authentication"
|
9
18
|
require "synapsis/user"
|
10
19
|
require "synapsis/bank"
|
20
|
+
require "synapsis/withdrawal"
|
21
|
+
require "synapsis/deposit"
|
22
|
+
require "synapsis/order"
|
11
23
|
require "synapsis/error"
|
12
24
|
|
25
|
+
API_V2_PATH = 'api/v2/'
|
26
|
+
|
13
27
|
module Synapsis
|
14
28
|
class << self
|
15
29
|
attr_accessor :client_id, :client_secret, :environment
|
@@ -34,4 +48,6 @@ module Synapsis
|
|
34
48
|
yield(self)
|
35
49
|
end
|
36
50
|
end
|
51
|
+
|
52
|
+
class Response < OpenStruct; end
|
37
53
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Synapsis::APIResource do
|
4
|
+
context '.class_name' do
|
5
|
+
it 'gets the class name, without the Synapsis namespace' do
|
6
|
+
class Synapsis::Thingie < Synapsis::APIResource; end
|
7
|
+
|
8
|
+
expect(Synapsis::Thingie.class_name).to eq 'thingie'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -25,13 +25,13 @@ RSpec.describe Synapsis::Bank do
|
|
25
25
|
|
26
26
|
new_bank = Synapsis::Bank.link(bank_params)
|
27
27
|
|
28
|
-
expect(new_bank.name_on_account).to eq user_params[:fullname]
|
29
|
-
expect(new_bank.bank_name).to eq bank_params[:bank]
|
28
|
+
expect(new_bank.banks.first.name_on_account).to eq user_params[:fullname]
|
29
|
+
expect(new_bank.banks.first.bank_name).to eq bank_params[:bank]
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
33
|
context 'errors' do
|
34
|
-
it 'bad username
|
34
|
+
it 'bad username raises a SynapsisError' do
|
35
35
|
new_user = Synapsis::User.create(user_params)
|
36
36
|
|
37
37
|
bank_params = {
|
@@ -43,28 +43,7 @@ RSpec.describe Synapsis::Bank do
|
|
43
43
|
mfa: 'test_answer'
|
44
44
|
}
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
expect(new_bank.class).to eq Synapsis::Error
|
49
|
-
expect(new_bank.reason).to be_a_kind_of String
|
50
|
-
end
|
51
|
-
|
52
|
-
it 'bad password returns a SynapsisError' do
|
53
|
-
new_user = Synapsis::User.create(user_params)
|
54
|
-
|
55
|
-
bank_params = {
|
56
|
-
username: 'synapse_good',
|
57
|
-
password: 'WRONG PASSWORD',
|
58
|
-
pin: '1234',
|
59
|
-
oauth_consumer_key: new_user.access_token,
|
60
|
-
bank: 'US Bank',
|
61
|
-
mfa: 'test_answer'
|
62
|
-
}
|
63
|
-
|
64
|
-
new_bank = Synapsis::Bank.link(bank_params)
|
65
|
-
|
66
|
-
expect(new_bank.class).to eq Synapsis::Error
|
67
|
-
expect(new_bank.reason).to be_a_kind_of String
|
46
|
+
expect{ Synapsis::Bank.link(bank_params) }.to raise_error(Synapsis::Error).with_message('The input you have entered is not valid. Please check your entry and try again.')
|
68
47
|
end
|
69
48
|
|
70
49
|
it 'bad mfa answer returns a SynapsisError' do
|
@@ -78,10 +57,7 @@ RSpec.describe Synapsis::Bank do
|
|
78
57
|
mfa: 'WRONG MFA ANSWER'
|
79
58
|
}
|
80
59
|
|
81
|
-
|
82
|
-
|
83
|
-
expect(new_bank.class).to eq Synapsis::Error
|
84
|
-
expect(new_bank.reason).to be_a_kind_of String
|
60
|
+
expect{ Synapsis::Bank.link(bank_params) }.to raise_error(Synapsis::Error).with_message('Wrong MFA answer.')
|
85
61
|
end
|
86
62
|
|
87
63
|
xit 'bad PIN returns a SynapsisError--pending since trying test data with a wrong PIN still completes the linking process' do
|
@@ -118,8 +94,8 @@ RSpec.describe Synapsis::Bank do
|
|
118
94
|
|
119
95
|
new_bank = Synapsis::Bank.link(bank_params)
|
120
96
|
|
121
|
-
expect(new_bank.name_on_account).to eq user_params[:fullname]
|
122
|
-
expect(new_bank.bank_name).to eq bank_params[:bank]
|
97
|
+
expect(new_bank.banks.first.name_on_account).to eq user_params[:fullname]
|
98
|
+
expect(new_bank.banks.first.bank_name).to eq bank_params[:bank]
|
123
99
|
end
|
124
100
|
|
125
101
|
context 'errors' do
|
@@ -135,28 +111,7 @@ RSpec.describe Synapsis::Bank do
|
|
135
111
|
mfa: 'test_answer'
|
136
112
|
}
|
137
113
|
|
138
|
-
|
139
|
-
|
140
|
-
expect(new_bank.class).to eq Synapsis::Error
|
141
|
-
expect(new_bank.reason).to be_a_kind_of String
|
142
|
-
end
|
143
|
-
|
144
|
-
it 'bad password returns a SynapsisError' do
|
145
|
-
new_user = Synapsis::User.create(user_params)
|
146
|
-
|
147
|
-
bank_params = {
|
148
|
-
username: 'synapse_code',
|
149
|
-
password: 'WRONG PASSWORD',
|
150
|
-
pin: '1234',
|
151
|
-
oauth_consumer_key: new_user.access_token,
|
152
|
-
bank: 'Ally',
|
153
|
-
mfa: 'test_answer'
|
154
|
-
}
|
155
|
-
|
156
|
-
new_bank = Synapsis::Bank.link(bank_params)
|
157
|
-
|
158
|
-
expect(new_bank.class).to eq Synapsis::Error
|
159
|
-
expect(new_bank.reason).to be_a_kind_of String
|
114
|
+
expect { Synapsis::Bank.link(bank_params) }.to raise_error(Synapsis::Error).with_message('Please Enter the Correct Username and Password')
|
160
115
|
end
|
161
116
|
|
162
117
|
it 'bad mfa answer returns a SynapsisError' do
|
@@ -170,10 +125,7 @@ RSpec.describe Synapsis::Bank do
|
|
170
125
|
mfa: 'WRONG MFA ANSWER'
|
171
126
|
}
|
172
127
|
|
173
|
-
|
174
|
-
|
175
|
-
expect(new_bank.class).to eq Synapsis::Error
|
176
|
-
expect(new_bank.reason).to be_a_kind_of String
|
128
|
+
expect { Synapsis::Bank.link(bank_params) }.to raise_error(Synapsis::Error).with_message('Wrong MFA answer.')
|
177
129
|
end
|
178
130
|
end
|
179
131
|
end
|
@@ -192,8 +144,9 @@ RSpec.describe Synapsis::Bank do
|
|
192
144
|
|
193
145
|
new_bank = Synapsis::Bank.link(bank_params)
|
194
146
|
|
195
|
-
|
196
|
-
expect(new_bank.
|
147
|
+
# Upcase since Synapse automatically downcases titles such as "MD, PHD" (it becomes Md or Phd)
|
148
|
+
expect(new_bank.banks.first.name_on_account.upcase).to eq user_params[:fullname].upcase
|
149
|
+
expect(new_bank.banks.first.bank_name).to eq bank_params[:bank]
|
197
150
|
end
|
198
151
|
end
|
199
152
|
|
@@ -208,26 +161,7 @@ RSpec.describe Synapsis::Bank do
|
|
208
161
|
bank: 'Capital One 360'
|
209
162
|
}
|
210
163
|
|
211
|
-
|
212
|
-
|
213
|
-
expect(new_bank.class).to eq Synapsis::Error
|
214
|
-
expect(new_bank.reason).to be_a_kind_of String
|
215
|
-
end
|
216
|
-
|
217
|
-
it 'bad password returns a SynapsisError' do
|
218
|
-
new_user = Synapsis::User.create(user_params)
|
219
|
-
|
220
|
-
bank_params = {
|
221
|
-
username: 'synapsenomfa',
|
222
|
-
password: 'test12345',
|
223
|
-
oauth_consumer_key: new_user.access_token,
|
224
|
-
bank: 'Capital One 360'
|
225
|
-
}
|
226
|
-
|
227
|
-
new_bank = Synapsis::Bank.link(bank_params)
|
228
|
-
|
229
|
-
expect(new_bank.class).to eq Synapsis::Error
|
230
|
-
expect(new_bank.reason).to be_a_kind_of String
|
164
|
+
expect { Synapsis::Bank.link(bank_params) }.to raise_error(Synapsis::Error).with_message('The username or password provided were not correct.')
|
231
165
|
end
|
232
166
|
|
233
167
|
it 'bad mfa answer returns a SynapsisError' do
|
@@ -241,12 +175,54 @@ RSpec.describe Synapsis::Bank do
|
|
241
175
|
mfa: 'WRONG MFA ANSWER'
|
242
176
|
}
|
243
177
|
|
244
|
-
|
245
|
-
|
246
|
-
expect(new_bank.class).to eq Synapsis::Error
|
247
|
-
expect(new_bank.reason).to be_a_kind_of String
|
178
|
+
expect { Synapsis::Bank.link(bank_params) }.to raise_error(Synapsis::Error).with_message('Wrong MFA answer.')
|
248
179
|
end
|
249
180
|
end
|
250
181
|
end
|
182
|
+
|
183
|
+
context 'multiple bank linkages' do
|
184
|
+
xit 'works' do
|
185
|
+
new_user = Synapsis::User.create(user_params)
|
186
|
+
|
187
|
+
first_bank_params = {
|
188
|
+
username: 'synapse_code',
|
189
|
+
password: 'test1234',
|
190
|
+
oauth_consumer_key: new_user.access_token,
|
191
|
+
bank: 'Ally',
|
192
|
+
mfa: 'test_answer'
|
193
|
+
}
|
194
|
+
|
195
|
+
first_bank = Synapsis::Bank.new(first_bank_params).link
|
196
|
+
|
197
|
+
expect(first_bank.name_on_account).to eq user_params[:fullname]
|
198
|
+
expect(first_bank.bank_name).to eq first_bank_params[:bank]
|
199
|
+
|
200
|
+
bank_params = {
|
201
|
+
fullname: new_user.fullname,
|
202
|
+
account_num: '1111111112',
|
203
|
+
routing_num: '121000358',
|
204
|
+
nickname: 'Sourcepad Bank',
|
205
|
+
oauth_consumer_key: new_user.access_token,
|
206
|
+
account_type: Synapsis::Bank::AccountType::CHECKING,
|
207
|
+
account_class: Synapsis::Bank::AccountClass::PERSONAL
|
208
|
+
}
|
209
|
+
|
210
|
+
new_bank = Synapsis::Bank.add(bank_params)
|
211
|
+
|
212
|
+
second_bank_params = {
|
213
|
+
username: 'synapse_good',
|
214
|
+
password: 'test1234',
|
215
|
+
oauth_consumer_key: new_user.access_token,
|
216
|
+
bank: 'PNC',
|
217
|
+
mfa: 'test_answer'
|
218
|
+
}
|
219
|
+
|
220
|
+
second_bank = Synapsis::Bank.new(second_bank_params).link
|
221
|
+
|
222
|
+
expect(second_bank.name_on_account).to eq user_params[:fullname]
|
223
|
+
expect(second_bank.bank_name).to eq second_bank_params[:bank]
|
224
|
+
|
225
|
+
end
|
226
|
+
end
|
251
227
|
end
|
252
228
|
end
|
data/spec/synapsis/bank_spec.rb
CHANGED
@@ -11,33 +11,29 @@ RSpec.describe Synapsis::Bank do
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
context '#add' do
|
15
|
-
it 'adds a bank account' do
|
16
|
-
|
17
|
-
user_params = {
|
18
|
-
email: Faker::Internet.email,
|
19
|
-
fullname: Faker::Name.name,
|
20
|
-
phonenumber: Faker::PhoneNumber.phone_number,
|
21
|
-
password: '5ourcep4d',
|
22
|
-
ip_address: '8.8.8.8'
|
23
|
-
}
|
14
|
+
context '#add/ #remove' do
|
15
|
+
it 'adds and removes a bank account' do
|
16
|
+
random_persons_access_token = 'dcd234d9d9fb55ad9711c4c41e254868ef3768d4'
|
24
17
|
|
25
|
-
|
18
|
+
viewed_user = Synapsis::User.view(random_persons_access_token)
|
26
19
|
|
27
20
|
bank_params = {
|
28
|
-
fullname:
|
21
|
+
fullname: viewed_user.user.fullname,
|
29
22
|
account_num: '1111111112',
|
30
23
|
routing_num: '121000358',
|
31
24
|
nickname: 'Sourcepad Bank',
|
32
|
-
oauth_consumer_key:
|
25
|
+
oauth_consumer_key: random_persons_access_token,
|
33
26
|
account_type: Synapsis::Bank::AccountType::CHECKING,
|
34
27
|
account_class: Synapsis::Bank::AccountClass::PERSONAL
|
35
28
|
}
|
36
29
|
|
37
30
|
new_bank = Synapsis::Bank.add(bank_params)
|
31
|
+
expect(new_bank.bank.name_on_account).to eq viewed_user.user.fullname
|
32
|
+
expect(new_bank.bank.nickname).to eq bank_params[:nickname]
|
38
33
|
|
39
|
-
|
40
|
-
|
34
|
+
removed_bank = Synapsis::Bank.remove(new_bank.bank.id, random_persons_access_token)
|
35
|
+
|
36
|
+
expect(removed_bank.success).to eq true
|
41
37
|
end
|
42
38
|
|
43
39
|
it 'adds a bank account (errors)' do
|
@@ -62,40 +58,7 @@ RSpec.describe Synapsis::Bank do
|
|
62
58
|
account_class: Synapsis::Bank::AccountClass::PERSONAL
|
63
59
|
}
|
64
60
|
|
65
|
-
|
66
|
-
|
67
|
-
expect(new_bank.class).to eq Synapsis::Error
|
68
|
-
expect(new_bank.reason).to be_a_kind_of String
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
context '#remove' do
|
73
|
-
it 'removes the bank' do
|
74
|
-
user_params = {
|
75
|
-
email: Faker::Internet.email,
|
76
|
-
fullname: Faker::Name.name,
|
77
|
-
phonenumber: Faker::PhoneNumber.phone_number,
|
78
|
-
password: '5ourcep4d',
|
79
|
-
ip_address: '8.8.8.8'
|
80
|
-
}
|
81
|
-
|
82
|
-
new_user = Synapsis::User.create(user_params)
|
83
|
-
|
84
|
-
bank_params = {
|
85
|
-
fullname: new_user.fullname,
|
86
|
-
account_num: '1111111112',
|
87
|
-
routing_num: '121000358',
|
88
|
-
nickname: 'Sourcepad Bank',
|
89
|
-
oauth_consumer_key: new_user.access_token,
|
90
|
-
account_type: Synapsis::Bank::AccountType::CHECKING,
|
91
|
-
account_class: Synapsis::Bank::AccountClass::PERSONAL
|
92
|
-
}
|
93
|
-
|
94
|
-
new_bank = Synapsis::Bank.add(bank_params)
|
95
|
-
|
96
|
-
removed_bank = Synapsis::Bank.remove(new_bank.id, new_user.access_token)
|
97
|
-
|
98
|
-
expect(JSON.parse(removed_bank.body)['success']).to eq true
|
61
|
+
expect { Synapsis::Bank.add(bank_params) }.to raise_error(Synapsis::Error).with_message('Because of security reasons you can only add a bank account that belongs to you and is in your name.')
|
99
62
|
end
|
100
63
|
end
|
101
64
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Synapsis::Deposit do
|
4
|
+
context '#add' do
|
5
|
+
let!(:deposit_params) {{
|
6
|
+
amount: 100,
|
7
|
+
oauth_consumer_key: '3bdb5790692d06983d8cb0feb40365886631e52d',
|
8
|
+
bank_id: 2182
|
9
|
+
}}
|
10
|
+
|
11
|
+
context 'happy path' do
|
12
|
+
it 'constructs the correct deposit object' do
|
13
|
+
deposit_response = Synapsis::Deposit.create(deposit_params)
|
14
|
+
|
15
|
+
DEPOSIT_SPECIFIC_PARAMS = ['amount', 'bank', 'date_created', 'id', 'resource_uri', 'status', 'status_url', 'user_id']
|
16
|
+
|
17
|
+
(DEPOSIT_SPECIFIC_PARAMS - ['status_url']).each do |x|
|
18
|
+
expect(deposit_response.deposit.send(x.to_s.gsub('@', ''))).not_to be_nil
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'errors' do
|
24
|
+
it 'create a Synapsis::Error object' do
|
25
|
+
# Missing amount
|
26
|
+
expect { Synapsis::Deposit.create(deposit_params.merge(amount: 0)) }.to raise_error(Synapsis::Error).with_message('Missing amount')
|
27
|
+
|
28
|
+
# OAuth error
|
29
|
+
expect { Synapsis::Deposit.create(deposit_params.merge(oauth_consumer_key: 'WRONG!!!')) }.to raise_error(Synapsis::Error).with_message('Error in OAuth Authentication.')
|
30
|
+
|
31
|
+
# Wrong bank ID (user does not own bank_id 1)
|
32
|
+
expect{ Synapsis::Deposit.create(deposit_params.merge(bank_id: 1))}.to raise_error(Synapsis::Error).with_message('Bank account not associated with the user')
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Synapsis::Order do
|
4
|
+
context '#add' do
|
5
|
+
let!(:delta) { 0.001 }
|
6
|
+
let!(:buyer_consumer_key) { '3bdb5790692d06983d8cb0feb40365886631e52d' }
|
7
|
+
let!(:seller_consumer_key) { '325ea5c0c3a7927280c54ed3ad310c02b45129d8' }
|
8
|
+
let!(:order_params) {{
|
9
|
+
amount: 1,
|
10
|
+
oauth_consumer_key: buyer_consumer_key,
|
11
|
+
seller_id: 3437
|
12
|
+
}}
|
13
|
+
|
14
|
+
context 'happy path' do
|
15
|
+
it 'constructs the correct Order object' do
|
16
|
+
order = Synapsis::Order.add(order_params)
|
17
|
+
|
18
|
+
ORDER_PARAMS = ['account_type', 'amount', 'date', 'date_settled', 'discount', 'facilitator_fee', 'fee', 'id', 'is_buyer', 'note', 'resource_uri', 'seller', 'status', 'status_uri', 'ticket_number', 'tip', 'total']
|
19
|
+
|
20
|
+
(ORDER_PARAMS - ['status_uri']).each do |x|
|
21
|
+
expect(order.order.send(x)).not_to be_nil
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'subtracts the money from the consumer\'s account and adds to the seller\'s account' do
|
26
|
+
buyer_account_balance = Synapsis::User.view(buyer_consumer_key).user.balance
|
27
|
+
seller_account_balance = Synapsis::User.view(seller_consumer_key).user.balance
|
28
|
+
|
29
|
+
order = Synapsis::Order.add(order_params)
|
30
|
+
|
31
|
+
new_buyer_account_balance = Synapsis::User.view(buyer_consumer_key).user.balance
|
32
|
+
new_seller_account_balance = Synapsis::User.view(seller_consumer_key).user.balance
|
33
|
+
|
34
|
+
expect(new_buyer_account_balance).to be_within(delta).of(buyer_account_balance - order_params[:amount])
|
35
|
+
expect(new_seller_account_balance).to be_within(seller_account_balance + order_params[:amount] - Synapsis::Order.synapse_fee(order_params[:amount]))
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'subtracts the money from the consumer\'s account and adds to the seller\'s account, with a charge of ' do
|
39
|
+
buyer_account_balance = Synapsis::User.view(buyer_consumer_key).user.balance
|
40
|
+
seller_account_balance = Synapsis::User.view(seller_consumer_key).user.balance
|
41
|
+
|
42
|
+
order = Synapsis::Order.add(order_params.merge(amount: 10.1))
|
43
|
+
|
44
|
+
new_buyer_account_balance = Synapsis::User.view(buyer_consumer_key).user.balance
|
45
|
+
new_seller_account_balance = Synapsis::User.view(seller_consumer_key).user.balance
|
46
|
+
|
47
|
+
expect(new_buyer_account_balance).to be_within(delta).of(buyer_account_balance - 10.1)
|
48
|
+
expect(new_seller_account_balance).to be_within(delta).of(seller_account_balance + 10.1- 0.25)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context 'no amount specified' do
|
53
|
+
it 'raises a Synapsis::Error' do
|
54
|
+
expect{ Synapsis::Order.add(order_params.merge(oauth_consumer_key: 'WRONG!')) }.to raise_error(Synapsis::Error).with_message('Error in OAuth Authentication.')
|
55
|
+
expect{ Synapsis::Order.add(order_params.merge(amount: 0)) }.to raise_error(Synapsis::Error).with_message('Missing amount')
|
56
|
+
expect{ Synapsis::Order.add(order_params.merge(seller_id: 0)) }.to raise_error(Synapsis::Error).with_message('Missing seller_id')
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
data/spec/synapsis/user_spec.rb
CHANGED
@@ -3,7 +3,7 @@ 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
|
6
|
+
user_email = Faker::Internet.email[0, 29] # Limit 30 characters
|
7
7
|
|
8
8
|
user_params = {
|
9
9
|
email: user_email,
|
@@ -15,11 +15,10 @@ RSpec.describe Synapsis::User do
|
|
15
15
|
|
16
16
|
new_synapse_user = Synapsis::User.create(user_params)
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
expect(new_synapse_user.refresh_token).to be_a_kind_of String
|
18
|
+
['access_token', 'oauth_consumer_key', 'expires_in',
|
19
|
+
'reason', 'refresh_token', 'success', 'username', 'user_id'].each do |k|
|
20
|
+
expect(new_synapse_user.send(k)).not_to be_nil
|
21
|
+
end
|
23
22
|
end
|
24
23
|
|
25
24
|
it 'returns an error if the params are bad' do
|
@@ -31,9 +30,7 @@ RSpec.describe Synapsis::User do
|
|
31
30
|
ip_address: '8.8.8.8'
|
32
31
|
}
|
33
32
|
|
34
|
-
|
35
|
-
|
36
|
-
expect(new_synapse_user).to be_a_kind_of Synapsis::Error
|
33
|
+
expect { Synapsis::User.create(user_params) }.to raise_error(Synapsis::Error).with_message('Add full name to create an account')
|
37
34
|
end
|
38
35
|
end
|
39
36
|
|
@@ -47,7 +44,7 @@ RSpec.describe Synapsis::User do
|
|
47
44
|
|
48
45
|
edited_user = Synapsis::User.edit(edit_user_attributes)
|
49
46
|
|
50
|
-
expect(edited_user.fullname).to eq edit_user_attributes['fullname']
|
47
|
+
expect(edited_user.user.fullname).to eq edit_user_attributes['fullname']
|
51
48
|
end
|
52
49
|
|
53
50
|
it 'returns an error if the update didnt work' do
|
@@ -57,42 +54,29 @@ RSpec.describe Synapsis::User do
|
|
57
54
|
'oauth_consumer_key' => oauth_token
|
58
55
|
}
|
59
56
|
|
60
|
-
|
61
|
-
|
62
|
-
expect(response.reason).to be_a_kind_of String
|
57
|
+
expect { Synapsis::User.edit(edit_user_attributes) }.to raise_error(Synapsis::Error).with_message('Error in OAuth Authentication.')
|
63
58
|
end
|
64
59
|
end
|
65
60
|
|
66
|
-
describe '
|
67
|
-
|
68
|
-
|
69
|
-
|
61
|
+
describe '.view' do
|
62
|
+
context 'happy path' do
|
63
|
+
it 'retrieves the user and returns their information in Struct form' do
|
64
|
+
oauth_token = 'c7eda20ff7b2554c0bed2ad596ac5dfeb33124e1'
|
65
|
+
response = Synapsis::User.view(oauth_token)
|
70
66
|
|
71
|
-
|
67
|
+
user_attributes = [:accept_gratuity, :balance, :email, :fullname, :has_avatar, :phone_number, :seller_details, :user_id, :username, :visit_count, :visit_message]
|
72
68
|
|
73
|
-
|
74
|
-
|
69
|
+
user_attributes.each do |user_attribute|
|
70
|
+
expect(response.user.send(user_attribute)).not_to be_nil
|
71
|
+
end
|
75
72
|
end
|
76
73
|
end
|
77
|
-
end
|
78
|
-
|
79
|
-
describe 'infrastructure' do
|
80
|
-
it 'builds' do
|
81
|
-
result = '{"email":"test5@synapsepay.com","fullname":"Test Account","ip_address":"11.111.11.11","phonenumber":"123456789","client_id":"ce65d5ce9116ae4c77bb","client_secret":"41877da204b32dbee3095033069ed81bcf512154"}'
|
82
|
-
|
83
|
-
parsed_result = JSON.parse(result)
|
84
|
-
|
85
|
-
user_params = {
|
86
|
-
email: 'test5@synapsepay.com',
|
87
|
-
fullname: 'Test Account',
|
88
|
-
ip_address: '11.111.11.11',
|
89
|
-
phonenumber: '123456789'
|
90
|
-
}
|
91
74
|
|
92
|
-
|
75
|
+
context 'error' do
|
76
|
+
it ' raises an Error' do
|
77
|
+
oauth_token = 'WRONG!!!'
|
93
78
|
|
94
|
-
|
95
|
-
expect(built[k]).to eq(parsed_result[k])
|
79
|
+
expect { Synapsis::User.view(oauth_token) }.to raise_error(Synapsis::Error).with_message('Error in OAuth Authentication.')
|
96
80
|
end
|
97
81
|
end
|
98
82
|
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Synapsis::Withdrawal do
|
4
|
+
context '#add' do
|
5
|
+
let!(:withdrawal_params) {{
|
6
|
+
amount: 100,
|
7
|
+
oauth_consumer_key: '3bdb5790692d06983d8cb0feb40365886631e52d',
|
8
|
+
bank_id: 2182
|
9
|
+
}}
|
10
|
+
|
11
|
+
context 'happy path' do
|
12
|
+
it 'constructs the correct Withdrawal object' do
|
13
|
+
withdrawal_response = Synapsis::Withdrawal.create(withdrawal_params)
|
14
|
+
|
15
|
+
WITHDRAWAL_SPECIFIC_PARAMS = ['amount', 'bank', 'date_created', 'fee', 'id', 'instant_credit', 'resource_uri', 'status', 'status_url', 'user_id']
|
16
|
+
|
17
|
+
(WITHDRAWAL_SPECIFIC_PARAMS - ['status_url']).each do |x|
|
18
|
+
expect(withdrawal_response.withdrawal.send(x.to_s.gsub('@', ''))).not_to be_nil
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'errors' do
|
24
|
+
it 'create a Synapsis::Error object' do
|
25
|
+
# Missing amount
|
26
|
+
expect { Synapsis::Withdrawal.create(withdrawal_params.merge(amount: 0)) }.to raise_error(Synapsis::Error).with_message('Missing amount')
|
27
|
+
|
28
|
+
# OAuth error
|
29
|
+
expect { Synapsis::Withdrawal.create(withdrawal_params.merge(oauth_consumer_key: 'WRONG!!!')) }.to raise_error(Synapsis::Error).with_message('Error in OAuth Authentication.')
|
30
|
+
|
31
|
+
# Wrong bank ID (user does not own bank_id 1)
|
32
|
+
expect{ Synapsis::Withdrawal.create(withdrawal_params.merge(bank_id: 1))}.to raise_error(Synapsis::Error).with_message('Bank account not associated with the user')
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context '#view' do
|
38
|
+
context 'no ID' do
|
39
|
+
let!(:withdrawal_params) {{
|
40
|
+
oauth_consumer_key: '3bdb5790692d06983d8cb0feb40365886631e52d'
|
41
|
+
}}
|
42
|
+
|
43
|
+
context 'happy path' do
|
44
|
+
xit 'returns an array of the user\'s withdrawals' do
|
45
|
+
all_withdrawals = Synapsis::Withdrawal.view(withdrawal_params)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'with ID' do
|
51
|
+
let!(:withdrawal_params) {{
|
52
|
+
id: 354,
|
53
|
+
oauth_consumer_key: '3bdb5790692d06983d8cb0feb40365886631e52d'
|
54
|
+
}}
|
55
|
+
|
56
|
+
context 'happy path' do
|
57
|
+
xit 'returns an array of the user\'s withdrawals' do
|
58
|
+
pending
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
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.7
|
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-
|
11
|
+
date: 2015-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -109,19 +109,30 @@ files:
|
|
109
109
|
- README.md
|
110
110
|
- Rakefile
|
111
111
|
- lib/synapsis.rb
|
112
|
+
- lib/synapsis/api_operations/create.rb
|
113
|
+
- lib/synapsis/api_operations/edit.rb
|
114
|
+
- lib/synapsis/api_operations/view.rb
|
115
|
+
- lib/synapsis/api_resource.rb
|
112
116
|
- lib/synapsis/authentication.rb
|
113
117
|
- lib/synapsis/bank.rb
|
118
|
+
- lib/synapsis/deposit.rb
|
114
119
|
- lib/synapsis/error.rb
|
120
|
+
- lib/synapsis/order.rb
|
115
121
|
- lib/synapsis/user.rb
|
116
122
|
- lib/synapsis/utilities.rb
|
117
123
|
- lib/synapsis/version.rb
|
124
|
+
- lib/synapsis/withdrawal.rb
|
118
125
|
- spec/config.yml
|
119
126
|
- spec/spec_helper.rb
|
120
127
|
- spec/support/json_helpers.rb
|
128
|
+
- spec/synapsis/api_resource_spec.rb
|
121
129
|
- spec/synapsis/authentication_spec.rb
|
122
130
|
- spec/synapsis/bank_link_spec.rb
|
123
131
|
- spec/synapsis/bank_spec.rb
|
132
|
+
- spec/synapsis/deposit_spec.rb
|
133
|
+
- spec/synapsis/order_spec.rb
|
124
134
|
- spec/synapsis/user_spec.rb
|
135
|
+
- spec/synapsis/withdrawal_spec.rb
|
125
136
|
- synapsis.gemspec
|
126
137
|
homepage: ''
|
127
138
|
licenses:
|
@@ -151,7 +162,11 @@ test_files:
|
|
151
162
|
- spec/config.yml
|
152
163
|
- spec/spec_helper.rb
|
153
164
|
- spec/support/json_helpers.rb
|
165
|
+
- spec/synapsis/api_resource_spec.rb
|
154
166
|
- spec/synapsis/authentication_spec.rb
|
155
167
|
- spec/synapsis/bank_link_spec.rb
|
156
168
|
- spec/synapsis/bank_spec.rb
|
169
|
+
- spec/synapsis/deposit_spec.rb
|
170
|
+
- spec/synapsis/order_spec.rb
|
157
171
|
- spec/synapsis/user_spec.rb
|
172
|
+
- spec/synapsis/withdrawal_spec.rb
|