synapse_client 0.2.2 → 0.2.3

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: 131aec4ce3d48a03376e146f41f4092ca2fc1a35
4
- data.tar.gz: d0f75baee590de793d9f237dd8359cf8fb7520ed
3
+ metadata.gz: 98a03c3a76c3f5d2072a6d0304cc17b111aca582
4
+ data.tar.gz: 1b2923e7bf0fb2eb67e4ab3d7efb27dc3149e80e
5
5
  SHA512:
6
- metadata.gz: f8bfecdafeca230a074ec90e8fd0e304becebdc12508ed4ec42062712ab14e3b6f35ee4f967f664c4c1f422d25f71e1186944c9a035188bf2c737d59950789e1
7
- data.tar.gz: d234b470917a3da844ef552b3459a818ae986e03dddc598e268c1158e254ebe6406cc4e01ccc1b1e6f04b23fe948bfd9aafb55fb13646e2d6e944900a2ce9818
6
+ metadata.gz: d76d123e034c97d45f48e28c04f45ea31c0892883dccc6edc6941eeb63ffa27a465f2a3398a29870a1ed59929d9bcf8e33ca504046f3fd13b6c9f763a3a3f9eb
7
+ data.tar.gz: cb0e445e8f7a45ed0f17cdbbc0777d876c66015be4db7fa2db2fa501b6b929d38868c8cca5da4fdac7dcc5a4314c72ba070f48bffb2df2afb211b01f7939882d
data/README.md CHANGED
@@ -110,8 +110,9 @@ _See the specs for the most up to date usage demo._
110
110
 
111
111
  ## TODO (in order of priority)
112
112
 
113
+ * Add KYC Documents
114
+ * Logger config
113
115
  * MassPay
114
- * Refresh access tokens
115
116
  * Security Questions
116
117
  * Deposits
117
118
  * Withdrawals
@@ -15,6 +15,7 @@ require "synapse_client/refreshed_tokens"
15
15
  require "synapse_client/security_question"
16
16
  require "synapse_client/customer"
17
17
  require "synapse_client/util"
18
+ require "synapse_client/question_set"
18
19
  require "synapse_client/version"
19
20
 
20
21
  module SynapseClient
@@ -59,7 +59,28 @@ module SynapseClient
59
59
  response
60
60
  end
61
61
 
62
- # TODO
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
+
@@ -1,3 +1,3 @@
1
1
  module SynapseClient
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
@@ -8,8 +8,8 @@ require 'synapse_client'
8
8
  #
9
9
  def test_credentials
10
10
  Map.new({
11
- :client_id => "e06fa0f143a267c2ed8e",
12
- :client_secret => "f578105bf9ae03d9310e0af6f4637c1bf363998b",
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 => true)
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.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-06-11 00:00:00.000000000 Z
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