smile-identity-core 2.2.3 → 2.2.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'smile-identity-core'
4
4
 
5
- # See https://docs.smileidentity.com/server-to-server/ruby/products/enhanced_document-verification for
5
+ # See https://docs.usesmileid.com/server-to-server/ruby/products/enhanced_document-verification for
6
6
  # how to setup and retrieve configuation values for the WebApi class.
7
7
 
8
8
  # Initialize
@@ -17,7 +17,7 @@ connection = SmileIdentityCore::WebApi.new(partner_id, default_callback, api_key
17
17
  partner_params = {
18
18
  user_id: '<put your unique ID for the user here>',
19
19
  job_id: '<put your unique job ID here>',
20
- job_type: 11
20
+ job_type: 11,
21
21
  }
22
22
 
23
23
  # Create image list
@@ -33,27 +33,27 @@ partner_params = {
33
33
  image_details = [
34
34
  {
35
35
  image_type_id: '<0 | 2>',
36
- image: '<full path to selfie image or base64image string>'
36
+ image: '<full path to selfie image or base64image string>',
37
37
  },
38
38
  { # Not required if you don't require proof of life (note photo of photo check
39
39
  # will still be performed on the uploaded selfie)
40
40
  image_type_id: '<4 | 6>',
41
- image: '<full path to liveness image or base64 image string>'
41
+ image: '<full path to liveness image or base64 image string>',
42
42
  },
43
43
  {
44
44
  image_type_id: '<1 | 3>',
45
- image: '<full path to front of id document image or base64image string>'
45
+ image: '<full path to front of id document image or base64image string>',
46
46
  },
47
47
  { # Optional, only use if you're uploading the back of the id document image
48
48
  image_type_id: '<5 | 7>',
49
- image: '<full path to back of id document image or base64image string>'
50
- }
49
+ image: '<full path to back of id document image or base64image string>',
50
+ },
51
51
  ]
52
52
 
53
53
  # The ID Document Information
54
54
  id_info = {
55
55
  country: '<2-letter country code>', # The country where ID document was issued
56
- id_type: '<id type>' # The ID document type
56
+ id_type: '<id type>', # The ID document type
57
57
  }
58
58
 
59
59
  # Set options for the job
@@ -67,7 +67,7 @@ options = {
67
67
  # Set to true to receive links to the selfie and the photo it was compared to.
68
68
  # You must set return_job_status to true to use this flag.
69
69
  return_image_links: '<true |false>',
70
- signature: true
70
+ signature: true,
71
71
  }
72
72
 
73
73
  # Submit the job
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'smile-identity-core'
4
4
 
5
- # See https://docs.smileidentity.com/server-to-server/ruby/products/enhanced-kyc for
5
+ # See https://docs.usesmileid.com/server-to-server/ruby/products/enhanced-kyc for
6
6
  # how to setup and retrieve configuation values for the IDApi class.
7
7
 
8
8
  # Initialize
@@ -16,7 +16,7 @@ connection = SmileIdentityCore::IDApi.new(partner_id, api_key, sid_server)
16
16
  partner_params = {
17
17
  job_id: '<put your unique job ID here>',
18
18
  user_id: '<put your unique ID for the user here>',
19
- job_type: 5
19
+ job_type: 5,
20
20
  }
21
21
 
22
22
  # Create ID info
@@ -27,12 +27,12 @@ id_info = {
27
27
  id_type: '<id type>',
28
28
  id_number: '<valid id number>',
29
29
  dob: '<date of birth>', # yyyy-mm-dd
30
- phone_number: '<phone number>'
30
+ phone_number: '<phone number>',
31
31
  }
32
32
 
33
33
  # Set the options for the job
34
34
  options = {
35
- signature: true
35
+ signature: true,
36
36
  }
37
37
 
38
38
  # Submit the job
@@ -1,6 +1,6 @@
1
1
  # Example Project
2
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.
3
+ This project is an example implementation of the Smile Identity Ruby SDK on the server side. The example implements [Enhanced KYC](https://docs.usesmileid.com/products/identity-lookup), [Biometric KYC](https://docs.usesmileid.com/products/biometric-kyc), [Document Verification](https://docs.usesmileid.com/products/document-verification) and [SmartSelfieTM Authentication](https://docs.usesmileid.com/products/biometric-authentication) job types.
4
4
 
5
5
  ## Setup
6
6
 
@@ -11,11 +11,12 @@ class SmartBank
11
11
 
12
12
  def initialize
13
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
14
+ @partner_id = ENV.fetch('SMILE_PARTNER_ID', nil)
15
+ # See https://docs.usesmileid.com/server-to-server/ruby/products/biometric-kyc#create-a-callback-endpoint
16
+ @default_callback = ENV.fetch('SMILE_JOB_CALLBACK_URL', nil)
17
+ @api_key = ENV.fetch('SMILE_API_KEY', nil) # copy your API key from the Smile Identity portal
18
+ # Use '0' for the sandbox server, use '1' for production server
19
+ @sid_server = ENV.fetch('SMILE_SERVER_ENVIRONMENT', nil)
19
20
  @user_id = SecureRandom.uuid # your unique ID for the user
20
21
  @job_id = SecureRandom.uuid # your unique job ID
21
22
  end
@@ -35,12 +36,12 @@ class SmartBank
35
36
  id_type: 'PASSPORT',
36
37
  id_number: 'G0000000',
37
38
  dob: '1992-12-07', # yyyy-mm-dd
38
- phone_number: '00000000000'
39
+ phone_number: '00000000000',
39
40
  }
40
41
 
41
42
  # Set the options for the job
42
43
  options = {
43
- signature: true
44
+ signature: true,
44
45
  }
45
46
 
46
47
  # Submit the job
@@ -57,13 +58,13 @@ class SmartBank
57
58
  image_details = [
58
59
  {
59
60
  image_type_id: SmileIdentityCore::ImageType::SELFIE_IMAGE_FILE,
60
- image: '/path/to/selfie_image.jpeg'
61
+ image: '/path/to/selfie_image.jpeg',
61
62
  },
62
63
  { # Not required if you don't require proof of life (note photo of photo check will
63
64
  # still be performed on the uploaded selfie)
64
65
  image_type_id: SmileIdentityCore::ImageType::LIVENESS_IMAGE_FILE,
65
- image: '/path/to/liveness_image.jpeg'
66
- }
66
+ image: '/path/to/liveness_image.jpeg',
67
+ },
67
68
  ]
