yoti_sandbox 1.0.0 → 1.1.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 (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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ee3b93e52cfe923f7311c9fb4e426c82f543d335d77986afce33a156020ebd49
4
- data.tar.gz: c364243f9462bce1e2d115b4d538353b34c764412109e5fdbde6587e90e07ad3
3
+ metadata.gz: 60f6434723e625e3bbf2148d1af084c6800f4a7e682305f3eb731325174ac75a
4
+ data.tar.gz: 72205e69a037a63094fe043b5ce4fd5108f3f76ded8da6ef82ee96dc4865c066
5
5
  SHA512:
6
- metadata.gz: 942ea35d3fb25a5d7b7cf9dc70c8bef7e61b15109295de0c56fabbb5ae15d8cf10fbb202a54b879cda88980ef940ceed2293fe0c0db3506a2318dce9c213f58d
7
- data.tar.gz: 965241d45bb97c05cd45c3d2a88c5ac843655ce427787c76b5a4b84c57fd4d9d2501f8a8f7a8317e7a55e81c780a768dd172e167e38623346acfb2522d20990d
6
+ metadata.gz: 9a042d5227329c22a0e60af7e5c44e4875af419a05e1e1816992194ff49382b4e7a23cc10028ebaf9fbf63a3d7d7614b9d4f2f4992c3c810e4f1f244003e1166
7
+ data.tar.gz: 0471a65f852b28fb64533842483587232d2051c7859a6c343e708b542999f1b119ec9b8bb7dc3e2aff450a2545f419e2642cdaf369212e2ebfbb70a8a6c12280
data/README.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Yoti Ruby Sandbox SDK
2
2
 
3
+ [![Build Status](https://travis-ci.com/getyoti/yoti-ruby-sdk-sandbox.svg?branch=master)](https://travis-ci.com/getyoti/yoti-ruby-sdk-sandbox)
4
+ [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=getyoti%3Aruby-sandbox&metric=coverage)](https://sonarcloud.io/dashboard?id=getyoti%3Aruby-sandbox)
5
+ [![Bugs](https://sonarcloud.io/api/project_badges/measure?project=getyoti%3Aruby-sandbox&metric=bugs)](https://sonarcloud.io/dashboard?id=getyoti%3Aruby-sandbox)
6
+ [![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=getyoti%3Aruby-sandbox&metric=code_smells)](https://sonarcloud.io/dashboard?id=getyoti%3Aruby-sandbox)
7
+ [![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=getyoti%3Aruby-sandbox&metric=vulnerabilities)](https://sonarcloud.io/dashboard?id=getyoti%3Aruby-sandbox)
8
+
3
9
  This repository contains the tools you need to test your Yoti integration.
4
10
 
5
11
  ## Installing the Sandbox
@@ -42,4 +48,5 @@ end
42
48
 
43
49
  ## Examples
44
50
 
45
- - See [examples/profile](examples/profile) for a general example of how to use the Profile Sandbox in your tests.
51
+ - [Profile Sandbox](examples/profile)
52
+ - [Doc Scan Sandbox](examples/doc_scan)
@@ -1 +1,2 @@
1
1
  require_relative 'yoti_sandbox/profile'
2
+ require_relative 'yoti_sandbox/doc_scan'
@@ -0,0 +1,18 @@
1
+ require 'yoti'
2
+
3
+ require_relative 'doc_scan/client'
4
+ require_relative 'doc_scan/request/task_results'
5
+ require_relative 'doc_scan/request/check_reports'
6
+ require_relative 'doc_scan/request/response_config'
7
+ require_relative 'doc_scan/request/document_filter'
8
+ require_relative 'doc_scan/request/check/check'
9
+ require_relative 'doc_scan/request/check/document_check'
10
+ require_relative 'doc_scan/request/check/document_authenticity_check'
11
+ require_relative 'doc_scan/request/check/document_face_match_check'
12
+ require_relative 'doc_scan/request/check/document_text_data_check'
13
+ require_relative 'doc_scan/request/check/liveness_check'
14
+ require_relative 'doc_scan/request/check/zoom_liveness_check'
15
+ require_relative 'doc_scan/request/check/report/breakdown'
16
+ require_relative 'doc_scan/request/check/report/recommendation'
17
+ require_relative 'doc_scan/request/check/report/detail'
18
+ require_relative 'doc_scan/request/task/document_text_data_extraction_task'
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yoti
4
+ module Sandbox
5
+ module DocScan
6
+ #
7
+ # Client for the Doc Scan sandbox service
8
+ #
9
+ class Client
10
+ #
11
+ # @param [String] base_url
12
+ #
13
+ def initialize(base_url: nil)
14
+ @base_url = base_url || "#{Yoti.configuration.api_url}/sandbox/idverify/v1"
15
+ end
16
+
17
+ #
18
+ # @param [String] session_id
19
+ # @param [Yoti::SandboxDocScan::Request::ResponseConfig] response_config
20
+ #
21
+ def configure_session_response(session_id, response_config)
22
+ Yoti::Request
23
+ .builder
24
+ .with_http_method('PUT')
25
+ .with_base_url(@base_url)
26
+ .with_endpoint("sessions/#{session_id}/response-config")
27
+ .with_query_param('sdkId', Yoti.configuration.client_sdk_id)
28
+ .with_payload(response_config)
29
+ .build
30
+ .execute
31
+ end
32
+
33
+ #
34
+ # @param [Yoti::SandboxDocScan::Request::ResponseConfig] response_config
35
+ #
36
+ def configure_application_response(response_config)
37
+ Yoti::Request
38
+ .builder
39
+ .with_http_method('PUT')
40
+ .with_base_url(@base_url)
41
+ .with_endpoint("apps/#{Yoti.configuration.client_sdk_id}/response-config")
42
+ .with_payload(response_config)
43
+ .build
44
+ .execute
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,115 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yoti
4
+ module Sandbox
5
+ module DocScan
6
+ module Request
7
+ class Check
8
+ #
9
+ # @param [CheckResult] result
10
+ #
11
+ def initialize(result)
12
+ raise(TypeError, "#{self.class} cannot be instantiated") if self.class == Check
13
+
14
+ Validation.assert_is_a(CheckResult, result, 'result')
15
+ @result = result
16
+ end
17
+
18
+ def to_json(*_args)
19
+ as_json.to_json
20
+ end
21
+
22
+ def as_json(*_args)
23
+ {
24
+ result: @result.as_json
25
+ }
26
+ end
27
+ end
28
+
29
+ class CheckBuilder
30
+ def initialize
31
+ @breakdowns = []
32
+ end
33
+
34
+ #
35
+ # @param [Recommendation] recommendation
36
+ #
37
+ # @return [self]
38
+ #
39
+ def with_recommendation(recommendation)
40
+ Validation.assert_is_a(Recommendation, recommendation, 'recommendation')
41
+ @recommendation = recommendation
42
+ self
43
+ end
44
+
45
+ #
46
+ # @param [Breakdown] breakdown
47
+ #
48
+ # @return [self]
49
+ #
50
+ def with_breakdown(breakdown)
51
+ Validation.assert_is_a(Breakdown, breakdown, 'breakdown')
52
+ @breakdowns.push(breakdown)
53
+ self
54
+ end
55
+
56
+ #
57
+ # @param [Array<Breakdown>] breakdowns
58
+ #
59
+ # @return [self]
60
+ #
61
+ def with_breakdowns(breakdowns)
62
+ Validation.assert_is_a(Array, breakdowns, 'breakdown')
63
+ @breakdowns = breakdowns
64
+ self
65
+ end
66
+ end
67
+
68
+ class CheckResult
69
+ #
70
+ # @param [CheckReport] report
71
+ #
72
+ def initialize(report)
73
+ Validation.assert_is_a(CheckReport, report, 'report')
74
+ @report = report
75
+ end
76
+
77
+ def to_json(*_args)
78
+ as_json.to_json
79
+ end
80
+
81
+ def as_json(*_args)
82
+ {
83
+ report: @report.as_json
84
+ }
85
+ end
86
+ end
87
+
88
+ class CheckReport
89
+ #
90
+ # @param [Recommendation] recommendation
91
+ # @param [Breakdown] breakdowns
92
+ #
93
+ def initialize(recommendation, breakdowns)
94
+ Validation.assert_is_a(Recommendation, recommendation, 'recommendation')
95
+ @recommendation = recommendation
96
+
97
+ Validation.assert_is_a(Array, breakdowns, 'breakdowns')
98
+ @breakdowns = breakdowns
99
+ end
100
+
101
+ def to_json(*_args)
102
+ as_json.to_json
103
+ end
104
+
105
+ def as_json(*_args)
106
+ {
107
+ recommendation: @recommendation.as_json,
108
+ breakdown: @breakdowns.map(&:as_json)
109
+ }
110
+ end
111
+ end
112
+ end
113
+ end
114
+ end
115
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yoti
4
+ module Sandbox
5
+ module DocScan
6
+ module Request
7
+ class DocumentAuthenticityCheck < DocumentCheck
8
+ #
9
+ # @return [DocumentAuthenticityCheckBuilder]
10
+ #
11
+ def self.builder
12
+ DocumentAuthenticityCheckBuilder.new
13
+ end
14
+ end
15
+
16
+ class DocumentAuthenticityCheckBuilder < DocumentCheckBuilder
17
+ #
18
+ # @return [DocumentAuthenticityCheck]
19
+ #
20
+ def build
21
+ report = CheckReport.new(@recommendation, @breakdowns)
22
+ result = CheckResult.new(report)
23
+ DocumentAuthenticityCheck.new(result, @document_filter)
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yoti
4
+ module Sandbox
5
+ module DocScan
6
+ module Request
7
+ class DocumentCheck < Check
8
+ #
9
+ # @param [CheckResult] result
10
+ # @param [DocumentFilter] document_filter
11
+ #
12
+ def initialize(result, document_filter)
13
+ raise(TypeError, "#{self.class} cannot be instantiated") if self.class == DocumentCheck
14
+
15
+ super(result)
16
+
17
+ Validation.assert_is_a(DocumentFilter, document_filter, 'document_filter', true)
18
+ @document_filter = document_filter
19
+ end
20
+
21
+ def as_json(*_args)
22
+ json = super
23
+ json[:document_filter] = @document_filter.as_json unless @document_filter.nil?
24
+ json
25
+ end
26
+ end
27
+
28
+ class DocumentCheckBuilder < CheckBuilder
29
+ def initialize
30
+ raise(TypeError, "#{self.class} cannot be instantiated") if self.class == DocumentCheckBuilder
31
+
32
+ super
33
+ end
34
+
35
+ #
36
+ # @param [DocumentFilter] document_filter
37
+ #
38
+ # @return [self]
39
+ #
40
+ def with_document_filter(document_filter)
41
+ @document_filter = document_filter
42
+ self
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yoti
4
+ module Sandbox
5
+ module DocScan
6
+ module Request
7
+ class DocumentFaceMatchCheck < DocumentCheck
8
+ #
9
+ # @return [DocumentFaceMatchCheckBuilder]
10
+ #
11
+ def self.builder
12
+ DocumentFaceMatchCheckBuilder.new
13
+ end
14
+ end
15
+
16
+ class DocumentFaceMatchCheckBuilder < DocumentCheckBuilder
17
+ #
18
+ # @return [DocumentFaceMatchCheck]
19
+ #
20
+ def build
21
+ report = CheckReport.new(@recommendation, @breakdowns)
22
+ result = CheckResult.new(report)
23
+ DocumentFaceMatchCheck.new(result, @document_filter)
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,79 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yoti
4
+ module Sandbox
5
+ module DocScan
6
+ module Request
7
+ class DocumentTextDataCheck < DocumentCheck
8
+ #
9
+ # @return [DocumentTextDataCheckBuilder]
10
+ #
11
+ def self.builder
12
+ DocumentTextDataCheckBuilder.new
13
+ end
14
+ end
15
+
16
+ class DocumentTextDataCheckResult < CheckResult
17
+ #
18
+ # @param [CheckReport] report
19
+ # @param [Hash] document_fields
20
+ #
21
+ def initialize(report, document_fields)
22
+ super(report)
23
+
24
+ Validation.assert_is_a(Hash, document_fields, 'document_fields')
25
+ document_fields.each { |_k, v| Validation.assert_is_a(String, v, 'document_fields value') }
26
+ @document_fields = document_fields
27
+ end
28
+
29
+ def as_json(*_args)
30
+ super.merge(
31
+ document_fields: @document_fields
32
+ ).compact
33
+ end
34
+ end
35
+
36
+ class DocumentTextDataCheckBuilder < DocumentCheckBuilder
37
+ def initialize
38
+ super
39
+
40
+ @document_fields = {}
41
+ end
42
+
43
+ #
44
+ # @param [String] key
45
+ # @param [String] value
46
+ #
47
+ # @return [self]
48
+ #
49
+ def with_document_field(key, value)
50
+ Validation.assert_is_a(String, key, 'key')
51
+ Validation.assert_is_a(String, value, 'value')
52
+ @document_fields[key] = value
53
+ self
54
+ end
55
+
56
+ #
57
+ # @param [Hash] document_fields
58
+ #
59
+ # @return [self]
60
+ #
61
+ def with_document_fields(document_fields)
62
+ Validation.assert_is_a(Hash, document_fields, 'document_fields')
63
+ @document_fields = document_fields
64
+ self
65
+ end
66
+
67
+ #
68
+ # @return [DocumentTextDataCheck]
69
+ #
70
+ def build
71
+ report = CheckReport.new(@recommendation, @breakdowns)
72
+ result = DocumentTextDataCheckResult.new(report, @document_fields)
73
+ DocumentTextDataCheck.new(result, @document_filter)
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
79
+ 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 LivenessCheck < Check
8
+ #
9
+ # @param [CheckResult] result
10
+ # @param [String] liveness_type
11
+ #
12
+ def initialize(result, liveness_type)
13
+ raise(TypeError, "#{self.class} cannot be instantiated") if self.class == LivenessCheck
14
+
15
+ super(result)
16
+
17
+ Validation.assert_is_a(String, liveness_type, 'liveness_type')
18
+ @liveness_type = liveness_type
19
+ end
20
+
21
+ def to_json(*_args)
22
+ as_json.to_json
23
+ end
24
+
25
+ def as_json(*_args)
26
+ super.merge(
27
+ liveness_type: @liveness_type
28
+ ).compact
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end