yoti 1.6.4 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -0
  3. data/Rakefile +0 -8
  4. data/lib/yoti.rb +50 -1
  5. data/lib/yoti/client.rb +13 -4
  6. data/lib/yoti/configuration.rb +7 -2
  7. data/lib/yoti/data_type/age_verification.rb +1 -1
  8. data/lib/yoti/data_type/base_profile.rb +1 -1
  9. data/lib/yoti/data_type/image.rb +4 -12
  10. data/lib/yoti/data_type/image_jpeg.rb +2 -0
  11. data/lib/yoti/data_type/image_png.rb +2 -0
  12. data/lib/yoti/data_type/media.rb +19 -0
  13. data/lib/yoti/doc_scan/client.rb +163 -0
  14. data/lib/yoti/doc_scan/constants.rb +28 -0
  15. data/lib/yoti/doc_scan/session/create/create_session_result.rb +50 -0
  16. data/lib/yoti/doc_scan/session/create/document_filter.rb +31 -0
  17. data/lib/yoti/doc_scan/session/create/document_restrictions_filter.rb +140 -0
  18. data/lib/yoti/doc_scan/session/create/notification_config.rb +142 -0
  19. data/lib/yoti/doc_scan/session/create/orthogonal_restrictions_filter.rb +150 -0
  20. data/lib/yoti/doc_scan/session/create/requested_check.rb +39 -0
  21. data/lib/yoti/doc_scan/session/create/requested_document_authenticity_check.rb +53 -0
  22. data/lib/yoti/doc_scan/session/create/requested_face_match_check.rb +95 -0
  23. data/lib/yoti/doc_scan/session/create/requested_liveness_check.rb +108 -0
  24. data/lib/yoti/doc_scan/session/create/requested_task.rb +39 -0
  25. data/lib/yoti/doc_scan/session/create/requested_text_extraction_task.rb +94 -0
  26. data/lib/yoti/doc_scan/session/create/required_document.rb +31 -0
  27. data/lib/yoti/doc_scan/session/create/required_id_document.rb +53 -0
  28. data/lib/yoti/doc_scan/session/create/sdk_config.rb +221 -0
  29. data/lib/yoti/doc_scan/session/create/session_specification.rb +203 -0
  30. data/lib/yoti/doc_scan/session/retrieve/authenticity_check_response.rb +12 -0
  31. data/lib/yoti/doc_scan/session/retrieve/breakdown_response.rb +38 -0
  32. data/lib/yoti/doc_scan/session/retrieve/check_response.rb +63 -0
  33. data/lib/yoti/doc_scan/session/retrieve/details_response.rb +28 -0
  34. data/lib/yoti/doc_scan/session/retrieve/document_fields_response.rb +21 -0
  35. data/lib/yoti/doc_scan/session/retrieve/face_map_response.rb +21 -0
  36. data/lib/yoti/doc_scan/session/retrieve/face_match_check_response.rb +12 -0
  37. data/lib/yoti/doc_scan/session/retrieve/frame_response.rb +21 -0
  38. data/lib/yoti/doc_scan/session/retrieve/generated_check_response.rb +28 -0
  39. data/lib/yoti/doc_scan/session/retrieve/generated_media.rb +28 -0
  40. data/lib/yoti/doc_scan/session/retrieve/generated_text_data_check_response.rb +12 -0
  41. data/lib/yoti/doc_scan/session/retrieve/get_session_result.rb +113 -0
  42. data/lib/yoti/doc_scan/session/retrieve/id_document_resource_response.rb +52 -0
  43. data/lib/yoti/doc_scan/session/retrieve/liveness_check_response.rb +12 -0
  44. data/lib/yoti/doc_scan/session/retrieve/liveness_resource_response.rb +24 -0
  45. data/lib/yoti/doc_scan/session/retrieve/media_response.rb +38 -0
  46. data/lib/yoti/doc_scan/session/retrieve/page_response.rb +27 -0
  47. data/lib/yoti/doc_scan/session/retrieve/recommendation_response.rb +34 -0
  48. data/lib/yoti/doc_scan/session/retrieve/report_response.rb +31 -0
  49. data/lib/yoti/doc_scan/session/retrieve/resource_container.rb +50 -0
  50. data/lib/yoti/doc_scan/session/retrieve/resource_response.rb +39 -0
  51. data/lib/yoti/doc_scan/session/retrieve/task_response.rb +87 -0
  52. data/lib/yoti/doc_scan/session/retrieve/text_data_check_response.rb +12 -0
  53. data/lib/yoti/doc_scan/session/retrieve/text_extraction_task_response.rb +18 -0
  54. data/lib/yoti/doc_scan/session/retrieve/zoom_liveness_resource_response.rb +33 -0
  55. data/lib/yoti/doc_scan/support/supported_documents.rb +60 -0
  56. data/lib/yoti/dynamic_share_service/extension/thirdparty_attribute_extension.rb +1 -1
  57. data/lib/yoti/dynamic_share_service/policy/dynamic_policy.rb +4 -4
  58. data/lib/yoti/dynamic_share_service/share_url.rb +26 -33
  59. data/lib/yoti/errors.rb +17 -2
  60. data/lib/yoti/http/aml_check_request.rb +12 -6
  61. data/lib/yoti/http/payloads/aml_address.rb +4 -0
  62. data/lib/yoti/http/payloads/aml_profile.rb +7 -1
  63. data/lib/yoti/http/profile_request.rb +11 -6
  64. data/lib/yoti/http/request.rb +218 -18
  65. data/lib/yoti/http/signed_request.rb +13 -4
  66. data/lib/yoti/ssl.rb +2 -2
  67. data/lib/yoti/util/anchor_processor.rb +1 -1
  68. data/lib/yoti/util/validation.rb +41 -0
  69. data/lib/yoti/version.rb +1 -1
  70. data/rubocop.yml +9 -1
  71. data/yoti.gemspec +1 -2
  72. metadata +49 -18
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yoti
4
+ module DocScan
5
+ module Session
6
+ module Create
7
+ #
8
+ # Requests creation of a Check to be performed on a document
9
+ #
10
+ class RequestedCheck
11
+ #
12
+ # @param [String] type The type of the Check to create
13
+ # @param [#as_json] config The configuration to apply to the Check
14
+ #
15
+ def initialize(type, config)
16
+ raise(TypeError, "#{self.class} cannot be instantiated") if self.class == RequestedCheck
17
+
18
+ Validation.assert_is_a(String, type, 'type')
19
+ @type = type
20
+
21
+ Validation.assert_respond_to(:as_json, config, 'config')
22
+ @config = config
23
+ end
24
+
25
+ def to_json(*_args)
26
+ as_json.to_json
27
+ end
28
+
29
+ def as_json(*_args)
30
+ {
31
+ type: @type,
32
+ config: @config.as_json
33
+ }
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yoti
4
+ module DocScan
5
+ module Session
6
+ module Create
7
+ #
8
+ # Requests creation of a Document Authenticity Check
9
+ #
10
+ class RequestedDocumentAuthenticityCheck < RequestedCheck
11
+ def initialize(config)
12
+ Validation.assert_is_a(
13
+ RequestedDocumentAuthenticityCheckConfig,
14
+ config,
15
+ 'config'
16
+ )
17
+
18
+ super(Constants::ID_DOCUMENT_AUTHENTICITY, config)
19
+ end
20
+
21
+ #
22
+ # @return [RequestedDocumentAuthenticityCheckBuilder]
23
+ #
24
+ def self.builder
25
+ RequestedDocumentAuthenticityCheckBuilder.new
26
+ end
27
+ end
28
+
29
+ #
30
+ # The configuration applied when creating a {RequestedDocumentAuthenticityCheck}
31
+ #
32
+ class RequestedDocumentAuthenticityCheckConfig
33
+ def as_json(*_args)
34
+ {}
35
+ end
36
+ end
37
+
38
+ #
39
+ # Builder to assist the creation of {RequestedDocumentAuthenticityCheck}
40
+ #
41
+ class RequestedDocumentAuthenticityCheckBuilder
42
+ #
43
+ # @return [RequestedDocumentAuthenticityCheck]
44
+ #
45
+ def build
46
+ config = RequestedDocumentAuthenticityCheckConfig.new
47
+ RequestedDocumentAuthenticityCheck.new(config)
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,95 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yoti
4
+ module DocScan
5
+ module Session
6
+ module Create
7
+ #
8
+ # Requests creation of a Face Match Check
9
+ #
10
+ class RequestedFaceMatchCheck < RequestedCheck
11
+ #
12
+ # @param [RequestedFaceMatchCheckConfig] config
13
+ #
14
+ def initialize(config)
15
+ Validation.assert_is_a(
16
+ RequestedFaceMatchCheckConfig,
17
+ config,
18
+ 'config'
19
+ )
20
+
21
+ super(Constants::ID_DOCUMENT_FACE_MATCH, config)
22
+ end
23
+
24
+ #
25
+ # @return [RequestedFaceMatchCheckBuilder]
26
+ #
27
+ def self.builder
28
+ RequestedFaceMatchCheckBuilder.new
29
+ end
30
+ end
31
+
32
+ #
33
+ # The configuration applied when creating a {RequestedFaceMatchCheck}
34
+ #
35
+ class RequestedFaceMatchCheckConfig
36
+ #
37
+ # @param [String] manual_check
38
+ #
39
+ def initialize(manual_check)
40
+ Validation.assert_is_a(String, manual_check, 'manual_check')
41
+ @manual_check = manual_check
42
+ end
43
+
44
+ def as_json(*_args)
45
+ {
46
+ manual_check: @manual_check
47
+ }
48
+ end
49
+ end
50
+
51
+ #
52
+ # Builder to assist the creation of {RequestedFaceMatchCheck}
53
+ #
54
+ class RequestedFaceMatchCheckBuilder
55
+ #
56
+ # Requires that a manual follow-up check is always performed
57
+ #
58
+ # @return [self]
59
+ #
60
+ def with_manual_check_always
61
+ @manual_check = Constants::ALWAYS
62
+ self
63
+ end
64
+
65
+ #
66
+ # Requires that a manual follow-up check is performed only on failed Checks,
67
+ # and those with a low level of confidence
68
+ #
69
+ # @return [self]
70
+ #
71
+ def with_manual_check_fallback
72
+ @manual_check = Constants::FALLBACK
73
+ self
74
+ end
75
+
76
+ #
77
+ # Requires that only an automated Check is performed. No manual follow-up
78
+ # Check will ever be initiated
79
+ #
80
+ # @return [self]
81
+ #
82
+ def with_manual_check_never
83
+ @manual_check = Constants::NEVER
84
+ self
85
+ end
86
+
87
+ def build
88
+ config = RequestedFaceMatchCheckConfig.new(@manual_check)
89
+ RequestedFaceMatchCheck.new(config)
90
+ end
91
+ end
92
+ end
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,108 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yoti
4
+ module DocScan
5
+ module Session
6
+ module Create
7
+ #
8
+ # Requests creation of a Liveness Check
9
+ #
10
+ class RequestedLivenessCheck < RequestedCheck
11
+ #
12
+ # @param [RequestedLivenessCheckConfig] config
13
+ #
14
+ def initialize(config)
15
+ Validation.assert_is_a(
16
+ RequestedLivenessCheckConfig,
17
+ config,
18
+ 'config'
19
+ )
20
+
21
+ super(Constants::LIVENESS, config)
22
+ end
23
+
24
+ #
25
+ # @return [RequestedLivenessCheckBuilder]
26
+ #
27
+ def self.builder
28
+ RequestedLivenessCheckBuilder.new
29
+ end
30
+ end
31
+
32
+ #
33
+ # The configuration applied when creating a {RequestedLivenessCheck}
34
+ #
35
+ class RequestedLivenessCheckConfig
36
+ #
37
+ # @param [String] liveness_type
38
+ # @param [String] max_retries
39
+ #
40
+ def initialize(liveness_type, max_retries)
41
+ Validation.assert_is_a(String, liveness_type, 'liveness_type')
42
+ @liveness_type = liveness_type
43
+
44
+ Validation.assert_is_a(Integer, max_retries, 'max_retries')
45
+ @max_retries = max_retries
46
+ end
47
+
48
+ def as_json(*_args)
49
+ {
50
+ liveness_type: @liveness_type,
51
+ max_retries: @max_retries
52
+ }
53
+ end
54
+ end
55
+
56
+ #
57
+ # Builder to assist the creation of {RequestedLivenessCheck}
58
+ #
59
+ class RequestedLivenessCheckBuilder
60
+ def initialize
61
+ @max_retries = 1
62
+ end
63
+
64
+ #
65
+ # Sets the type of the liveness check to the supplied value
66
+ #
67
+ # @param [String] liveness_type
68
+ #
69
+ # @return [self]
70
+ #
71
+ def for_liveness_type(liveness_type)
72
+ @liveness_type = liveness_type
73
+ self
74
+ end
75
+
76
+ #
77
+ # Sets the type to be of a ZOOM liveness check
78
+ #
79
+ # @return [self]
80
+ #
81
+ def for_zoom_liveness
82
+ for_liveness_type(Constants::ZOOM)
83
+ end
84
+
85
+ #
86
+ # Sets the maximum number of retries allowed by the user
87
+ #
88
+ # @param [Integer] max_retries
89
+ #
90
+ # @return [self]
91
+ #
92
+ def with_max_retries(max_retries)
93
+ @max_retries = max_retries
94
+ self
95
+ end
96
+
97
+ #
98
+ # @return [RequestedLivenessCheck]
99
+ #
100
+ def build
101
+ config = RequestedLivenessCheckConfig.new(@liveness_type, @max_retries)
102
+ RequestedLivenessCheck.new(config)
103
+ end
104
+ end
105
+ end
106
+ end
107
+ end
108
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yoti
4
+ module DocScan
5
+ module Session
6
+ module Create
7
+ #
8
+ # Requests creation of a Task to be performed on each document
9
+ #
10
+ class RequestedTask
11
+ #
12
+ # @param [String] type The type of the Task to create
13
+ # @param [#as_json] config Configuration to apply to the Task
14
+ #
15
+ def initialize(type, config)
16
+ raise(TypeError, "#{self.class} cannot be instantiated") if self.class == RequestedTask
17
+
18
+ Validation.assert_is_a(String, type, 'type')
19
+ @type = type
20
+
21
+ Validation.assert_respond_to(:as_json, config, 'config')
22
+ @config = config
23
+ end
24
+
25
+ def to_json(*_args)
26
+ as_json.to_json
27
+ end
28
+
29
+ def as_json(*_args)
30
+ {
31
+ type: @type,
32
+ config: @config.as_json
33
+ }
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,94 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yoti
4
+ module DocScan
5
+ module Session
6
+ module Create
7
+ class RequestedTextExtractionTask < RequestedTask
8
+ #
9
+ # @param [RequestedTextExtractionTaskConfig] config
10
+ #
11
+ def initialize(config)
12
+ Validation.assert_is_a(
13
+ RequestedTextExtractionTaskConfig,
14
+ config,
15
+ 'config'
16
+ )
17
+
18
+ super(Constants::ID_DOCUMENT_TEXT_DATA_EXTRACTION, config)
19
+ end
20
+
21
+ #
22
+ # @return [RequestedTextExtractionTaskBuilder]
23
+ #
24
+ def self.builder
25
+ RequestedTextExtractionTaskBuilder.new
26
+ end
27
+ end
28
+
29
+ #
30
+ # The configuration applied when creating each TextExtractionTask
31
+ #
32
+ class RequestedTextExtractionTaskConfig
33
+ #
34
+ # @param [String] manual_check
35
+ # Describes the manual fallback behaviour applied to each Task
36
+ #
37
+ def initialize(manual_check)
38
+ Validation.assert_is_a(String, manual_check, 'manual_check')
39
+ @manual_check = manual_check
40
+ end
41
+
42
+ def as_json(*_args)
43
+ {
44
+ manual_check: @manual_check
45
+ }
46
+ end
47
+ end
48
+
49
+ #
50
+ # Builder to assist creation of {RequestedTextExtractionTask}
51
+ #
52
+ class RequestedTextExtractionTaskBuilder
53
+ #
54
+ # Requires that the Task is always followed by a manual TextDataCheck
55
+ #
56
+ # @return [self]
57
+ #
58
+ def with_manual_check_always
59
+ @manual_check = Constants::ALWAYS
60
+ self
61
+ end
62
+
63
+ #
64
+ # Requires that only failed Tasks are followed by a manual TextDataCheck
65
+ #
66
+ # @return [self]
67
+ #
68
+ def with_manual_check_fallback
69
+ @manual_check = Constants::FALLBACK
70
+ self
71
+ end
72
+
73
+ #
74
+ # The TextExtractionTask will never fallback to a manual TextDataCheck
75
+ #
76
+ # @return [self]
77
+ #
78
+ def with_manual_check_never
79
+ @manual_check = Constants::NEVER
80
+ self
81
+ end
82
+
83
+ #
84
+ # @return [RequestedTextExtractionTask]
85
+ #
86
+ def build
87
+ config = RequestedTextExtractionTaskConfig.new(@manual_check)
88
+ RequestedTextExtractionTask.new(config)
89
+ end
90
+ end
91
+ end
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yoti
4
+ module DocScan
5
+ module Session
6
+ module Create
7
+ class RequiredDocument
8
+ #
9
+ # @param [String] type
10
+ #
11
+ def initialize(type)
12
+ raise(TypeError, "#{self.class} cannot be instantiated") if self.class == RequiredDocument
13
+
14
+ Validation.assert_is_a(String, type, 'type')
15
+ @type = type
16
+ end
17
+
18
+ def to_json(*_args)
19
+ as_json.to_json
20
+ end
21
+
22
+ def as_json(*_args)
23
+ {
24
+ type: @type
25
+ }
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end