trustid_sdk 0.2.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.
- checksums.yaml +7 -0
- data/README.md +80 -0
- data/lib/trustid_sdk/client.rb +21 -0
- data/lib/trustid_sdk/concerns/attribute_resolution.rb +19 -0
- data/lib/trustid_sdk/concerns/has_nested_models.rb +179 -0
- data/lib/trustid_sdk/config.rb +45 -0
- data/lib/trustid_sdk/errors.rb +23 -0
- data/lib/trustid_sdk/models/access_lock.rb +28 -0
- data/lib/trustid_sdk/models/advanced_query_arguments.rb +78 -0
- data/lib/trustid_sdk/models/application_flexible_field.rb +34 -0
- data/lib/trustid_sdk/models/application_flexible_field_attribute.rb +75 -0
- data/lib/trustid_sdk/models/application_flexible_field_list.rb +79 -0
- data/lib/trustid_sdk/models/application_flexible_field_value.rb +79 -0
- data/lib/trustid_sdk/models/base_model.rb +53 -0
- data/lib/trustid_sdk/models/branch.rb +34 -0
- data/lib/trustid_sdk/models/callback_info.rb +33 -0
- data/lib/trustid_sdk/models/callback_state.rb +46 -0
- data/lib/trustid_sdk/models/chargeable_status.rb +31 -0
- data/lib/trustid_sdk/models/configuration.rb +78 -0
- data/lib/trustid_sdk/models/container.rb +254 -0
- data/lib/trustid_sdk/models/custom_field.rb +29 -0
- data/lib/trustid_sdk/models/dbs_check_initiation.rb +14 -0
- data/lib/trustid_sdk/models/dbs_form.rb +108 -0
- data/lib/trustid_sdk/models/digital_identification_scheme.rb +43 -0
- data/lib/trustid_sdk/models/document.rb +646 -0
- data/lib/trustid_sdk/models/document_configuration.rb +21 -0
- data/lib/trustid_sdk/models/document_container_field.rb +31 -0
- data/lib/trustid_sdk/models/document_container_validation.rb +45 -0
- data/lib/trustid_sdk/models/document_container_validation_outcome.rb +58 -0
- data/lib/trustid_sdk/models/document_feature_feedback.rb +24 -0
- data/lib/trustid_sdk/models/document_feedback.rb +35 -0
- data/lib/trustid_sdk/models/document_field.rb +48 -0
- data/lib/trustid_sdk/models/document_field_data_type.rb +22 -0
- data/lib/trustid_sdk/models/document_field_source.rb +34 -0
- data/lib/trustid_sdk/models/document_sorting_column.rb +27 -0
- data/lib/trustid_sdk/models/document_source.rb +29 -0
- data/lib/trustid_sdk/models/document_status.rb +34 -0
- data/lib/trustid_sdk/models/document_storage_type.rb +32 -0
- data/lib/trustid_sdk/models/document_type.rb +46 -0
- data/lib/trustid_sdk/models/document_type_charge_status.rb +37 -0
- data/lib/trustid_sdk/models/document_validation.rb +45 -0
- data/lib/trustid_sdk/models/document_validation_result.rb +60 -0
- data/lib/trustid_sdk/models/established_document_data.rb +20 -0
- data/lib/trustid_sdk/models/external_service_data.rb +29 -0
- data/lib/trustid_sdk/models/filter_date_option.rb +36 -0
- data/lib/trustid_sdk/models/flexible_field_data_type.rb +39 -0
- data/lib/trustid_sdk/models/flexible_field_search_specification.rb +50 -0
- data/lib/trustid_sdk/models/flexible_field_specification_search_operator.rb +30 -0
- data/lib/trustid_sdk/models/gender.rb +31 -0
- data/lib/trustid_sdk/models/guest_link_response.rb +38 -0
- data/lib/trustid_sdk/models/image.rb +101 -0
- data/lib/trustid_sdk/models/image_orientation.rb +52 -0
- data/lib/trustid_sdk/models/image_type.rb +89 -0
- data/lib/trustid_sdk/models/kdb_country.rb +37 -0
- data/lib/trustid_sdk/models/kdb_document_number.rb +37 -0
- data/lib/trustid_sdk/models/kdb_document_sub_type.rb +28 -0
- data/lib/trustid_sdk/models/kdb_feature_type.rb +45 -0
- data/lib/trustid_sdk/models/liveness_result_type.rb +55 -0
- data/lib/trustid_sdk/models/mrz_query_option.rb +35 -0
- data/lib/trustid_sdk/models/ocr_coordinates.rb +19 -0
- data/lib/trustid_sdk/models/ocr_field.rb +78 -0
- data/lib/trustid_sdk/models/ocr_field_data.rb +28 -0
- data/lib/trustid_sdk/models/organisation.rb +19 -0
- data/lib/trustid_sdk/models/overall_status.rb +39 -0
- data/lib/trustid_sdk/models/pdf.rb +17 -0
- data/lib/trustid_sdk/models/referral_history_record.rb +68 -0
- data/lib/trustid_sdk/models/referral_type.rb +27 -0
- data/lib/trustid_sdk/models/remaining_credits.rb +16 -0
- data/lib/trustid_sdk/models/report.rb +17 -0
- data/lib/trustid_sdk/models/review_application_state.rb +33 -0
- data/lib/trustid_sdk/models/sorting_direction.rb +28 -0
- data/lib/trustid_sdk/models/user.rb +41 -0
- data/lib/trustid_sdk/models/user_archive_visibility.rb +28 -0
- data/lib/trustid_sdk/models/user_reference.rb +16 -0
- data/lib/trustid_sdk/models/webhook_callback.rb +129 -0
- data/lib/trustid_sdk/models/webhook_data.rb +272 -0
- data/lib/trustid_sdk/models/webhook_response.rb +89 -0
- data/lib/trustid_sdk/models/workflow_storage_item.rb +52 -0
- data/lib/trustid_sdk/models/workflow_type.rb +31 -0
- data/lib/trustid_sdk/request.rb +116 -0
- data/lib/trustid_sdk/services/authentication.rb +23 -0
- data/lib/trustid_sdk/services/containers.rb +20 -0
- data/lib/trustid_sdk/services/documents.rb +23 -0
- data/lib/trustid_sdk/services/guest_links.rb +19 -0
- data/lib/trustid_sdk/services/images.rb +21 -0
- data/lib/trustid_sdk/services/reports.rb +79 -0
- data/lib/trustid_sdk/services/webhook_parser.rb +220 -0
- data/lib/trustid_sdk/version.rb +5 -0
- data/lib/trustid_sdk.rb +23 -0
- metadata +186 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module TrustID
|
|
4
|
+
# ApplicationFlexibleFieldValue
|
|
5
|
+
#
|
|
6
|
+
# Represents the value for an application-level custom field.
|
|
7
|
+
#
|
|
8
|
+
# Fields:
|
|
9
|
+
# behaviour_flags_dup - Integer: Behaviour flags for this field.
|
|
10
|
+
# data_range_dup - String: Duplicated data range information.
|
|
11
|
+
# default_value_dup - String: Duplicated default value.
|
|
12
|
+
# document_container_id - String: ID of the document container this value is assigned to.
|
|
13
|
+
# field_order_index_dup - Integer: Duplicated field order index.
|
|
14
|
+
# field_value_date - DateTime: Value if the field is a date/time.
|
|
15
|
+
# field_value_decimal - Decimal: Value if the field is a decimal.
|
|
16
|
+
# field_value_int - Integer: Value if the field is an integer.
|
|
17
|
+
# field_value_string - String: Value if the field is a string.
|
|
18
|
+
# flexible_field_data_type_id_dup - Integer: Duplicated field type ID.
|
|
19
|
+
# flexible_field_display_name_dup - String: Duplicated field display name.
|
|
20
|
+
# flexible_field_id - String: ID of the corresponding custom field attribute.
|
|
21
|
+
# flexible_field_name_dup - String: Duplicated field name.
|
|
22
|
+
# flexible_field_version_id - String: Version ID of the custom field attribute.
|
|
23
|
+
# help_text_dup - String: Duplicated help text.
|
|
24
|
+
# mandatory_dup - Boolean: Duplicated mandatory flag.
|
|
25
|
+
# mandatory_if_value_list_or_dup - String: Conditions for when the field is mandatory.
|
|
26
|
+
# template - Hash: Template for the field.
|
|
27
|
+
# validation_status - String: Fail, Warning, or Pass value when measured against validation criteria.
|
|
28
|
+
#
|
|
29
|
+
# The model exposes a `document_container` method to resolve the related container by ID.
|
|
30
|
+
#
|
|
31
|
+
# @see https://developer.trustid.co.uk/documentation/ref/raw_ref/model/ApplicationFlexibleFieldValue.html
|
|
32
|
+
class ApplicationFlexibleFieldValue < BaseModel
|
|
33
|
+
attribute :behaviour_flags_dup, :integer
|
|
34
|
+
attribute :data_range_dup, :string
|
|
35
|
+
attribute :default_value_dup, :string
|
|
36
|
+
attribute :document_container_id, :string
|
|
37
|
+
attribute :field_order_index_dup, :integer
|
|
38
|
+
attribute :field_value_date, :datetime
|
|
39
|
+
attribute :field_value_decimal, :decimal
|
|
40
|
+
attribute :field_value_int, :integer
|
|
41
|
+
attribute :field_value_string, :string
|
|
42
|
+
attribute :flexible_field_data_type_id_dup, :integer
|
|
43
|
+
attribute :flexible_field_display_name_dup, :string
|
|
44
|
+
attribute :flexible_field_id, :string
|
|
45
|
+
attribute :flexible_field_name_dup, :string
|
|
46
|
+
attribute :flexible_field_version_id, :string
|
|
47
|
+
attribute :help_text_dup, :string
|
|
48
|
+
attribute :mandatory_dup, :boolean
|
|
49
|
+
attribute :mandatory_if_value_list_or_dup, :string
|
|
50
|
+
attribute :template
|
|
51
|
+
attribute :validation_status, :string
|
|
52
|
+
|
|
53
|
+
def initialize(attributes = {})
|
|
54
|
+
# Normalize keys to handle API response format
|
|
55
|
+
attributes = normalize_keys(attributes)
|
|
56
|
+
super
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# Only expose document_container as a related model, loaded on demand.
|
|
60
|
+
# Uses a block to define how to resolve the association, for maximum flexibility.
|
|
61
|
+
def document_container
|
|
62
|
+
return nil unless document_container_id
|
|
63
|
+
|
|
64
|
+
@document_container ||= TrustID::Services::Containers.find(document_container_id)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
private
|
|
68
|
+
|
|
69
|
+
# Helper method to normalize keys to lowercase underscored symbols
|
|
70
|
+
def normalize_keys(hash)
|
|
71
|
+
result = {}
|
|
72
|
+
hash.each do |key, value|
|
|
73
|
+
key_str = key.to_s.underscore.downcase
|
|
74
|
+
result[key_str.to_sym] = value
|
|
75
|
+
end
|
|
76
|
+
result
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../concerns/attribute_resolution'
|
|
4
|
+
require 'active_support'
|
|
5
|
+
|
|
6
|
+
module TrustID
|
|
7
|
+
# Base model for all models in the TrustID SDK.
|
|
8
|
+
class BaseModel
|
|
9
|
+
include ActiveModel::Model
|
|
10
|
+
include ActiveModel::Attributes
|
|
11
|
+
include AttributeResolution
|
|
12
|
+
|
|
13
|
+
attribute :response
|
|
14
|
+
|
|
15
|
+
def self.from_hash(hash)
|
|
16
|
+
attrs = normalize_keys(hash)
|
|
17
|
+
attrs = parse_dates(attrs)
|
|
18
|
+
attrs = filter_undefined_attributes(attrs)
|
|
19
|
+
attrs[:response] = hash
|
|
20
|
+
new(attrs)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
class << self
|
|
24
|
+
private
|
|
25
|
+
|
|
26
|
+
def normalize_keys(hash)
|
|
27
|
+
hash.transform_keys do |key|
|
|
28
|
+
key.is_a?(String) ? key.underscore : key.to_s.underscore
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def parse_dates(attrs)
|
|
33
|
+
attrs.transform_values do |value|
|
|
34
|
+
if value.is_a?(String) && value.match(%r{^/Date\((\d+)([+-]\d+)?\)/$})
|
|
35
|
+
ms = value.match(%r{^/Date\((\d+)([+-]\d+)?\)/$})[1].to_i
|
|
36
|
+
Time.at(ms / 1000.0).to_datetime
|
|
37
|
+
else
|
|
38
|
+
value
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def filter_undefined_attributes(attrs)
|
|
44
|
+
failed_attributes = attrs.keys.reject { |key| attribute_names.include?(key.to_s) }
|
|
45
|
+
unless failed_attributes.empty?
|
|
46
|
+
warn "Warning: The following attributes are not defined in #{name}: #{failed_attributes.join(', ')}"
|
|
47
|
+
attrs = attrs.reject { |key| failed_attributes.include?(key) }
|
|
48
|
+
end
|
|
49
|
+
attrs
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module TrustID
|
|
4
|
+
# Branch
|
|
5
|
+
#
|
|
6
|
+
# Represents a branch or office location within the TrustID system.
|
|
7
|
+
#
|
|
8
|
+
# Fields:
|
|
9
|
+
# id - String: Unique identifier for the branch.
|
|
10
|
+
# name - String: Display name of the branch.
|
|
11
|
+
# address - String: Address of the branch.
|
|
12
|
+
# created_at - DateTime: When the branch was created (ISO8601).
|
|
13
|
+
# updated_at - DateTime: When the branch was last updated (ISO8601).
|
|
14
|
+
# organisation_id - String: Reference to the parent organisation.
|
|
15
|
+
# organisation - Organisation: Parent organisation, resolved model (optional, loaded on demand).
|
|
16
|
+
#
|
|
17
|
+
# When initialized, the model will resolve the organisation if provided in the attributes.
|
|
18
|
+
#
|
|
19
|
+
# @see https://developer.trustid.co.uk/documentation/ref/raw_ref/model/Branch.html
|
|
20
|
+
class Branch < BaseModel
|
|
21
|
+
attribute :id, :string
|
|
22
|
+
attribute :name, :string
|
|
23
|
+
attribute :address, :string
|
|
24
|
+
attribute :created_at, :datetime
|
|
25
|
+
attribute :updated_at, :datetime
|
|
26
|
+
attribute :organisation_id, :string
|
|
27
|
+
attr_reader :organisation
|
|
28
|
+
|
|
29
|
+
def initialize(attributes = {})
|
|
30
|
+
super
|
|
31
|
+
@organisation = resolve_model(attributes[:organisation], TrustID::Organisation)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module TrustID
|
|
4
|
+
# CallbackInfo
|
|
5
|
+
#
|
|
6
|
+
# Represents metadata and state for a callback event in the TrustID system.
|
|
7
|
+
#
|
|
8
|
+
# Fields:
|
|
9
|
+
# id - String: Unique identifier for the callback event.
|
|
10
|
+
# event_type - String: Type of event triggering the callback.
|
|
11
|
+
# status - Integer: Status code (see CallbackState).
|
|
12
|
+
# payload - Hash/Object: Data sent with the callback.
|
|
13
|
+
# created_at - DateTime: When the callback was created.
|
|
14
|
+
# processed_at - DateTime: When the callback was processed.
|
|
15
|
+
# error_message- String: Optional, error details if processing failed.
|
|
16
|
+
#
|
|
17
|
+
# The model exposes a `status_name` method to resolve the status code to a human-readable name using CallbackState.
|
|
18
|
+
#
|
|
19
|
+
# @see https://developer.trustid.co.uk/documentation/ref/raw_ref/model/CallbackInfo.html
|
|
20
|
+
class CallbackInfo < BaseModel
|
|
21
|
+
attribute :id, :string
|
|
22
|
+
attribute :event_type, :string
|
|
23
|
+
attribute :status, :integer
|
|
24
|
+
attribute :payload
|
|
25
|
+
attribute :created_at, :datetime
|
|
26
|
+
attribute :processed_at, :datetime
|
|
27
|
+
attribute :error_message, :string
|
|
28
|
+
|
|
29
|
+
def status_name
|
|
30
|
+
TrustID::CallbackState.name_for(status)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module TrustID
|
|
4
|
+
# CallbackState
|
|
5
|
+
#
|
|
6
|
+
# Enum representing the possible states for a callback event in the TrustID system.
|
|
7
|
+
#
|
|
8
|
+
# Enum values:
|
|
9
|
+
# SCHEDULED (1) - A callback operation has been scheduled to be processed shortly.
|
|
10
|
+
# PROCESSING (2) - A callback operation is currently being processed.
|
|
11
|
+
# OPERATOR_ACTION (3) - Waiting for manual operator action.
|
|
12
|
+
# READY_TO_DISPATCH (4) - Ready to be dispatched back through the callback mechanism.
|
|
13
|
+
# DISPATCHED (5) - Callback has been dispatched successfully.
|
|
14
|
+
# UNABLE_TO_DISPATCH (6) - Unable to dispatch the callback operation.
|
|
15
|
+
# WORKFLOW (10) - Executing a workflow associated with this callback operation.
|
|
16
|
+
# WORKFLOW_COMPLETE (11) - Workflow completed, no callback required.
|
|
17
|
+
#
|
|
18
|
+
# Use as: CallbackState::SCHEDULED, etc.
|
|
19
|
+
#
|
|
20
|
+
# @see https://developer.trustid.co.uk/documentation/ref/raw_ref/model/CallbackState.html
|
|
21
|
+
class CallbackState
|
|
22
|
+
SCHEDULED = 1
|
|
23
|
+
PROCESSING = 2
|
|
24
|
+
OPERATOR_ACTION = 3
|
|
25
|
+
READY_TO_DISPATCH = 4
|
|
26
|
+
DISPATCHED = 5
|
|
27
|
+
UNABLE_TO_DISPATCH = 6
|
|
28
|
+
WORKFLOW = 10
|
|
29
|
+
WORKFLOW_COMPLETE = 11
|
|
30
|
+
|
|
31
|
+
NAMES = {
|
|
32
|
+
SCHEDULED => 'Scheduled',
|
|
33
|
+
PROCESSING => 'Processing',
|
|
34
|
+
OPERATOR_ACTION => 'OperatorAction',
|
|
35
|
+
READY_TO_DISPATCH => 'ReadyToDispatch',
|
|
36
|
+
DISPATCHED => 'Dispatched',
|
|
37
|
+
UNABLE_TO_DISPATCH => 'UnableToDispatch',
|
|
38
|
+
WORKFLOW => 'Workflow',
|
|
39
|
+
WORKFLOW_COMPLETE => 'WorkflowComplete'
|
|
40
|
+
}.freeze
|
|
41
|
+
|
|
42
|
+
def self.name_for(code)
|
|
43
|
+
NAMES[code]
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module TrustID
|
|
4
|
+
# ChargeableStatus
|
|
5
|
+
#
|
|
6
|
+
# Enum representing the charge status for scans with a given document type.
|
|
7
|
+
#
|
|
8
|
+
# Enum values:
|
|
9
|
+
# NO_CHARGE (0) - Don’t charge for scans with this document type.
|
|
10
|
+
# CHARGE (1) - Charge for scans with this document type.
|
|
11
|
+
# CHARGE_IF_REVIEWED (2) - Charge for scans with this document type if the scan has been manually reviewed.
|
|
12
|
+
#
|
|
13
|
+
# Use as: ChargeableStatus::NO_CHARGE, etc.
|
|
14
|
+
#
|
|
15
|
+
# @see https://developer.trustid.co.uk/documentation/ref/raw_ref/model/ChargeableStatus.html
|
|
16
|
+
class ChargeableStatus
|
|
17
|
+
NO_CHARGE = 0
|
|
18
|
+
CHARGE = 1
|
|
19
|
+
CHARGE_IF_REVIEWED = 2
|
|
20
|
+
|
|
21
|
+
NAMES = {
|
|
22
|
+
NO_CHARGE => 'NoCharge',
|
|
23
|
+
CHARGE => 'Charge',
|
|
24
|
+
CHARGE_IF_REVIEWED => 'ChargeIfReviewed'
|
|
25
|
+
}.freeze
|
|
26
|
+
|
|
27
|
+
def self.name_for(code)
|
|
28
|
+
NAMES[code]
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'active_model'
|
|
4
|
+
require_relative '../concerns/attribute_resolution'
|
|
5
|
+
|
|
6
|
+
module TrustID
|
|
7
|
+
# Configuration
|
|
8
|
+
#
|
|
9
|
+
# Represents a set of configuration key/value pairs from the TrustID API.
|
|
10
|
+
#
|
|
11
|
+
# Fields:
|
|
12
|
+
# config_map - Hash: Internal map of configuration keys to values (as returned by the API).
|
|
13
|
+
#
|
|
14
|
+
# Example API response:
|
|
15
|
+
# "Configuration": [
|
|
16
|
+
# { "Key": "support.pagination", "Value": "False" },
|
|
17
|
+
# ...
|
|
18
|
+
# ]
|
|
19
|
+
#
|
|
20
|
+
# Provides boolean and integer accessors for common configuration keys, and generic access via [].
|
|
21
|
+
#
|
|
22
|
+
# @see https://developer.trustid.co.uk/documentation/ref/raw_ref/model/Configuration.html
|
|
23
|
+
class Configuration < BaseModel
|
|
24
|
+
attr_reader :config_map
|
|
25
|
+
|
|
26
|
+
def initialize(config_array)
|
|
27
|
+
@config_map = Array(config_array).each_with_object({}) do |item, map|
|
|
28
|
+
map[item['Key'] || item[:Key]] = item['Value'] || item[:Value]
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Accessors for common configuration keys (see API docs)
|
|
33
|
+
def support_pagination?
|
|
34
|
+
config_bool('support.pagination')
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def ui_photo_matches_required_enabled?
|
|
38
|
+
config_bool('ui.photomatchesrequired.enabled')
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def ui_person_not_seen_required_enabled?
|
|
42
|
+
config_bool('ui.personnotseenrequired.enabled')
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def ui_multiple_documents_per_application_disabled?
|
|
46
|
+
config_bool('ui.multiple_documents_per_application.disabled')
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def ui_driving_licence_side2_mandatory_enabled?
|
|
50
|
+
config_bool('ui.drivinglicenceside2.mandatory.enabled')
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def ui_id_card_side2_mandatory_enabled?
|
|
54
|
+
config_bool('ui.idcardside2.mandatory.enabled')
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def service_system_type
|
|
58
|
+
config_int('servicesystemtype')
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# Generic access
|
|
62
|
+
def [](key)
|
|
63
|
+
@config_map[key]
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
private
|
|
67
|
+
|
|
68
|
+
def config_bool(key)
|
|
69
|
+
@config_map[key].to_s.downcase == 'true'
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def config_int(key)
|
|
73
|
+
Integer(@config_map[key])
|
|
74
|
+
rescue StandardError
|
|
75
|
+
nil
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'access_lock'
|
|
4
|
+
require_relative 'application_flexible_field_list'
|
|
5
|
+
require_relative 'branch'
|
|
6
|
+
require_relative 'dbs_check_initiation'
|
|
7
|
+
require_relative 'document'
|
|
8
|
+
require_relative 'document_container_field'
|
|
9
|
+
require_relative 'document_container_validation'
|
|
10
|
+
require_relative 'document_container_validation_outcome'
|
|
11
|
+
require_relative 'document_source'
|
|
12
|
+
require_relative 'document_storage_type'
|
|
13
|
+
require_relative 'image'
|
|
14
|
+
require_relative 'liveness_result_type'
|
|
15
|
+
require_relative 'overall_status'
|
|
16
|
+
require_relative 'referral_history_record'
|
|
17
|
+
require_relative 'referral_type'
|
|
18
|
+
require_relative 'review_application_state'
|
|
19
|
+
require_relative 'user_reference'
|
|
20
|
+
require_relative 'workflow_type'
|
|
21
|
+
require_relative 'base_model'
|
|
22
|
+
|
|
23
|
+
module TrustID
|
|
24
|
+
# Container
|
|
25
|
+
#
|
|
26
|
+
# Represents a document container within the TrustID system, holding documents and related metadata.
|
|
27
|
+
# The model uses HasNestedModels to handle nested data structures with proper type conversion.
|
|
28
|
+
#
|
|
29
|
+
# @see https://developer.trustid.co.uk/documentation/ref/raw_ref/model/Container.html
|
|
30
|
+
class Container < BaseModel
|
|
31
|
+
include HasNestedModels
|
|
32
|
+
|
|
33
|
+
# Define nested models with their key variants (now inferred automatically)
|
|
34
|
+
nested_model :documents, Document, array: true
|
|
35
|
+
|
|
36
|
+
nested_model :applicant_photo_image, Image
|
|
37
|
+
|
|
38
|
+
nested_model :document_container_field_list, DocumentContainerField, array: true
|
|
39
|
+
|
|
40
|
+
nested_model :referred_from, UserReference
|
|
41
|
+
|
|
42
|
+
nested_model :dbs_check_initiation, DbsCheckInitiation
|
|
43
|
+
|
|
44
|
+
nested_model :access_lock, AccessLock
|
|
45
|
+
|
|
46
|
+
nested_model :referral_history, ReferralHistoryRecord, array: true
|
|
47
|
+
|
|
48
|
+
nested_model :application_flexible_field_list, ApplicationFlexibleFieldList, array: true
|
|
49
|
+
|
|
50
|
+
nested_model :document_container_validation_list, DocumentContainerValidation, array: true
|
|
51
|
+
|
|
52
|
+
# Define all attributes
|
|
53
|
+
attribute :access_lock
|
|
54
|
+
attribute :applicant_photo_image
|
|
55
|
+
attribute :application_flexible_field_list, array: true
|
|
56
|
+
attribute :application_read, :boolean
|
|
57
|
+
attribute :address_history, array: true
|
|
58
|
+
attribute :branch_id, :string
|
|
59
|
+
attribute :branch_name, :string
|
|
60
|
+
attribute :client_app_id, :integer
|
|
61
|
+
attribute :created_at, :datetime
|
|
62
|
+
attribute :dbs_check_initiation
|
|
63
|
+
attribute :dbs_status, :string
|
|
64
|
+
attribute :document_container_field_list, array: true
|
|
65
|
+
attribute :document_container_validation_list, array: true
|
|
66
|
+
attribute :document_source, :integer
|
|
67
|
+
attribute :document_storage_type, :integer
|
|
68
|
+
attribute :documents, array: true
|
|
69
|
+
attribute :entity_id, :string
|
|
70
|
+
attribute :fullname, :string
|
|
71
|
+
attribute :id, :string
|
|
72
|
+
attribute :is_full_check, :boolean
|
|
73
|
+
attribute :journey_id, :string
|
|
74
|
+
attribute :liveness_test_count, :integer
|
|
75
|
+
attribute :liveness_test_result, :integer
|
|
76
|
+
attribute :liveness_test_result_auto, :integer
|
|
77
|
+
attribute :organisation_id, :string
|
|
78
|
+
attribute :organisation_name, :string
|
|
79
|
+
attribute :overall_status, :integer
|
|
80
|
+
attribute :process_expiry_time_utc, :datetime
|
|
81
|
+
attribute :referral_history, array: true
|
|
82
|
+
attribute :referral_type, :integer
|
|
83
|
+
attribute :referred, :boolean
|
|
84
|
+
attribute :referred_at, :datetime
|
|
85
|
+
attribute :referred_from
|
|
86
|
+
attribute :review_application_instigating_user, :string
|
|
87
|
+
attribute :review_application_state, :integer
|
|
88
|
+
attribute :scanned_by_user, :string
|
|
89
|
+
attribute :synchronised, :boolean
|
|
90
|
+
attribute :system_id, :string
|
|
91
|
+
attribute :total_alerts, :integer
|
|
92
|
+
attribute :tta_import, :boolean
|
|
93
|
+
attribute :updated_at, :datetime
|
|
94
|
+
attribute :user_id, :string
|
|
95
|
+
attribute :vpe_device_id, :string
|
|
96
|
+
attribute :vpe_name, :string
|
|
97
|
+
attribute :vpe_type, :integer
|
|
98
|
+
attribute :workflow_type, :integer
|
|
99
|
+
|
|
100
|
+
DocumentStorageType::NAMES.each do |code, name|
|
|
101
|
+
define_method("document_storage_#{name.underscore}?") do
|
|
102
|
+
document_storage_type == code
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def document_storage_type_name
|
|
107
|
+
DocumentStorageType.name_for(document_storage_type)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
LivenessResultType::NAMES.each do |code, name|
|
|
111
|
+
define_method("liveness_result_#{name.underscore}?") do
|
|
112
|
+
liveness_test_result == code
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def liveness_test_result_name
|
|
117
|
+
LivenessResultType.name_for(liveness_test_result)
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
OverallStatus::NAMES.each do |code, name|
|
|
121
|
+
define_method("overall_status_#{name.underscore}?") do
|
|
122
|
+
overall_status == code
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def overall_status_name
|
|
127
|
+
OverallStatus.name_for(overall_status)
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
ReferralType::NAMES.each do |code, name|
|
|
131
|
+
define_method("referral_#{name.underscore}?") do
|
|
132
|
+
referral_type == code
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def referral_type_name
|
|
137
|
+
ReferralType.name_for(referral_type)
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
WorkflowType::NAMES.each do |code, name|
|
|
141
|
+
define_method("workflow_#{name.underscore}?") do
|
|
142
|
+
workflow_type == code
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
def workflow_type_name
|
|
147
|
+
WorkflowType.name_for(workflow_type)
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def overall_status_ok?
|
|
151
|
+
overall_status_no_alert? || overall_status_resolved?
|
|
152
|
+
end
|
|
153
|
+
alias ok? overall_status_ok?
|
|
154
|
+
|
|
155
|
+
def self.find(container_id)
|
|
156
|
+
TrustID::Services::Containers.retrieve(container_id: container_id)
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
# Convenience methods for easier access to container data
|
|
160
|
+
|
|
161
|
+
# Get the first document (most common use case)
|
|
162
|
+
#
|
|
163
|
+
# @return [Document, nil] The first document if available, nil otherwise
|
|
164
|
+
def first_document
|
|
165
|
+
documents&.first
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
# Find a document by document ID
|
|
169
|
+
#
|
|
170
|
+
# @param document_id [String] The document ID to find
|
|
171
|
+
# @return [Document, nil] The document if found, nil otherwise
|
|
172
|
+
def document_by_id(document_id)
|
|
173
|
+
return nil unless documents.is_a?(Array)
|
|
174
|
+
|
|
175
|
+
documents.find { |doc| doc.document_id == document_id.to_s }
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
# Find documents by document type
|
|
179
|
+
#
|
|
180
|
+
# @param document_type [Integer] The document type code
|
|
181
|
+
# @return [Array<Document>] Array of documents of the specified type
|
|
182
|
+
def documents_by_type(document_type)
|
|
183
|
+
return [] unless documents.is_a?(Array)
|
|
184
|
+
|
|
185
|
+
documents.select { |doc| doc.document_type == document_type }
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
# Find a container validation by name (case-insensitive)
|
|
189
|
+
#
|
|
190
|
+
# @param validation_name [String] The name of the validation to find
|
|
191
|
+
# @return [DocumentContainerValidation, nil] The container validation if found, nil otherwise
|
|
192
|
+
def validation_by_name(validation_name)
|
|
193
|
+
return nil unless document_container_validation_list.is_a?(Array)
|
|
194
|
+
|
|
195
|
+
document_container_validation_list.find { |v| v.name&.downcase == validation_name.to_s.downcase }
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
# Get all passed container validations
|
|
199
|
+
#
|
|
200
|
+
# @return [Array<DocumentContainerValidation>] Array of passed validations
|
|
201
|
+
def passed_validations
|
|
202
|
+
return [] unless document_container_validation_list.is_a?(Array)
|
|
203
|
+
|
|
204
|
+
document_container_validation_list.select do |v|
|
|
205
|
+
v.validation_outcome == DocumentContainerValidationOutcome::PASSED
|
|
206
|
+
end
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
# Get all failed container validations (excluding passed and unknown)
|
|
210
|
+
#
|
|
211
|
+
# @return [Array<DocumentContainerValidation>] Array of failed validations
|
|
212
|
+
def failed_validations
|
|
213
|
+
return [] unless document_container_validation_list.is_a?(Array)
|
|
214
|
+
|
|
215
|
+
document_container_validation_list.reject do |v|
|
|
216
|
+
[DocumentContainerValidationOutcome::PASSED,
|
|
217
|
+
DocumentContainerValidationOutcome::UNKNOWN].include?(v.validation_outcome)
|
|
218
|
+
end
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
# Check if all container validations passed
|
|
222
|
+
#
|
|
223
|
+
# @return [Boolean] True if all validations passed, false otherwise
|
|
224
|
+
def all_validations_passed?
|
|
225
|
+
return true unless document_container_validation_list.is_a?(Array)
|
|
226
|
+
|
|
227
|
+
document_container_validation_list.all? do |v|
|
|
228
|
+
[DocumentContainerValidationOutcome::PASSED,
|
|
229
|
+
DocumentContainerValidationOutcome::UNKNOWN].include?(v.validation_outcome)
|
|
230
|
+
end
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
# Get a container field by name (case-insensitive)
|
|
234
|
+
#
|
|
235
|
+
# @param field_name [String] The name of the field to find
|
|
236
|
+
# @return [DocumentContainerField, nil] The container field if found, nil otherwise
|
|
237
|
+
def field_by_name(field_name)
|
|
238
|
+
return nil unless document_container_field_list.is_a?(Array)
|
|
239
|
+
|
|
240
|
+
document_container_field_list.find { |f| f.name&.downcase == field_name.to_s.downcase }
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
# Get the value of a container field by name
|
|
244
|
+
#
|
|
245
|
+
# @param field_name [String] The name of the field
|
|
246
|
+
# @return [String, DateTime, nil] The field value (string or date), or nil if not found
|
|
247
|
+
def field_value(field_name)
|
|
248
|
+
field = field_by_name(field_name)
|
|
249
|
+
return nil unless field
|
|
250
|
+
|
|
251
|
+
field.field_value_string || field.field_value_date
|
|
252
|
+
end
|
|
253
|
+
end
|
|
254
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module TrustID
|
|
4
|
+
# CustomField
|
|
5
|
+
#
|
|
6
|
+
# Represents a custom field attached to a document or application in TrustID.
|
|
7
|
+
#
|
|
8
|
+
# Fields:
|
|
9
|
+
# display_name - String: Label for the field.
|
|
10
|
+
# help - String: Help text for the field.
|
|
11
|
+
# index - Integer: Order/index of the field.
|
|
12
|
+
# property_name - String: Internal property name.
|
|
13
|
+
# required - Boolean: Whether the field is required.
|
|
14
|
+
# value - String: The field value.
|
|
15
|
+
# values - Array<String>: Allowed values if the field is an enum.
|
|
16
|
+
#
|
|
17
|
+
# Not all attributes may be present for every custom field; structure is flexible.
|
|
18
|
+
#
|
|
19
|
+
# @see https://developer.trustid.co.uk/documentation/ref/raw_ref/model/CustomField.html
|
|
20
|
+
class CustomField < BaseModel
|
|
21
|
+
attribute :display_name, :string
|
|
22
|
+
attribute :help, :string
|
|
23
|
+
attribute :index, :integer
|
|
24
|
+
attribute :property_name, :string
|
|
25
|
+
attribute :required, :boolean
|
|
26
|
+
attribute :value, :string
|
|
27
|
+
attribute :values, default: []
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module TrustID
|
|
4
|
+
# DbsCheckInitiation
|
|
5
|
+
#
|
|
6
|
+
# Represents the DBS (Disclosure and Barring Service) check initiation details.
|
|
7
|
+
#
|
|
8
|
+
# Fields:
|
|
9
|
+
# state - Integer: The state of the DBS check initiation.
|
|
10
|
+
#
|
|
11
|
+
class DbsCheckInitiation < BaseModel
|
|
12
|
+
attribute :state, :integer
|
|
13
|
+
end
|
|
14
|
+
end
|