yoti_sandbox 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (27) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +8 -1
  3. data/lib/yoti_sandbox.rb +1 -0
  4. data/lib/yoti_sandbox/doc_scan.rb +18 -0
  5. data/lib/yoti_sandbox/doc_scan/client.rb +49 -0
  6. data/lib/yoti_sandbox/doc_scan/request/check/check.rb +115 -0
  7. data/lib/yoti_sandbox/doc_scan/request/check/document_authenticity_check.rb +29 -0
  8. data/lib/yoti_sandbox/doc_scan/request/check/document_check.rb +48 -0
  9. data/lib/yoti_sandbox/doc_scan/request/check/document_face_match_check.rb +29 -0
  10. data/lib/yoti_sandbox/doc_scan/request/check/document_text_data_check.rb +79 -0
  11. data/lib/yoti_sandbox/doc_scan/request/check/liveness_check.rb +34 -0
  12. data/lib/yoti_sandbox/doc_scan/request/check/report/breakdown.rb +97 -0
  13. data/lib/yoti_sandbox/doc_scan/request/check/report/detail.rb +34 -0
  14. data/lib/yoti_sandbox/doc_scan/request/check/report/recommendation.rb +88 -0
  15. data/lib/yoti_sandbox/doc_scan/request/check/zoom_liveness_check.rb +36 -0
  16. data/lib/yoti_sandbox/doc_scan/request/check_reports.rb +136 -0
  17. data/lib/yoti_sandbox/doc_scan/request/document_filter.rb +77 -0
  18. data/lib/yoti_sandbox/doc_scan/request/response_config.rb +75 -0
  19. data/lib/yoti_sandbox/doc_scan/request/task/document_text_data_extraction_task.rb +113 -0
  20. data/lib/yoti_sandbox/doc_scan/request/task_results.rb +65 -0
  21. data/lib/yoti_sandbox/profile.rb +2 -0
  22. data/lib/yoti_sandbox/profile/age_verification.rb +7 -0
  23. data/lib/yoti_sandbox/profile/client.rb +8 -26
  24. data/lib/yoti_sandbox/profile/token_request.rb +7 -0
  25. data/rubocop.yml +7 -3
  26. data/yoti_sandbox.gemspec +4 -4
  27. metadata +25 -8
