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
@@ -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,113 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yoti
4
+ module Sandbox
5
+ module DocScan
6
+ module Request
7
+ class DocumentTextDataExtractionTask
8
+ #
9
+ # @param [DocumentTextDataExtractionTaskResult] 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
+ 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] document_fields
45
+ #
46
+ def initialize(document_fields)
47
+ Validation.assert_is_a(Hash, document_fields, 'document_fields')
48
+ document_fields.each { |_k, v| Validation.assert_is_a(String, v, 'document_fields value') }
49
+ @document_fields = document_fields
50
+ end
51
+
52
+ def to_json(*_args)
53
+ as_json.to_json
54
+ end
55
+
56
+ def as_json(*_args)
57
+ {
58
+ document_fields: @document_fields
59
+ }
60
+ end
61
+ end
62
+
63
+ class DocumentTextDataExtractionTaskBuilder
64
+ def initialize
65
+ @document_fields = {}
66
+ end
67
+
68
+ #
69
+ # @param [String] key
70
+ # @param [String] value
71
+ #
72
+ # @return [self]
73
+ #
74
+ def with_document_field(key, value)
75
+ Validation.assert_is_a(String, key, 'key')
76
+ Validation.assert_is_a(String, value, 'value')
77
+ @document_fields[key] = value
78
+ self
79
+ end
80
+
81
+ #
82
+ # @param [Hash] document_fields
83
+ #
84
+ # @return [self]
85
+ #
86
+ def with_document_fields(document_fields)
87
+ Validation.assert_is_a(Hash, document_fields, 'document_fields')
88
+ @document_fields = document_fields
89
+ self
90
+ end
91
+
92
+ #
93
+ # @param [DocumentFilter] document_filter
94
+ #
95
+ # @return [self]
96
+ #
97
+ def with_document_filter(document_filter)
98
+ @document_filter = document_filter
99
+ self
100
+ end
101
+
102
+ #
103
+ # @return [DocumentTextDataExtractionTask]
104
+ #
105
+ def build
106
+ result = DocumentTextDataExtractionTaskResult.new(@document_fields)
107
+ DocumentTextDataExtractionTask.new(result, @document_filter)
108
+ end
109
+ end
110
+ end
111
+ end
112
+ end
113
+ end
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yoti
4
+ module Sandbox
5
+ module DocScan
6
+ module Request
7
+ class TaskResults
8
+ #
9
+ # @param [Array<DocumentTextDataExtractionTask>] document_text_data_extraction_tasks
10
+ #
11
+ def initialize(document_text_data_extraction_tasks)
12
+ Validation.assert_is_a(
13
+ Array,
14
+ document_text_data_extraction_tasks,
15
+ 'document_text_data_extraction_tasks'
16
+ )
17
+ @document_text_data_extraction_tasks = document_text_data_extraction_tasks
18
+ end
19
+
20
+ def self.builder
21
+ TaskResultsBuilder.new
22
+ end
23
+
24
+ def to_json(*_args)
25
+ as_json.to_json
26
+ end
27
+
28
+ def as_json(*_args)
29
+ {
30
+ Yoti::DocScan::Constants::ID_DOCUMENT_TEXT_DATA_EXTRACTION => @document_text_data_extraction_tasks
31
+ }
32
+ end
33
+ end
34
+
35
+ class TaskResultsBuilder
36
+ def initialize
37
+ @document_text_data_extraction_tasks = []
38
+ end
39
+
40
+ #
41
+ # @param [DocumentTextDataExtractionTask] document_text_data_extraction_task
42
+ #
43
+ # @return [self]
44
+ #
45
+ def with_document_text_data_extraction_task(document_text_data_extraction_task)
46
+ Validation.assert_is_a(
47
+ DocumentTextDataExtractionTask,
48
+ document_text_data_extraction_task,
49
+ 'document_text_data_extraction_task'
50
+ )
51
+ @document_text_data_extraction_tasks << document_text_data_extraction_task
52
+ self
53
+ end
54
+
55
+ #
56
+ # @return [TaskResults]
57
+ #
58
+ def build
59
+ TaskResults.new(@document_text_data_extraction_tasks)
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
@@ -1,3 +1,5 @@
1
+ require 'yoti'
2
+
1
3
  require_relative 'profile/age_verification'
2
4
  require_relative 'profile/anchor'
3
5
  require_relative 'profile/attribute'
@@ -25,6 +25,13 @@ module Yoti
25
25
  @anchors = anchors
26
26
  end
27
27
 
28
+ #
29
+ # @return [AgeVerificationBuilder]
30
+ #
31
+ def self.builder
32
+ AgeVerificationBuilder.new
33
+ end
34
+
28
35
  #
29
36
  # @return [Attribute]
30
37
  #
@@ -1,8 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'yoti'
4
- require 'securerandom'
5
-
6
3
  module Yoti
7
4
  module Sandbox
8
5
  module Profile
@@ -23,30 +20,15 @@ module Yoti
23
20
  # @return [String]
24
21
  #
25
22
  def setup_sharing_profile(token_request)