68
69
 
69
70
  # Create ID number info
@@ -74,7 +75,7 @@ class SmartBank
74
75
  id_type: 'PASSPORT',
75
76
  id_number: 'G0000000',
76
77
  dob: '1992-12-07', # yyyy-mm-dd
77
- entered: 'true' # must be a string
78
+ entered: 'true', # must be a string
78
79
  }
79
80
 
80
81
  # Submit the job
@@ -91,27 +92,27 @@ class SmartBank
91
92
  image_details = [
92
93
  {
93
94
  image_type_id: SmileIdentityCore::ImageType::SELFIE_IMAGE_FILE,
94
- image: '/path/to/selfie_image.jpeg'
95
+ image: '/path/to/selfie_image.jpeg',
95
96
  },
96
97
  { # Not required if you don't require proof of life (note photo of photo
97
98
  # check will still be performed on the uploaded selfie)
98
99
  image_type_id: SmileIdentityCore::ImageType::LIVENESS_IMAGE_FILE,
99
- image: '/path/to/liveness_image.jpeg'
100
+ image: '/path/to/liveness_image.jpeg',
100
101
  },
101
102
  {
102
103
  image_type_id: SmileIdentityCore::ImageType::ID_CARD_IMAGE_FILE,
103
- image: '/path/to/front_document_image.jpeg'
104
+ image: '/path/to/front_document_image.jpeg',
104
105
  },
105
106
  { # Optional, only use if you're uploading the back of the id document image
106
107
  image_type_id: SmileIdentityCore::ImageType::ID_CARD_BACK_IMAGE_FILE,
107
- image: '/path/to/back_document_image.jpeg'
108
- }
108
+ image: '/path/to/back_document_image.jpeg',
109
+ },
109
110
  ]
110
111
 
111
112
  # The ID Document Information
112
113
  id_info = {
113
114
  country: 'GH', # The country where ID document was issued
114
- id_type: 'PASSPORT' # The ID document type
115
+ id_type: 'PASSPORT', # The ID document type
115
116
  }
116
117
 
117
118
  # Submit the job
@@ -128,20 +129,20 @@ class SmartBank
128
129
  partner_params = {
129
130
  user_id: '512c9c37-a689-4959-a620-bed75fb41344', # previously registered user's user_id
130
131
  job_id: SecureRandom.uuid, # new unique job ID
131
- job_type: SmileIdentityCore::JobType::SMART_SELFIE_REGISTRATION
132
+ job_type: SmileIdentityCore::JobType::SMART_SELFIE_REGISTRATION,
132
133
  }
