synapsis_v3 0.2.3 → 0.2.4
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 +4 -4
- data/lib/synapsis_v3.rb +1 -0
- data/lib/synapsis_v3/api_resource.rb +10 -5
- data/lib/synapsis_v3/user.rb +19 -22
- data/lib/synapsis_v3/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4ddc30a2ecbb6d13b32233a572c2d44829d5d94
|
4
|
+
data.tar.gz: dffafdb4732f83b7510261577884147d310f1186
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8fd0962b03fb8bcb29e7bf0587af61e8ca2b5e8ef38a89a921015f819c6f4975eaf17a78fd3c65ea4eda6a20fc2c73327cd8aa7385a2deb65759d69372a390f2
|
7
|
+
data.tar.gz: 09b9e4e1a246377e5c235b079eaf6606cda877156103ab69ae0464d705fb6b21756be629ccedbc1d0c2bdce49eecfbd6978c4c5d4cf9a7b67426dbc0c1ac3474
|
data/lib/synapsis_v3.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
class Synapsis::APIResource
|
2
|
-
def self.request(method, url, params,
|
2
|
+
def self.request(method, url, params, headers = {})
|
3
3
|
Synapsis.connection.send(method) do |req|
|
4
4
|
req.headers['Content-Type'] = 'application/json'
|
5
5
|
req.headers['X-SP-LANG'] = 'EN' # Set language to English
|
6
6
|
req.headers['X-SP-GATEWAY'] = "#{Synapsis.client_id}|#{Synapsis.client_secret}"
|
7
7
|
|
8
|
-
if oauth_key && fingerprint
|
9
|
-
req.headers['X-SP-USER'] = "#{oauth_key}|#{fingerprint}"
|
8
|
+
if headers[:oauth_key] && headers[:fingerprint]
|
9
|
+
req.headers['X-SP-USER'] = "#{headers[:oauth_key]}|#{headers[:fingerprint]}"
|
10
10
|
end
|
11
11
|
|
12
|
-
if ip_address
|
13
|
-
req.headers['X-SP-USER-IP'] = ip_address
|
12
|
+
if headers[:ip_address]
|
13
|
+
req.headers['X-SP-USER-IP'] = headers[:ip_address]
|
14
14
|
end
|
15
15
|
|
16
16
|
if Synapsis.environment == 'production'
|
@@ -28,6 +28,10 @@ class Synapsis::APIResource
|
|
28
28
|
name.partition('::').last.downcase
|
29
29
|
end
|
30
30
|
|
31
|
+
def self.class_name_pluralized
|
32
|
+
"#{class_name}s"
|
33
|
+
end
|
34
|
+
|
31
35
|
def class_name
|
32
36
|
self.class.name.partition('::').last.downcase
|
33
37
|
end
|
@@ -38,6 +42,7 @@ class Synapsis::APIResource
|
|
38
42
|
if response.success?
|
39
43
|
return parsed_response
|
40
44
|
else
|
45
|
+
puts parsed_response
|
41
46
|
raise Synapsis::Error.new(
|
42
47
|
error: parsed_response.error,
|
43
48
|
http_code: parsed_response.http_code,
|
data/lib/synapsis_v3/user.rb
CHANGED
@@ -34,32 +34,30 @@ class Synapsis::User < Synapsis::APIResource
|
|
34
34
|
return sign_in(params)
|
35
35
|
end
|
36
36
|
|
37
|
-
def self.
|
38
|
-
|
37
|
+
def self.add_document(payload, headers)
|
38
|
+
verify_kyc_new_url = "#{API_V3_NEW_PATH}users/#{headers[:synapse_id]}"
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
|
40
|
+
# Automatically convert all physical documents to base64 format
|
41
|
+
physical_doc_array = payload[:documents][0][:physical_docs]
|
42
|
+
physical_doc_array = convert_all_physical_documents_to_base64(physical_doc_array)
|
43
43
|
|
44
|
-
|
45
|
-
verify_kyc_url = "#{API_V3_PATH}#{class_name}/doc/verify"
|
44
|
+
response = request(:patch, verify_kyc_new_url, payload, headers)
|
46
45
|
|
47
|
-
response = request(:post, verify_kyc_url, params)
|
48
46
|
return_response(response)
|
49
47
|
end
|
50
48
|
|
51
|
-
def self.
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
49
|
+
def self.convert_all_physical_documents_to_base64(docs_array)
|
50
|
+
if docs_array
|
51
|
+
docs_array.map do |doc|
|
52
|
+
doc[:document_value] = convert_attachment_to_base_64(doc[:document_value])
|
53
|
+
end
|
54
|
+
end
|
57
55
|
end
|
58
56
|
|
59
|
-
def self.show(
|
60
|
-
show_user_url = "#{
|
57
|
+
def self.show(payload, headers)
|
58
|
+
show_user_url = "#{API_V3_NEW_PATH}#{class_name_pluralized}/#{headers[:synapse_id]}"
|
61
59
|
|
62
|
-
response = request(:
|
60
|
+
response = request(:get, show_user_url, payload, headers)
|
63
61
|
|
64
62
|
return_response(response)
|
65
63
|
end
|
@@ -80,8 +78,8 @@ class Synapsis::User < Synapsis::APIResource
|
|
80
78
|
return_response(response)
|
81
79
|
end
|
82
80
|
|
83
|
-
def self.convert_attachment_to_base_64(
|
84
|
-
file_type = MIME::Types.type_for(
|
81
|
+
def self.convert_attachment_to_base_64(doc)
|
82
|
+
file_type = MIME::Types.type_for(doc).first.content_type
|
85
83
|
|
86
84
|
if file_type == 'text/plain'
|
87
85
|
mime_padding = "data:text/csv;base64,"
|
@@ -89,11 +87,10 @@ class Synapsis::User < Synapsis::APIResource
|
|
89
87
|
mime_padding = "data:#{file_type};base64,"
|
90
88
|
end
|
91
89
|
|
92
|
-
|
93
|
-
|
94
|
-
return doc_params
|
90
|
+
return "#{mime_padding}#{Base64.encode64(File.open(doc, 'rb') { |f| f.read })}"
|
95
91
|
end
|
96
92
|
|
93
|
+
private_class_method :convert_all_physical_documents_to_base64
|
97
94
|
private_class_method :convert_attachment_to_base_64
|
98
95
|
end
|
99
96
|
|
data/lib/synapsis_v3/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: synapsis_v3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daryll Santos
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|