yoti 1.6.0 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/ISSUE_TEMPLATE.md +17 -0
- data/CONTRIBUTING.md +0 -29
- data/README.md +4 -0
- data/Rakefile +7 -10
- data/lib/yoti.rb +50 -1
- data/lib/yoti/activity_details.rb +5 -1
- data/lib/yoti/client.rb +13 -4
- data/lib/yoti/configuration.rb +7 -2
- data/lib/yoti/data_type/age_verification.rb +1 -1
- data/lib/yoti/data_type/base_profile.rb +1 -1
- data/lib/yoti/data_type/document_details.rb +5 -13
- data/lib/yoti/data_type/image.rb +4 -12
- data/lib/yoti/data_type/image_jpeg.rb +2 -0
- data/lib/yoti/data_type/image_png.rb +2 -0
- data/lib/yoti/data_type/media.rb +19 -0
- data/lib/yoti/doc_scan/client.rb +163 -0
- data/lib/yoti/doc_scan/constants.rb +28 -0
- data/lib/yoti/doc_scan/session/create/create_session_result.rb +50 -0
- data/lib/yoti/doc_scan/session/create/document_filter.rb +31 -0
- data/lib/yoti/doc_scan/session/create/document_restrictions_filter.rb +140 -0
- data/lib/yoti/doc_scan/session/create/notification_config.rb +142 -0
- data/lib/yoti/doc_scan/session/create/orthogonal_restrictions_filter.rb +150 -0
- data/lib/yoti/doc_scan/session/create/requested_check.rb +39 -0
- data/lib/yoti/doc_scan/session/create/requested_document_authenticity_check.rb +53 -0
- data/lib/yoti/doc_scan/session/create/requested_face_match_check.rb +95 -0
- data/lib/yoti/doc_scan/session/create/requested_liveness_check.rb +108 -0
- data/lib/yoti/doc_scan/session/create/requested_task.rb +39 -0
- data/lib/yoti/doc_scan/session/create/requested_text_extraction_task.rb +94 -0
- data/lib/yoti/doc_scan/session/create/required_document.rb +31 -0
- data/lib/yoti/doc_scan/session/create/required_id_document.rb +53 -0
- data/lib/yoti/doc_scan/session/create/sdk_config.rb +221 -0
- data/lib/yoti/doc_scan/session/create/session_specification.rb +203 -0
- data/lib/yoti/doc_scan/session/retrieve/authenticity_check_response.rb +12 -0
- data/lib/yoti/doc_scan/session/retrieve/breakdown_response.rb +38 -0
- data/lib/yoti/doc_scan/session/retrieve/check_response.rb +63 -0
- data/lib/yoti/doc_scan/session/retrieve/details_response.rb +28 -0
- data/lib/yoti/doc_scan/session/retrieve/document_fields_response.rb +21 -0
- data/lib/yoti/doc_scan/session/retrieve/face_map_response.rb +21 -0
- data/lib/yoti/doc_scan/session/retrieve/face_match_check_response.rb +12 -0
- data/lib/yoti/doc_scan/session/retrieve/frame_response.rb +21 -0
- data/lib/yoti/doc_scan/session/retrieve/generated_check_response.rb +28 -0
- data/lib/yoti/doc_scan/session/retrieve/generated_media.rb +28 -0
- data/lib/yoti/doc_scan/session/retrieve/generated_text_data_check_response.rb +12 -0
- data/lib/yoti/doc_scan/session/retrieve/get_session_result.rb +113 -0
- data/lib/yoti/doc_scan/session/retrieve/id_document_resource_response.rb +52 -0
- data/lib/yoti/doc_scan/session/retrieve/liveness_check_response.rb +12 -0
- data/lib/yoti/doc_scan/session/retrieve/liveness_resource_response.rb +24 -0
- data/lib/yoti/doc_scan/session/retrieve/media_response.rb +38 -0
- data/lib/yoti/doc_scan/session/retrieve/page_response.rb +27 -0
- data/lib/yoti/doc_scan/session/retrieve/recommendation_response.rb +34 -0
- data/lib/yoti/doc_scan/session/retrieve/report_response.rb +31 -0
- data/lib/yoti/doc_scan/session/retrieve/resource_container.rb +50 -0
- data/lib/yoti/doc_scan/session/retrieve/resource_response.rb +39 -0
- data/lib/yoti/doc_scan/session/retrieve/task_response.rb +87 -0
- data/lib/yoti/doc_scan/session/retrieve/text_data_check_response.rb +12 -0
- data/lib/yoti/doc_scan/session/retrieve/text_extraction_task_response.rb +18 -0
- data/lib/yoti/doc_scan/session/retrieve/zoom_liveness_resource_response.rb +33 -0
- data/lib/yoti/doc_scan/support/supported_documents.rb +60 -0
- data/lib/yoti/dynamic_share_service/extension/thirdparty_attribute_extension.rb +73 -12
- data/lib/yoti/dynamic_share_service/policy/dynamic_policy.rb +17 -17
- data/lib/yoti/dynamic_share_service/share_url.rb +28 -33
- data/lib/yoti/errors.rb +17 -2
- data/lib/yoti/http/aml_check_request.rb +12 -6
- data/lib/yoti/http/payloads/aml_address.rb +4 -0
- data/lib/yoti/http/payloads/aml_profile.rb +7 -1
- data/lib/yoti/http/profile_request.rb +11 -6
- data/lib/yoti/http/request.rb +220 -18
- data/lib/yoti/http/signed_request.rb +13 -4
- data/lib/yoti/protobuf/main.rb +16 -6
- data/lib/yoti/share/attribute_issuance_details.rb +1 -1
- data/lib/yoti/ssl.rb +3 -2
- data/lib/yoti/util/anchor_processor.rb +1 -1
- data/lib/yoti/util/validation.rb +41 -0
- data/lib/yoti/version.rb +1 -1
- data/rubocop.yml +9 -1
- data/yoti.gemspec +2 -5
- metadata +51 -60
- data/lib/yoti/sandbox.rb +0 -5
- data/lib/yoti/sandbox/anchor.rb +0 -49
- data/lib/yoti/sandbox/attribute.rb +0 -52
- data/lib/yoti/sandbox/profile.rb +0 -171
- data/lib/yoti/sandbox/sandbox.rb +0 -105
- data/lib/yoti/sandbox/sandbox_client.rb +0 -45
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 02fe8b8e97eb660a8f100add12f7a07591fd78c39a0b476ce386b01af9d8c18e
|
4
|
+
data.tar.gz: b37386c172ecf56164d5e8b18129c41698444459e4611b35e8aeda4da9176287
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36f47a7c8728ccdde726c67d7ecde1282051f128e63ffd685c6981634d660bba98ff7de9c0aed53dee950112a392978c5ffce44d3a130d16d7487eb5fd22431c
|
7
|
+
data.tar.gz: bbbee64ecc44ce41a204c8109fb673339972886d5818db20d3952009b76fedf12222e705b7eb090c4da0fb0f9c8375fc4402e0ed9c595a8a72974e3f37ea5397
|
@@ -0,0 +1,17 @@
|
|
1
|
+
---
|
2
|
+
name: Custom issue template
|
3
|
+
about: " There's a better way to get help!"
|
4
|
+
title: ''
|
5
|
+
labels: ''
|
6
|
+
assignees: ''
|
7
|
+
|
8
|
+
---
|
9
|
+
|
10
|
+
#
|
11
|
+
# Wait ✋
|
12
|
+
#
|
13
|
+
# There's a better way to get help!
|
14
|
+
#
|
15
|
+
# Send your questions or issues to sdksupport@yoti.com
|
16
|
+
#
|
17
|
+
#
|
data/CONTRIBUTING.md
CHANGED
@@ -16,35 +16,6 @@ bundle exec guard
|
|
16
16
|
|
17
17
|
Although this gem supports Ruby 2.0.0, in order to use the latest development dependencies you have to use at least Ruby 2.2.2.
|
18
18
|
|
19
|
-
If you wish to compile `.proto` definitions to Ruby, you will need to install [Google's Protocol Buffers](http://code.google.com/p/protobuf).
|
20
|
-
|
21
|
-
### OSX
|
22
|
-
|
23
|
-
```shell
|
24
|
-
brew install protobuf
|
25
|
-
```
|
26
|
-
|
27
|
-
### Ubuntu
|
28
|
-
|
29
|
-
```shell
|
30
|
-
sudo apt-get install -y protobuf
|
31
|
-
```
|
32
|
-
|
33
|
-
This gem relies heavily on the [Ruby Protobuf][] gem. For more information on how Google Protobuf works, please see the [Wiki pages][].
|
34
|
-
|
35
|
-
Compiling the common and attribute `.proto` definitions can be done with the following commands:
|
36
|
-
|
37
|
-
```shell
|
38
|
-
cd lib/yoti/protobuf/v1
|
39
|
-
protoc -I definitions/attribute-public-api/attrpubapi_v1 --ruby_out ./attribute_public_api definitions/attribute-public-api/attrpubapi_v1/*.proto
|
40
|
-
protoc -I definitions/common-public-api/compubapi_v1/ --ruby_out ./common_public_api definitions/common-public-api/compubapi_v1/*.proto
|
41
|
-
```
|
42
|
-
|
43
|
-
These commands will overwrite the current protobuf Ruby modules, which have been modified. If the protobuf files have to be updated, a good idea would be to change them manually, or generate the files in a new location, and compare the content.
|
44
|
-
|
45
|
-
[Ruby Protobuf]: https://github.com/ruby-protobuf/protobuf/
|
46
|
-
[Wiki Pages]: https://github.com/ruby-protobuf/protobuf/wiki
|
47
|
-
|
48
19
|
## Requirements
|
49
20
|
|
50
21
|
### Code coverage
|
data/README.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
# Yoti Ruby SDK
|
2
2
|
|
3
3
|
[![Build Status](https://travis-ci.com/getyoti/yoti-ruby-sdk.svg?branch=master)](https://travis-ci.com/getyoti/yoti-ruby-sdk)
|
4
|
+
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=getyoti%3Aruby&metric=coverage)](https://sonarcloud.io/dashboard?id=getyoti%3Aruby)
|
5
|
+
[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=getyoti%3Aruby&metric=bugs)](https://sonarcloud.io/dashboard?id=getyoti%3Aruby)
|
6
|
+
[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=getyoti%3Aruby&metric=code_smells)](https://sonarcloud.io/dashboard?id=getyoti%3Aruby)
|
7
|
+
[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=getyoti%3Aruby&metric=vulnerabilities)](https://sonarcloud.io/dashboard?id=getyoti%3Aruby)
|
4
8
|
|
5
9
|
Welcome to the Yoti Ruby SDK. This repository contains the tools you need to quickly integrate your Ruby back-end with Yoti so that your users can share their identity details with your application in a secure and trusted way.
|
6
10
|
|
data/Rakefile
CHANGED
@@ -6,16 +6,13 @@ require 'yaml'
|
|
6
6
|
# Tests #
|
7
7
|
################################
|
8
8
|
|
9
|
-
RSpec::Core::RakeTask.new
|
10
|
-
|
11
|
-
|
12
|
-
################################
|
13
|
-
# Coveralls #
|
14
|
-
################################
|
9
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
10
|
+
t.pattern = ['spec/yoti']
|
11
|
+
end
|
15
12
|
|
16
|
-
|
17
|
-
|
18
|
-
|
13
|
+
RSpec::Core::RakeTask.new(:test_generators) do |t|
|
14
|
+
t.pattern = ['spec/generators']
|
15
|
+
end
|
19
16
|
|
20
17
|
################################
|
21
18
|
# Rubocop #
|
@@ -46,4 +43,4 @@ end
|
|
46
43
|
# Defaults #
|
47
44
|
################################
|
48
45
|
|
49
|
-
task default: %i[spec rubocop]
|
46
|
+
task default: %i[spec test_generators rubocop]
|
data/lib/yoti.rb
CHANGED
@@ -18,6 +18,7 @@ require_relative 'yoti/data_type/application_profile'
|
|
18
18
|
require_relative 'yoti/data_type/profile'
|
19
19
|
require_relative 'yoti/data_type/attribute'
|
20
20
|
require_relative 'yoti/data_type/signed_time_stamp'
|
21
|
+
require_relative 'yoti/data_type/media'
|
21
22
|
require_relative 'yoti/data_type/image'
|
22
23
|
require_relative 'yoti/data_type/image_jpeg'
|
23
24
|
require_relative 'yoti/data_type/image_png'
|
@@ -26,7 +27,8 @@ require_relative 'yoti/data_type/document_details'
|
|
26
27
|
|
27
28
|
require_relative 'yoti/util/age_processor'
|
28
29
|
require_relative 'yoti/util/anchor_processor'
|
29
|
-
require_relative 'yoti/util/log
|
30
|
+
require_relative 'yoti/util/log'
|
31
|
+
require_relative 'yoti/util/validation'
|
30
32
|
|
31
33
|
require_relative 'yoti/activity_details'
|
32
34
|
require_relative 'yoti/client'
|
@@ -47,6 +49,53 @@ require_relative 'yoti/dynamic_share_service/extension/thirdparty_attribute_exte
|
|
47
49
|
require_relative 'yoti/share/extra_data'
|
48
50
|
require_relative 'yoti/share/attribute_issuance_details'
|
49
51
|
|
52
|
+
require_relative 'yoti/doc_scan/client'
|
53
|
+
require_relative 'yoti/doc_scan/constants'
|
54
|
+
|
55
|
+
require_relative 'yoti/doc_scan/session/create/create_session_result'
|
56
|
+
require_relative 'yoti/doc_scan/session/create/requested_check'
|
57
|
+
require_relative 'yoti/doc_scan/session/create/requested_document_authenticity_check'
|
58
|
+
require_relative 'yoti/doc_scan/session/create/requested_face_match_check'
|
59
|
+
require_relative 'yoti/doc_scan/session/create/requested_liveness_check'
|
60
|
+
require_relative 'yoti/doc_scan/session/create/requested_task'
|
61
|
+
require_relative 'yoti/doc_scan/session/create/requested_text_extraction_task'
|
62
|
+
require_relative 'yoti/doc_scan/session/create/document_filter'
|
63
|
+
require_relative 'yoti/doc_scan/session/create/document_restrictions_filter'
|
64
|
+
require_relative 'yoti/doc_scan/session/create/orthogonal_restrictions_filter'
|
65
|
+
require_relative 'yoti/doc_scan/session/create/required_document'
|
66
|
+
require_relative 'yoti/doc_scan/session/create/required_id_document'
|
67
|
+
require_relative 'yoti/doc_scan/session/create/sdk_config'
|
68
|
+
require_relative 'yoti/doc_scan/session/create/notification_config'
|
69
|
+
require_relative 'yoti/doc_scan/session/create/session_specification'
|
70
|
+
|
71
|
+
require_relative 'yoti/doc_scan/session/retrieve/check_response'
|
72
|
+
require_relative 'yoti/doc_scan/session/retrieve/resource_response'
|
73
|
+
require_relative 'yoti/doc_scan/session/retrieve/authenticity_check_response'
|
74
|
+
require_relative 'yoti/doc_scan/session/retrieve/breakdown_response'
|
75
|
+
require_relative 'yoti/doc_scan/session/retrieve/details_response'
|
76
|
+
require_relative 'yoti/doc_scan/session/retrieve/document_fields_response'
|
77
|
+
require_relative 'yoti/doc_scan/session/retrieve/face_map_response'
|
78
|
+
require_relative 'yoti/doc_scan/session/retrieve/face_match_check_response'
|
79
|
+
require_relative 'yoti/doc_scan/session/retrieve/frame_response'
|
80
|
+
require_relative 'yoti/doc_scan/session/retrieve/generated_check_response'
|
81
|
+
require_relative 'yoti/doc_scan/session/retrieve/generated_media'
|
82
|
+
require_relative 'yoti/doc_scan/session/retrieve/generated_text_data_check_response'
|
83
|
+
require_relative 'yoti/doc_scan/session/retrieve/get_session_result'
|
84
|
+
require_relative 'yoti/doc_scan/session/retrieve/id_document_resource_response'
|
85
|
+
require_relative 'yoti/doc_scan/session/retrieve/liveness_check_response'
|
86
|
+
require_relative 'yoti/doc_scan/session/retrieve/liveness_resource_response'
|
87
|
+
require_relative 'yoti/doc_scan/session/retrieve/media_response'
|
88
|
+
require_relative 'yoti/doc_scan/session/retrieve/page_response'
|
89
|
+
require_relative 'yoti/doc_scan/session/retrieve/recommendation_response'
|
90
|
+
require_relative 'yoti/doc_scan/session/retrieve/report_response'
|
91
|
+
require_relative 'yoti/doc_scan/session/retrieve/resource_container'
|
92
|
+
require_relative 'yoti/doc_scan/session/retrieve/task_response'
|
93
|
+
require_relative 'yoti/doc_scan/session/retrieve/text_data_check_response'
|
94
|
+
require_relative 'yoti/doc_scan/session/retrieve/text_extraction_task_response'
|
95
|
+
require_relative 'yoti/doc_scan/session/retrieve/zoom_liveness_resource_response'
|
96
|
+
|
97
|
+
require_relative 'yoti/doc_scan/support/supported_documents'
|
98
|
+
|
50
99
|
# The main module namespace of the Yoti gem
|
51
100
|
module Yoti
|
52
101
|
class << self
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'net/http'
|
2
|
+
require 'time'
|
2
3
|
|
3
4
|
module Yoti
|
4
5
|
#
|
@@ -93,6 +94,9 @@ module Yoti
|
|
93
94
|
#
|
94
95
|
# @param receipt [Hash] the receipt from the API request
|
95
96
|
# @param decrypted_profile [Object] Protobuf AttributeList decrypted object containing the profile attributes
|
97
|
+
# @param decrypted_application_profile [Object] Protobuf AttributeList decrypted object containing profile attributes for the application profile
|
98
|
+
# @param extra_data [Yoti::Share::ExtraData|nil] Processed extra data object or nil
|
99
|
+
# if absent from the receipt
|
96
100
|
#
|
97
101
|
def initialize(receipt, decrypted_profile = nil, decrypted_application_profile = nil, extra_data = nil)
|
98
102
|
@remember_me_id = receipt['remember_me_id']
|
@@ -103,7 +107,7 @@ module Yoti
|
|
103
107
|
@timestamp = receipt['timestamp'] ? Time.parse(receipt['timestamp']) : nil
|
104
108
|
@extended_user_profile = process_decrypted_profile(decrypted_profile)
|
105
109
|
@extended_application_profile = process_decrypted_profile(decrypted_application_profile)
|
106
|
-
@extra_data =
|
110
|
+
@extra_data = extra_data
|
107
111
|
@user_profile = @extended_user_profile.map do |name, attribute|
|
108
112
|
[name, attribute.value]
|
109
113
|
end.to_h
|
data/lib/yoti/client.rb
CHANGED
@@ -1,15 +1,17 @@
|
|
1
1
|
module Yoti
|
2
2
|
#
|
3
|
-
# Handles all the publicly
|
4
|
-
#
|
3
|
+
# Handles all the publicly accessible Yoti methods for
|
4
|
+
# getting data using an encrypted connect token
|
5
5
|
#
|
6
6
|
module Client
|
7
7
|
#
|
8
8
|
# Performs all the steps required to get the decrypted profile from an API request
|
9
9
|
#
|
10
|
-
# @param
|
10
|
+
# @param [String] encrypted_connect_token
|
11
|
+
# Token provided as a base 64 string
|
11
12
|
#
|
12
|
-
# @return [
|
13
|
+
# @return [ActivityDetails]
|
14
|
+
# An ActivityDetails instance encapsulating the user profile
|
13
15
|
#
|
14
16
|
def self.get_activity_details(encrypted_connect_token)
|
15
17
|
receipt = Yoti::ProfileRequest.new(encrypted_connect_token).receipt
|
@@ -22,6 +24,13 @@ module Yoti
|
|
22
24
|
ActivityDetails.new(receipt, user_profile, application_profile, extra_data)
|
23
25
|
end
|
24
26
|
|
27
|
+
#
|
28
|
+
# Perform AML check
|
29
|
+
#
|
30
|
+
# @param [AmlProfile] aml_profile
|
31
|
+
#
|
32
|
+
# @return [<Hash>]
|
33
|
+
#
|
25
34
|
def self.aml_check(aml_profile)
|
26
35
|
Yoti::AmlCheckRequest.new(aml_profile).response
|
27
36
|
end
|
data/lib/yoti/configuration.rb
CHANGED
@@ -3,7 +3,7 @@ module Yoti
|
|
3
3
|
attr_accessor :client_sdk_id, :key_file_path, :key, :sdk_identifier,
|
4
4
|
:api_url, :api_port, :api_version
|
5
5
|
|
6
|
-
attr_writer :api_endpoint
|
6
|
+
attr_writer :api_endpoint, :doc_scan_api_endpoint
|
7
7
|
|
8
8
|
# Set config variables by using a configuration block
|
9
9
|
def initialize
|
@@ -18,7 +18,12 @@ module Yoti
|
|
18
18
|
|
19
19
|
# @return [String] the API endpoint for the selected API version
|
20
20
|
def api_endpoint
|
21
|
-
@api_endpoint ||= "#{@api_url}/api/#{@api_version}"
|
21
|
+
@api_endpoint ||= ENV['YOTI_API_URL'] || "#{@api_url}/api/#{@api_version}"
|
22
|
+
end
|
23
|
+
|
24
|
+
# @return [String] the Doc Scan API endpoint
|
25
|
+
def doc_scan_api_endpoint
|
26
|
+
@doc_scan_api_endpoint ||= ENV['YOTI_DOC_SCAN_API_URL'] || "#{@api_url}/idverify/#{@api_version}"
|
22
27
|
end
|
23
28
|
|
24
29
|
# Validates the configuration values set in instance variables
|
@@ -37,7 +37,7 @@ module Yoti
|
|
37
37
|
attr_reader :age
|
38
38
|
|
39
39
|
#
|
40
|
-
# @param [Yoti::Attribute]
|
40
|
+
# @param [Yoti::Attribute] attribute
|
41
41
|
#
|
42
42
|
def initialize(attribute)
|
43
43
|
raise(ArgumentError, "'#{attribute.name}' is not a valid age verification") unless /^[^:]+:(?!.*:)[0-9]+$/.match?(attribute.name)
|
@@ -1,10 +1,10 @@
|
|
1
1
|
module Yoti
|
2
2
|
class DocumentDetails
|
3
3
|
#
|
4
|
-
#
|
5
|
-
# e.g PASS_CARD GBR 22719564893 - CITIZENCARD, the last two are optionals
|
4
|
+
# @deprecated 2.0.0 pattern is no longer used for validation.
|
6
5
|
#
|
7
6
|
VALIDATION_PATTERN = '^([A-Za-z_]*) ([A-Za-z]{3}) ([A-Za-z0-9]{1}).*$'
|
7
|
+
|
8
8
|
TYPE_INDEX = 0
|
9
9
|
COUNTRY_INDEX = 1
|
10
10
|
NUMBER_INDEX = 2
|
@@ -51,28 +51,20 @@ module Yoti
|
|
51
51
|
# @param [String] value
|
52
52
|
#
|
53
53
|
def initialize(value)
|
54
|
-
validate_value(value)
|
55
54
|
parse_value(value)
|
56
55
|
end
|
57
56
|
|
58
57
|
private
|
59
58
|
|
60
|
-
#
|
61
|
-
# Asserts provided matches VALIDATION_PATTERN
|
62
|
-
#
|
63
|
-
# @param [String] value
|
64
|
-
#
|
65
|
-
def validate_value(value)
|
66
|
-
raise(ArgumentError, "Invalid value for #{self.class.name}") unless /#{VALIDATION_PATTERN}/.match?(value)
|
67
|
-
end
|
68
|
-
|
69
59
|
#
|
70
60
|
# Parses provided value into separate attributes
|
71
61
|
#
|
72
62
|
# @param [String] value
|
73
63
|
#
|
74
64
|
def parse_value(value)
|
75
|
-
attributes = value.split(
|
65
|
+
attributes = value.split(/ /)
|
66
|
+
raise(ArgumentError, "Invalid value for #{self.class.name}") if attributes.length < 3 || attributes.include?('')
|
67
|
+
|
76
68
|
@type = attributes[TYPE_INDEX]
|
77
69
|
@issuing_country = attributes[COUNTRY_INDEX]
|
78
70
|
@document_number = attributes[NUMBER_INDEX]
|
data/lib/yoti/data_type/image.rb
CHANGED
@@ -1,19 +1,11 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Yoti
|
4
|
-
class Image
|
5
|
-
attr_reader :content
|
6
|
-
attr_reader :mime_type
|
7
|
-
|
4
|
+
class Image < Media
|
8
5
|
def initialize(content, mime_type)
|
9
|
-
raise(TypeError,
|
10
|
-
|
11
|
-
@content = content
|
12
|
-
@mime_type = mime_type
|
13
|
-
end
|
6
|
+
raise(TypeError, "#{self.class} is an abstract class, so cannot be instantiated") if self.class == Image
|
14
7
|
|
15
|
-
|
16
|
-
"data:#{mime_type};base64,#{Base64.strict_encode64(content)}"
|
8
|
+
super(content, mime_type)
|
17
9
|
end
|
18
10
|
end
|
19
11
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'base64'
|
4
|
+
|
5
|
+
module Yoti
|
6
|
+
class Media
|
7
|
+
attr_reader :content
|
8
|
+
attr_reader :mime_type
|
9
|
+
|
10
|
+
def initialize(content, mime_type)
|
11
|
+
@content = content
|
12
|
+
@mime_type = mime_type
|
13
|
+
end
|
14
|
+
|
15
|
+
def base64_content
|
16
|
+
"data:#{mime_type};base64,#{Base64.strict_encode64(content)}"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,163 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Yoti
|
4
|
+
module DocScan
|
5
|
+
class Client
|
6
|
+
class << self
|
7
|
+
#
|
8
|
+
# Creates a Doc Scan session using the supplied session specification
|
9
|
+
#
|
10
|
+
# @param [Yoti::DocScan::Session::Create::SessionSpecification] session_specification
|
11
|
+
#
|
12
|
+
# @return [Yoti::DocScan::Session::Create::CreateSessionResult]
|
13
|
+
#
|
14
|
+
def create_session(session_specification)
|
15
|
+
Validation.assert_is_a(
|
16
|
+
Yoti::DocScan::Session::Create::SessionSpecification,
|
17
|
+
session_specification,
|
18
|
+
'session_specification'
|
19
|
+
)
|
20
|
+
|
21
|
+
response = create_request
|
22
|
+
.with_http_method('POST')
|
23
|
+
.with_endpoint('sessions')
|
24
|
+
.with_payload(session_specification)
|
25
|
+
.with_query_param('sdkId', Yoti.configuration.client_sdk_id)
|
26
|
+
.build
|
27
|
+
.execute
|
28
|
+
|
29
|
+
Yoti::DocScan::Session::Create::CreateSessionResult.new(JSON.parse(response.body))
|
30
|
+
end
|
31
|
+
|
32
|
+
#
|
33
|
+
# Retrieves the state of a previously created Yoti Doc Scan session
|
34
|
+
#
|
35
|
+
# @param [String] session_id
|
36
|
+
#
|
37
|
+
# @return [Yoti::DocScan::Session::Retrieve::GetSessionResult]
|
38
|
+
#
|
39
|
+
def get_session(session_id)
|
40
|
+
Validation.assert_is_a(String, session_id, 'session_id')
|
41
|
+
|
42
|
+
response = create_request
|
43
|
+
.with_http_method('GET')
|
44
|
+
.with_endpoint(session_path(session_id))
|
45
|
+
.with_query_param('sdkId', Yoti.configuration.client_sdk_id)
|
46
|
+
.build
|
47
|
+
.execute
|
48
|
+
|
49
|
+
Yoti::DocScan::Session::Retrieve::GetSessionResult.new(JSON.parse(response.body))
|
50
|
+
end
|
51
|
+
|
52
|
+
#
|
53
|
+
# Deletes a previously created Yoti Doc Scan session and all
|
54
|
+
# of its related resources
|
55
|
+
#
|
56
|
+
# @param [String] session_id
|
57
|
+
#
|
58
|
+
def delete_session(session_id)
|
59
|
+
Validation.assert_is_a(String, session_id, 'session_id')
|
60
|
+
|
61
|
+
create_request
|
62
|
+
.with_http_method('DELETE')
|
63
|
+
.with_endpoint(session_path(session_id))
|
64
|
+
.with_query_param('sdkId', Yoti.configuration.client_sdk_id)
|
65
|
+
.build
|
66
|
+
.execute
|
67
|
+
end
|
68
|
+
|
69
|
+
#
|
70
|
+
# Retrieves media related to a Yoti Doc Scan session based
|
71
|
+
# on the supplied media ID
|
72
|
+
#
|
73
|
+
# @param [String] session_id
|
74
|
+
# @param [String] media_id
|
75
|
+
#
|
76
|
+
# @return [Yoti::Media]
|
77
|
+
#
|
78
|
+
def get_media_content(session_id, media_id)
|
79
|
+
Validation.assert_is_a(String, session_id, 'session_id')
|
80
|
+
Validation.assert_is_a(String, media_id, 'media_id')
|
81
|
+
|
82
|
+
response = create_request
|
83
|
+
.with_http_method('GET')
|
84
|
+
.with_endpoint(media_path(session_id, media_id))
|
85
|
+
.with_query_param('sdkId', Yoti.configuration.client_sdk_id)
|
86
|
+
.build
|
87
|
+
.execute
|
88
|
+
|
89
|
+
Yoti::Media.new(
|
90
|
+
response.body,
|
91
|
+
response.get_fields('content-type')[0]
|
92
|
+
)
|
93
|
+
end
|
94
|
+
|
95
|
+
#
|
96
|
+
# Deletes media related to a Yoti Doc Scan session based
|
97
|
+
# on the supplied media ID
|
98
|
+
#
|
99
|
+
# @param [String] session_id
|
100
|
+
# @param [String] media_id
|
101
|
+
#
|
102
|
+
def delete_media_content(session_id, media_id)
|
103
|
+
Validation.assert_is_a(String, session_id, 'session_id')
|
104
|
+
Validation.assert_is_a(String, media_id, 'media_id')
|
105
|
+
|
106
|
+
create_request
|
107
|
+
.with_http_method('DELETE')
|
108
|
+
.with_endpoint(media_path(session_id, media_id))
|
109
|
+
.with_query_param('sdkId', Yoti.configuration.client_sdk_id)
|
110
|
+
.build
|
111
|
+
.execute
|
112
|
+
end
|
113
|
+
|
114
|
+
#
|
115
|
+
# Gets a list of supported documents.
|
116
|
+
#
|
117
|
+
# @return [Yoti::DocScan::Support::SupportedDocumentsResponse]
|
118
|
+
#
|
119
|
+
def supported_documents
|
120
|
+
response = create_request
|
121
|
+
.with_http_method('GET')
|
122
|
+
.with_endpoint('supported-documents')
|
123
|
+
.build
|
124
|
+
.execute
|
125
|
+
|
126
|
+
Yoti::DocScan::Support::SupportedDocumentsResponse.new(JSON.parse(response.body))
|
127
|
+
end
|
128
|
+
|
129
|
+
private
|
130
|
+
|
131
|
+
#
|
132
|
+
# @param [String] session_id
|
133
|
+
#
|
134
|
+
# @return [String]
|
135
|
+
#
|
136
|
+
def session_path(session_id)
|
137
|
+
"sessions/#{session_id}"
|
138
|
+
end
|
139
|
+
|
140
|
+
#
|
141
|
+
# @param [String] session_id
|
142
|
+
# @param [String] media_id
|
143
|
+
#
|
144
|
+
# @return [String]
|
145
|
+
#
|
146
|
+
def media_path(session_id, media_id)
|
147
|
+
"#{session_path(session_id)}/media/#{media_id}/content"
|
148
|
+
end
|
149
|
+
|
150
|
+
#
|
151
|
+
# Create a base Doc Scan request
|
152
|
+
#
|
153
|
+
# @return [Yoti::Request]
|
154
|
+
#
|
155
|
+
def create_request
|
156
|
+
Yoti::Request
|
157
|
+
.builder
|
158
|
+
.with_base_url(Yoti.configuration.doc_scan_api_endpoint)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|