133
134
 
134
135
  # Create image list
135
136
  image_details = [
136
137
  {
137
138
  image_type_id: SmileIdentityCore::ImageType::SELFIE_IMAGE_FILE,
138
- image: '/path/to/selfie_image.jpeg'
139
+ image: '/path/to/selfie_image.jpeg',
139
140
  },
140
141
  { # Not required if you don't require proof of life
141
142
  # (note photo of photo check will still be performed on the uploaded selfie)
142
143
  image_type_id: SmileIdentityCore::ImageType::LIVENESS_IMAGE_FILE,
143
- image: '/path/to/liveness_image.jpeg'
144
- }
144
+ image: '/path/to/liveness_image.jpeg',
145
+ },
145
146
  ]
146
147
 
147
148
  # Submit the job
@@ -154,7 +155,7 @@ class SmartBank
154
155
  {
155
156
  user_id: user_id,
156
157
  job_id: job_id,
157
- job_type: job_type
158
+ job_type: job_type,
158
159
  }
159
160
  end
160
161
 
@@ -175,7 +176,7 @@ class SmartBank
175
176
  # Set to true to receive links to the selfie and the photo it was compared to.
176
177
  # You must set return_job_status to true to use this flag.
177
178
  return_image_links: true,
178
- signature: true
179
+ signature: true,
179
180
  }
180
181
  end
181
182
  end
@@ -187,7 +188,7 @@ enhanced_kyc_response['success'] # => true
187
188
  enhanced_kyc_response['result']['PartnerParams']['job_id'] # job_id
188
189
  enhanced_kyc_response['result']['PartnerParams']['user_id'] # user_id
189
190
  enhanced_kyc_response['result']['PartnerParams']['job_type'] # => 5
190
- # See https://docs.smileidentity.com/products/for-individuals-kyc/identity-lookup#return-values
191
+ # See https://docs.usesmileid.com/products/for-individuals-kyc/identity-lookup#return-values
191
192
  # for the full JSON response interpretation
192
193
 
193
194
  # Biometric KYC
@@ -212,5 +213,5 @@ smart_selfie_auth_response['result']['PartnerParams']['user_id'] # user_id
212
213
  smart_selfie_auth_response['result']['PartnerParams']['job_type'] # => 2
213
214
 
214
215
  # 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
+ # see https://docs.usesmileid.com/products/for-individuals-kyc/biometric-kyc#return-values.
216
217
  # Save the returned user_id and job_id in your DB as you would need them later when you call other services.
@@ -3,7 +3,7 @@
3
3
  require 'smile-identity-core'
4
4
  require 'random/formatter'
5
5
 
6
- # See https://docs.smileidentity.com/server-to-server/ruby/products/biometric-kyc for
6
+ # See https://docs.usesmileid.com/server-to-server/ruby/products/biometric-kyc for
7
7
  # how to setup and retrieve configuation values for the WebApi class.
8
8
 
9
9
  # Initialize
@@ -19,7 +19,7 @@ request_params = {
19
19
  user_id: '<your unique user id>',
20
20
  job_id: '<your unique job id>',
21
21
  product: '<smile identity product type>',
22
- callback_url: '<your callback url>'
22
+ callback_url: '<your callback url>',
23
23
  }
24
24
 
25
25
  # Get web token
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'smile-identity-core'
4
4
 
5
- # See https://docs.smileidentity.com/server-to-server/ruby/products/smartselfie-tm-authentication for
5
+ # See https://docs.usesmileid.com/server-to-server/ruby/products/smartselfie-tm-authentication for
6
6
  # how to setup and retrieve configuation values for the WebApi class.
7
7
 
8
8
  # Initialize
