Skip to content

Commit

Permalink
Merge pull request #135 from getyoti/release/1.9.0
Browse files Browse the repository at this point in the history
Release 1.9.0
  • Loading branch information
davidgrayston authored Sep 21, 2020
2 parents 1a34042 + 5c87ce9 commit 3b8b9d0
Show file tree
Hide file tree
Showing 18 changed files with 367 additions and 65 deletions.
18 changes: 18 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.0.0
hooks:
- id: trailing-whitespace
- id: check-yaml
- repo: local
hooks:
- id: lint
name: 'lint'
entry: bundle exec rake rubocop
language: system
description: "Lint"
- id: test
name: 'test'
entry: bundle exec rake spec
language: system
description: "Test"
2 changes: 1 addition & 1 deletion examples/doc_scan/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
1. Create your application in the [Yoti Hub](https://hub.yoti.com)
1. Set the application domain of your app to `localhost:3002`
1. Rename the [.env.example](.env.example) file to `.env`
1. Fill in the environment variables in this file with the ones specific to your application (mentioned in the [Configuration](#configuration) section)
1. Fill in the environment variables in this file with the ones specific to your application, generated in the Yoti Hub when you create (and then publish) your application
1. Install the dependencies by running the following commands from this folder
```shell
$ bundle install
Expand Down
39 changes: 28 additions & 11 deletions examples/doc_scan/app/controllers/yoti_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require 'base64'

class YotiController < ApplicationController
#
# Create Session
Expand Down Expand Up @@ -27,6 +25,11 @@ def index
.with_manual_check_never
.build
)
.with_requested_check(
Yoti::DocScan::Session::Create::RequestedIdDocumentComparisonCheck
.builder
.build
)
.with_requested_task(
Yoti::DocScan::Session::Create::RequestedTextExtractionTask
.builder
Expand All @@ -47,6 +50,28 @@ def index
.with_error_url("#{request.base_url}/error")
.build
)
.with_required_document(
Yoti::DocScan::Session::Create::RequiredIdDocument
.builder
.with_filter(
Yoti::DocScan::Session::Create::OrthogonalRestrictionsFilter
.builder
.with_included_document_types(['PASSPORT'])
.build
)
.build
)
.with_required_document(
Yoti::DocScan::Session::Create::RequiredIdDocument
.builder
.with_filter(
Yoti::DocScan::Session::Create::OrthogonalRestrictionsFilter
.builder
.with_included_document_types(['DRIVING_LICENCE'])
.build
)
.build
)
.build

create_session = Yoti::DocScan::Client.create_session(session_spec)
Expand All @@ -73,15 +98,7 @@ def media

media = Yoti::DocScan::Client.get_media_content(session[:DOC_SCAN_SESSION_ID], media_id)

body = media.content
content_type = media.mime_type

if request.query_parameters[:base64Zip] == '1' && content_type == 'application/octet-stream'
body = Base64.strict_decode64(body)
content_type = 'application/zip'
end

render body: body, content_type: content_type
render body: media.content, content_type: media.mime_type
end

#
Expand Down
64 changes: 31 additions & 33 deletions examples/doc_scan/app/views/yoti/success.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@
<td>User Tracking ID</td>
<td><%= @session_result.user_tracking_id %></td>
</tr>
<% if @session_result.biometric_consent_timestamp %>
<tr>
<td>Biometric Consent Timestamp</td>
<td>
<%= @session_result.biometric_consent_timestamp %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
Expand Down Expand Up @@ -137,6 +145,29 @@
</div>
</div>
<% end %>
<% if @session_result.id_document_comparison_checks.count.positive? %>
<div class="card">
<div class="card-header" id="comparison-checks">
<h3 class="mb-0">
<button class="btn btn-link" type="button" data-toggle="collapse"
data-target="#collapse-comparison-checks" aria-expanded="true"
aria-controls="collapse-comparison-checks">
ID Document Comparison Checks
</button>
</h3>
</div>

<div id="collapse-comparison-checks" class="collapse" aria-labelledby="comparison-checks">
<div class="card-body">
<% @session_result.id_document_comparison_checks.each do |check| %>
<%= render partial: "check", locals: {check: check} %>
<% end %>
</div>
</div>
</div>
<% end %>

</div>
</div>
</div>
Expand Down Expand Up @@ -338,39 +369,6 @@

<div class="accordion mt-3">

<% unless liveness_resource.facemap.nil? %>
<div class="card">
<div class="card-header" id="liveness-<%= liveness_num %>-facemap">
<h3 class="mb-0">
<button class="btn btn-link" type="button" data-toggle="collapse"
data-target="#collapse-liveness-<%= liveness_num %>-facemap" aria-expanded="true"
aria-controls="collapse-liveness-<%= liveness_num %>-facemap">
Face Map
</button>
</h3>
</div>
<div id="collapse-liveness-<%= liveness_num %>-facemap" class="collapse" aria-labelledby="liveness-<%= liveness_num %>-facemap">
<div class="card-body">
<% unless liveness_resource.facemap.media.nil? %>
<h4>Media</h4>
<table class="table table-striped">
<tbody>
<tr>
<td>ID</td>
<td>
<a href="/media?mediaId=<%= liveness_resource.facemap.media.id %>&base64Zip=1">
<%= liveness_resource.facemap.media.id %>
</a>
</td>
</tr>
</tbody>
</table>
<% end %>
</div>
</div>
</div>
<% end %>
<% if liveness_resource.frames.count.positive? %>
<div class="card">
<div class="card-header" id="liveness-<%= liveness_num %>-frames">
Expand Down
2 changes: 2 additions & 0 deletions lib/yoti.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
require_relative 'yoti/doc_scan/session/create/create_session_result'
require_relative 'yoti/doc_scan/session/create/requested_check'
require_relative 'yoti/doc_scan/session/create/requested_document_authenticity_check'
require_relative 'yoti/doc_scan/session/create/requested_id_document_comparison_check'
require_relative 'yoti/doc_scan/session/create/requested_face_match_check'
require_relative 'yoti/doc_scan/session/create/requested_liveness_check'
require_relative 'yoti/doc_scan/session/create/requested_task'
Expand All @@ -72,6 +73,7 @@
require_relative 'yoti/doc_scan/session/retrieve/check_response'
require_relative 'yoti/doc_scan/session/retrieve/resource_response'
require_relative 'yoti/doc_scan/session/retrieve/authenticity_check_response'
require_relative 'yoti/doc_scan/session/retrieve/id_document_comparison_check_response'
require_relative 'yoti/doc_scan/session/retrieve/breakdown_response'
require_relative 'yoti/doc_scan/session/retrieve/details_response'
require_relative 'yoti/doc_scan/session/retrieve/document_fields_response'
Expand Down
1 change: 1 addition & 0 deletions lib/yoti/doc_scan/constants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module Yoti
module DocScan
class Constants
ID_DOCUMENT_AUTHENTICITY = 'ID_DOCUMENT_AUTHENTICITY'
ID_DOCUMENT_COMPARISON = 'ID_DOCUMENT_COMPARISON'
ID_DOCUMENT_TEXT_DATA_CHECK = 'ID_DOCUMENT_TEXT_DATA_CHECK'
ID_DOCUMENT_FACE_MATCH = 'ID_DOCUMENT_FACE_MATCH'
LIVENESS = 'LIVENESS'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,62 @@ def self.builder
# The configuration applied when creating a {RequestedDocumentAuthenticityCheck}
#
class RequestedDocumentAuthenticityCheckConfig
#
# @param [String] manual_check
#
def initialize(manual_check)
Validation.assert_is_a(String, manual_check, 'manual_check', true)
@manual_check = manual_check
end

def as_json(*_args)
{}
{
manual_check: @manual_check
}.compact
end
end

#
# Builder to assist the creation of {RequestedDocumentAuthenticityCheck}
#
class RequestedDocumentAuthenticityCheckBuilder
#
# Requires that a manual follow-up check is always performed
#
# @return [self]
#
def with_manual_check_always
@manual_check = Constants::ALWAYS
self
end

#
# Requires that a manual follow-up check is performed only on failed checks,
# and those with a low level of confidence
#
# @return [self]
#
def with_manual_check_fallback
@manual_check = Constants::FALLBACK
self
end

#
# Requires that only an automated check is performed. No manual follow-up
# Check will ever be initiated
#
# @return [self]
#
def with_manual_check_never
@manual_check = Constants::NEVER
self
end

#
# @return [RequestedDocumentAuthenticityCheck]
#
def build
config = RequestedDocumentAuthenticityCheckConfig.new
config = RequestedDocumentAuthenticityCheckConfig.new(@manual_check)
RequestedDocumentAuthenticityCheck.new(config)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def with_manual_check_always
end

#
# Requires that a manual follow-up check is performed only on failed Checks,
# Requires that a manual follow-up check is performed only on failed checks,
# and those with a low level of confidence
#
# @return [self]
Expand All @@ -74,7 +74,7 @@ def with_manual_check_fallback
end

#
# Requires that only an automated Check is performed. No manual follow-up
# Requires that only an automated check is performed. No manual follow-up
# Check will ever be initiated
#
# @return [self]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# frozen_string_literal: true

module Yoti
module DocScan
module Session
module Create
#
# Requests creation of an ID Document Comparison Check
#
class RequestedIdDocumentComparisonCheck < RequestedCheck
def initialize(config)
Validation.assert_is_a(
RequestedIdDocumentComparisonCheckConfig,
config,
'config'
)

super(Constants::ID_DOCUMENT_COMPARISON, config)
end

#
# @return [RequestedIdDocumentComparisonCheckBuilder]
#
def self.builder
RequestedIdDocumentComparisonCheckBuilder.new
end
end

#
# The configuration applied when creating a {RequestedIdDocumentComparisonCheck}
#
class RequestedIdDocumentComparisonCheckConfig
def as_json(*_args)
{}
end
end

#
# Builder to assist the creation of {RequestedIdDocumentComparisonCheck}
#
class RequestedIdDocumentComparisonCheckBuilder
#
# @return [RequestedIdDocumentComparisonCheck]
#
def build
config = RequestedIdDocumentComparisonCheckConfig.new
RequestedIdDocumentComparisonCheck.new(config)
end
end
end
end
end
end
Loading

0 comments on commit 3b8b9d0

Please sign in to comment.