yoti 1.6.0 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/ISSUE_TEMPLATE.md +17 -0
- data/CONTRIBUTING.md +0 -29
- data/README.md +4 -0
- data/Rakefile +7 -10
- data/lib/yoti.rb +50 -1
- data/lib/yoti/activity_details.rb +5 -1
- data/lib/yoti/client.rb +13 -4
- data/lib/yoti/configuration.rb +7 -2
- data/lib/yoti/data_type/age_verification.rb +1 -1
- data/lib/yoti/data_type/base_profile.rb +1 -1
- data/lib/yoti/data_type/document_details.rb +5 -13
- data/lib/yoti/data_type/image.rb +4 -12
- data/lib/yoti/data_type/image_jpeg.rb +2 -0
- data/lib/yoti/data_type/image_png.rb +2 -0
- data/lib/yoti/data_type/media.rb +19 -0
- data/lib/yoti/doc_scan/client.rb +163 -0
- data/lib/yoti/doc_scan/constants.rb +28 -0
- data/lib/yoti/doc_scan/session/create/create_session_result.rb +50 -0
- data/lib/yoti/doc_scan/session/create/document_filter.rb +31 -0
- data/lib/yoti/doc_scan/session/create/document_restrictions_filter.rb +140 -0
- data/lib/yoti/doc_scan/session/create/notification_config.rb +142 -0
- data/lib/yoti/doc_scan/session/create/orthogonal_restrictions_filter.rb +150 -0
- data/lib/yoti/doc_scan/session/create/requested_check.rb +39 -0
- data/lib/yoti/doc_scan/session/create/requested_document_authenticity_check.rb +53 -0
- data/lib/yoti/doc_scan/session/create/requested_face_match_check.rb +95 -0
- data/lib/yoti/doc_scan/session/create/requested_liveness_check.rb +108 -0
- data/lib/yoti/doc_scan/session/create/requested_task.rb +39 -0
- data/lib/yoti/doc_scan/session/create/requested_text_extraction_task.rb +94 -0
- data/lib/yoti/doc_scan/session/create/required_document.rb +31 -0
- data/lib/yoti/doc_scan/session/create/required_id_document.rb +53 -0
- data/lib/yoti/doc_scan/session/create/sdk_config.rb +221 -0
- data/lib/yoti/doc_scan/session/create/session_specification.rb +203 -0
- data/lib/yoti/doc_scan/session/retrieve/authenticity_check_response.rb +12 -0
- data/lib/yoti/doc_scan/session/retrieve/breakdown_response.rb +38 -0
- data/lib/yoti/doc_scan/session/retrieve/check_response.rb +63 -0
- data/lib/yoti/doc_scan/session/retrieve/details_response.rb +28 -0
- data/lib/yoti/doc_scan/session/retrieve/document_fields_response.rb +21 -0
- data/lib/yoti/doc_scan/session/retrieve/face_map_response.rb +21 -0
- data/lib/yoti/doc_scan/session/retrieve/face_match_check_response.rb +12 -0
- data/lib/yoti/doc_scan/session/retrieve/frame_response.rb +21 -0
- data/lib/yoti/doc_scan/session/retrieve/generated_check_response.rb +28 -0
- data/lib/yoti/doc_scan/session/retrieve/generated_media.rb +28 -0
- data/lib/yoti/doc_scan/session/retrieve/generated_text_data_check_response.rb +12 -0
- data/lib/yoti/doc_scan/session/retrieve/get_session_result.rb +113 -0
- data/lib/yoti/doc_scan/session/retrieve/id_document_resource_response.rb +52 -0
- data/lib/yoti/doc_scan/session/retrieve/liveness_check_response.rb +12 -0
- data/lib/yoti/doc_scan/session/retrieve/liveness_resource_response.rb +24 -0
- data/lib/yoti/doc_scan/session/retrieve/media_response.rb +38 -0
- data/lib/yoti/doc_scan/session/retrieve/page_response.rb +27 -0
- data/lib/yoti/doc_scan/session/retrieve/recommendation_response.rb +34 -0
- data/lib/yoti/doc_scan/session/retrieve/report_response.rb +31 -0
- data/lib/yoti/doc_scan/session/retrieve/resource_container.rb +50 -0
- data/lib/yoti/doc_scan/session/retrieve/resource_response.rb +39 -0
- data/lib/yoti/doc_scan/session/retrieve/task_response.rb +87 -0
- data/lib/yoti/doc_scan/session/retrieve/text_data_check_response.rb +12 -0
- data/lib/yoti/doc_scan/session/retrieve/text_extraction_task_response.rb +18 -0
- data/lib/yoti/doc_scan/session/retrieve/zoom_liveness_resource_response.rb +33 -0
- data/lib/yoti/doc_scan/support/supported_documents.rb +60 -0
- data/lib/yoti/dynamic_share_service/extension/thirdparty_attribute_extension.rb +73 -12
- data/lib/yoti/dynamic_share_service/policy/dynamic_policy.rb +17 -17
- data/lib/yoti/dynamic_share_service/share_url.rb +28 -33
- data/lib/yoti/errors.rb +17 -2
- data/lib/yoti/http/aml_check_request.rb +12 -6
- data/lib/yoti/http/payloads/aml_address.rb +4 -0
- data/lib/yoti/http/payloads/aml_profile.rb +7 -1
- data/lib/yoti/http/profile_request.rb +11 -6
- data/lib/yoti/http/request.rb +220 -18
- data/lib/yoti/http/signed_request.rb +13 -4
- data/lib/yoti/protobuf/main.rb +16 -6
- data/lib/yoti/share/attribute_issuance_details.rb +1 -1
- data/lib/yoti/ssl.rb +3 -2
- data/lib/yoti/util/anchor_processor.rb +1 -1
- data/lib/yoti/util/validation.rb +41 -0
- data/lib/yoti/version.rb +1 -1
- data/rubocop.yml +9 -1
- data/yoti.gemspec +2 -5
- metadata +51 -60
- data/lib/yoti/sandbox.rb +0 -5
- data/lib/yoti/sandbox/anchor.rb +0 -49
- data/lib/yoti/sandbox/attribute.rb +0 -52
- data/lib/yoti/sandbox/profile.rb +0 -171
- data/lib/yoti/sandbox/sandbox.rb +0 -105
- data/lib/yoti/sandbox/sandbox_client.rb +0 -45
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Yoti
|
4
|
+
module DocScan
|
5
|
+
class Constants
|
6
|
+
ID_DOCUMENT_AUTHENTICITY = 'ID_DOCUMENT_AUTHENTICITY'
|
7
|
+
ID_DOCUMENT_TEXT_DATA_CHECK = 'ID_DOCUMENT_TEXT_DATA_CHECK'
|
8
|
+
ID_DOCUMENT_FACE_MATCH = 'ID_DOCUMENT_FACE_MATCH'
|
9
|
+
LIVENESS = 'LIVENESS'
|
10
|
+
ID_DOCUMENT_TEXT_DATA_EXTRACTION = 'ID_DOCUMENT_TEXT_DATA_EXTRACTION'
|
11
|
+
ID_DOCUMENT = 'ID_DOCUMENT'
|
12
|
+
ORTHOGONAL_RESTRICTIONS = 'ORTHOGONAL_RESTRICTIONS'
|
13
|
+
DOCUMENT_RESTRICTIONS = 'DOCUMENT_RESTRICTIONS'
|
14
|
+
INCLUDE = 'WHITELIST'
|
15
|
+
EXCLUDE = 'BLACKLIST'
|
16
|
+
ALWAYS = 'ALWAYS'
|
17
|
+
FALLBACK = 'FALLBACK'
|
18
|
+
NEVER = 'NEVER'
|
19
|
+
ZOOM = 'ZOOM'
|
20
|
+
CAMERA = 'CAMERA'
|
21
|
+
CAMERA_AND_UPLOAD = 'CAMERA_AND_UPLOAD'
|
22
|
+
RESOURCE_UPDATE = 'RESOURCE_UPDATE'
|
23
|
+
TASK_COMPLETION = 'TASK_COMPLETION'
|
24
|
+
CHECK_COMPLETION = 'CHECK_COMPLETION'
|
25
|
+
SESSION_COMPLETION = 'SESSION_COMPLETION'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Yoti
|
4
|
+
module DocScan
|
5
|
+
module Session
|
6
|
+
module Create
|
7
|
+
#
|
8
|
+
# The response to a successful CreateSession call
|
9
|
+
#
|
10
|
+
class CreateSessionResult
|
11
|
+
#
|
12
|
+
# Returns the time-to-live (TTL) for the client session
|
13
|
+
# token for the created session
|
14
|
+
#
|
15
|
+
# @return [Integer]
|
16
|
+
#
|
17
|
+
attr_reader :client_session_token_ttl
|
18
|
+
|
19
|
+
#
|
20
|
+
# Returns the client session token for the created session
|
21
|
+
#
|
22
|
+
# @return [String]
|
23
|
+
#
|
24
|
+
attr_reader :client_session_token
|
25
|
+
|
26
|
+
#
|
27
|
+
# Session ID of the created session
|
28
|
+
#
|
29
|
+
# @return [String]
|
30
|
+
#
|
31
|
+
attr_reader :session_id
|
32
|
+
|
33
|
+
#
|
34
|
+
# @param [Hash] response
|
35
|
+
#
|
36
|
+
def initialize(response)
|
37
|
+
Validation.assert_is_a(Integer, response['client_session_token_ttl'], 'client_session_token_ttl', true)
|
38
|
+
@client_session_token_ttl = response['client_session_token_ttl']
|
39
|
+
|
40
|
+
Validation.assert_is_a(String, response['client_session_token'], 'client_session_token', true)
|
41
|
+
@client_session_token = response['client_session_token']
|
42
|
+
|
43
|
+
Validation.assert_is_a(String, response['session_id'], 'session_id', true)
|
44
|
+
@session_id = response['session_id']
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
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 DocumentFilter
|
8
|
+
#
|
9
|
+
# @param [String] type
|
10
|
+
#
|
11
|
+
def initialize(type)
|
12
|
+
raise(TypeError, "#{self.class} cannot be instantiated") if self.class == DocumentFilter
|
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
|
@@ -0,0 +1,140 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Yoti
|
4
|
+
module DocScan
|
5
|
+
module Session
|
6
|
+
module Create
|
7
|
+
class DocumentRestrictionsFilter < DocumentFilter
|
8
|
+
#
|
9
|
+
# @param [String] inclusion
|
10
|
+
# @param [Array<DocumentRestriction>] documents
|
11
|
+
#
|
12
|
+
def initialize(inclusion, documents)
|
13
|
+
super(Constants::DOCUMENT_RESTRICTIONS)
|
14
|
+
|
15
|
+
Validation.assert_is_a(String, inclusion, 'country_restriction')
|
16
|
+
@inclusion = inclusion
|
17
|
+
|
18
|
+
Validation.assert_is_a(Array, documents, 'documents')
|
19
|
+
@documents = documents
|
20
|
+
end
|
21
|
+
|
22
|
+
def as_json(*_args)
|
23
|
+
super.merge(
|
24
|
+
inclusion: @inclusion,
|
25
|
+
documents: @documents.map(&:as_json)
|
26
|
+
).compact
|
27
|
+
end
|
28
|
+
|
29
|
+
#
|
30
|
+
# @return [DocumentRestrictionsFilterBuilder]
|
31
|
+
#
|
32
|
+
def self.builder
|
33
|
+
DocumentRestrictionsFilterBuilder.new
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
class DocumentRestrictionsFilterBuilder
|
38
|
+
def initialize
|
39
|
+
@documents = []
|
40
|
+
end
|
41
|
+
|
42
|
+
#
|
43
|
+
# @return [self]
|
44
|
+
#
|
45
|
+
def for_inclusion
|
46
|
+
@inclusion = Constants::INCLUDE
|
47
|
+
self
|
48
|
+
end
|
49
|
+
|
50
|
+
#
|
51
|
+
# @return [self]
|
52
|
+
#
|
53
|
+
def for_exclusion
|
54
|
+
@inclusion = Constants::EXCLUDE
|
55
|
+
self
|
56
|
+
end
|
57
|
+
|
58
|
+
#
|
59
|
+
# @param [DocumentRestriction] document_restriction
|
60
|
+
#
|
61
|
+
# @return [self]
|
62
|
+
#
|
63
|
+
def with_document_restriction(document_restriction)
|
64
|
+
Validation.assert_is_a(DocumentRestriction, document_restriction, 'document_restriction')
|
65
|
+
@documents.push(document_restriction)
|
66
|
+
self
|
67
|
+
end
|
68
|
+
|
69
|
+
#
|
70
|
+
# @return [DocumentRestrictionsFilter]
|
71
|
+
#
|
72
|
+
def build
|
73
|
+
DocumentRestrictionsFilter.new(@inclusion, @documents)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
class DocumentRestriction
|
78
|
+
#
|
79
|
+
# @param [Array<String>] country_codes
|
80
|
+
# @param [Array<String>] document_types
|
81
|
+
#
|
82
|
+
def initialize(country_codes, document_types)
|
83
|
+
Validation.assert_is_a(Array, country_codes, 'country_codes', true)
|
84
|
+
@country_codes = country_codes
|
85
|
+
|
86
|
+
Validation.assert_is_a(Array, document_types, 'document_types', true)
|
87
|
+
@document_types = document_types
|
88
|
+
end
|
89
|
+
|
90
|
+
def to_json(*_args)
|
91
|
+
as_json.to_json
|
92
|
+
end
|
93
|
+
|
94
|
+
def as_json(*_args)
|
95
|
+
json = {}
|
96
|
+
json[:document_types] = @document_types unless @document_types.nil?
|
97
|
+
json[:country_codes] = @country_codes unless @country_codes.nil?
|
98
|
+
json
|
99
|
+
end
|
100
|
+
|
101
|
+
#
|
102
|
+
# @return [DocumentRestrictionBuilder]
|
103
|
+
#
|
104
|
+
def self.builder
|
105
|
+
DocumentRestrictionBuilder.new
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
class DocumentRestrictionBuilder
|
110
|
+
#
|
111
|
+
# @param [Array<String>] document_types
|
112
|
+
#
|
113
|
+
# @return [self]
|
114
|
+
#
|
115
|
+
def with_document_types(document_types)
|
116
|
+
@document_types = document_types
|
117
|
+
self
|
118
|
+
end
|
119
|
+
|
120
|
+
#
|
121
|
+
# @param [Array<String>] country_codes
|
122
|
+
#
|
123
|
+
# @return [self]
|
124
|
+
#
|
125
|
+
def with_countries(country_codes)
|
126
|
+
@country_codes = country_codes
|
127
|
+
self
|
128
|
+
end
|
129
|
+
|
130
|
+
#
|
131
|
+
# @return [DocumentRestriction]
|
132
|
+
#
|
133
|
+
def build
|
134
|
+
DocumentRestriction.new(@country_codes, @document_types)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
@@ -0,0 +1,142 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Yoti
|
4
|
+
module DocScan
|
5
|
+
module Session
|
6
|
+
module Create
|
7
|
+
#
|
8
|
+
# Configures call-back Notifications to some backend endpoint provided
|
9
|
+
# by the Relying Business.
|
10
|
+
#
|
11
|
+
# Notifications can be configured to notified a client backend of certain
|
12
|
+
# events, avoiding the need to poll for the state of the Session.
|
13
|
+
#
|
14
|
+
class NotificationConfig
|
15
|
+
#
|
16
|
+
# @param [String] auth_token
|
17
|
+
# The authorization token to be included in call-back messages
|
18
|
+
# @param [String] endpoint
|
19
|
+
# The endpoint that notifications should be sent to
|
20
|
+
# @param [Array<String>] topics
|
21
|
+
# The list of topics that should trigger notifications
|
22
|
+
#
|
23
|
+
def initialize(auth_token, endpoint, topics)
|
24
|
+
Validation.assert_is_a(String, auth_token, 'auth_token', true)
|
25
|
+
@auth_token = auth_token
|
26
|
+
|
27
|
+
Validation.assert_is_a(String, endpoint, 'endpoint', true)
|
28
|
+
@endpoint = endpoint
|
29
|
+
|
30
|
+
Validation.assert_is_a(Array, topics, 'auth_token', true)
|
31
|
+
@topics = topics.uniq unless topics.nil?
|
32
|
+
end
|
33
|
+
|
34
|
+
def to_json(*_args)
|
35
|
+
as_json.to_json
|
36
|
+
end
|
37
|
+
|
38
|
+
def as_json(*_args)
|
39
|
+
{
|
40
|
+
auth_token: @auth_token,
|
41
|
+
endpoint: @endpoint,
|
42
|
+
topics: @topics
|
43
|
+
}.compact
|
44
|
+
end
|
45
|
+
|
46
|
+
#
|
47
|
+
# @return [NotificationConfigBuilder]
|
48
|
+
#
|
49
|
+
def self.builder
|
50
|
+
NotificationConfigBuilder.new
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
class NotificationConfigBuilder
|
55
|
+
def initialize
|
56
|
+
@topics = []
|
57
|
+
end
|
58
|
+
|
59
|
+
#
|
60
|
+
# Sets the authorization token to be included in call-back messages
|
61
|
+
#
|
62
|
+
# @param [String] auth_token
|
63
|
+
#
|
64
|
+
# @return [self]
|
65
|
+
#
|
66
|
+
def with_auth_token(auth_token)
|
67
|
+
@auth_token = auth_token
|
68
|
+
self
|
69
|
+
end
|
70
|
+
|
71
|
+
#
|
72
|
+
# Sets the endpoint that notifications should be sent to
|
73
|
+
#
|
74
|
+
# @param [String] endpoint
|
75
|
+
#
|
76
|
+
# @return [self]
|
77
|
+
#
|
78
|
+
def with_endpoint(endpoint)
|
79
|
+
@endpoint = endpoint
|
80
|
+
self
|
81
|
+
end
|
82
|
+
|
83
|
+
#
|
84
|
+
# Adds a topic to the list of topics that trigger notification messages
|
85
|
+
#
|
86
|
+
# @param [String] topic
|
87
|
+
#
|
88
|
+
# @return [self]
|
89
|
+
#
|
90
|
+
def with_topic(topic)
|
91
|
+
Validation.assert_is_a(String, topic, 'topic')
|
92
|
+
@topics.push(topic)
|
93
|
+
self
|
94
|
+
end
|
95
|
+
|
96
|
+
#
|
97
|
+
# Adds RESOURCE_UPDATE to the list of topics that trigger notification messages
|
98
|
+
#
|
99
|
+
# @return [self]
|
100
|
+
#
|
101
|
+
def for_resource_update
|
102
|
+
with_topic(Constants::RESOURCE_UPDATE)
|
103
|
+
end
|
104
|
+
|
105
|
+
#
|
106
|
+
# Adds TASK_COMPLETION to the list of topics that trigger notification messages
|
107
|
+
#
|
108
|
+
# @return [self]
|
109
|
+
#
|
110
|
+
def for_task_completion
|
111
|
+
with_topic(Constants::TASK_COMPLETION)
|
112
|
+
end
|
113
|
+
|
114
|
+
#
|
115
|
+
# Adds CHECK_COMPLETION to the list of topics that trigger notification messages
|
116
|
+
#
|
117
|
+
# @return [self]
|
118
|
+
#
|
119
|
+
def for_check_completion
|
120
|
+
with_topic(Constants::CHECK_COMPLETION)
|
121
|
+
end
|
122
|
+
|
123
|
+
#
|
124
|
+
# Adds SESSION_COMPLETION to the list of topics that trigger notification messages
|
125
|
+
#
|
126
|
+
# @return [self]
|
127
|
+
#
|
128
|
+
def for_session_completion
|
129
|
+
with_topic(Constants::SESSION_COMPLETION)
|
130
|
+
end
|
131
|
+
|
132
|
+
#
|
133
|
+
# @return [NotificationConfig]
|
134
|
+
#
|
135
|
+
def build
|
136
|
+
NotificationConfig.new(@auth_token, @endpoint, @topics)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
@@ -0,0 +1,150 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Yoti
|
4
|
+
module DocScan
|
5
|
+
module Session
|
6
|
+
module Create
|
7
|
+
class OrthogonalRestrictionsFilter < DocumentFilter
|
8
|
+
#
|
9
|
+
# @param [CountryRestriction] country_restriction
|
10
|
+
# @param [TypeRestriction] type_restriction
|
11
|
+
#
|
12
|
+
def initialize(country_restriction, type_restriction)
|
13
|
+
super(Constants::ORTHOGONAL_RESTRICTIONS)
|
14
|
+
|
15
|
+
Validation.assert_is_a(CountryRestriction, country_restriction, 'country_restriction', true)
|
16
|
+
@country_restriction = country_restriction
|
17
|
+
|
18
|
+
Validation.assert_is_a(TypeRestriction, type_restriction, 'type_restriction', true)
|
19
|
+
@type_restriction = type_restriction
|
20
|
+
end
|
21
|
+
|
22
|
+
def as_json(*_args)
|
23
|
+
json = super
|
24
|
+
json[:country_restriction] = @country_restriction.as_json unless @country_restriction.nil?
|
25
|
+
json[:type_restriction] = @type_restriction.as_json unless @type_restriction.nil?
|
26
|
+
json
|
27
|
+
end
|
28
|
+
|
29
|
+
#
|
30
|
+
# @return [OrthogonalRestrictionsFilterBuilder]
|
31
|
+
#
|
32
|
+
def self.builder
|
33
|
+
OrthogonalRestrictionsFilterBuilder.new
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
class OrthogonalRestrictionsFilterBuilder
|
38
|
+
#
|
39
|
+
# @param [Array<String>] country_codes
|
40
|
+
#
|
41
|
+
# @return [self]
|
42
|
+
#
|
43
|
+
def with_included_countries(country_codes)
|
44
|
+
@country_restriction = CountryRestriction.new(
|
45
|
+
Constants::INCLUDE,
|
46
|
+
country_codes
|
47
|
+
)
|
48
|
+
self
|
49
|
+
end
|
50
|
+
|
51
|
+
#
|
52
|
+
# @param [Array<String>] country_codes
|
53
|
+
#
|
54
|
+
# @return [self]
|
55
|
+
#
|
56
|
+
def with_excluded_countries(country_codes)
|
57
|
+
@country_restriction = CountryRestriction.new(
|
58
|
+
Constants::EXCLUDE,
|
59
|
+
country_codes
|
60
|
+
)
|
61
|
+
self
|
62
|
+
end
|
63
|
+
|
64
|
+
#
|
65
|
+
# @param [Array<String>] document_types
|
66
|
+
#
|
67
|
+
# @return [self]
|
68
|
+
#
|
69
|
+
def with_included_document_types(document_types)
|
70
|
+
@type_restriction = TypeRestriction.new(
|
71
|
+
Constants::INCLUDE,
|
72
|
+
document_types
|
73
|
+
)
|
74
|
+
self
|
75
|
+
end
|
76
|
+
|
77
|
+
#
|
78
|
+
# @param [Array<String>] document_types
|
79
|
+
#
|
80
|
+
# @return [self]
|
81
|
+
#
|
82
|
+
def with_excluded_document_types(document_types)
|
83
|
+
@type_restriction = TypeRestriction.new(
|
84
|
+
Constants::EXCLUDE,
|
85
|
+
document_types
|
86
|
+
)
|
87
|
+
self
|
88
|
+
end
|
89
|
+
|
90
|
+
#
|
91
|
+
# @return [OrthogonalRestrictionsFilter]
|
92
|
+
#
|
93
|
+
def build
|
94
|
+
OrthogonalRestrictionsFilter.new(@country_restriction, @type_restriction)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
class CountryRestriction
|
99
|
+
#
|
100
|
+
# @param [String] inclusion
|
101
|
+
# @param [Array<String>] country_codes
|
102
|
+
#
|
103
|
+
def initialize(inclusion, country_codes)
|
104
|
+
Validation.assert_is_a(String, inclusion, 'inclusion')
|
105
|
+
@inclusion = inclusion
|
106
|
+
|
107
|
+
Validation.assert_is_a(Array, country_codes, 'country_codes')
|
108
|
+
@country_codes = country_codes
|
109
|
+
end
|
110
|
+
|
111
|
+
def to_json(*_args)
|
112
|
+
as_json.to_json
|
113
|
+
end
|
114
|
+
|
115
|
+
def as_json(*_args)
|
116
|
+
{
|
117
|
+
inclusion: @inclusion,
|
118
|
+
country_codes: @country_codes
|
119
|
+
}
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
class TypeRestriction
|
124
|
+
#
|
125
|
+
# @param [String] inclusion
|
126
|
+
# @param [Array<String>] document_types
|
127
|
+
#
|
128
|
+
def initialize(inclusion, document_types)
|
129
|
+
Validation.assert_is_a(String, inclusion, 'inclusion')
|
130
|
+
@inclusion = inclusion
|
131
|
+
|
132
|
+
Validation.assert_is_a(Array, document_types, 'document_types')
|
133
|
+
@document_types = document_types
|
134
|
+
end
|
135
|
+
|
136
|
+
def to_json(*_args)
|
137
|
+
as_json.to_json
|
138
|
+
end
|
139
|
+
|
140
|
+
def as_json(*_args)
|
141
|
+
{
|
142
|
+
inclusion: @inclusion,
|
143
|
+
document_types: @document_types
|
144
|
+
}
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|