Skip to content

Commit

Permalink
Allow leaving id_number and id_type fields empty in id_info for JT6. (#…
Browse files Browse the repository at this point in the history
…60)

* Allow leaving country and id_type fields empty in id_info for JT6.

* Cleanup.

* Revert changes.

* Cleanup.

* Assert no other error is thrown.

* Fixes.

* cleanup conditional

Co-authored-by: Michael <michael.l.dangelo@gmail.com>

* Fix indentation.

* Cleanup jt6 validation.

* Update changelog.

* Increment version.

---------

Co-authored-by: Laud Bruce Tagoe <niinyarko@yahoo.com>
Co-authored-by: Michael <michael.l.dangelo@gmail.com>
  • Loading branch information
3 people committed Aug 31, 2023
1 parent e63b13a commit 11e2622
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [2.2.1] - 2023-08-31
### Changed
- Don't validate the presence of `id_type` and `id_number` for Document Verification jobs

## [2.2.0] - 2023-04-05
### Added
- Adds support for AML check
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
smile-identity-core (2.2.0)
smile-identity-core (2.2.1)
rubyzip (~> 1.2, >= 1.2.3)
typhoeus (~> 1.0, >= 1.0.1)

Expand Down
2 changes: 1 addition & 1 deletion lib/smile-identity-core/version.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

module SmileIdentityCore
VERSION = '2.2.0'
VERSION = '2.2.1'
SOURCE_SDK = 'Ruby'
end
11 changes: 9 additions & 2 deletions lib/smile-identity-core/web_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,15 @@ def id_info=(id_info)
# if it's a boolean
updated_id_info[:entered] = id_info[:entered].to_s if !updated_id_info[:entered].nil? == updated_id_info[:entered]

if updated_id_info[:entered] && updated_id_info[:entered] == 'true'
%i[country id_type id_number].each do |key|
is_jt6 = @partner_params[:job_type].to_i == JobType::DOCUMENT_VERIFICATION
keys = if is_jt6
%i[country]
else
%i[country id_type id_number]
end

if updated_id_info[:entered] == 'true' || is_jt6
keys.each do |key|
raise ArgumentError, "Please make sure that #{key} is included in the id_info" if id_info[key].to_s.empty?
end
end
Expand Down
34 changes: 34 additions & 0 deletions spec/smile-identity-core/web_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,40 @@
end
end

it 'allows leaving id_number and id_type fields empty in id_info for JT6' do
connection.instance_variable_set('@url', 'https://www.example.com')
response_upload_url = 'https://smile-uploads-somewhere.amazonaws.com/videos/a_signed_url'
body = {
'upload_url' => response_upload_url,
'ref_id' => '125-0000000583-s8fqo7ju2ji2u32hhu4us11bq3yhww',
'smile_job_id' => '0000000583',
'camera_config' => 'null',
'code' => '2202'
}.to_json
Typhoeus.stub('https://www.example.com/upload').and_return(Typhoeus::Response.new(code: 200, body: body))
allow(IO).to receive(:read).with('./tmp/selfie.png').and_return('')
allow(IO).to receive(:read).with('./tmp/id_image.png').and_return('')
Typhoeus.stub(response_upload_url).and_return(Typhoeus::Response.new(code: 200))

amended_partner_params = partner_params.merge({
job_type: SmileIdentityCore::JobType::DOCUMENT_VERIFICATION
})
%i[id_number id_type].each do |key|
amended_id_info = id_info.merge(key => '')
expect { connection.submit_job(amended_partner_params, images, amended_id_info, options) }
.not_to raise_error
end
end

it 'country field in id_info is required for JT6' do
amended_id_info = id_info.merge('country' => '')
amended_partner_params = partner_params.merge({
job_type: SmileIdentityCore::JobType::DOCUMENT_VERIFICATION
})
expect { connection.submit_job(amended_partner_params, images, amended_id_info, options) }
.to raise_error(ArgumentError, 'Please make sure that country is included in the id_info')
end

it 'checks that return_job_status is a boolean' do
expect { connection.submit_job(partner_params, images, id_info, options.merge(return_job_status: 'false')) }
.to raise_error(ArgumentError, 'return_job_status needs to be a boolean')
Expand Down

0 comments on commit 11e2622

Please sign in to comment.