26
- endpoint = "/apps/#{Yoti.configuration.client_sdk_id}/tokens?\
27
- nonce=#{SecureRandom.uuid}&timestamp=#{Time.now.to_i}"
28
- uri = URI(
29
- "#{@base_url}#{endpoint}"
30
- )
31
-
32
- response = Net::HTTP.start(
33
- uri.hostname,
34
- uri.port,
35
- use_ssl: true
36
- ) do |http|
37
- unsigned = Net::HTTP::Post.new uri
38
- unsigned.body = token_request.to_json
39
- signed_request = Yoti::SignedRequest.new(
40
- unsigned,
41
- endpoint,
42
- token_request
43
- ).sign
44
- http.request signed_request
45
- end
46
-
47
- raise "Failed to share profile #{response.code}: #{response.body}" unless response.code == '201'
23
+ request = Yoti::Request
24
+ .builder
25
+ .with_base_url(@base_url)
26
+ .with_endpoint("apps/#{Yoti.configuration.client_sdk_id}/tokens")
27
+ .with_http_method('POST')
28
+ .with_payload(token_request)
29
+ .build
48
30
 
49
- JSON.parse(response.body)['token']
31
+ JSON.parse(request.execute.body)['token']
50
32
  end
51
33
  end
52
34
  end
@@ -22,6 +22,13 @@ module Yoti
22
22
  @attributes = attributes
23
23
  end
24
24
 
25
+ #
26
+ # @return [TokenRequestBuilder]
27
+ #
28
+ def self.builder
29
+ TokenRequestBuilder.new
30
+ end
31
+
25
32
  #
26
33
  # @return [Hash]
27
34
  #
@@ -16,12 +16,13 @@ Metrics/ClassLength:
16
16
  Enabled: false
17
17
  Max: 115
18
18
 
19
+ Metrics/ModuleLength:
20
+ Exclude:
21
+ - examples/doc_scan/**/*.rb
22
+
19
23
  Metrics/CyclomaticComplexity:
20
24
  Max: 9
21
25
 
22
- Metrics/LineLength:
23
- Enabled: false
24
-
25
26
  Metrics/MethodLength:
26
27
  Enabled: false
27
28
  CountComments: false
@@ -39,6 +40,9 @@ Style/NumericLiterals:
39
40
  Style/MutableConstant:
40
41
  Enabled: false
41
42
 
43
+ Layout/LineLength:
44
+ Enabled: false
45
+
42
46
  Layout/MultilineMethodCallIndentation:
43
47
  Exclude:
44
48
  - examples/**/*.rb
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = 'yoti_sandbox'
6
- spec.version = '1.0.0'
6
+ spec.version = '1.1.0'
7
7
  spec.authors = ['Yoti']
8
8
  spec.email = ['websdk@yoti.com']
9
9
 
@@ -21,12 +21,12 @@ Gem::Specification.new do |spec|
21
21
 
22
22
  spec.required_ruby_version = '>= 2.4'
23
23
 
24
- spec.add_dependency 'yoti', '~> 1.6'
24
+ spec.add_dependency 'yoti', '~> 1.7'
25
25
 
26
26
  spec.add_development_dependency 'bundler', '~> 2.0'
27
- spec.add_development_dependency 'rake', '~> 12.0'
27
+ spec.add_development_dependency 'rake', '~> 13.0'
28
28
  spec.add_development_dependency 'rspec', '~> 3.5'
29
- spec.add_development_dependency 'simplecov', '~> 0.13'
29
+ spec.add_development_dependency 'simplecov', '~> 0.17.1'
30
30
  spec.add_development_dependency 'webmock', '~> 3.3'
31
31
  spec.add_development_dependency 'yard', '~> 0.9'
32
32
  spec.add_development_dependency 'yardstick', '~> 0.9'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yoti_sandbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yoti
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-06 00:00:00.000000000 Z
11
+ date: 2020-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yoti
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.6'
19
+ version: '1.7'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.6'
26
+ version: '1.7'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '12.0'
47
+ version: '13.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '12.0'
54
+ version: '13.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0.13'
75
+ version: 0.17.1
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0.13'
82
+ version: 0.17.1
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: webmock
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -140,6 +140,23 @@ files:
140
140
  - README.md
141
141
  - Rakefile
142
142
  - lib/yoti_sandbox.rb
143
+ - lib/yoti_sandbox/doc_scan.rb
144
+ - lib/yoti_sandbox/doc_scan/client.rb
145
+ - lib/yoti_sandbox/doc_scan/request/check/check.rb
146
+ - lib/yoti_sandbox/doc_scan/request/check/document_authenticity_check.rb
147
+ - lib/yoti_sandbox/doc_scan/request/check/document_check.rb
148
+ - lib/yoti_sandbox/doc_scan/request/check/document_face_match_check.rb
149
+ - lib/yoti_sandbox/doc_scan/request/check/document_text_data_check.rb
150
+ - lib/yoti_sandbox/doc_scan/request/check/liveness_check.rb
151
+ - lib/yoti_sandbox/doc_scan/request/check/report/breakdown.rb
152
+ - lib/yoti_sandbox/doc_scan/request/check/report/detail.rb
153
+ - lib/yoti_sandbox/doc_scan/request/check/report/recommendation.rb
154
+ - lib/yoti_sandbox/doc_scan/request/check/zoom_liveness_check.rb
155
+ - lib/yoti_sandbox/doc_scan/request/check_reports.rb
156
+ - lib/yoti_sandbox/doc_scan/request/document_filter.rb
157
+ - lib/yoti_sandbox/doc_scan/request/response_config.rb
158
+ - lib/yoti_sandbox/doc_scan/request/task/document_text_data_extraction_task.rb
159
+ - lib/yoti_sandbox/doc_scan/request/task_results.rb
143
160
  - lib/yoti_sandbox/profile.rb
144
161
  - lib/yoti_sandbox/profile/age_verification.rb
145
162
  - lib/yoti_sandbox/profile/anchor.rb