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,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module TrustID
|
|
4
|
+
# FilterDateOption
|
|
5
|
+
#
|
|
6
|
+
# Enum representing date filter options for queries (TrustID API).
|
|
7
|
+
#
|
|
8
|
+
# Enum values:
|
|
9
|
+
# NONE (0) - No date filter.
|
|
10
|
+
# BEFORE (1) - Filter for dates before the specified value.
|
|
11
|
+
# AFTER (2) - Filter for dates after the specified value.
|
|
12
|
+
# EXACT (3) - Filter for the exact date.
|
|
13
|
+
#
|
|
14
|
+
# Use as: FilterDateOption::BEFORE, etc.
|
|
15
|
+
#
|
|
16
|
+
# The model exposes a `name_for` method to resolve the code to a human-readable name.
|
|
17
|
+
#
|
|
18
|
+
# @see https://developer.trustid.co.uk/documentation/ref/raw_ref/model/FilterDateOption.html
|
|
19
|
+
class FilterDateOption < BaseModel
|
|
20
|
+
NONE = 0
|
|
21
|
+
BEFORE = 1
|
|
22
|
+
AFTER = 2
|
|
23
|
+
EXACT = 3
|
|
24
|
+
|
|
25
|
+
NAMES = {
|
|
26
|
+
NONE => 'None',
|
|
27
|
+
BEFORE => 'Before',
|
|
28
|
+
AFTER => 'After',
|
|
29
|
+
EXACT => 'Exact'
|
|
30
|
+
}.freeze
|
|
31
|
+
|
|
32
|
+
def self.name_for(code)
|
|
33
|
+
NAMES[code]
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module TrustID
|
|
4
|
+
# FlexibleFieldDataType
|
|
5
|
+
#
|
|
6
|
+
# Enum representing the data type for a flexible field (TrustID API).
|
|
7
|
+
#
|
|
8
|
+
# Enum values:
|
|
9
|
+
# INT (0) - Integer value.
|
|
10
|
+
# STRING (1) - String value.
|
|
11
|
+
# DATETIME (2) - DateTime value.
|
|
12
|
+
# DECIMAL (3) - Decimal value.
|
|
13
|
+
# ENUM (4) - Enum value.
|
|
14
|
+
#
|
|
15
|
+
# Use as: FlexibleFieldDataType::STRING, etc.
|
|
16
|
+
#
|
|
17
|
+
# The model exposes a `name_for` method to resolve the code to a human-readable name.
|
|
18
|
+
#
|
|
19
|
+
# @see https://developer.trustid.co.uk/documentation/ref/raw_ref/model/FlexibleFieldDataType.html
|
|
20
|
+
class FlexibleFieldDataType < BaseModel
|
|
21
|
+
INT = 0
|
|
22
|
+
STRING = 1
|
|
23
|
+
DATETIME = 2
|
|
24
|
+
DECIMAL = 3
|
|
25
|
+
ENUM = 4
|
|
26
|
+
|
|
27
|
+
NAMES = {
|
|
28
|
+
INT => 'Int',
|
|
29
|
+
STRING => 'String',
|
|
30
|
+
DATETIME => 'DateTime',
|
|
31
|
+
DECIMAL => 'Decimal',
|
|
32
|
+
ENUM => 'Enum'
|
|
33
|
+
}.freeze
|
|
34
|
+
|
|
35
|
+
def self.name_for(code)
|
|
36
|
+
NAMES[code]
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module TrustID
|
|
4
|
+
# FlexibleFieldSearchSpecification
|
|
5
|
+
#
|
|
6
|
+
# Represents search criteria for flexible fields in container searches.
|
|
7
|
+
#
|
|
8
|
+
# Fields:
|
|
9
|
+
# flexible_field_id - String: Identifier for the flexible field to search against (or use
|
|
10
|
+
# flexible_field_name).
|
|
11
|
+
# flexible_field_name - String: Internal name for the flexible field (exact match, unless
|
|
12
|
+
# flexible_field_id is provided).
|
|
13
|
+
# __type - String: Type of search criteria (e.g. FlexibleFieldSearchStringValues,
|
|
14
|
+
# FlexibleFieldSearchEnumValues, etc).
|
|
15
|
+
# string_exact_match_list - Array<String>: Find containers whose field value exactly matches one of
|
|
16
|
+
# these (OR logic).
|
|
17
|
+
# string_partial_match_list - Array<String>: Find containers whose field value contains any of these
|
|
18
|
+
# substrings (OR logic).
|
|
19
|
+
# enum_exact_match_list - Array<String>: Find containers whose field value exactly matches one of
|
|
20
|
+
# these enum values (OR logic).
|
|
21
|
+
# int_exact_match_list - Array<Integer>: Find containers whose field value exactly matches one of
|
|
22
|
+
# these integers (OR logic).
|
|
23
|
+
# int_range_list - Array<[Integer, Integer]>: Each tuple defines a range of integers to match
|
|
24
|
+
# (inclusive, OR logic).
|
|
25
|
+
# decimal_exact_match_list - Array<Decimal>: Find containers whose field value exactly matches one of
|
|
26
|
+
# these decimals (OR logic).
|
|
27
|
+
# decimal_range_list - Array<[Decimal, Decimal]>: Each tuple defines a range of decimals to match
|
|
28
|
+
# (inclusive, OR logic).
|
|
29
|
+
# date_exact_match_list - Array<Date/DateTime>: Find containers whose field value exactly matches one
|
|
30
|
+
# of these dates (OR logic).
|
|
31
|
+
# date_range_list - Array<[Date/DateTime, Date/DateTime]>: Each tuple defines a range of dates
|
|
32
|
+
# to match (inclusive, OR logic).
|
|
33
|
+
#
|
|
34
|
+
# @see https://developer.trustid.co.uk/documentation/ref/raw_ref/model/FlexibleFieldSearchSpecification.html
|
|
35
|
+
class FlexibleFieldSearchSpecification < BaseModel
|
|
36
|
+
# Define all attributes
|
|
37
|
+
attribute :flexible_field_id, :string
|
|
38
|
+
attribute :flexible_field_name, :string
|
|
39
|
+
attribute :__type, :string
|
|
40
|
+
attribute :string_exact_match_list, default: []
|
|
41
|
+
attribute :string_partial_match_list, default: []
|
|
42
|
+
attribute :enum_exact_match_list, default: []
|
|
43
|
+
attribute :int_exact_match_list, default: []
|
|
44
|
+
attribute :int_range_list, default: []
|
|
45
|
+
attribute :decimal_exact_match_list, default: []
|
|
46
|
+
attribute :decimal_range_list, default: []
|
|
47
|
+
attribute :date_exact_match_list, default: []
|
|
48
|
+
attribute :date_range_list, default: []
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module TrustID
|
|
4
|
+
# FlexibleFieldSpecificationSearchOperator
|
|
5
|
+
#
|
|
6
|
+
# Enum representing how flexible-field search-specification records are to be combined (TrustID API).
|
|
7
|
+
#
|
|
8
|
+
# Enum values:
|
|
9
|
+
# OR - Combine search criteria so that not all criteria must match (logical OR).
|
|
10
|
+
# AND - Combine search criteria so that all criteria must match (logical AND).
|
|
11
|
+
#
|
|
12
|
+
# Use as: FlexibleFieldSpecificationSearchOperator::OR, etc.
|
|
13
|
+
#
|
|
14
|
+
# The model exposes a `name_for` method to resolve the code to a human-readable name.
|
|
15
|
+
#
|
|
16
|
+
# @see https://developer.trustid.co.uk/documentation/ref/raw_ref/model/FlexibleFieldSpecificationSearchOperator.html
|
|
17
|
+
class FlexibleFieldSpecificationSearchOperator
|
|
18
|
+
OR = 'OR'
|
|
19
|
+
AND = 'AND'
|
|
20
|
+
|
|
21
|
+
NAMES = {
|
|
22
|
+
OR => 'OR',
|
|
23
|
+
AND => 'AND'
|
|
24
|
+
}.freeze
|
|
25
|
+
|
|
26
|
+
def self.name_for(code)
|
|
27
|
+
NAMES[code]
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module TrustID
|
|
4
|
+
# Enum values (from TrustID API):
|
|
5
|
+
# 0 - Male
|
|
6
|
+
# 1 - Female
|
|
7
|
+
# 2 - Transgender
|
|
8
|
+
# 3 - Unspecified
|
|
9
|
+
# 4 - Unknown
|
|
10
|
+
#
|
|
11
|
+
# @see https://developer.trustid.co.uk/documentation/ref/raw_ref/model/Gender.html
|
|
12
|
+
class Gender
|
|
13
|
+
MALE = 0
|
|
14
|
+
FEMALE = 1
|
|
15
|
+
TRANSGENDER = 2
|
|
16
|
+
UNSPECIFIED = 3
|
|
17
|
+
UNKNOWN = 4
|
|
18
|
+
|
|
19
|
+
NAMES = {
|
|
20
|
+
MALE => 'Male',
|
|
21
|
+
FEMALE => 'Female',
|
|
22
|
+
TRANSGENDER => 'Transgender',
|
|
23
|
+
UNSPECIFIED => 'Unspecified',
|
|
24
|
+
UNKNOWN => 'Unknown'
|
|
25
|
+
}.freeze
|
|
26
|
+
|
|
27
|
+
def self.name_for(code)
|
|
28
|
+
NAMES[code]
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module TrustID
|
|
4
|
+
class GuestLinkResponse < BaseModel
|
|
5
|
+
# Represents the response from creating a guest link.
|
|
6
|
+
#
|
|
7
|
+
# ## Fields
|
|
8
|
+
# - `access_denied [Boolean]`: Indicates if access was denied.
|
|
9
|
+
# - `callback_id [String, nil]`: ID of the callback, if any.
|
|
10
|
+
# - `locked [Boolean]`: Indicates if the guest link is locked.
|
|
11
|
+
# - `message [String]`: Message about the operation.
|
|
12
|
+
# - `mfa_code_required [Boolean]`: Indicates if MFA code is required.
|
|
13
|
+
# - `new_password_required [Boolean]`: Indicates if a new password is required.
|
|
14
|
+
# - `session_expired [Boolean]`: Indicates if the session has expired.
|
|
15
|
+
# - `success [Boolean]`: Indicates if the operation was successful.
|
|
16
|
+
# - `vpe_unreachable [Boolean]`: Indicates if the VPE service is unreachable.
|
|
17
|
+
# - `csv_rows_imported_count [Integer]`: Number of CSV rows successfully imported.
|
|
18
|
+
# - `csv_rows_not_imported_count [Integer]`: Number of CSV rows not imported.
|
|
19
|
+
# - `error_list [Array]`: List of errors, if any.
|
|
20
|
+
# - `error_messages [Array]`: List of error messages, if any.
|
|
21
|
+
# - `container_id [String]`: ID of the container created.
|
|
22
|
+
|
|
23
|
+
attribute :access_denied, :boolean
|
|
24
|
+
attribute :callback_id, :string
|
|
25
|
+
attribute :locked, :boolean
|
|
26
|
+
attribute :message, :string
|
|
27
|
+
attribute :mfa_code_required, :boolean
|
|
28
|
+
attribute :new_password_required, :boolean
|
|
29
|
+
attribute :session_expired, :boolean
|
|
30
|
+
attribute :success, :boolean
|
|
31
|
+
attribute :vpe_unreachable, :boolean
|
|
32
|
+
attribute :csv_rows_imported_count, :integer
|
|
33
|
+
attribute :csv_rows_not_imported_count, :integer
|
|
34
|
+
attribute :error_list, array: true
|
|
35
|
+
attribute :error_messages, array: true
|
|
36
|
+
attribute :container_id, :string
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'mini_magick'
|
|
4
|
+
require_relative 'image_type'
|
|
5
|
+
|
|
6
|
+
module TrustID
|
|
7
|
+
class Image < BaseModel
|
|
8
|
+
# Represents meta data for a document image in TrustID Cloud.
|
|
9
|
+
#
|
|
10
|
+
# @see https://developer.trustid.co.uk/documentation/ref/raw_ref/model/Image.html
|
|
11
|
+
#
|
|
12
|
+
# @!attribute [rw] id
|
|
13
|
+
# @return [String] The unique identifier of this image record.
|
|
14
|
+
# @!attribute [rw] document_id
|
|
15
|
+
# @return [String] The unique identifier of the document this image belongs to.
|
|
16
|
+
# @!attribute [rw] container_id
|
|
17
|
+
# @return [String] The unique identifier of the container this image belongs to.
|
|
18
|
+
# @!attribute [rw] image_source_id
|
|
19
|
+
# @return [String, nil] If this is a cropped image, the unique identifier of the original image record
|
|
20
|
+
# this cropped image is based on.
|
|
21
|
+
# @!attribute [rw] image_type
|
|
22
|
+
# @return [Integer] The type of image (see ImageType enum).
|
|
23
|
+
# @!attribute [rw] crop_area
|
|
24
|
+
# @return [Hash, nil] The crop region in image space (pixels) after rotation, if applicable.
|
|
25
|
+
# @!attribute [rw] rotation
|
|
26
|
+
# @return [Integer, nil] The rotation in degrees (only 90-degree intervals supported), if applicable.
|
|
27
|
+
# @!attribute [rw] filename
|
|
28
|
+
# @return [String, nil] The original name of the uploaded file, if available.
|
|
29
|
+
# @!attribute [rw] file_type
|
|
30
|
+
# @return [Integer] The type of file.
|
|
31
|
+
# @!attribute [rw] created_at
|
|
32
|
+
# @return [String, nil] The timestamp when this image record was created.
|
|
33
|
+
# @!attribute [rw] current_height
|
|
34
|
+
# @return [Integer] The current height of the image in pixels.
|
|
35
|
+
# @!attribute [rw] current_width
|
|
36
|
+
# @return [Integer] The current width of the image in pixels.
|
|
37
|
+
# @!attribute [rw] current_size
|
|
38
|
+
# @return [Integer] The current size of the image in bytes.
|
|
39
|
+
# @!attribute [rw] original_height
|
|
40
|
+
# @return [Integer] The original height of the image in pixels.
|
|
41
|
+
# @!attribute [rw] original_width
|
|
42
|
+
# @return [Integer] The original width of the image in pixels.
|
|
43
|
+
# @!attribute [rw] original_size
|
|
44
|
+
# @return [Integer] The original size of the image in bytes.
|
|
45
|
+
# @!attribute [rw] time_taken_to_process
|
|
46
|
+
# @return [Integer] The time taken to process the image in milliseconds.
|
|
47
|
+
# @!attribute [rw] time_taken_to_upload
|
|
48
|
+
# @return [Integer] The time taken to upload the image in milliseconds.
|
|
49
|
+
# @!attribute [rw] data
|
|
50
|
+
# @return [String, nil] The binary data of the image.
|
|
51
|
+
# @!attribute [rw] format
|
|
52
|
+
# @return [String, nil] The format of the image (e.g., 'jpg', 'png').
|
|
53
|
+
attribute :id, :string
|
|
54
|
+
attribute :document_id, :string
|
|
55
|
+
attribute :container_id, :string
|
|
56
|
+
attribute :image_source_id, :string
|
|
57
|
+
attribute :image_type, :integer
|
|
58
|
+
attribute :crop_area
|
|
59
|
+
attribute :rotation, :integer
|
|
60
|
+
attribute :filename, :string
|
|
61
|
+
attribute :file_type, :integer
|
|
62
|
+
attribute :created_at, :string
|
|
63
|
+
attribute :current_height, :integer
|
|
64
|
+
attribute :current_width, :integer
|
|
65
|
+
attribute :current_size, :integer
|
|
66
|
+
attribute :original_height, :integer
|
|
67
|
+
attribute :original_width, :integer
|
|
68
|
+
attribute :original_size, :integer
|
|
69
|
+
attribute :time_taken_to_process, :integer
|
|
70
|
+
attribute :time_taken_to_upload, :integer
|
|
71
|
+
attribute :data, :string
|
|
72
|
+
attribute :format, :string
|
|
73
|
+
|
|
74
|
+
# Helper to get image type name
|
|
75
|
+
#
|
|
76
|
+
# @return [String, nil] The image type name, or nil if not found
|
|
77
|
+
def image_type_name
|
|
78
|
+
ImageType.name_for(image_type)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Initializes an Image object from binary data.
|
|
82
|
+
#
|
|
83
|
+
# @param binary_data [String] The binary data of the image.
|
|
84
|
+
# @return [TrustID::Image] The initialized Image object with inferred format.
|
|
85
|
+
def self.from_binary(binary_data)
|
|
86
|
+
format = infer_format(binary_data)
|
|
87
|
+
new(data: binary_data, format: format)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# Infers the format of the image from binary data.
|
|
91
|
+
#
|
|
92
|
+
# @param binary_data [String] The binary data of the image.
|
|
93
|
+
# @return [String, nil] The inferred format of the image (e.g., 'jpg', 'png').
|
|
94
|
+
def self.infer_format(binary_data)
|
|
95
|
+
image = MiniMagick::Image.read(binary_data)
|
|
96
|
+
image.type.downcase
|
|
97
|
+
rescue StandardError
|
|
98
|
+
nil
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module TrustID
|
|
4
|
+
class ImageOrientation < BaseModel
|
|
5
|
+
# Represents the orientation of the image as detected by TrustID Cloud.
|
|
6
|
+
#
|
|
7
|
+
# This model provides constants representing possible orientations of an image
|
|
8
|
+
# and a utility method to retrieve the symbolic name for a given orientation value.
|
|
9
|
+
#
|
|
10
|
+
# ## Enum Values
|
|
11
|
+
# - `UNKNOWN_ROTATION (-1)`: The rotation is unknown or not detected.
|
|
12
|
+
# - `NO_ROTATION (0)`: The document is in the correct orientation.
|
|
13
|
+
# - `CLOCKWISE (1)`: Rotated clockwise by 90 degrees.
|
|
14
|
+
# - `COUNTERCLOCKWISE (2)`: Rotated counter-clockwise by 90 degrees.
|
|
15
|
+
# - `UPSIDEDOWN (3)`: Upside down (180 degrees).
|
|
16
|
+
#
|
|
17
|
+
# ## Usage Notes
|
|
18
|
+
# Use the `name_for` method to retrieve the symbolic name for a given orientation value.
|
|
19
|
+
#
|
|
20
|
+
# ## References
|
|
21
|
+
# [TrustID API Documentation - ImageOrientation](https://developer.trustid.co.uk/documentation/ref/raw_ref/model/ImageOrientation.html)
|
|
22
|
+
#
|
|
23
|
+
# Enum values:
|
|
24
|
+
# UNKNOWN_ROTATION (-1): The rotation is unknown or not detected.
|
|
25
|
+
# NO_ROTATION (0): The document is in the correct orientation.
|
|
26
|
+
# CLOCKWISE (1): Rotated clockwise by 90 degrees.
|
|
27
|
+
# COUNTERCLOCKWISE (2): Rotated counter-clockwise by 90 degrees.
|
|
28
|
+
# UPSIDEDOWN (3): Upside down (180 degrees).
|
|
29
|
+
#
|
|
30
|
+
UNKNOWN_ROTATION = -1
|
|
31
|
+
NO_ROTATION = 0
|
|
32
|
+
CLOCKWISE = 1
|
|
33
|
+
COUNTERCLOCKWISE = 2
|
|
34
|
+
UPSIDEDOWN = 3
|
|
35
|
+
|
|
36
|
+
# Mapping of enum values to their symbolic names
|
|
37
|
+
NAMES = {
|
|
38
|
+
UNKNOWN_ROTATION => 'UnknownRotation',
|
|
39
|
+
NO_ROTATION => 'NoRotation',
|
|
40
|
+
CLOCKWISE => 'Clockwise',
|
|
41
|
+
COUNTERCLOCKWISE => 'Counterclockwise',
|
|
42
|
+
UPSIDEDOWN => 'Upsidedown'
|
|
43
|
+
}.freeze
|
|
44
|
+
|
|
45
|
+
# Returns the symbolic name for a given value
|
|
46
|
+
# @param value [Integer] the orientation value
|
|
47
|
+
# @return [String, nil] the symbolic name or nil if not found
|
|
48
|
+
def self.name_for(value)
|
|
49
|
+
NAMES[value]
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module TrustID
|
|
4
|
+
class ImageType < BaseModel
|
|
5
|
+
# Represents the type of a document image as defined by TrustID Cloud.
|
|
6
|
+
#
|
|
7
|
+
# @see https://developer.trustid.co.uk/documentation/ref/raw_ref/model/ImageType.html
|
|
8
|
+
#
|
|
9
|
+
# Enum values:
|
|
10
|
+
# FACE (1): Image of the face of the document holder.
|
|
11
|
+
# DOCUMENT (2): Image of the entire document under white light.
|
|
12
|
+
# INFRARED (3): Image of the entire document under infrared light.
|
|
13
|
+
# ULTRAVIOLET (4): Image of the entire document under ultraviolet light.
|
|
14
|
+
# RFID (5): Image of the face of the document holder as stored on the RFID chip.
|
|
15
|
+
# BARCODE (6): Image of the barcode area on the document.
|
|
16
|
+
# MRZ (7): Image of the machine-readable zone (MRZ) or code line under ultraviolet light.
|
|
17
|
+
# FINGERPRINT (8): Image of the fingerprint(s) as stored on the RFID chip.
|
|
18
|
+
# DETECTED_FACE (9): Detected image of the face of the document holder.
|
|
19
|
+
# OCR (21): Image version prepared for OCR.
|
|
20
|
+
# DOCUMENT_BACK (52): Image of the entire document (backside, Non-MRZ) under white light.
|
|
21
|
+
# INFRARED_BACK (53): Image of the entire document (backside, Non-MRZ) under infrared light.
|
|
22
|
+
# ULTRAVIOLET_BACK (54): Image of the entire document (backside, Non-MRZ) under ultraviolet light.
|
|
23
|
+
# ORIGINAL_DOCUMENT (60): The original full document image as obtained or uploaded.
|
|
24
|
+
# ORIGINAL_DOCUMENT_BACK (62): The original full rear document image as obtained or uploaded.
|
|
25
|
+
# DOCUMENT_SIDE3 (72): Image of the entire document (side 3) under white light.
|
|
26
|
+
# INFRARED_SIDE3 (73): Image of the entire document (side 3) under infrared light.
|
|
27
|
+
# ULTRAVIOLET_SIDE3 (74): Image of the entire document (side 3) under ultraviolet light.
|
|
28
|
+
# DOCUMENT_SIDE4 (82): Image of the entire document (side 4) under white light.
|
|
29
|
+
# INFRARED_SIDE4 (83): Image of the entire document (side 4) under infrared light.
|
|
30
|
+
# ULTRAVIOLET_SIDE4 (84): Image of the entire document (side 4) under ultraviolet light.
|
|
31
|
+
# UNKNOWN (999): The image type is unknown or undefined.
|
|
32
|
+
#
|
|
33
|
+
FACE = 1
|
|
34
|
+
DOCUMENT = 2
|
|
35
|
+
INFRARED = 3
|
|
36
|
+
ULTRAVIOLET = 4
|
|
37
|
+
RFID = 5
|
|
38
|
+
BARCODE = 6
|
|
39
|
+
MRZ = 7
|
|
40
|
+
FINGERPRINT = 8
|
|
41
|
+
DETECTED_FACE = 9
|
|
42
|
+
OCR = 21
|
|
43
|
+
DOCUMENT_BACK = 52
|
|
44
|
+
INFRARED_BACK = 53
|
|
45
|
+
ULTRAVIOLET_BACK = 54
|
|
46
|
+
ORIGINAL_DOCUMENT = 60
|
|
47
|
+
ORIGINAL_DOCUMENT_BACK = 62
|
|
48
|
+
DOCUMENT_SIDE3 = 72
|
|
49
|
+
INFRARED_SIDE3 = 73
|
|
50
|
+
ULTRAVIOLET_SIDE3 = 74
|
|
51
|
+
DOCUMENT_SIDE4 = 82
|
|
52
|
+
INFRARED_SIDE4 = 83
|
|
53
|
+
ULTRAVIOLET_SIDE4 = 84
|
|
54
|
+
UNKNOWN = 999
|
|
55
|
+
|
|
56
|
+
# Mapping of enum values to their symbolic names
|
|
57
|
+
NAMES = {
|
|
58
|
+
FACE => 'Face',
|
|
59
|
+
DOCUMENT => 'Document',
|
|
60
|
+
INFRARED => 'Infrared',
|
|
61
|
+
ULTRAVIOLET => 'Ultraviolet',
|
|
62
|
+
RFID => 'RFID',
|
|
63
|
+
BARCODE => 'Barcode',
|
|
64
|
+
MRZ => 'MRZ',
|
|
65
|
+
FINGERPRINT => 'Fingerprint',
|
|
66
|
+
DETECTED_FACE => 'DetectedFace',
|
|
67
|
+
OCR => 'OCR',
|
|
68
|
+
DOCUMENT_BACK => 'DocumentBack',
|
|
69
|
+
INFRARED_BACK => 'InfraredBack',
|
|
70
|
+
ULTRAVIOLET_BACK => 'UltravioletBack',
|
|
71
|
+
ORIGINAL_DOCUMENT => 'OriginalDocument',
|
|
72
|
+
ORIGINAL_DOCUMENT_BACK => 'OriginalDocumentBack',
|
|
73
|
+
DOCUMENT_SIDE3 => 'DocumentSide3',
|
|
74
|
+
INFRARED_SIDE3 => 'InfraredSide3',
|
|
75
|
+
ULTRAVIOLET_SIDE3 => 'UltravioletSide3',
|
|
76
|
+
DOCUMENT_SIDE4 => 'DocumentSide4',
|
|
77
|
+
INFRARED_SIDE4 => 'InfraredSide4',
|
|
78
|
+
ULTRAVIOLET_SIDE4 => 'UltravioletSide4',
|
|
79
|
+
UNKNOWN => 'Unknown'
|
|
80
|
+
}.freeze
|
|
81
|
+
|
|
82
|
+
# Returns the symbolic name for a given value
|
|
83
|
+
# @param value [Integer] the image type value
|
|
84
|
+
# @return [String, nil] the symbolic name or nil if not found
|
|
85
|
+
def self.name_for(value)
|
|
86
|
+
NAMES[value]
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module TrustID
|
|
4
|
+
class KDBCountry < BaseModel
|
|
5
|
+
# Represents an issuing country or nationality of the issuing country.
|
|
6
|
+
#
|
|
7
|
+
# @see https://developer.trustid.co.uk/documentation/ref/raw_ref/model/KDBCountry.html
|
|
8
|
+
#
|
|
9
|
+
# @!attribute [rw] name
|
|
10
|
+
# @return [String] Full name of the country.
|
|
11
|
+
# @!attribute [rw] nationality
|
|
12
|
+
# @return [String] The term for referencing the nationality of the country.
|
|
13
|
+
# @!attribute [rw] alias1
|
|
14
|
+
# @return [String, nil] Common alias name (1).
|
|
15
|
+
# @!attribute [rw] alias2
|
|
16
|
+
# @return [String, nil] Common alias name (2).
|
|
17
|
+
# @!attribute [rw] alias3
|
|
18
|
+
# @return [String, nil] Common alias name (3).
|
|
19
|
+
# @!attribute [rw] mrz
|
|
20
|
+
# @return [String, nil] Encoding format of the country/nationality in the MRZ.
|
|
21
|
+
# @!attribute [rw] alt_mrz
|
|
22
|
+
# @return [String, nil] Alternative encoding format in the MRZ.
|
|
23
|
+
# @!attribute [rw] uk
|
|
24
|
+
# @return [Boolean, nil] True if the country is a member of the United Kingdom.
|
|
25
|
+
# @!attribute [rw] eu
|
|
26
|
+
# @return [Boolean, nil] True if the country is a member state of the European Union.
|
|
27
|
+
attribute :name, :string
|
|
28
|
+
attribute :nationality, :string
|
|
29
|
+
attribute :alias1, :string
|
|
30
|
+
attribute :alias2, :string
|
|
31
|
+
attribute :alias3, :string
|
|
32
|
+
attribute :mrz, :string
|
|
33
|
+
attribute :alt_mrz, :string
|
|
34
|
+
attribute :uk, :boolean
|
|
35
|
+
attribute :eu, :boolean
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module TrustID
|
|
4
|
+
# Represents the type of document number as defined by TrustID Cloud.
|
|
5
|
+
#
|
|
6
|
+
# Enum values (from TrustID API):
|
|
7
|
+
# 0 - PassportNumber: The primary document number for passports.
|
|
8
|
+
# 1 - VisaNumber: The primary document number for VISA documents.
|
|
9
|
+
# 2 - IdentityCardNumber: The primary document number for national id cards.
|
|
10
|
+
# 3 - DrivingLicenseNumber: The primary document number for driving licences.
|
|
11
|
+
# 4 - Default: The primary document number is simply stored as primary document number and is not
|
|
12
|
+
# available depending on the type of document.
|
|
13
|
+
#
|
|
14
|
+
# @see https://developer.trustid.co.uk/documentation/ref/raw_ref/model/KDBDocumentNumber.html
|
|
15
|
+
class KDBDocumentNumber
|
|
16
|
+
PASSPORT_NUMBER = 0
|
|
17
|
+
VISA_NUMBER = 1
|
|
18
|
+
IDENTITY_CARD_NUMBER = 2
|
|
19
|
+
DRIVING_LICENSE_NUMBER = 3
|
|
20
|
+
DEFAULT = 4
|
|
21
|
+
|
|
22
|
+
NAMES = {
|
|
23
|
+
PASSPORT_NUMBER => 'PassportNumber',
|
|
24
|
+
VISA_NUMBER => 'VisaNumber',
|
|
25
|
+
IDENTITY_CARD_NUMBER => 'IdentityCardNumber',
|
|
26
|
+
DRIVING_LICENSE_NUMBER => 'DrivingLicenseNumber',
|
|
27
|
+
DEFAULT => 'Default'
|
|
28
|
+
}.freeze
|
|
29
|
+
|
|
30
|
+
# Returns the symbolic name for a given value
|
|
31
|
+
# @param value [Integer] the document number type value
|
|
32
|
+
# @return [String, nil] the symbolic name or nil if not found
|
|
33
|
+
def self.name_for(value)
|
|
34
|
+
NAMES[value]
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module TrustID
|
|
4
|
+
class KDBDocumentSubType < BaseModel
|
|
5
|
+
# Represents a document sub-type, for example Resident Permit (Visa).
|
|
6
|
+
#
|
|
7
|
+
# Fields as per TrustID API documentation:
|
|
8
|
+
# id [String]: The unique identifier of this document sub-type.
|
|
9
|
+
# name [String]: The name of this document sub-type.
|
|
10
|
+
# mrz [String, nil]: The encoding of this document sub-type within the machine-readable zone.
|
|
11
|
+
# document_type [String, nil]: The corresponding document type of this document sub-type.
|
|
12
|
+
# rewrite_document_type [String, nil]: The document type that should be used for this document sub-type
|
|
13
|
+
# (for normalisation/correction).
|
|
14
|
+
# rewrite_document_number [Integer, nil]: The type of document number to use for this sub-type (see
|
|
15
|
+
# KDBDocumentNumber).
|
|
16
|
+
attribute :id, :string
|
|
17
|
+
attribute :name, :string
|
|
18
|
+
attribute :mrz, :string
|
|
19
|
+
attribute :document_type, :string
|
|
20
|
+
attribute :rewrite_document_type, :string
|
|
21
|
+
attribute :rewrite_document_number, :integer
|
|
22
|
+
|
|
23
|
+
# Optionally, you may want to add initialization and type validation logic here if needed.
|
|
24
|
+
# def initialize(attributes = {})
|
|
25
|
+
# ...
|
|
26
|
+
# end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module TrustID
|
|
4
|
+
# Represents the type of document feature as defined by TrustID Cloud.
|
|
5
|
+
#
|
|
6
|
+
# Enum values (from TrustID API):
|
|
7
|
+
# 0 - FULL_DOCUMENT_COMPARISON: Comparing the entire document with a sample image.
|
|
8
|
+
# 1 - HOLOGRAM: Comparing a hologram feature with a sample and instructions how to correctly check holograms.
|
|
9
|
+
# 2 - PRIMARY_FACE: The primary facial image of the document holder.
|
|
10
|
+
# 3 - PRIMARY_FACE_AND_COLOUR_VS_IR: Comparing the primary facial image under visual light vs infrared.
|
|
11
|
+
# 4 - SECONDARY_FACE: Secondary facial image of the document holder.
|
|
12
|
+
# 5 - SCANNED_VS_STOCK: Compare scanned document against a similar sample document.
|
|
13
|
+
# 6 - COLOUR_VS_IR: Compare the document under visual light against the same document under infrared.
|
|
14
|
+
# 7 - OCR: The region on the document that is captured through optical character recognition (OCR).
|
|
15
|
+
#
|
|
16
|
+
# @see https://developer.trustid.co.uk/documentation/ref/raw_ref/model/KDBFeatureType.html
|
|
17
|
+
class KDBFeatureType
|
|
18
|
+
FULL_DOCUMENT_COMPARISON = 0
|
|
19
|
+
HOLOGRAM = 1
|
|
20
|
+
PRIMARY_FACE = 2
|
|
21
|
+
PRIMARY_FACE_AND_COLOUR_VS_IR = 3
|
|
22
|
+
SECONDARY_FACE = 4
|
|
23
|
+
SCANNED_VS_STOCK = 5
|
|
24
|
+
COLOUR_VS_IR = 6
|
|
25
|
+
OCR = 7
|
|
26
|
+
|
|
27
|
+
NAMES = {
|
|
28
|
+
FULL_DOCUMENT_COMPARISON => 'FullDocumentComparison',
|
|
29
|
+
HOLOGRAM => 'Hologram',
|
|
30
|
+
PRIMARY_FACE => 'PrimaryFace',
|
|
31
|
+
PRIMARY_FACE_AND_COLOUR_VS_IR => 'PrimaryFaceAndColourVsIR',
|
|
32
|
+
SECONDARY_FACE => 'SecondaryFace',
|
|
33
|
+
SCANNED_VS_STOCK => 'ScannedVsStock',
|
|
34
|
+
COLOUR_VS_IR => 'ColourVsIR',
|
|
35
|
+
OCR => 'OCR'
|
|
36
|
+
}.freeze
|
|
37
|
+
|
|
38
|
+
# Returns the symbolic name for a given value
|
|
39
|
+
# @param value [Integer] the feature type value
|
|
40
|
+
# @return [String, nil] the symbolic name or nil if not found
|
|
41
|
+
def self.name_for(value)
|
|
42
|
+
NAMES[value]
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module TrustID
|
|
4
|
+
# Represents the result of a liveness test as detected by TrustID Cloud.
|
|
5
|
+
#
|
|
6
|
+
# This model provides constants representing possible outcomes of a liveness test
|
|
7
|
+
# and a utility method to retrieve the symbolic name for a given result code.
|
|
8
|
+
#
|
|
9
|
+
# ## Enum Values
|
|
10
|
+
# - `NOT_LIVE (0)`: The liveness test has not been performed.
|
|
11
|
+
# - `LIVE (1)`: The liveness test was successful.
|
|
12
|
+
# - `ERROR (2)`: The liveness test failed.
|
|
13
|
+
# - `POOR_IMAGE_QUALITY (3)`: The image quality is too poor to perform the test.
|
|
14
|
+
# - `FACE_TOO_CLOSE (4)`: The face is too close to the camera.
|
|
15
|
+
# - `FACE_NOT_FOUND (5)`: No face was detected in the image.
|
|
16
|
+
# - `FACE_TOO_SMALL (6)`: The face is too small to perform the test.
|
|
17
|
+
# - `FACE_ANGLE_TOO_LARGE (7)`: The face angle is too large for a valid test.
|
|
18
|
+
# - `FAILED_TO_READ_IMAGE (8)`: The image could not be read.
|
|
19
|
+
# - `UNKNOWN (9)`: The result is unknown or not recognized.
|
|
20
|
+
#
|
|
21
|
+
# ## Usage Notes
|
|
22
|
+
# Use the `name_for` method to retrieve the symbolic name for a given result code.
|
|
23
|
+
#
|
|
24
|
+
# ## References
|
|
25
|
+
# [TrustID API Documentation - LivenessResultType](https://developer.trustid.co.uk/documentation/ref/raw_ref/model/LivenessResultType.html)
|
|
26
|
+
class LivenessResultType
|
|
27
|
+
NOT_LIVE = 0
|
|
28
|
+
LIVE = 1
|
|
29
|
+
ERROR = 2
|
|
30
|
+
POOR_IMAGE_QUALITY = 3
|
|
31
|
+
FACE_TOO_CLOSE = 4
|
|
32
|
+
FACE_NOT_FOUND = 5
|
|
33
|
+
FACE_TOO_SMALL = 6
|
|
34
|
+
FACE_ANGLE_TOO_LARGE = 7
|
|
35
|
+
FAILED_TO_READ_IMAGE = 8
|
|
36
|
+
UNKNOWN = 9
|
|
37
|
+
|
|
38
|
+
NAMES = {
|
|
39
|
+
NOT_LIVE => 'NotLive',
|
|
40
|
+
LIVE => 'Live',
|
|
41
|
+
ERROR => 'Error',
|
|
42
|
+
POOR_IMAGE_QUALITY => 'PoorImageQuality',
|
|
43
|
+
FACE_TOO_CLOSE => 'FaceTooClose',
|
|
44
|
+
FACE_NOT_FOUND => 'FaceNotFound',
|
|
45
|
+
FACE_TOO_SMALL => 'FaceTooSmall',
|
|
46
|
+
FACE_ANGLE_TOO_LARGE => 'FaceAngleTooLarge',
|
|
47
|
+
FAILED_TO_READ_IMAGE => 'FailedToReadImage',
|
|
48
|
+
UNKNOWN => 'Unknown'
|
|
49
|
+
}.freeze
|
|
50
|
+
|
|
51
|
+
def self.name_for(code)
|
|
52
|
+
NAMES[code]
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|