smile-identity-core 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 84fcac3562348da2011a2ccb7d84c2ca44ae2927284212f3430dbc164bd1a704
4
- data.tar.gz: 487c49c050a929a5339bc8dccbc44d3b117eca7af717d7a73e0fe6303a86608d
3
+ metadata.gz: 0256a5d5a35915153e433d6bef6c697a4e5670ed25014b21c184253f5b8cea31
4
+ data.tar.gz: 311bcb8052308ba0d543fa7d23f557b3e49555c31436b1cfe22833bf96d09c39
5
5
  SHA512:
6
- metadata.gz: afda841be8343b9c9708e08e2fefc57e384ef5e6adc3223f1b173371199dbdeba68a8a9bbbf89f5ece247c607ecb3f7b614f1ad973ecffc537443c59fe102e30
7
- data.tar.gz: 9f7b159ca49672cae6a81d6e6ce76259d5582592ee8b9bb924747161b7c829e562a866f9365d7774544790074bd5c96c1bde5566b41fb3765e4863839f2f428a
6
+ metadata.gz: 5892d83748e2c5a320e99dcfa639de14a0a701f3fe39192173600f264c7b0d466873b6752728b57e5cf83d06f1ab1ce3535cd511d6be9d1c148e18a50b7e75ca
7
+ data.tar.gz: 4876f4872cddb222bbf354dc050902d4c92d36c73a88f6b9ee40eadc41996aae72f7a5b844b269366dbbb514f586fbafbf28226f96efc9249451cf74567a670c
data/CHANGELOG.md CHANGED
@@ -6,16 +6,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ # [2.1.0] - 2022-10-28
10
+ ## Changed
11
+ - Moved Business verification to IDApi
12
+
9
13
  # [2.0.0] - 2022-10-24
10
14
  ### Added
11
15
  - build: Adds support for ruby 3.1
12
16
  - docs: adds "examples" folder
13
- - Adds Business Verfication product
17
+ - Adds Business Verification product
14
18
 
15
19
  ### Changed
16
20
  - ci: Move from TravisCI to Github Actions
17
21
  - core: Enforces the use of signature on all API calls
18
- - core: Adds helper constants SMILE_IDENTITY_CORE::ENV, SMILE_IDENTITY_CORE::IMAGE_TYPE, SMILE_IDENTITY_CORE::JOB_TYPE
22
+ - core: Adds helper constants SMILE_IDENTITY_CORE::ENV, SMILE_IDENTITY_CORE::ImageType, SMILE_IDENTITY_CORE::JobType
19
23
  - Fixes invalid links in gemspec
20
24
 
21
25
  ### Removed
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- smile-identity-core (2.0.0)
4
+ smile-identity-core (2.1.0)
5
5
  rubyzip (~> 1.2, >= 1.2.3)
6
6
  typhoeus (~> 1.0, >= 1.0.1)
7
7
 
@@ -11,12 +11,12 @@ default_callback = '<Put your default callback url here>'
11
11
  api_key = '<Put your API key here>'; # copy your API key from the Smile Identity portal
12
12
  sid_server = '<0 | 1>'; # Use '0' for the sandbox server, use '1' for production server
13
13
 
14
- connection = SmileIdentityCore::WebApi.new(partner_id, default_callback, api_key, sid_server)
14
+ connection = SmileIdentityCore::IDApi.new(partner_id, default_callback, api_key, sid_server)
15
15
 
16
16
  # Create required tracking parameters
17
17
  partner_params = {
18
- job_id: "job-#{SecureRandom.uuid}",
19
- user_id: "user-#{SecureRandom.uuid}",
18
+ job_id: '<put your unique job ID here>',
19
+ user_id: '<put your unique ID for the user here>',
20
20
  job_type: SmileIdentityCore::JobType::BUSINESS_VERIFICATION
21
21
  }
22
22
 
@@ -25,13 +25,21 @@ id_info = {
25
25
  # The country where ID document was issued
26
26
  country: '<2-letter country code>',
27
27
  # The ID document type
28
+ # Available types BASIC_BUSINESS_REGISTRATION, BUSINESS_REGISTRATION and TAX_INFORMATION
28
29
  id_type: '<id type>',
29
30
  # The business registration or tax number
30
- id_number: '<id number>',
31
+ id_number: '0000000',
31
32
  # The business incorporation type bn - business name, co - private/public limited, it - incorporated trustees
32
33
  # Only required for BASIC_BUSINESS_REGISTRATION and BUSINESS_REGISTRATION in Nigeria
33
- business_type: '<co | bn | it>'
34
+ business_type: 'co',
35
+ # Postal address of business. Only Required for BUSINESS_REGISTRATION in Kenya
36
+ postal_address: '<postal address>',
37
+ # Postal code of business. Only Required for BUSINESS_REGISTRATION in Kenya
38
+ postal_code: '<postal code>'
34
39
  }
35
40
 
41
+ # Set the options for the job
42
+ options = {}
43
+
36
44
  # Submit the job
37
- connection.submit_job(partner_params, [], id_info, {})
45
+ connection.submit_job(partner_params, id_info, options)
@@ -1,9 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'json'
4
- require 'base64'
5
- require 'openssl'
6
- require 'uri'
7
4
  require 'typhoeus'
8
5
  require_relative 'validations'
9
6
 