@@ -0,0 +1,97 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yoti
4
+ module Sandbox
5
+ module DocScan
6
+ module Request
7
+ class Breakdown
8
+ #
9
+ # @param [String] sub_check
10
+ # @param [String] result
11
+ # @param [Array<Detail>] details
12
+ #
13
+ def initialize(sub_check, result, details)
14
+ Validation.assert_is_a(String, sub_check, 'sub_check')
15
+ @sub_check = sub_check
16
+
17
+ Validation.assert_is_a(String, result, 'result')
18
+ @result = result
19
+
20
+ Validation.assert_is_a(Array, details, 'details')
21
+ @details = details
22
+ end
23
+
24
+ def as_json(*_args)
25
+ {
26
+ sub_check: @sub_check,
27
+ result: @result,
28
+ details: @details.map(&:as_json)
29
+ }
30
+ end
31
+
32
+ def to_json(*_args)
33
+ as_json.to_json
34
+ end
35
+
36
+ #
37
+ # @return [BreakdownBuilder]
38
+ #
39
+ def self.builder
40
+ BreakdownBuilder.new
41
+ end
42
+ end
43
+
44
+ class BreakdownBuilder
45
+ def initialize
46
+ @details = []
47
+ end
48
+
49
+ #
50
+ # @param [String] sub_check
51
+ #
52
+ # @return [self]
53
+ #
54
+ def with_sub_check(sub_check)
55
+ Validation.assert_is_a(String, sub_check, 'sub_check')
56
+ @sub_check = sub_check
57
+ self
58
+ end
59
+
60
+ #
61
+ # @param [String] result
62
+ #
63
+ # @return [self]
64
+ #
65
+ def with_result(result)
66
+ Validation.assert_is_a(String, result, 'result')
67
+ @result = result
68
+ self
69
+ end
70
+
71
+ #
72
+ # @param [String] name
73
+ # @param [String] value
74
+ #
75
+ # @return [self]
76
+ #
77
+ def with_detail(name, value)
78
+ Validation.assert_is_a(String, name, 'name')
79
+ Validation.assert_is_a(String, value, 'value')
80
+ @details.push(Detail.new(name, value))
81
+ self
82
+ end
83
+
84
+ #
85
+ # @return [Breakdown]
86
+ #
87
+ def build
88
+ Validation.assert_not_nil(@sub_check, 'sub_check')
89
+ Validation.assert_not_nil(@result, 'result')
90
+
91
+ Breakdown.new(@sub_check, @result, @details)
92
+ end
93
+ end
94
+ end
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yoti
4
+ module Sandbox
5
+ module DocScan
6
+ module Request
7
+ class Detail
8
+ #
9
+ # @param [String] name
10
+ # @param [String] value
11
+ #
12
+ def initialize(name, value)
13
+ Validation.assert_is_a(String, name, 'name')
14
+ @name = name
15
+
16
+ Validation.assert_is_a(String, value, 'value')
17
+ @value = value
18
+ end
19
+
20
+ def as_json(*_args)
21
+ {
22
+ name: @name,
23
+ value: @value
24
+ }
25
+ end
26
+
27
+ def to_json(*_args)
28
+ as_json.to_json
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,88 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yoti
4
+ module Sandbox
5
+ module DocScan
6
+ module Request
7
+ class Recommendation
8
+ #
9
+ # @param [String] value
10
+ # @param [String] reason
11
+ # @param [String] recovery_suggestion
12
+ #
13
+ def initialize(value, reason, recovery_suggestion)
14
+ Validation.assert_is_a(String, value, 'value')
15
+ @value = value
16
+
17
+ Validation.assert_is_a(String, reason, 'reason', true)
18
+ @reason = reason
19
+
20
+ Validation.assert_is_a(String, recovery_suggestion, 'recovery_suggestion', true)
21
+ @recovery_suggestion = recovery_suggestion
22
+ end
23
+
24
+ def as_json(*_args)
25
+ {
26
+ value: @value,
27
+ reason: @reason,
28
+ recovery_suggestion: @recovery_suggestion
29
+ }.compact
30
+ end
31
+
32
+ def to_json(*_args)
33
+ as_json.to_json
34
+ end
35
+
36
+ #
37
+ # @return [RecommendationBuilder]
38
+ #
39
+ def self.builder
40
+ RecommendationBuilder.new
41
+ end
42
+ end
43
+
44
+ class RecommendationBuilder
45
+ #
46
+ # @param [String] value
47
+ #
48
+ # @return [self]
49
+ #
50
+ def with_value(value)
51
+ Validation.assert_is_a(String, value, 'value')
52
+ @value = value
53
+ self
54
+ end
55
+
56
+ #
57
+ # @param [String] reason
58
+ #
59
+ # @return [self]
60
+ #
61
+ def with_reason(reason)
62
+ Validation.assert_is_a(String, reason, 'reason')
63
+ @reason = reason
64
+ self
65
+ end
66
+
67
+ #
68
+ # @param [String] recovery_suggestion
69
+ #
70
+ # @return [self]
71
+ #
72
+ def with_recovery_suggestion(recovery_suggestion)
73
+ Validation.assert_is_a(String, recovery_suggestion, 'recovery_suggestion')
74
+ @recovery_suggestion = recovery_suggestion
75
+ self
76
+ end
77
+
78
+ #
79
+ # @return [Recommendation]
80
+ #
81
+ def build
82
+ Recommendation.new(@value, @reason, @recovery_suggestion)
83
+ end
84
+ end
85
+ end
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yoti
4
+ module Sandbox
5
+ module DocScan
6
+ module Request
7
+ class ZoomLivenessCheck < LivenessCheck
8
+ #
9
+ # @param [CheckResult] result
10
+ #
11
+ def initialize(result)
12
+ super(result, Yoti::DocScan::Constants::ZOOM)
13
+ end
14
+
15
+ #
16
+ # @return [ZoomLivenessCheckBuilder]
17
+ #
18
+ def self.builder
19
+ ZoomLivenessCheckBuilder.new
20
+ end
21
+ end
22
+
23
+ class ZoomLivenessCheckBuilder < CheckBuilder
24
+ #
25
+ # @return [ZoomLivenessCheck]
26
+ #
27
+ def build
28
+ report = CheckReport.new(@recommendation, @breakdowns)
29
+ result = CheckResult.new(report)
30
+ ZoomLivenessCheck.new(result)
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,136 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yoti
4
+ module Sandbox
5
+ module DocScan
6
+ module Request
7
+ class CheckReports
8
+ #
9
+ # @param [Array<DocumentTextDataCheck>] document_text_data_checks
10
+ # @param [Array<DocumentAuthenticityCheck>] document_authenticity_checks
11
+ # @param [Array<LivenessCheck>] liveness_checks
12
+ # @param [Array<DocumentFaceMatchCheck>] document_face_match_checks
13
+ # @param [Integer] async_report_delay
14
+ #
15
+ def initialize(
16
+ document_text_data_checks,
17
+ document_authenticity_checks,
18
+ liveness_checks,
19
+ document_face_match_checks,
20
+ async_report_delay
21
+ )
22
+ Validation.assert_is_a(Array, document_text_data_checks, 'document_text_data_checks')
23
+ @document_text_data_checks = document_text_data_checks
24
+
25
+ Validation.assert_is_a(Array, document_authenticity_checks, 'document_authenticity_checks')
26
+ @document_authenticity_checks = document_authenticity_checks
27
+
28
+ Validation.assert_is_a(Array, liveness_checks, 'liveness_checks')
29
+ @liveness_checks = liveness_checks
30
+
31
+ Validation.assert_is_a(Array, document_face_match_checks, 'document_face_match_checks')
32
+ @document_face_match_checks = document_face_match_checks
33
+
34
+ Validation.assert_is_a(Integer, async_report_delay, 'async_report_delay', true)
35
+ @async_report_delay = async_report_delay
36
+ end
37
+
38
+ def self.builder
39
+ CheckReportsBuilder.new
40
+ end
41
+
42
+ def to_json(*_args)
43
+ as_json.to_json
44
+ end
45
+
46
+ def as_json(*_args)
47
+ {
48
+ Yoti::DocScan::Constants::ID_DOCUMENT_TEXT_DATA_CHECK => @document_text_data_checks,
49
+ Yoti::DocScan::Constants::ID_DOCUMENT_AUTHENTICITY => @document_authenticity_checks,
50
+ Yoti::DocScan::Constants::ID_DOCUMENT_FACE_MATCH => @document_face_match_checks,
51
+ Yoti::DocScan::Constants::LIVENESS => @liveness_checks,
52
+ :async_report_delay => @async_report_delay
53
+ }
54
+ end
55
+ end
56
+
57
+ class CheckReportsBuilder
58
+ def initialize
59
+ @liveness_checks = []
60
+ @document_text_data_checks = []
61
+ @document_authenticity_checks = []
62
+ @document_face_match_checks = []
63
+ end
64
+
65
+ #
66
+ # @param [LivenessCheck] liveness_check
67
+ #
68
+ # @return [self]
69
+ #
70
+ def with_liveness_check(liveness_check)
71
+ Validation.assert_is_a(LivenessCheck, liveness_check, 'liveness_check')
72
+ @liveness_checks << liveness_check
73
+ self
74
+ end
75
+
76
+ #
77
+ # @param [DocumentTextDataCheck] document_text_data_check
78
+ #
79
+ # @return [self]
80
+ #
81
+ def with_document_text_data_check(document_text_data_check)
82
+ Validation.assert_is_a(DocumentTextDataCheck, document_text_data_check, 'document_text_data_check')
83
+ @document_text_data_checks << document_text_data_check
84
+ self
85
+ end
86
+
87
+ #
88
+ # @param [DocumentAuthenticityCheck] document_authenticity_check
89
+ #
90
+ # @return [self]
91
+ #
92
+ def with_document_authenticity_check(document_authenticity_check)
93
+ Validation.assert_is_a(DocumentAuthenticityCheck, document_authenticity_check, 'document_authenticity_check')
94
+ @document_authenticity_checks << document_authenticity_check
95
+ self
96
+ end
97
+
98
+ #
99
+ # @param [DocumentFaceMatchCheck] document_face_match_check
100
+ #
101
+ # @return [self]
102
+ #
103
+ def with_document_face_match_check(document_face_match_check)
104
+ Validation.assert_is_a(DocumentFaceMatchCheck, document_face_match_check, 'document_face_match_check')
105
+ @document_face_match_checks << document_face_match_check
106
+ self
107
+ end
108
+
109
+ #
110
+ # @param [Integer] async_report_delay
111
+ #
112
+ # @return [self]
113
+ #
114
+ def with_async_report_delay(async_report_delay)
115
+ Validation.assert_is_a(Integer, async_report_delay, 'async_report_delay')
116
+ @async_report_delay = async_report_delay
117
+ self
118
+ end
119
+
120
+ #
121
+ # @return [CheckReports]
122
+ #
123
+ def build
124
+ CheckReports.new(
125
+ @document_text_data_checks,
126
+ @document_authenticity_checks,
127
+ @liveness_checks,
128
+ @document_face_match_checks,
129
+ @async_report_delay
130
+ )
131
+ end
132
+ end
133
+ end
134
+ end
135
+ end
136
+ end
@@ -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