synapse_client 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/lib/synapse_client.rb +1 -0
- data/lib/synapse_client/customer.rb +22 -1
- data/lib/synapse_client/question_set.rb +40 -0
- data/lib/synapse_client/version.rb +1 -1
- data/spec/spec_helper.rb +41 -2
- data/spec/synapse_client_customer_spec.rb +45 -1
- 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: 98a03c3a76c3f5d2072a6d0304cc17b111aca582
|
4
|
+
data.tar.gz: 1b2923e7bf0fb2eb67e4ab3d7efb27dc3149e80e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d76d123e034c97d45f48e28c04f45ea31c0892883dccc6edc6941eeb63ffa27a465f2a3398a29870a1ed59929d9bcf8e33ca504046f3fd13b6c9f763a3a3f9eb
|
7
|
+
data.tar.gz: cb0e445e8f7a45ed0f17cdbbc0777d876c66015be4db7fa2db2fa501b6b929d38868c8cca5da4fdac7dcc5a4314c72ba070f48bffb2df2afb211b01f7939882d
|
data/README.md
CHANGED
data/lib/synapse_client.rb
CHANGED
@@ -59,7 +59,28 @@ module SynapseClient
|
|
59
59
|
response
|
60
60
|
end
|
61
61
|
|
62
|
-
|
62
|
+
#
|
63
|
+
def add_kyc_info(opts={})
|
64
|
+
response = SynapseClient.request(:post, "/api/v2/user/ssn/add", opts.merge({
|
65
|
+
:access_token => @access_token
|
66
|
+
}))
|
67
|
+
|
68
|
+
unless response.data["question_set"].nil?
|
69
|
+
return SynapseClient::QuestionSet.new(response.data.question_set)
|
70
|
+
else
|
71
|
+
return response
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def verify_kyc_info(opts={})
|
76
|
+
response = SynapseClient.request(:post, "/api/v2/user/ssn/answer", opts.merge({
|
77
|
+
:access_token => @access_token
|
78
|
+
}))
|
79
|
+
|
80
|
+
return response
|
81
|
+
end
|
82
|
+
|
83
|
+
# TODO
|
63
84
|
def login
|
64
85
|
# use http://synapsepay.readme.io/v1.0/docs/authentication-login
|
65
86
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
|
2
|
+
module SynapseClient
|
3
|
+
class QuestionSet
|
4
|
+
|
5
|
+
attr_accessor :id, :questions
|
6
|
+
|
7
|
+
def initialize(opts={})
|
8
|
+
@id = opts.id
|
9
|
+
@questions = opts.questions.map{|q| Question.new(q)}
|
10
|
+
end
|
11
|
+
|
12
|
+
def successful?
|
13
|
+
true
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
#
|
18
|
+
class Question
|
19
|
+
attr_reader :id, :question, :answers
|
20
|
+
|
21
|
+
def initialize(opts = {})
|
22
|
+
@id = opts.id
|
23
|
+
@question = opts.question
|
24
|
+
@answers = opts.answers.map{|a| Answer.new(a)}
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
#
|
29
|
+
class Answer
|
30
|
+
attr_reader :id, :answer
|
31
|
+
|
32
|
+
def initialize(opts = {})
|
33
|
+
@id = opts.id
|
34
|
+
@answer = opts.answer
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
data/spec/spec_helper.rb
CHANGED
@@ -8,8 +8,8 @@ require 'synapse_client'
|
|
8
8
|
#
|
9
9
|
def test_credentials
|
10
10
|
Map.new({
|
11
|
-
:client_id => "
|
12
|
-
:client_secret => "
|
11
|
+
:client_id => "S2JuLaRWro3PjrHJ3Wha",
|
12
|
+
:client_secret => "pWsKLv9pDiGPaBXCYfijOIlUOdXK24k8sjHd64EI",
|
13
13
|
:merchant_synapse_id => 536,
|
14
14
|
:merchant_oauth_token => "16688788f22d8b46a83711b42ad9b0dec39b09ce",
|
15
15
|
:merchant_refresh_token => "37e6f092e3c9a5ad0c1a2f2c62fec6ab8cb44808",
|
@@ -43,6 +43,45 @@ require 'synapse_client'
|
|
43
43
|
SynapseClient::Customer.create(dummy_customer_data)
|
44
44
|
end
|
45
45
|
|
46
|
+
def base_kyc_info
|
47
|
+
Map.new({
|
48
|
+
:birth_day => "05",
|
49
|
+
:birth_month => "08",
|
50
|
+
:birth_year => "1980",
|
51
|
+
:name_first => "Bob",
|
52
|
+
:name_last => "Barker",
|
53
|
+
:address_street_1 => "123 Animal Ct",
|
54
|
+
:address_postal_code => "90210",
|
55
|
+
:address_country_code => "US"
|
56
|
+
})
|
57
|
+
end
|
58
|
+
|
59
|
+
def failure_kyc_info
|
60
|
+
base_kyc_info.merge({
|
61
|
+
:ssn => "1111"
|
62
|
+
})
|
63
|
+
end
|
64
|
+
|
65
|
+
def unverified_kyc_info
|
66
|
+
base_kyc_info.merge({
|
67
|
+
:ssn => "3333"
|
68
|
+
})
|
69
|
+
end
|
70
|
+
|
71
|
+
def verified_kyc_info
|
72
|
+
base_kyc_info.merge({
|
73
|
+
:ssn => "2222"
|
74
|
+
})
|
75
|
+
end
|
76
|
+
|
77
|
+
def kyc_verify_values(question_set)
|
78
|
+
questions = question_set.questions.map{|q| {:question_id => q.id, :answer_id => q.answers.sample.id}}
|
79
|
+
Map.new({
|
80
|
+
:id => question_set.id,
|
81
|
+
:questions => questions
|
82
|
+
})
|
83
|
+
end
|
84
|
+
|
46
85
|
#
|
47
86
|
def dummy_add_bank_account_info
|
48
87
|
Map.new({
|
@@ -27,7 +27,7 @@ describe SynapseClient::Customer do
|
|
27
27
|
end
|
28
28
|
|
29
29
|
it "should successfully return a customer when a dup user is created and force_create is used" do
|
30
|
-
@dup_data = @dummy_customer_data.merge(:force_create =>
|
30
|
+
@dup_data = @dummy_customer_data.merge(:force_create => "no")
|
31
31
|
@customer_dup = SynapseClient::Customer.create(@dup_data)
|
32
32
|
|
33
33
|
expect(@customer_dup).to be_a SynapseClient::Customer
|
@@ -100,5 +100,49 @@ describe SynapseClient::Customer do
|
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
103
|
+
describe "adding failure kyc info for a customer" do
|
104
|
+
it "should return an error" do
|
105
|
+
response = @customer.add_kyc_info(failure_kyc_info)
|
106
|
+
|
107
|
+
expect(response.successful?).to be false
|
108
|
+
expect(response.error_msg).to be_a String
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
describe "adding unverified kyc info for a customer" do
|
113
|
+
it "should return ssn questions" do
|
114
|
+
response = @customer.add_kyc_info(unverified_kyc_info)
|
115
|
+
|
116
|
+
expect(response.successful?).to be true
|
117
|
+
|
118
|
+
expect(response).to be_a SynapseClient::QuestionSet
|
119
|
+
|
120
|
+
expect(response.questions).to be_an Array
|
121
|
+
expect(response.questions).not_to be_empty
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
describe "verifying ssn with question answers" do
|
126
|
+
it "should return success" do
|
127
|
+
response = @customer.add_kyc_info(unverified_kyc_info)
|
128
|
+
|
129
|
+
expect(response).to be_a SynapseClient::QuestionSet
|
130
|
+
|
131
|
+
verify_response = @customer.verify_kyc_info(kyc_verify_values(response))
|
132
|
+
|
133
|
+
expect(verify_response.successful?).to be true
|
134
|
+
expect(verify_response.success).to be true
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
describe "adding successful kyc info for a customer" do
|
139
|
+
it "should return success" do
|
140
|
+
response = @customer.add_kyc_info(verified_kyc_info)
|
141
|
+
|
142
|
+
expect(response.successful?).to be true
|
143
|
+
expect(response.success).to be true
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
103
147
|
end
|
104
148
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: synapse_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miles Matthias
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -212,6 +212,7 @@ files:
|
|
212
212
|
- lib/synapse_client/merchant.rb
|
213
213
|
- lib/synapse_client/mfa.rb
|
214
214
|
- lib/synapse_client/order.rb
|
215
|
+
- lib/synapse_client/question_set.rb
|
215
216
|
- lib/synapse_client/refreshed_tokens.rb
|
216
217
|
- lib/synapse_client/security_question.rb
|
217
218
|
- lib/synapse_client/util.rb
|