@@ -1,8 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'validations'
4
+
3
5
  module SmileIdentityCore
4
6
  # Allows you to query the Identity Information for an individual using their ID number
5
7
  class IDApi
8
+ include Validations
9
+
10
+ REQUIRED_ID_INFO_FIELD = %i[country id_type id_number].freeze
11
+
6
12
  def initialize(partner_id, api_key, sid_server)
7
13
  @partner_id = partner_id.to_s
8
14
  @api_key = api_key
@@ -15,47 +21,23 @@ module SmileIdentityCore
15
21
  end
16
22
 
17
23
  def submit_job(partner_params, id_info, options = {})
18
- self.partner_params = symbolize_keys partner_params
19
- self.id_info = symbolize_keys id_info
20
- options = symbolize_keys(options || {})
21
- @use_async_endpoint = options.fetch(:async, false)
24
+ @partner_params = validate_partner_params(symbolize_keys(partner_params))
25
+ @id_info = validate_id_info(symbolize_keys(id_info), REQUIRED_ID_INFO_FIELD)
22
26
 
23
- if @partner_params[:job_type].to_i != 5
24
- raise ArgumentError, 'Please ensure that you are setting your job_type to 5 to query ID Api'
27
+ unless [JobType::ENHANCED_KYC, JobType::BUSINESS_VERIFICATION].include?(@partner_params[:job_type].to_i)
28
+ raise ArgumentError, 'Please ensure that you are setting your job_type to 5 or 7 to query ID Api'
25
29
  end
26
30
 
27
- setup_requests
28
- end
29
-
30
- def partner_params=(partner_params)
31
- raise ArgumentError, 'Please ensure that you send through partner params' if partner_params.nil?
32
-
33
- raise ArgumentError, 'Partner params needs to be a hash' unless partner_params.is_a?(Hash)
34
-
35
- %i[user_id job_id job_type].each do |key|
36
- if partner_params[key].to_s.empty?
37
- raise ArgumentError,
38
- "Please make sure that #{key} is included in the partner params"
39
- end
31
+ if partner_params[:job_type] == JobType::BUSINESS_VERIFICATION
32
+ return SmileIdentityCore::BusinessVerification
33
+ .new(@partner_id, @api_key, @url)
34
+ .submit_job(partner_params, id_info)
40
35
  end
41
36
 
42
- @partner_params = partner_params
43
- end
44
-
45
- def id_info=(id_info)
46
- updated_id_info = id_info
47
-
48
- if updated_id_info.nil? || updated_id_info.keys.length.zero?
49
- raise ArgumentError, 'Please make sure that id_info not empty or nil'
50
- end
51
-
52
- %i[country id_type id_number].each do |key|
53
- unless updated_id_info[key] && !updated_id_info[key].nil? && !updated_id_info[key].empty?
54
- raise ArgumentError, "Please make sure that #{key} is included in the id_info"
55
- end
56
- end
37
+ options = symbolize_keys(options || {})
38
+ @use_async_endpoint = options.fetch(:async, false)
57
39
 
58
- @id_info = updated_id_info
40
+ setup_requests
59
41
  end
60
42
 
61
43
  private
@@ -18,7 +18,7 @@ module SmileIdentityCore
18
18
  end
19
19
 
20
20
  def validate_id_info(id_info, required_id_info_fields)
21
- raise ArgumentError, 'Please make sure that id_info not empty or nil' if id_info.nil? || id_info.empty?
21
+ raise ArgumentError, 'Please make sure that id_info is not empty or nil' if id_info.nil? || id_info.empty?
22
22
 
23
23
  raise ArgumentError, 'Id info needs to be a hash' unless id_info.is_a?(Hash)
24
24
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SmileIdentityCore
4
- VERSION = '2.0.0'
4
+ VERSION = '2.1.0'
5
5
  SOURCE_SDK = 'Ruby'
6
6
  end
@@ -25,14 +25,9 @@ module SmileIdentityCore
25
25
 
26
26
  def submit_job(partner_params, images, id_info, options)
27
27
  self.partner_params = symbolize_keys partner_params
28
- if @partner_params[:job_type].to_i == JobType::ENHANCED_KYC
29
- return SmileIdentityCore::IDApi.new(@partner_id, @api_key, @sid_server).submit_job(partner_params, id_info)
30
- end
31
28
 
32
- if @partner_params[:job_type].to_i == JobType::BUSINESS_VERIFICATION
33
- return SmileIdentityCore::BusinessVerification.new(@partner_id, @api_key, @sid_server).submit_job(
34
- partner_params, id_info
35
- )
29
+ if [JobType::ENHANCED_KYC, JobType::BUSINESS_VERIFICATION].include?(@partner_params[:job_type].to_i)
30
+ return SmileIdentityCore::IDApi.new(@partner_id, @api_key, @sid_server).submit_job(partner_params, id_info)
36
31
  end
37
32
 
38
33
  self.images = images
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smile-identity-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Smile Identity
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-11-24 00:00:00.000000000 Z
11
+ date: 2022-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -213,7 +213,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
213
213
  - !ruby/object:Gem::Version
214
214
  version: '0'
215
215
  requirements: []
216
- rubygems_version: 3.3.7
216
+ rubygems_version: 3.3.26
217
217
  signing_key:
218
218
  specification_version: 4
219
219
  summary: The Smile Identity Web API allows the user to access\ most of the features