yoti_sandbox 1.0.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/README.md +8 -1
- data/lib/yoti_sandbox.rb +1 -0
- data/lib/yoti_sandbox/doc_scan.rb +25 -0
- data/lib/yoti_sandbox/doc_scan/client.rb +59 -0
- data/lib/yoti_sandbox/doc_scan/errors.rb +83 -0
- data/lib/yoti_sandbox/doc_scan/request/check/check.rb +115 -0
- data/lib/yoti_sandbox/doc_scan/request/check/document_authenticity_check.rb +29 -0
- data/lib/yoti_sandbox/doc_scan/request/check/document_check.rb +48 -0
- data/lib/yoti_sandbox/doc_scan/request/check/document_face_match_check.rb +29 -0
- data/lib/yoti_sandbox/doc_scan/request/check/document_text_data_check.rb +78 -0
- data/lib/yoti_sandbox/doc_scan/request/check/id_document_comparison_check.rb +56 -0
- data/lib/yoti_sandbox/doc_scan/request/check/liveness_check.rb +34 -0
- data/lib/yoti_sandbox/doc_scan/request/check/report/breakdown.rb +97 -0
- data/lib/yoti_sandbox/doc_scan/request/check/report/detail.rb +34 -0
- data/lib/yoti_sandbox/doc_scan/request/check/report/recommendation.rb +88 -0
- data/lib/yoti_sandbox/doc_scan/request/check/supplementary_document_text_data_check.rb +78 -0
- data/lib/yoti_sandbox/doc_scan/request/check/zoom_liveness_check.rb +36 -0
- data/lib/yoti_sandbox/doc_scan/request/check_reports.rb +182 -0
- data/lib/yoti_sandbox/doc_scan/request/document_filter.rb +77 -0
- data/lib/yoti_sandbox/doc_scan/request/response_config.rb +75 -0
- data/lib/yoti_sandbox/doc_scan/request/task/document_id_photo.rb +35 -0
- data/lib/yoti_sandbox/doc_scan/request/task/document_text_data_extraction_task.rb +170 -0
- data/lib/yoti_sandbox/doc_scan/request/task/supplementary_document_text_data_extraction_task.rb +152 -0
- data/lib/yoti_sandbox/doc_scan/request/task/text_data_extraction_reason.rb +78 -0
- data/lib/yoti_sandbox/doc_scan/request/task/text_data_extraction_recommendation.rb +86 -0
- data/lib/yoti_sandbox/doc_scan/request/task_results.rb +96 -0
- data/lib/yoti_sandbox/profile.rb +5 -0
- data/lib/yoti_sandbox/profile/age_verification.rb +7 -0
- data/lib/yoti_sandbox/profile/client.rb +8 -26
- data/lib/yoti_sandbox/profile/document_images.rb +69 -0
- data/lib/yoti_sandbox/profile/extra_data.rb +92 -0
- data/lib/yoti_sandbox/profile/third_party.rb +158 -0
- data/lib/yoti_sandbox/profile/token_request.rb +47 -6
- data/yoti_sandbox.gemspec +18 -5
- metadata +38 -18
- data/.github/ISSUE_TEMPLATE.md +0 -17
- data/.gitignore +0 -56
- data/CONTRIBUTING.md +0 -30
- data/Guardfile +0 -11
- data/Rakefile +0 -41
- data/rubocop.yml +0 -44
- data/yardstick.yml +0 -9
@@ -0,0 +1,77 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Yoti
|
4
|
+
module Sandbox
|
5
|
+
module DocScan
|
6
|
+
module Request
|
7
|
+
class DocumentFilter
|
8
|
+
#
|
9
|
+
# @param [Array<String>] document_types
|
10
|
+
# @param [Array<String>] country_codes
|
11
|
+
#
|
12
|
+
def initialize(document_types, country_codes)
|
13
|
+
Validation.assert_is_a(Array, document_types, 'document_types')
|
14
|
+
@document_types = document_types
|
15
|
+
|
16
|
+
Validation.assert_is_a(Array, country_codes, 'country_codes')
|
17
|
+
@country_codes = country_codes
|
18
|
+
end
|
19
|
+
|
20
|
+
def as_json(*_args)
|
21
|
+
{
|
22
|
+
document_types: @document_types,
|
23
|
+
country_codes: @country_codes
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
def to_json(*_args)
|
28
|
+
as_json.to_json
|
29
|
+
end
|
30
|
+
|
31
|
+
#
|
32
|
+
# @return [DocumentFilterBuilder]
|
33
|
+
#
|
34
|
+
def self.builder
|
35
|
+
DocumentFilterBuilder.new
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
class DocumentFilterBuilder
|
40
|
+
def initialize
|
41
|
+
@document_types = []
|
42
|
+
@country_codes = []
|
43
|
+
end
|
44
|
+
|
45
|
+
#
|
46
|
+
# @param [String] country_code
|
47
|
+
#
|
48
|
+
# @return [self]
|
49
|
+
#
|
50
|
+
def with_country_code(country_code)
|
51
|
+
Validation.assert_is_a(String, country_code, 'country_code')
|
52
|
+
@country_codes.push(country_code)
|
53
|
+
self
|
54
|
+
end
|
55
|
+
|
56
|
+
#
|
57
|
+
# @param [String] document_type
|
58
|
+
#
|
59
|
+
# @return [self]
|
60
|
+
#
|
61
|
+
def with_document_type(document_type)
|
62
|
+
Validation.assert_is_a(String, document_type, 'country_code')
|
63
|
+
@document_types.push(document_type)
|
64
|
+
self
|
65
|
+
end
|
66
|
+
|
67
|
+
#
|
68
|
+
# @return [DocumentFilter]
|
69
|
+
#
|
70
|
+
def build
|
71
|
+
DocumentFilter.new(@document_types, @country_codes)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Yoti
|
4
|
+
module Sandbox
|
5
|
+
module DocScan
|
6
|
+
module Request
|
7
|
+
class ResponseConfig
|
8
|
+
#
|
9
|
+
# @param [TaskResults,nil] task_results
|
10
|
+
# @param [CheckReports] check_reports
|
11
|
+
#
|
12
|
+
def initialize(
|
13
|
+
task_results,
|
14
|
+
check_reports
|
15
|
+
)
|
16
|
+
Validation.assert_is_a(TaskResults, task_results, 'task_results', true)
|
17
|
+
@task_results = task_results
|
18
|
+
|
19
|
+
Validation.assert_is_a(CheckReports, check_reports, 'check_reports')
|
20
|
+
@check_reports = check_reports
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.builder
|
24
|
+
ResponseConfigBuilder.new
|
25
|
+
end
|
26
|
+
|
27
|
+
def to_json(*_args)
|
28
|
+
as_json.to_json
|
29
|
+
end
|
30
|
+
|
31
|
+
def as_json(*_args)
|
32
|
+
{
|
33
|
+
task_results: @task_results,
|
34
|
+
check_reports: @check_reports
|
35
|
+
}.compact
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
class ResponseConfigBuilder
|
40
|
+
#
|
41
|
+
# @param [TaskResults] task_results
|
42
|
+
#
|
43
|
+
# @return [self]
|
44
|
+
#
|
45
|
+
def with_task_results(task_results)
|
46
|
+
Validation.assert_is_a(TaskResults, task_results, 'task_results')
|
47
|
+
@task_results = task_results
|
48
|
+
self
|
49
|
+
end
|
50
|
+
|
51
|
+
#
|
52
|
+
# @param [CheckReports] check_reports
|
53
|
+
#
|
54
|
+
# @return [self]
|
55
|
+
#
|
56
|
+
def with_check_reports(check_reports)
|
57
|
+
Validation.assert_is_a(CheckReports, check_reports, 'check_reports')
|
58
|
+
@check_reports = check_reports
|
59
|
+
self
|
60
|
+
end
|
61
|
+
|
62
|
+
#
|
63
|
+
# @return [ResponseConfig]
|
64
|
+
#
|
65
|
+
def build
|
66
|
+
ResponseConfig.new(
|
67
|
+
@task_results,
|
68
|
+
@check_reports
|
69
|
+
)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'base64'
|
4
|
+
|
5
|
+
module Yoti
|
6
|
+
module Sandbox
|
7
|
+
module DocScan
|
8
|
+
module Request
|
9
|
+
class DocumentIdPhoto
|
10
|
+
#
|
11
|
+
# @param [String] content_type
|
12
|
+
# @param [bin] data
|
13
|
+
#
|
14
|
+
def initialize(content_type, data)
|
15
|
+
Validation.assert_is_a(String, content_type, 'content_type')
|
16
|
+
@content_type = content_type
|
17
|
+
|
18
|
+
@data = data
|
19
|
+
end
|
20
|
+
|
21
|
+
def to_json(*_args)
|
22
|
+
as_json.to_json
|
23
|
+
end
|
24
|
+
|
25
|
+
def as_json(*_args)
|
26
|
+
{
|
27
|
+
content_type: @content_type,
|
28
|
+
data: Base64.strict_encode64(@data)
|
29
|
+
}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,170 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module Yoti
|
6
|
+
module Sandbox
|
7
|
+
module DocScan
|
8
|
+
module Request
|
9
|
+
class DocumentTextDataExtractionTask
|
10
|
+
#
|
11
|
+
# @param [DocumentTextDataExtractionTaskResult] result
|
12
|
+
# @param [DocumentFilter] document_filter
|
13
|
+
#
|
14
|
+
def initialize(result, document_filter)
|
15
|
+
Validation.assert_is_a(DocumentTextDataExtractionTaskResult, result, 'result')
|
16
|
+
@result = result
|
17
|
+
|
18
|
+
Validation.assert_is_a(DocumentFilter, document_filter, 'document_filter', true)
|
19
|
+
@document_filter = document_filter
|
20
|
+
end
|
21
|
+
|
22
|
+
def to_json(*_args)
|
23
|
+
as_json.to_json
|
24
|
+
end
|
25
|
+
|
26
|
+
def as_json(*_args)
|
27
|
+
json = {
|
28
|
+
result: @result.as_json
|
29
|
+
}
|
30
|
+
json[:document_filter] = @document_filter.as_json unless @document_filter.nil?
|
31
|
+
json
|
32
|
+
end
|
33
|
+
|
34
|
+
#
|
35
|
+
# @return [DocumentTextDataExtractionTaskBuilder]
|
36
|
+
#
|
37
|
+
def self.builder
|
38
|
+
DocumentTextDataExtractionTaskBuilder.new
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
class DocumentTextDataExtractionTaskResult
|
43
|
+
#
|
44
|
+
# @param [Hash,nil] document_fields
|
45
|
+
# @param [DocumentIdPhoto,nil] document_id_photo
|
46
|
+
# @param [String,nil] detected_country
|
47
|
+
# @param [TextDataExtractionRecommendation,nil] recommendation
|
48
|
+
#
|
49
|
+
def initialize(
|
50
|
+
document_fields,
|
51
|
+
document_id_photo = nil,
|
52
|
+
detected_country = nil,
|
53
|
+
recommendation = nil
|
54
|
+
)
|
55
|
+
unless document_fields.nil?
|
56
|
+
Validation.assert_is_a(Hash, document_fields, 'document_fields')
|
57
|
+
document_fields.each { |_k, v| Validation.assert_respond_to(:to_json, v, 'document_fields value') }
|
58
|
+
end
|
59
|
+
@document_fields = document_fields
|
60
|
+
|
61
|
+
Validation.assert_is_a(DocumentIdPhoto, document_id_photo, 'document_id_photo', true)
|
62
|
+
@document_id_photo = document_id_photo
|
63
|
+
|
64
|
+
Validation.assert_is_a(String, detected_country, 'detected_country', true)
|
65
|
+
@detected_country = detected_country
|
66
|
+
|
67
|
+
Validation.assert_is_a(TextDataExtractionRecommendation, recommendation, 'recommendation', true)
|
68
|
+
@recommendation = recommendation
|
69
|
+
end
|
70
|
+
|
71
|
+
def to_json(*_args)
|
72
|
+
as_json.to_json
|
73
|
+
end
|
74
|
+
|
75
|
+
def as_json(*_args)
|
76
|
+
{
|
77
|
+
document_fields: @document_fields,
|
78
|
+
document_id_photo: @document_id_photo,
|
79
|
+
detected_country: @detected_country,
|
80
|
+
recommendation: @recommendation
|
81
|
+
}.compact
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
class DocumentTextDataExtractionTaskBuilder
|
86
|
+
#
|
87
|
+
# @param [String] key
|
88
|
+
# @param [#to_json] value
|
89
|
+
#
|
90
|
+
# @return [self]
|
91
|
+
#
|
92
|
+
def with_document_field(key, value)
|
93
|
+
Validation.assert_is_a(String, key, 'key')
|
94
|
+
Validation.assert_respond_to(:to_json, value, 'value')
|
95
|
+
@document_fields ||= {}
|
96
|
+
@document_fields[key] = value
|
97
|
+
self
|
98
|
+
end
|
99
|
+
|
100
|
+
#
|
101
|
+
# @param [Hash] document_fields
|
102
|
+
#
|
103
|
+
# @return [self]
|
104
|
+
#
|
105
|
+
def with_document_fields(document_fields)
|
106
|
+
Validation.assert_is_a(Hash, document_fields, 'document_fields')
|
107
|
+
@document_fields = document_fields
|
108
|
+
self
|
109
|
+
end
|
110
|
+
|
111
|
+
#
|
112
|
+
# @param [DocumentFilter] document_filter
|
113
|
+
#
|
114
|
+
# @return [self]
|
115
|
+
#
|
116
|
+
def with_document_filter(document_filter)
|
117
|
+
@document_filter = document_filter
|
118
|
+
self
|
119
|
+
end
|
120
|
+
|
121
|
+
#
|
122
|
+
# @param [String] content_type
|
123
|
+
# @param [bin] data
|
124
|
+
#
|
125
|
+
# @return [self]
|
126
|
+
#
|
127
|
+
def with_document_id_photo(content_type, data)
|
128
|
+
@document_id_photo = DocumentIdPhoto.new(content_type, data)
|
129
|
+
self
|
130
|
+
end
|
131
|
+
|
132
|
+
#
|
133
|
+
# @param [TextDataExtractionRecommendation] recommendation
|
134
|
+
#
|
135
|
+
# @return [self]
|
136
|
+
#
|
137
|
+
def with_recommendation(recommendation)
|
138
|
+
Validation.assert_is_a(TextDataExtractionRecommendation, recommendation, 'recommendation')
|
139
|
+
@recommendation = recommendation
|
140
|
+
self
|
141
|
+
end
|
142
|
+
|
143
|
+
#
|
144
|
+
# @param [String] detected_country
|
145
|
+
#
|
146
|
+
# @return [self]
|
147
|
+
#
|
148
|
+
def with_detected_country(detected_country)
|
149
|
+
Validation.assert_is_a(String, detected_country, 'detected_country')
|
150
|
+
@detected_country = detected_country
|
151
|
+
self
|
152
|
+
end
|
153
|
+
|
154
|
+
#
|
155
|
+
# @return [DocumentTextDataExtractionTask]
|
156
|
+
#
|
157
|
+
def build
|
158
|
+
result = DocumentTextDataExtractionTaskResult.new(
|
159
|
+
@document_fields,
|
160
|
+
@document_id_photo,
|
161
|
+
@detected_country,
|
162
|
+
@recommendation
|
163
|
+
)
|
164
|
+
DocumentTextDataExtractionTask.new(result, @document_filter)
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
data/lib/yoti_sandbox/doc_scan/request/task/supplementary_document_text_data_extraction_task.rb
ADDED
@@ -0,0 +1,152 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module Yoti
|
6
|
+
module Sandbox
|
7
|
+
module DocScan
|
8
|
+
module Request
|
9
|
+
class SupplementaryDocumentTextDataExtractionTask
|
10
|
+
#
|
11
|
+
# @param [SupplementaryDocumentTextDataExtractionTaskResult] result
|
12
|
+
# @param [DocumentFilter] document_filter
|
13
|
+
#
|
14
|
+
def initialize(result, document_filter)
|
15
|
+
Validation.assert_is_a(SupplementaryDocumentTextDataExtractionTaskResult, result, 'result')
|
16
|
+
@result = result
|
17
|
+
|
18
|
+
Validation.assert_is_a(DocumentFilter, document_filter, 'document_filter', true)
|
19
|
+
@document_filter = document_filter
|
20
|
+
end
|
21
|
+
|
22
|
+
def to_json(*_args)
|
23
|
+
as_json.to_json
|
24
|
+
end
|
25
|
+
|
26
|
+
def as_json(*_args)
|
27
|
+
json = {
|
28
|
+
result: @result.as_json
|
29
|
+
}
|
30
|
+
json[:document_filter] = @document_filter.as_json unless @document_filter.nil?
|
31
|
+
json
|
32
|
+
end
|
33
|
+
|
34
|
+
#
|
35
|
+
# @return [SupplementaryDocumentTextDataExtractionTaskBuilder]
|
36
|
+
#
|
37
|
+
def self.builder
|
38
|
+
SupplementaryDocumentTextDataExtractionTaskBuilder.new
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
class SupplementaryDocumentTextDataExtractionTaskResult
|
43
|
+
#
|
44
|
+
# @param [Hash,nil] document_fields
|
45
|
+
# @param [String,nil] detected_country
|
46
|
+
# @param [TextDataExtractionRecommendation,nil] recommendation
|
47
|
+
#
|
48
|
+
def initialize(
|
49
|
+
document_fields,
|
50
|
+
detected_country = nil,
|
51
|
+
recommendation = nil
|
52
|
+
)
|
53
|
+
unless document_fields.nil?
|
54
|
+
Validation.assert_is_a(Hash, document_fields, 'document_fields')
|
55
|
+
document_fields.each { |_k, v| Validation.assert_respond_to(:to_json, v, 'document_fields value') }
|
56
|
+
end
|
57
|
+
@document_fields = document_fields
|
58
|
+
|
59
|
+
Validation.assert_is_a(String, detected_country, 'detected_country', true)
|
60
|
+
@detected_country = detected_country
|
61
|
+
|
62
|
+
Validation.assert_is_a(TextDataExtractionRecommendation, recommendation, 'recommendation', true)
|
63
|
+
@recommendation = recommendation
|
64
|
+
end
|
65
|
+
|
66
|
+
def to_json(*_args)
|
67
|
+
as_json.to_json
|
68
|
+
end
|
69
|
+
|
70
|
+
def as_json(*_args)
|
71
|
+
{
|
72
|
+
document_fields: @document_fields,
|
73
|
+
detected_country: @detected_country,
|
74
|
+
recommendation: @recommendation
|
75
|
+
}.compact
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
class SupplementaryDocumentTextDataExtractionTaskBuilder
|
80
|
+
#
|
81
|
+
# @param [String] key
|
82
|
+
# @param [#to_json] value
|
83
|
+
#
|
84
|
+
# @return [self]
|
85
|
+
#
|
86
|
+
def with_document_field(key, value)
|
87
|
+
Validation.assert_is_a(String, key, 'key')
|
88
|
+
Validation.assert_respond_to(:to_json, value, 'value')
|
89
|
+
@document_fields ||= {}
|
90
|
+
@document_fields[key] = value
|
91
|
+
self
|
92
|
+
end
|
93
|
+
|
94
|
+
#
|
95
|
+
# @param [Hash] document_fields
|
96
|
+
#
|
97
|
+
# @return [self]
|
98
|
+
#
|
99
|
+
def with_document_fields(document_fields)
|
100
|
+
Validation.assert_is_a(Hash, document_fields, 'document_fields')
|
101
|
+
@document_fields = document_fields
|
102
|
+
self
|
103
|
+
end
|
104
|
+
|
105
|
+
#
|
106
|
+
# @param [DocumentFilter] document_filter
|
107
|
+
#
|
108
|
+
# @return [self]
|
109
|
+
#
|
110
|
+
def with_document_filter(document_filter)
|
111
|
+
@document_filter = document_filter
|
112
|
+
self
|
113
|
+
end
|
114
|
+
|
115
|
+
#
|
116
|
+
# @param [TextDataExtractionRecommendation] recommendation
|
117
|
+
#
|
118
|
+
# @return [self]
|
119
|
+
#
|
120
|
+
def with_recommendation(recommendation)
|
121
|
+
Validation.assert_is_a(TextDataExtractionRecommendation, recommendation, 'recommendation')
|
122
|
+
@recommendation = recommendation
|
123
|
+
self
|
124
|
+
end
|
125
|
+
|
126
|
+
#
|
127
|
+
# @param [String] detected_country
|
128
|
+
#
|
129
|
+
# @return [self]
|
130
|
+
#
|
131
|
+
def with_detected_country(detected_country)
|
132
|
+
Validation.assert_is_a(String, detected_country, 'detected_country')
|
133
|
+
@detected_country = detected_country
|
134
|
+
self
|
135
|
+
end
|
136
|
+
|
137
|
+
#
|
138
|
+
# @return [SupplementaryDocumentTextDataExtractionTask]
|
139
|
+
#
|
140
|
+
def build
|
141
|
+
result = SupplementaryDocumentTextDataExtractionTaskResult.new(
|
142
|
+
@document_fields,
|
143
|
+
@detected_country,
|
144
|
+
@recommendation
|
145
|
+
)
|
146
|
+
SupplementaryDocumentTextDataExtractionTask.new(result, @document_filter)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|