smile-identity-core 1.2.1 → 2.0.0
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/.github/workflows/release.yml +18 -0
- data/.github/workflows/test.yml +36 -0
- data/.gitignore +3 -0
- data/.rubocop.yml +6 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +71 -30
- data/Gemfile +3 -1
- data/Gemfile.lock +35 -7
- data/README.md +33 -464
- data/Rakefile +5 -3
- data/bin/console +4 -3
- data/examples/biometric_kyc.rb +67 -0
- data/examples/business_verification.rb +37 -0
- data/examples/document_verification.rb +74 -0
- data/examples/enhanced_kyc.rb +39 -0
- data/examples/example-project/Gemfile +7 -0
- data/examples/example-project/Gemfile.lock +25 -0
- data/examples/example-project/README.md +14 -0
- data/examples/example-project/sample.env +4 -0
- data/examples/example-project/smart_bank.rb +216 -0
- data/examples/smart_selfie_authentication.rb +56 -0
- data/lib/smile-identity-core/business_verification.rb +109 -0
- data/lib/smile-identity-core/constants/env.rb +13 -0
- data/lib/smile-identity-core/constants/image_type.rb +14 -0
- data/lib/smile-identity-core/constants/job_type.rb +13 -0
- data/lib/smile-identity-core/id_api.rb +35 -58
- data/lib/smile-identity-core/signature.rb +15 -36
- data/lib/smile-identity-core/utilities.rb +28 -55
- data/lib/smile-identity-core/validations.rb +32 -0
- data/lib/smile-identity-core/version.rb +4 -1
- data/lib/smile-identity-core/web_api.rb +92 -136
- data/lib/smile-identity-core.rb +11 -5
- data/smile-identity-core.gemspec +26 -21
- metadata +82 -22
- data/.travis.yml +0 -11
@@ -0,0 +1,74 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'smile-identity-core'
|
4
|
+
|
5
|
+
# See https://docs.smileidentity.com/server-to-server/ruby/products/document-verification for
|
6
|
+
# how to setup and retrieve configuation values for the WebApi class.
|
7
|
+
|
8
|
+
# Initialize
|
9
|
+
partner_id = '<Put your partner ID here>'; # login to the Smile Identity portal to view your partner id
|
10
|
+
default_callback = '<Put your default callback url here>'
|
11
|
+
api_key = '<Put your API key here>'; # copy your API key from the Smile Identity portal
|
12
|
+
sid_server = '<0 | 1>'; # Use '0' for the sandbox server, use '1' for production server
|
13
|
+
|
14
|
+
connection = SmileIdentityCore::WebApi.new(partner_id, default_callback, api_key, sid_server)
|
15
|
+
|
16
|
+
# Create required tracking parameters
|
17
|
+
partner_params = {
|
18
|
+
user_id: '<put your unique ID for the user here>',
|
19
|
+
job_id: '<put your unique job ID here>',
|
20
|
+
job_type: 6
|
21
|
+
}
|
22
|
+
|
23
|
+
# Create image list
|
24
|
+
# image_type_id (Integer) - This infers to either a file or a base64 encoded image, but not both.
|
25
|
+
# 0 - Selfie image jpg or png (if you have the full path of the selfie)
|
26
|
+
# 2 - Selfie image jpg or png base64 encoded (if you have the base64image string of the selfie)
|
27
|
+
# 4 - Liveness image jpg or png (if you have the full path of the liveness image)
|
28
|
+
# 6 - Liveness image jpg or png base64 encoded (if you have the base64image string of the liveness image)
|
29
|
+
# 1 - Front of ID document image jpg or png (if you have the full path of the selfie)
|
30
|
+
# 3 - Front of ID document image jpg or png base64 encoded (if you have the base64image string of the selfie)
|
31
|
+
# 5 - Back of ID document image jpg or png (if you have the full path of the selfie)
|
32
|
+
# 7 - Back of ID document image jpg or png base64 encoded (if you have the base64image string of the selfie)
|
33
|
+
image_details = [
|
34
|
+
{
|
35
|
+
image_type_id: '<0 | 2>',
|
36
|
+
image: '<full path to selfie image or base64image string>'
|
37
|
+
},
|
38
|
+
{ # Not required if you don't require proof of life (note photo of photo check
|
39
|
+
# will still be performed on the uploaded selfie)
|
40
|
+
image_type_id: '<4 | 6>',
|
41
|
+
image: '<full path to liveness image or base64 image string>'
|
42
|
+
},
|
43
|
+
{
|
44
|
+
image_type_id: '<1 | 3>',
|
45
|
+
image: '<full path to front of id document image or base64image string>'
|
46
|
+
},
|
47
|
+
{ # Optional, only use if you're uploading the back of the id document image
|
48
|
+
image_type_id: '<5 | 7>',
|
49
|
+
image: '<full path to back of id document image or base64image string>'
|
50
|
+
}
|
51
|
+
]
|
52
|
+
|
53
|
+
# The ID Document Information
|
54
|
+
id_info = {
|
55
|
+
country: '<2-letter country code>', # The country where ID document was issued
|
56
|
+
id_type: '<id type>' # The ID document type
|
57
|
+
}
|
58
|
+
|
59
|
+
# Set options for the job
|
60
|
+
options = {
|
61
|
+
# Set to true if you want to get the job result in sync (in addition to the result
|
62
|
+
# been sent to your callback). If set to false, result is sent to callback url only.
|
63
|
+
return_job_status: '<true | false>',
|
64
|
+
# Set to true to receive all of the updates you would otherwise have received in your
|
65
|
+
# callback as opposed to only the final result. You must set return_job_status to true to use this flag.
|
66
|
+
return_history: '<true | false>',
|
67
|
+
# Set to true to receive links to the selfie and the photo it was compared to.
|
68
|
+
# You must set return_job_status to true to use this flag.
|
69
|
+
return_image_links: '<true |false>',
|
70
|
+
signature: true
|
71
|
+
}
|
72
|
+
|
73
|
+
# Submit the job
|
74
|
+
connection.submit_job(partner_params, image_details, id_info, options)
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'smile-identity-core'
|
4
|
+
|
5
|
+
# See https://docs.smileidentity.com/server-to-server/ruby/products/enhanced-kyc for
|
6
|
+
# how to setup and retrieve configuation values for the IDApi class.
|
7
|
+
|
8
|
+
# Initialize
|
9
|
+
partner_id = '<Your partner ID>'; # login to the Smile Identity portal to view your partner id
|
10
|
+
api_key = '<Your API key>'; # copy your API key from the Smile Identity portal
|
11
|
+
sid_server = '<0 or 1>'; # Use '0' for the sandbox server, use '1' for production server
|
12
|
+
|
13
|
+
connection = SmileIdentityCore::IDApi.new(partner_id, api_key, sid_server)
|
14
|
+
|
15
|
+
# Create required tracking parameters
|
16
|
+
partner_params = {
|
17
|
+
job_id: '<put your unique job ID here>',
|
18
|
+
user_id: '<put your unique ID for the user here>',
|
19
|
+
job_type: 5
|
20
|
+
}
|
21
|
+
|
22
|
+
# Create ID info
|
23
|
+
id_info = {
|
24
|
+
first_name: '<first name>',
|
25
|
+
last_name: '<surname>',
|
26
|
+
country: '<2-letter country code>',
|
27
|
+
id_type: '<id type>',
|
28
|
+
id_number: '<valid id number>',
|
29
|
+
dob: '<date of birth>', # yyyy-mm-dd
|
30
|
+
phone_number: '<phone number>'
|
31
|
+
}
|
32
|
+
|
33
|
+
# Set the options for the job
|
34
|
+
options = {
|
35
|
+
signature: true
|
36
|
+
}
|
37
|
+
|
38
|
+
# Submit the job
|
39
|
+
connection.submit_job(partner_params, id_info, options)
|
@@ -0,0 +1,25 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
dotenv (2.8.1)
|
5
|
+
ethon (0.15.0)
|
6
|
+
ffi (>= 1.15.0)
|
7
|
+
ffi (1.15.5)
|
8
|
+
rubyzip (1.3.0)
|
9
|
+
securerandom (0.2.0)
|
10
|
+
smile-identity-core (1.2.1)
|
11
|
+
rubyzip (~> 1.2, >= 1.2.3)
|
12
|
+
typhoeus (~> 1.0, >= 1.0.1)
|
13
|
+
typhoeus (1.4.0)
|
14
|
+
ethon (>= 0.9.0)
|
15
|
+
|
16
|
+
PLATFORMS
|
17
|
+
x86_64-darwin-20
|
18
|
+
|
19
|
+
DEPENDENCIES
|
20
|
+
dotenv
|
21
|
+
securerandom
|
22
|
+
smile-identity-core
|
23
|
+
|
24
|
+
BUNDLED WITH
|
25
|
+
2.2.6
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Example Project
|
2
|
+
|
3
|
+
This project is an example implementation of the Smile Identity Ruby SDK on the server side. The example implements [Enhanced KYC](https://docs.smileidentity.com/products/identity-lookup), [Biometric KYC](https://docs.smileidentity.com/products/biometric-kyc), [Document Verification](https://docs.smileidentity.com/products/document-verification) and [SmartSelfieTM Authentication](https://docs.smileidentity.com/products/biometric-authentication) job types.
|
4
|
+
|
5
|
+
## Setup
|
6
|
+
|
7
|
+
1. Run `bundle install` to install gem dependencies
|
8
|
+
2. Copy sample.env to .env and set secrets as appropriate
|
9
|
+
|
10
|
+
```bash
|
11
|
+
cp sample.env .env
|
12
|
+
```
|
13
|
+
|
14
|
+
3. Run `ruby smart_bank.rb` to call the different job types
|
@@ -0,0 +1,216 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'dotenv/load'
|
4
|
+
require 'smile-identity-core'
|
5
|
+
require 'securerandom'
|
6
|
+
require 'json'
|
7
|
+
|
8
|
+
# SmartBank is a fictional banking app
|
9
|
+
class SmartBank
|
10
|
+
attr_reader :partner_id, :default_callback, :api_key, :sid_server, :user_id, :job_id
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
# login to the Smile Identity portal to view your partner id
|
14
|
+
@partner_id = ENV['SMILE_PARTNER_ID']
|
15
|
+
# See https://docs.smileidentity.com/server-to-server/ruby/products/biometric-kyc#create-a-callback-endpoint
|
16
|
+
@default_callback = ENV['SMILE_JOB_CALLBACK_URL']
|
17
|
+
@api_key = ENV['SMILE_API_KEY'] # copy your API key from the Smile Identity portal
|
18
|
+
@sid_server = ENV['SMILE_SERVER_ENVIRONMENT'] # Use '0' for the sandbox server, use '1' for production server
|
19
|
+
@user_id = SecureRandom.uuid # your unique ID for the user
|
20
|
+
@job_id = SecureRandom.uuid # your unique job ID
|
21
|
+
end
|
22
|
+
|
23
|
+
# Public: Makes a request to query the Identity Information for an individual using
|
24
|
+
# their ID number from one of our supported ID Types.
|
25
|
+
#
|
26
|
+
# Returns a verification result Hash
|
27
|
+
def perform_enhanced_kyc
|
28
|
+
connection = SmileIdentityCore::IDApi.new(partner_id, api_key, sid_server)
|
29
|
+
|
30
|
+
# Create ID info
|
31
|
+
id_info = {
|
32
|
+
first_name: 'John',
|
33
|
+
last_name: 'Doe',
|
34
|
+
country: 'GH', # 2-letter country code>
|
35
|
+
id_type: 'PASSPORT',
|
36
|
+
id_number: 'G0000000',
|
37
|
+
dob: '1992-12-07', # yyyy-mm-dd
|
38
|
+
phone_number: '00000000000'
|
39
|
+
}
|
40
|
+
|
41
|
+
# Set the options for the job
|
42
|
+
options = {
|
43
|
+
signature: true
|
44
|
+
}
|
45
|
+
|
46
|
+
# Submit the job
|
47
|
+
JSON.parse(connection.submit_job(partner_params(5), id_info, options))
|
48
|
+
end
|
49
|
+
|
50
|
+
# Public: Makes a request to verify the ID information of a user by comparing
|
51
|
+
# the user's SmartSelfie to either the photo of the user on file in an ID authority
|
52
|
+
# database or a photo of their ID card.
|
53
|
+
#
|
54
|
+
# Returns a verification result Hash
|
55
|
+
def perform_biometric_kyc
|
56
|
+
# Create image list
|
57
|
+
image_details = [
|
58
|
+
{
|
59
|
+
image_type_id: SmileIdentityCore::ImageType::SELFIE_IMAGE_FILE,
|
60
|
+
image: '/path/to/selfie_image.jpeg'
|
61
|
+
},
|
62
|
+
{ # Not required if you don't require proof of life (note photo of photo check will
|
63
|
+
# still be performed on the uploaded selfie)
|
64
|
+
image_type_id: SmileIdentityCore::ImageType::LIVENESS_IMAGE_FILE,
|
65
|
+
image: '/path/to/liveness_image.jpeg'
|
66
|
+
}
|
67
|
+
]
|
68
|
+
|
69
|
+
# Create ID number info
|
70
|
+
id_info = {
|
71
|
+
first_name: 'John',
|
72
|
+
last_name: 'Doe',
|
73
|
+
country: 'GH', # 2-letter country code
|
74
|
+
id_type: 'PASSPORT',
|
75
|
+
id_number: 'G0000000',
|
76
|
+
dob: '1992-12-07', # yyyy-mm-dd
|
77
|
+
entered: 'true' # must be a string
|
78
|
+
}
|
79
|
+
|
80
|
+
# Submit the job
|
81
|
+
web_api_connection.submit_job(partner_params(1), image_details, id_info, job_options)
|
82
|
+
end
|
83
|
+
|
84
|
+
# Public: Makes a request to verify the authenticity of Identity documents submitted by users and
|
85
|
+
# confirm that the document actually belongs to the user by comparing the user's selfie to the
|
86
|
+
# photo on the document.
|
87
|
+
#
|
88
|
+
# Returns a verification result Hash
|
89
|
+
def perform_document_verification
|
90
|
+
# Create image list
|
91
|
+
image_details = [
|
92
|
+
{
|
93
|
+
image_type_id: SmileIdentityCore::ImageType::SELFIE_IMAGE_FILE,
|
94
|
+
image: '/path/to/selfie_image.jpeg'
|
95
|
+
},
|
96
|
+
{ # Not required if you don't require proof of life (note photo of photo
|
97
|
+
# check will still be performed on the uploaded selfie)
|
98
|
+
image_type_id: SmileIdentityCore::ImageType::LIVENESS_IMAGE_FILE,
|
99
|
+
image: '/path/to/liveness_image.jpeg'
|
100
|
+
},
|
101
|
+
{
|
102
|
+
image_type_id: SmileIdentityCore::ImageType::ID_CARD_IMAGE_FILE,
|
103
|
+
image: '/path/to/front_document_image.jpeg'
|
104
|
+
},
|
105
|
+
{ # Optional, only use if you're uploading the back of the id document image
|
106
|
+
image_type_id: SmileIdentityCore::ImageType::ID_CARD_BACK_IMAGE_FILE,
|
107
|
+
image: '/path/to/back_document_image.jpeg'
|
108
|
+
}
|
109
|
+
]
|
110
|
+
|
111
|
+
# The ID Document Information
|
112
|
+
id_info = {
|
113
|
+
country: 'GH', # The country where ID document was issued
|
114
|
+
id_type: 'PASSPORT' # The ID document type
|
115
|
+
}
|
116
|
+
|
117
|
+
# Submit the job
|
118
|
+
web_api_connection.submit_job(partner_params(6), image_details, id_info, job_options)
|
119
|
+
end
|
120
|
+
|
121
|
+
# Public: Makes a request to verify that an existing user is really the person attempting
|
122
|
+
# to access your system or service. SmartSelfie Authentication can be used as part of a multi-factor
|
123
|
+
# authentication system.
|
124
|
+
#
|
125
|
+
# Returns a verification result Hash
|
126
|
+
def perform_smart_selfie_authentication
|
127
|
+
# Create required tracking parameters
|
128
|
+
partner_params = {
|
129
|
+
user_id: '512c9c37-a689-4959-a620-bed75fb41344', # previously registered user's user_id
|
130
|
+
job_id: SecureRandom.uuid, # new unique job ID
|
131
|
+
job_type: SmileIdentityCore::JobType::SMART_SELFIE_REGISTRATION
|
132
|
+
}
|
133
|
+
|
134
|
+
# Create image list
|
135
|
+
image_details = [
|
136
|
+
{
|
137
|
+
image_type_id: SmileIdentityCore::ImageType::SELFIE_IMAGE_FILE,
|
138
|
+
image: '/path/to/selfie_image.jpeg'
|
139
|
+
},
|
140
|
+
{ # Not required if you don't require proof of life
|
141
|
+
# (note photo of photo check will still be performed on the uploaded selfie)
|
142
|
+
image_type_id: SmileIdentityCore::ImageType::LIVENESS_IMAGE_FILE,
|
143
|
+
image: '/path/to/liveness_image.jpeg'
|
144
|
+
}
|
145
|
+
]
|
146
|
+
|
147
|
+
# Submit the job
|
148
|
+
web_api_connection.submit_job(partner_params, image_details, nil, job_options)
|
149
|
+
end
|
150
|
+
|
151
|
+
private
|
152
|
+
|
153
|
+
def partner_params(job_type)
|
154
|
+
{
|
155
|
+
user_id: user_id,
|
156
|
+
job_id: job_id,
|
157
|
+
job_type: job_type
|
158
|
+
}
|
159
|
+
end
|
160
|
+
|
161
|
+
def web_api_connection
|
162
|
+
return @web_api_connection if defined?(@web_api_connection)
|
163
|
+
|
164
|
+
@web_api_connection = SmileIdentityCore::WebApi.new(partner_id, default_callback, api_key, sid_server)
|
165
|
+
end
|
166
|
+
|
167
|
+
def job_options
|
168
|
+
{
|
169
|
+
# Set to true if you want to get the job result in sync (in addition to the result been sent to your callback).
|
170
|
+
# If set to false, result is sent to callback url only.
|
171
|
+
return_job_status: true,
|
172
|
+
# Set to true to receive all of the updates you would otherwise have received in your callback as opposed to
|
173
|
+
# only the final result. You must set return_job_status to true to use this flag.
|
174
|
+
return_history: false,
|
175
|
+
# Set to true to receive links to the selfie and the photo it was compared to.
|
176
|
+
# You must set return_job_status to true to use this flag.
|
177
|
+
return_image_links: true,
|
178
|
+
signature: true
|
179
|
+
}
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
# Enhanced KYC
|
184
|
+
smart_bank = SmartBank.new
|
185
|
+
enhanced_kyc_response = smart_bank.perform_enhanced_kyc
|
186
|
+
enhanced_kyc_response['success'] # => true
|
187
|
+
enhanced_kyc_response['result']['PartnerParams']['job_id'] # job_id
|
188
|
+
enhanced_kyc_response['result']['PartnerParams']['user_id'] # user_id
|
189
|
+
enhanced_kyc_response['result']['PartnerParams']['job_type'] # => 5
|
190
|
+
# See https://docs.smileidentity.com/products/for-individuals-kyc/identity-lookup#return-values
|
191
|
+
# for the full JSON response interpretation
|
192
|
+
|
193
|
+
# Biometric KYC
|
194
|
+
bio_kyc_response = smart_bank.perform_biometric_kyc
|
195
|
+
bio_kyc_response['success'] # => true
|
196
|
+
bio_kyc_response['result']['PartnerParams']['job_id'] # job_id
|
197
|
+
bio_kyc_response['result']['PartnerParams']['user_id'] # user_id
|
198
|
+
bio_kyc_response['result']['PartnerParams']['job_type'] # => 1
|
199
|
+
|
200
|
+
# Document verification
|
201
|
+
doc_verification_response = smart_bank.perform_document_verification
|
202
|
+
doc_verification_response['success'] # => true
|
203
|
+
doc_verification_response['result']['PartnerParams']['job_id'] # job_id
|
204
|
+
doc_verification_response['result']['PartnerParams']['user_id'] # user_id
|
205
|
+
doc_verification_response['result']['PartnerParams']['job_type'] # => 6
|
206
|
+
|
207
|
+
# Smart Selfie Authentication
|
208
|
+
smart_selfie_auth_response = smart_bank.perform_smart_selfie_authentication
|
209
|
+
smart_selfie_auth_response['success'] # => true
|
210
|
+
smart_selfie_auth_response['result']['PartnerParams']['job_id'] # job_id
|
211
|
+
smart_selfie_auth_response['result']['PartnerParams']['user_id'] # user_id
|
212
|
+
smart_selfie_auth_response['result']['PartnerParams']['job_type'] # => 2
|
213
|
+
|
214
|
+
# All jobs submitted with a selfie has the same return values, result codes and texts. For example
|
215
|
+
# see https://docs.smileidentity.com/products/for-individuals-kyc/biometric-kyc#return-values.
|
216
|
+
# Save the returned user_id and job_id in your DB as you would need them later when you call other services.
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'smile-identity-core'
|
4
|
+
|
5
|
+
# See https://docs.smileidentity.com/server-to-server/ruby/products/smartselfie-tm-authentication for
|
6
|
+
# how to setup and retrieve configuation values for the WebApi class.
|
7
|
+
|
8
|
+
# Initialize
|
9
|
+
partner_id = '<Put your partner ID here>'; # login to the Smile Identity portal to view your partner id
|
10
|
+
default_callback = '<Put your default callback url here>'
|
11
|
+
api_key = '<Put your API key here>'; # copy your API key from the Smile Identity portal
|
12
|
+
sid_server = '<0 | 1>'; # Use '0' for the sandbox server, use '1' for production server
|
13
|
+
|
14
|
+
connection = SmileIdentityCore::WebApi.new(partner_id, default_callback, api_key, sid_server)
|
15
|
+
|
16
|
+
# Create required tracking parameters
|
17
|
+
partner_params = {
|
18
|
+
user_id: '<put previously registered user"s user_id here>',
|
19
|
+
job_id: '<put your unique job ID here>',
|
20
|
+
job_type: 2
|
21
|
+
}
|
22
|
+
|
23
|
+
# Create image list
|
24
|
+
# image_type_id Integer
|
25
|
+
# 0 - Selfie image jpg or png (if you have the full path of the selfie)
|
26
|
+
# 2 - Selfie image jpg or png base64 encoded (if you have the base64image string of the selfie)
|
27
|
+
# 4 - Liveness image jpg or png (if you have the full path of the liveness image)
|
28
|
+
# 6 - Liveness image jpg or png base64 encoded (if you have the base64image string of the liveness image)
|
29
|
+
image_details = [
|
30
|
+
{
|
31
|
+
image_type_id: '<0 | 2>',
|
32
|
+
image: '<full path to selfie image or base64image string>'
|
33
|
+
},
|
34
|
+
{ # Not required if you don't require proof of life (note photo of photo check will
|
35
|
+
# still be performed on the uploaded selfie)
|
36
|
+
image_type_id: '<4 | 6>',
|
37
|
+
image: '<full path to liveness image or base64 image string>'
|
38
|
+
}
|
39
|
+
]
|
40
|
+
|
41
|
+
# Set options for the job
|
42
|
+
options = {
|
43
|
+
# Set to true if you want to get the job result in sync (in addition to the result been sent to your callback).
|
44
|
+
# If set to false, result is sent to callback url only.
|
45
|
+
return_job_status: '<true | false>',
|
46
|
+
# Set to true to receive all of the updates you would otherwise have received in your callback as opposed
|
47
|
+
# to only the final result. You must set return_job_status to true to use this flag.
|
48
|
+
return_history: '<true | false>',
|
49
|
+
# Set to true to receive links to the selfie and the photo it was
|
50
|
+
# compared to. You must set return_job_status to true to use this flag.
|
51
|
+
return_image_links: '<true | false>',
|
52
|
+
signature: true
|
53
|
+
}
|
54
|
+
|
55
|
+
# Submit the job
|
56
|
+
connection.submit_job(partner_params, image_details, nil, options)
|
@@ -0,0 +1,109 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
require 'base64'
|
5
|
+
require 'openssl'
|
6
|
+
require 'uri'
|
7
|
+
require 'typhoeus'
|
8
|
+
require_relative 'validations'
|
9
|
+
|
10
|
+
module SmileIdentityCore
|
11
|
+
##
|
12
|
+
# The business verification product lets you search the business registration or
|
13
|
+
# tax information (available in Nigeria only) of a business from one of our supported countries.
|
14
|
+
# For more info visit https://docs.smileidentity.com/products/for-businesses-kyb/business-verification
|
15
|
+
class BusinessVerification
|
16
|
+
include Validations
|
17
|
+
|
18
|
+
BASIC_BUSINESS_REGISTRATION = 'BASIC_BUSINESS_REGISTRATION'
|
19
|
+
BUSINESS_REGISTRATION = 'BUSINESS_REGISTRATION'
|
20
|
+
TAX_INFORMATION = 'TAX_INFORMATION'
|
21
|
+
|
22
|
+
REQUIRED_ID_INFO_FIELD = %i[country id_type id_number].freeze
|
23
|
+
|
24
|
+
###
|
25
|
+
# Submit business verification
|
26
|
+
# @param [Hash] partner_params the options to create a message with.
|
27
|
+
# @option opts [String] :job_type The job type, this should be 7
|
28
|
+
# @option opts [String] :job_id A unique value generated by you to track jobs on your end.
|
29
|
+
# @option opts [String] :user_id A unique value generated by you.
|
30
|
+
def initialize(partner_id, api_key, sid_server)
|
31
|
+
@partner_id = partner_id.to_s
|
32
|
+
@api_key = api_key
|
33
|
+
@sid_server = sid_server
|
34
|
+
@url = if sid_server !~ URI::DEFAULT_PARSER.make_regexp
|
35
|
+
SmileIdentityCore::ENV::SID_SERVER_MAPPING[sid_server.to_s]
|
36
|
+
else
|
37
|
+
sid_server
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# Submit business verification
|
42
|
+
# @param [Hash] partner_params the options to create a job with.
|
43
|
+
# @option opts [String] :job_type The job type, this should be 7
|
44
|
+
# @option opts [String] :job_id A unique value generated by you to track jobs on your end.
|
45
|
+
# @option opts [String] :user_id A unique value generated by you.
|
46
|
+
# @param [Hash] id_info
|
47
|
+
# @option opts [String] :country The job type, this should be 7
|
48
|
+
# @option opts [String] :id_type A unique value generated by you to track jobs on your end.
|
49
|
+
# @option opts [String] :id_number A unique value generated by you.
|
50
|
+
# @option opts [String] :business_type The business incorporation type
|
51
|
+
# bn - business name co - private/public limited it - incorporated trustees
|
52
|
+
def submit_job(partner_params, id_info)
|
53
|
+
@partner_params = validate_partner_params(symbolize_keys(partner_params))
|
54
|
+
@id_info = validate_id_info(symbolize_keys(id_info), REQUIRED_ID_INFO_FIELD)
|
55
|
+
|
56
|
+
if @partner_params[:job_type].to_i != JobType::BUSINESS_VERIFICATION
|
57
|
+
raise ArgumentError, 'Please ensure that you are setting your job_type to 7 to query Business Verification'
|
58
|
+
end
|
59
|
+
|
60
|
+
submit_requests
|
61
|
+
end
|
62
|
+
|
63
|
+
private
|
64
|
+
|
65
|
+
def symbolize_keys(params)
|
66
|
+
params.is_a?(Hash) ? params.transform_keys(&:to_sym) : params
|
67
|
+
end
|
68
|
+
|
69
|
+
def build_payload
|
70
|
+
@payload = generate_signature
|
71
|
+
@payload.merge!(@id_info)
|
72
|
+
add_partner_info
|
73
|
+
add_sdk_info
|
74
|
+
@payload
|
75
|
+
end
|
76
|
+
|
77
|
+
def add_partner_info
|
78
|
+
@payload[:partner_id] = @partner_id
|
79
|
+
@payload[:partner_params] = @partner_params
|
80
|
+
end
|
81
|
+
|
82
|
+
def add_sdk_info
|
83
|
+
@payload[:source_sdk] = SmileIdentityCore::SOURCE_SDK
|
84
|
+
@payload[:source_sdk_version] = SmileIdentityCore::VERSION
|
85
|
+
end
|
86
|
+
|
87
|
+
def generate_signature
|
88
|
+
SmileIdentityCore::Signature.new(@partner_id, @api_key).generate_signature
|
89
|
+
end
|
90
|
+
|
91
|
+
def submit_requests
|
92
|
+
request = Typhoeus::Request.new(
|
93
|
+
"#{@url}/business_verification",
|
94
|
+
method: 'POST',
|
95
|
+
headers: { 'Content-Type' => 'application/json' },
|
96
|
+
body: build_payload.to_json
|
97
|
+
)
|
98
|
+
|
99
|
+
request.on_complete do |response|
|
100
|
+
return response.body if response.success?
|
101
|
+
|
102
|
+
raise "#{response.code}: #{response.body}"
|
103
|
+
end
|
104
|
+
request.run
|
105
|
+
end
|
106
|
+
|
107
|
+
alias setup_requests submit_requests
|
108
|
+
end
|
109
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SmileIdentityCore
|
4
|
+
module ImageType
|
5
|
+
SELFIE_IMAGE_FILE = 0
|
6
|
+
ID_CARD_IMAGE_FILE = 1
|
7
|
+
SELFIE_IMAGE_BASE64 = 2
|
8
|
+
ID_CARD_IMAGE_BASE64 = 3
|
9
|
+
LIVENESS_IMAGE_FILE = 4
|
10
|
+
ID_CARD_BACK_IMAGE_FILE = 5
|
11
|
+
LIVENESS_IMAGE_BASE64 = 6
|
12
|
+
ID_CARD_BACK_IMAGE_BASE64 = 7
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SmileIdentityCore
|
4
|
+
module JobType
|
5
|
+
BIOMETRIC_KYC = 1
|
6
|
+
SMART_SELFIE_REGISTRATION = 2
|
7
|
+
SMART_SELFIE_AUTHENTICATION = 4
|
8
|
+
BASIC_KYC = 5
|
9
|
+
ENHANCED_KYC = 5
|
10
|
+
DOCUMENT_VERIFICATION = 6
|
11
|
+
BUSINESS_VERIFICATION = 7
|
12
|
+
end
|
13
|
+
end
|