@@ -17,7 +17,7 @@ connection = SmileIdentityCore::WebApi.new(partner_id, default_callback, api_key
17
17
  partner_params = {
18
18
  user_id: '<put previously registered user"s user_id here>',
19
19
  job_id: '<put your unique job ID here>',
20
- job_type: 2
20
+ job_type: 2,
21
21
  }
22
22
 
23
23
  # Create image list
@@ -29,13 +29,13 @@ partner_params = {
29
29
  image_details = [
30
30
  {
31
31
  image_type_id: '<0 | 2>',
32
- image: '<full path to selfie image or base64image string>'
32
+ image: '<full path to selfie image or base64image string>',
33
33
  },
34
34
  { # Not required if you don't require proof of life (note photo of photo check will
35
35
  # still be performed on the uploaded selfie)
36
36
  image_type_id: '<4 | 6>',
37
- image: '<full path to liveness image or base64 image string>'
38
- }
37
+ image: '<full path to liveness image or base64 image string>',
38
+ },
39
39
  ]
40
40
 
41
41
  # Set options for the job
@@ -49,7 +49,7 @@ options = {
49
49
  # Set to true to receive links to the selfie and the photo it was
50
50
  # compared to. You must set return_job_status to true to use this flag.
51
51
  return_image_links: '<true | false>',
52
- signature: true
52
+ signature: true,
53
53
  }
54
54
 
55
55
  # Submit the job
@@ -8,7 +8,7 @@ module SmileIdentityCore
8
8
  ##
9
9
  # The AML Check product allows you to perform due diligence on your customers by screening them against
10
10
  # global watchlists, politically exposed persons lists, and adverse media publications.
11
- # For more info visit https://docs.smileidentity.com/products/for-individuals-kyc/aml-check
11
+ # For more info visit https://docs.usesmileid.com/products/for-individuals-kyc/aml-check
12
12
  class AmlCheck
13
13
  include Validations
14
14
 
@@ -33,6 +33,7 @@ module SmileIdentityCore
33
33
  # @option opts [Array] :countries An array that takes the customer’s known nationalities in 2-character
34
34
  # (ISO 3166-1 alpha-2) format e.g. Nigeria is NG, Kenya is KE, etc
35
35
  # @option opts [boolean] :search_existing_user If you intend to re-use the name and year of birth
36
+ # @option opts [boolean] :strict_match If you want to perform a strict match on the serach criteria.
36
37
  # of a user’s previous KYC job
37
38
  # @option opts [Hash] :optional_info Any optional data, this will be returned
38
39
  # in partner_params.
@@ -51,6 +52,7 @@ module SmileIdentityCore
51
52
  def build_payload
52
53
  @payload = generate_signature
53
54
  @payload.merge!(@params)
55
+ @payload[:strict_match] = true unless @params.key?(:strict_match)
54
56
  add_partner_info
55
57
  add_sdk_info
56
58
  @payload
@@ -73,8 +75,8 @@ module SmileIdentityCore
73
75
 
74
76
  def submit_requests
75
77
  request = Typhoeus::Request.new("#{@url}/aml", method: 'POST',
76
- headers: { 'Content-Type' => 'application/json' },
77
- body: build_payload.to_json)
78
+ headers: { 'Content-Type' => 'application/json' },
79
+ body: build_payload.to_json)
78
80
 
79
81
  request.on_complete do |response|
80
82
  return response.body if response.success?
@@ -8,7 +8,7 @@ module SmileIdentityCore
8
8
  ##
9
9
  # The business verification product lets you search the business registration or
10
10
  # tax information (available in Nigeria only) of a business from one of our supported countries.
11
- # For more info visit https://docs.smileidentity.com/products/for-businesses-kyb/business-verification
11
+ # For more info visit https://docs.usesmileid.com/products/for-businesses-kyb/business-verification
12
12
  class BusinessVerification
13
13
  include Validations
14
14
 
@@ -85,7 +85,7 @@ module SmileIdentityCore
85
85
  "#{@url}/business_verification",
86
86
  method: 'POST',
87
87
  headers: { 'Content-Type' => 'application/json' },
88
- body: build_payload.to_json
88
+ body: build_payload.to_json,
89
89
  )
90
90
 
91
91
  request.on_complete do |response|
@@ -6,7 +6,7 @@ module SmileIdentityCore
6
6
  module ENV
7
7
  SID_SERVER_MAPPING = {
8
8
  '0' => 'https://testapi.smileidentity.com/v1',
9
- '1' => 'https://api.smileidentity.com/v1'
9
+ '1' => 'https://api.smileidentity.com/v1',
10
10
  }.freeze
11
11
 
12
12
  TEST = '0'
@@ -15,10 +15,10 @@ module SmileIdentityCore
15
15
  module_function
16
16
 
17
17
  def determine_url(sid_server)
18
- if sid_server.to_s !~ URI::DEFAULT_PARSER.make_regexp
19
- SID_SERVER_MAPPING[sid_server.to_s] || sid_server
20
- else
18
+ if sid_server.to_s =~ URI::DEFAULT_PARSER.make_regexp
21
19
  sid_server
20
+ else
21
+ SID_SERVER_MAPPING[sid_server.to_s] || sid_server
22
22
  end
23
23
  end
24
24
  end
@@ -25,8 +25,8 @@ module SmileIdentityCore
25
25
 
26
26
  if partner_params[:job_type] == JobType::BUSINESS_VERIFICATION
27
27
  return SmileIdentityCore::BusinessVerification
28
- .new(@partner_id, @api_key, @url)
29
- .submit_job(partner_params, id_info)
28
+ .new(@partner_id, @api_key, @url)
29
+ .submit_job(partner_params, id_info)
30
30
  end
31
31
 
32
32
  options = symbolize_keys(options || {})
@@ -46,7 +46,7 @@ module SmileIdentityCore
46
46
  "#{@url}/#{endpoint}",
47
47
  method: 'POST',
48
48
  headers: { 'Content-Type' => 'application/json' },
49
- body: configure_json
49
+ body: configure_json,
50
50
  )
51
51
 
52
52
  request.on_complete do |response|
@@ -63,14 +63,14 @@ module SmileIdentityCore
63
63
 
64
64
  def configure_json
65
65
  signature_generator.generate_signature(Time.now.to_s)
66
- .merge(@id_info)
67
- .merge(
68
- partner_id: @partner_id,
69
- partner_params: @partner_params,
70
- source_sdk: SmileIdentityCore::SOURCE_SDK,
71
- source_sdk_version: SmileIdentityCore::VERSION
72
- )
73
- .to_json
66
+ .merge(@id_info)
67
+ .merge(
68
+ partner_id: @partner_id,
69
+ partner_params: @partner_params,
70
+ source_sdk: SmileIdentityCore::SOURCE_SDK,
71
+ source_sdk_version: SmileIdentityCore::VERSION,
72
+ )
73
+ .to_json
74
74
  end
75
75
 
76
76
  def signature_generator
@@ -19,7 +19,7 @@ module SmileIdentityCore
19
19
  @signature = Base64.strict_encode64(hmac.digest)
20
20
  {
21
21
  signature: @signature,
22
- timestamp: timestamp.to_s
22
+ timestamp: timestamp.to_s,
23
23
  }
24
24
  end
25
25
 
@@ -17,7 +17,7 @@ module SmileIdentityCore
17
17
  options[:return_image_links] ||= false
18
18
 
19
19
  query_job_status(configure_job_query(user_id, job_id,
20
- options).merge(@signature_connection.generate_signature(Time.now.to_s)))
20
+ options).merge(@signature_connection.generate_signature(Time.now.to_s)))
21
21
  end
22
22
 
23
23
  private
@@ -29,9 +29,9 @@ module SmileIdentityCore
29
29
  def query_job_status(request_json_data)
30
30
  request = Typhoeus::Request.new(
31
31
  "#{@url}/job_status",
32
- headers: { 'Content-Type': 'application/json', 'Accept': 'application/json' },
32
+ headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
33
33
  method: :post,
34
- body: request_json_data.to_json
34
+ body: request_json_data.to_json,
35
35
  )
36
36
 
37
37
  request.on_complete do |response|
@@ -47,8 +47,6 @@ module SmileIdentityCore
47
47
  raise 'Unable to confirm validity of the job_status response' unless valid
48
48
 
49
49
  return body
50
- rescue StandardError => e
51
- raise e
52
50
  end
53
51
 
54
52
  request.run
@@ -62,7 +60,7 @@ module SmileIdentityCore
62
60
  image_links: options[:return_image_links],
63
61
  history: options[:return_history],
64
62
  source_sdk: SmileIdentityCore::SOURCE_SDK,
65
- source_sdk_version: SmileIdentityCore::VERSION
63
+ source_sdk_version: SmileIdentityCore::VERSION,
66
64
  }
67
65
  end
68
66
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SmileIdentityCore
4
- module Validations # :nodoc:
4
+ module Validations # :nodoc:
5
5
  def validate_partner_params(partner_params)
6
6
  raise ArgumentError, 'Please ensure that you send through partner params' if partner_params.nil?
7
7
 
@@ -10,7 +10,7 @@ module SmileIdentityCore
10
10
  %i[user_id job_id job_type].each do |key|
11
11
  if partner_params[key].to_s.empty?
12
12
  raise ArgumentError,
13
- "Please make sure that #{key} is included in the partner params"
13
+ "Please make sure that #{key} is included in the partner params"
14
14
  end
15
15
  end
16
16
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SmileIdentityCore
4
- VERSION = '2.2.3'
4
+ VERSION = '2.2.5'
5
5
  SOURCE_SDK = 'Ruby'
6
6
  end