mindee 3.4.0 → 3.5.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 (65) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +20 -0
  3. data/README.md +4 -0
  4. data/bin/mindee.rb +39 -15
  5. data/docs/bank_statement_fr_v1.md +175 -0
  6. data/docs/carte_grise_v1.md +4 -4
  7. data/docs/code_samples/bank_statement_fr_v1_async.txt +19 -0
  8. data/docs/code_samples/default.txt +19 -19
  9. data/docs/code_samples/default_async.txt +25 -0
  10. data/docs/code_samples/eu_driver_license_v1.txt +19 -0
  11. data/docs/code_samples/international_id_v1_async.txt +19 -0
  12. data/docs/code_samples/international_id_v2_async.txt +19 -0
  13. data/docs/eu_driver_license_v1.md +223 -0
  14. data/docs/financial_document_v1.md +48 -40
  15. data/docs/generated_v1.md +90 -0
  16. data/docs/invoices_v4.md +4 -1
  17. data/docs/proof_of_address_v1.md +4 -4
  18. data/docs/us_driver_license_v1.md +2 -2
  19. data/lib/mindee/client.rb +5 -3
  20. data/lib/mindee/http/endpoint.rb +13 -12
  21. data/lib/mindee/input/sources.rb +28 -5
  22. data/lib/mindee/parsing/common/inference.rb +3 -1
  23. data/lib/mindee/parsing/generated/generated_list_field.rb +58 -0
  24. data/lib/mindee/parsing/generated/generated_object_field.rb +109 -0
  25. data/lib/mindee/parsing/generated.rb +4 -0
  26. data/lib/mindee/parsing.rb +1 -0
  27. data/lib/mindee/product/barcode_reader/barcode_reader_v1.rb +3 -1
  28. data/lib/mindee/product/cropper/cropper_v1.rb +3 -1
  29. data/lib/mindee/product/eu/driver_license/driver_license_v1.rb +41 -0
  30. data/lib/mindee/product/eu/driver_license/driver_license_v1_document.rb +88 -0
  31. data/lib/mindee/product/eu/driver_license/driver_license_v1_page.rb +53 -0
  32. data/lib/mindee/product/eu/license_plate/license_plate_v1.rb +3 -1
  33. data/lib/mindee/product/financial_document/financial_document_v1.rb +3 -1
  34. data/lib/mindee/product/fr/bank_account_details/bank_account_details_v1.rb +3 -1
  35. data/lib/mindee/product/fr/bank_account_details/bank_account_details_v2.rb +3 -1
  36. data/lib/mindee/product/fr/bank_statement/bank_statement_v1.rb +41 -0
  37. data/lib/mindee/product/fr/bank_statement/bank_statement_v1_document.rb +130 -0
  38. data/lib/mindee/product/fr/bank_statement/bank_statement_v1_page.rb +34 -0
  39. data/lib/mindee/product/fr/bank_statement/bank_statement_v1_transaction.rb +64 -0
  40. data/lib/mindee/product/fr/carte_grise/carte_grise_v1.rb +3 -1
  41. data/lib/mindee/product/fr/carte_vitale/carte_vitale_v1.rb +3 -1
  42. data/lib/mindee/product/fr/id_card/id_card_v1.rb +3 -1
  43. data/lib/mindee/product/fr/id_card/id_card_v2.rb +3 -1
  44. data/lib/mindee/product/generated/generated_v1.rb +38 -0
  45. data/lib/mindee/product/generated/generated_v1_document.rb +35 -0
  46. data/lib/mindee/product/generated/generated_v1_page.rb +51 -0
  47. data/lib/mindee/product/generated/generated_v1_prediction.rb +114 -0
  48. data/lib/mindee/product/international_id/international_id_v1.rb +39 -0
  49. data/lib/mindee/product/international_id/international_id_v1_document.rb +109 -0
  50. data/lib/mindee/product/international_id/international_id_v1_page.rb +32 -0
  51. data/lib/mindee/product/international_id/international_id_v2.rb +39 -0
  52. data/lib/mindee/product/international_id/international_id_v2_document.rb +119 -0
  53. data/lib/mindee/product/international_id/international_id_v2_page.rb +32 -0
  54. data/lib/mindee/product/invoice/invoice_v4.rb +3 -1
  55. data/lib/mindee/product/multi_receipts_detector/multi_receipts_detector_v1.rb +3 -1
  56. data/lib/mindee/product/passport/passport_v1.rb +3 -1
  57. data/lib/mindee/product/proof_of_address/proof_of_address_v1.rb +3 -1
  58. data/lib/mindee/product/receipt/receipt_v5.rb +3 -1
  59. data/lib/mindee/product/us/bank_check/bank_check_v1.rb +3 -1
  60. data/lib/mindee/product/us/driver_license/driver_license_v1.rb +3 -1
  61. data/lib/mindee/product/us/w9/w9_v1.rb +3 -1
  62. data/lib/mindee/product.rb +5 -0
  63. data/lib/mindee/version.rb +1 -1
  64. data/lib/mindee.rb +4 -0
  65. metadata +30 -2
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../parsing'
4
+
5
+ module Mindee
6
+ module Product
7
+ module FR
8
+ module BankStatement
9
+ # The list of values that represent the financial transactions recorded in a bank statement.
10
+ class BankStatementV1Transaction < Mindee::Parsing::Standard::FeatureField
11
+ include Mindee::Parsing::Standard
12
+ # The monetary amount of the transaction.
13
+ # @return [Float]
14
+ attr_reader :amount
15
+ # The date on which the transaction occurred.
16
+ # @return [String]
17
+ attr_reader :date
18
+ # The additional information about the transaction.
19
+ # @return [String]
20
+ attr_reader :description
21
+
22
+ # @param prediction [Hash]
23
+ # @param page_id [Integer, nil]
24
+ def initialize(prediction, page_id)
25
+ super(prediction, page_id)
26
+ @amount = prediction['amount']
27
+ @date = prediction['date']
28
+ @description = prediction['description']
29
+ @page_id = page_id
30
+ end
31
+
32
+ # @return [Hash]
33
+ def printable_values
34
+ printable = {}
35
+ printable[:amount] = @amount.nil? ? '' : Field.float_to_string(@amount)
36
+ printable[:date] = format_for_display(@date, nil)
37
+ printable[:description] = format_for_display(@description, 36)
38
+ printable
39
+ end
40
+
41
+ # @return [String]
42
+ def to_table_line
43
+ printable = printable_values
44
+ out_str = String.new
45
+ out_str << format('| %- 10s', printable[:amount])
46
+ out_str << format('| %- 11s', printable[:date])
47
+ out_str << format('| %- 37s', printable[:description])
48
+ out_str << '|'
49
+ end
50
+
51
+ # @return [String]
52
+ def to_s
53
+ printable = printable_values
54
+ out_str = String.new
55
+ out_str << "\n :Amount: #{printable[:amount]}"
56
+ out_str << "\n :Date: #{printable[:date]}"
57
+ out_str << "\n :Description: #{printable[:description]}"
58
+ out_str
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -20,7 +20,9 @@ module Mindee
20
20
  @prediction = CarteGriseV1Document.new(prediction['prediction'], nil)
21
21
  @pages = []
22
22
  prediction['pages'].each do |page|
23
- @pages.push(CarteGriseV1Page.new(page))
23
+ if page.key?('prediction') && !page['prediction'].nil? && !page['prediction'].empty?
24
+ @pages.push(CarteGriseV1Page.new(page))
25
+ end
24
26
  end
25
27
  end
26
28
 
@@ -20,7 +20,9 @@ module Mindee
20
20
  @prediction = CarteVitaleV1Document.new(prediction['prediction'], nil)
21
21
  @pages = []
22
22
  prediction['pages'].each do |page|
23
- @pages.push(CarteVitaleV1Page.new(page))
23
+ if page.key?('prediction') && !page['prediction'].nil? && !page['prediction'].empty?
24
+ @pages.push(CarteVitaleV1Page.new(page))
25
+ end
24
26
  end
25
27
  end
26
28
 
@@ -20,7 +20,9 @@ module Mindee
20
20
  @prediction = IdCardV1Document.new(prediction['prediction'], nil)
21
21
  @pages = []
22
22
  prediction['pages'].each do |page|
23
- @pages.push(IdCardV1Page.new(page))
23
+ if page.key?('prediction') && !page['prediction'].nil? && !page['prediction'].empty?
24
+ @pages.push(IdCardV1Page.new(page))
25
+ end
24
26
  end
25
27
  end
26
28
 
@@ -20,7 +20,9 @@ module Mindee
20
20
  @prediction = IdCardV2Document.new(prediction['prediction'], nil)
21
21
  @pages = []
22
22
  prediction['pages'].each do |page|
23
- @pages.push(IdCardV2Page.new(page))
23
+ if page.key?('prediction') && !page['prediction'].nil? && !page['prediction'].empty?
24
+ @pages.push(IdCardV2Page.new(page))
25
+ end
24
26
  end
25
27
  end
26
28
 
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'generated_v1_document'
4
+ require_relative 'generated_v1_page'
5
+
6
+ module Mindee
7
+ module Product
8
+ # Generated product module.
9
+ module Generated
10
+ # Generated Document V1 prediction inference.
11
+ class GeneratedV1 < Mindee::Parsing::Common::Inference
12
+ @endpoint_name = ''
13
+ @endpoint_version = ''
14
+
15
+ # @param prediction [Hash]
16
+ def initialize(prediction)
17
+ super
18
+ @prediction = GeneratedV1Document.new(prediction['prediction'])
19
+ @pages = []
20
+ prediction['pages'].each do |page|
21
+ if page.key?('prediction') && !page['prediction'].nil? && !page['prediction'].empty?
22
+ @pages.push(GeneratedV1Page.new(page))
23
+ end
24
+ end
25
+ end
26
+
27
+ class << self
28
+ # Name of the endpoint for this product.
29
+ # @return [String]
30
+ attr_reader :endpoint_name
31
+ # Version for this product.
32
+ # @return [String]
33
+ attr_reader :endpoint_version
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../parsing'
4
+ require_relative 'generated_v1_prediction'
5
+
6
+ module Mindee
7
+ module Product
8
+ module Generated
9
+ # Generated Document V1 prediction
10
+ class GeneratedV1Document < Mindee::Product::Generated::GeneratedV1Prediction
11
+ include Mindee::Parsing::Standard
12
+ # @param raw_prediction [Hash]
13
+ def initialize(raw_prediction)
14
+ # Generated document.
15
+
16
+ # raw_prediction: Dictionary containing the JSON document response
17
+ super()
18
+ raw_prediction.each do |field_name, field_contents|
19
+ if field_contents.is_a?(Array)
20
+ @fields[field_name] = Parsing::Generated::GeneratedListField.new(field_contents)
21
+ elsif field_contents.is_a?(Hash) && Parsing::Generated.generated_object?(field_contents)
22
+ @fields[field_name] = Parsing::Generated::GeneratedObjectField.new(field_contents)
23
+ else
24
+ field_contents_str = field_contents.dup
25
+ if field_contents_str.key?('value') && field_contents_str['value'].nil? == false
26
+ field_contents_str['value'] = field_contents_str['value'].to_s
27
+ end
28
+ @fields[field_name] = StringField.new(field_contents_str)
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../parsing'
4
+ require_relative 'generated_v1_prediction'
5
+
6
+ module Mindee
7
+ module Product
8
+ module Generated
9
+ # Generated Document V1 page.
10
+ class GeneratedV1Page < Mindee::Parsing::Common::Page
11
+ # @param prediction [Hash]
12
+ def initialize(prediction)
13
+ super(prediction)
14
+ @prediction = GeneratedV1PagePrediction.new(
15
+ prediction['prediction'],
16
+ prediction['id']
17
+ )
18
+ end
19
+ end
20
+
21
+ # Generated Document V1 page prediction.
22
+ class GeneratedV1PagePrediction < GeneratedV1Prediction
23
+ include Mindee::Parsing::Standard
24
+ include Mindee::Parsing::Generated
25
+ def initialize(raw_prediction, page_id = nil)
26
+ super()
27
+ raw_prediction.each do |field_name, field_contents|
28
+ if field_contents.is_a?(Array)
29
+ @fields[field_name] = GeneratedListField.new(field_contents, page_id)
30
+ elsif field_contents.is_a?(Hash) && Parsing::Generated.generated_object?(field_contents)
31
+ @fields[field_name] = GeneratedObjectField.new(field_contents, page_id)
32
+ else
33
+ field_contents_str = field_contents.dup
34
+ if field_contents_str.key?('value') && !field_contents_str['value'].nil?
35
+ field_contents_str['value'] = field_contents_str['value'].to_s
36
+ end
37
+ @fields[field_name] = StringField.new(field_contents_str, page_id)
38
+ end
39
+ end
40
+ end
41
+
42
+ # @return [String]
43
+ def to_s
44
+ out_str = String.new
45
+ out_str << "\n#{super}"
46
+ out_str
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,114 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../parsing'
4
+
5
+ module Mindee
6
+ module Product
7
+ module Generated
8
+ # Generated Document V1 page.
9
+ class GeneratedV1Prediction < Mindee::Parsing::Common::Prediction
10
+ include Mindee::Parsing::Common
11
+ include Mindee::Parsing::Standard
12
+ include Mindee::Parsing::Generated
13
+ # All value fields in the document
14
+ # @return [Hash<Symbol, Mindee::Parsing::Generated::GeneratedListField>]
15
+ attr_reader :fields
16
+
17
+ def initialize
18
+ super()
19
+ @fields = {}
20
+ end
21
+
22
+ # String representation.
23
+ def to_s
24
+ out_str = ''
25
+ pattern = %r{^(\n* *)( {2}):}
26
+ @fields.each do |field_name, field_value|
27
+ str_value = if field_value.is_a?(GeneratedListField) && field_value.values.length.positive?
28
+ generate_field_string(field_name, field_value, pattern)
29
+ else
30
+ field_value.to_s
31
+ end
32
+ out_str += "\n:#{field_name}:"
33
+
34
+ out_str += " #{str_value}".sub(%r{^\s+\n}, "\n") if str_value.length.positive?
35
+ end
36
+ out_str.sub("\n", '')
37
+ end
38
+
39
+ private
40
+
41
+ def generate_field_string(field_name, field_value, pattern)
42
+ return '' if field_value.values.empty? || field_value.values.nil?
43
+
44
+ str_value = ''
45
+ str_value += if field_value.values[0].is_a?(Parsing::Generated::GeneratedObjectField)
46
+ field_value.values[0].str_level(1).sub(pattern, '\\1* :')
47
+ else
48
+ "#{field_value.values[0].to_s.sub(pattern, '\\1* :')}\n"
49
+ end
50
+ field_value.values[1..].each do |sub_value|
51
+ str_value += if sub_value.is_a?(Parsing::Generated::GeneratedObjectField)
52
+ sub_value.str_level(1).sub(pattern, '\\1* :')
53
+ else
54
+ "#{' ' * (field_name.length + 2)} #{sub_value}\n"
55
+ end
56
+ end
57
+ str_value.rstrip
58
+ end
59
+
60
+ def generate_list_field_string(field_name, field_value, pattern)
61
+ str_value = ''
62
+ field_value.each_value do |sub_value|
63
+ str_value += generate_sub_value_string(field_name, sub_value, pattern)
64
+ end
65
+ str_value.rstrip
66
+ end
67
+
68
+ def generate_sub_value_string(field_name, sub_value, pattern)
69
+ if sub_value.is_a?(GeneratedObjectField)
70
+ sub_value.str_level(1).gsub(pattern, '\1* :')
71
+ else
72
+ (' ' * (field_name.length + 2)) + "#{sub_value}\n"
73
+ end
74
+ end
75
+
76
+ # Returns a hash of all fields that aren't a collection
77
+ # @return [Hash<String, StringField>]
78
+ def single_fields
79
+ single_fields = {}
80
+ @fields.each do |field_name, field_value|
81
+ single_fields[field_name] = field_value if field_value.is_a?(StringField)
82
+ end
83
+ single_fields
84
+ end
85
+
86
+ # Returns a hash of all list-like fields
87
+ # @return [Hash<String, GeneratedListField>]
88
+ def list_fields
89
+ list_fields = {}
90
+ @fields.each do |field_name, field_value|
91
+ list_fields[field_name] = field_value if field_value.is_a?(GeneratedListField)
92
+ end
93
+ list_fields
94
+ end
95
+
96
+ # Returns a hash of all object-like fields
97
+ # @return [Hash<String, GeneratedObjectField>]
98
+ def object_fields
99
+ object_fields = {}
100
+ @fields.each do |field_name, field_value|
101
+ object_fields[field_name] = field_value if field_value.is_a?(GeneratedObjectField)
102
+ end
103
+ object_fields
104
+ end
105
+
106
+ # Lists names of all top-level field keys
107
+ # @return [Array<String>]
108
+ def list_field_names
109
+ @fields.keys.map(&:to_s)
110
+ end
111
+ end
112
+ end
113
+ end
114
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../parsing'
4
+ require_relative 'international_id_v1_document'
5
+ require_relative 'international_id_v1_page'
6
+
7
+ module Mindee
8
+ module Product
9
+ # International ID module.
10
+ module InternationalId
11
+ # International ID V1 prediction inference.
12
+ class InternationalIdV1 < Mindee::Parsing::Common::Inference
13
+ @endpoint_name = 'international_id'
14
+ @endpoint_version = '1'
15
+
16
+ # @param prediction [Hash]
17
+ def initialize(prediction)
18
+ super
19
+ @prediction = InternationalIdV1Document.new(prediction['prediction'], nil)
20
+ @pages = []
21
+ prediction['pages'].each do |page|
22
+ if page.key?('prediction') && !page['prediction'].nil? && !page['prediction'].empty?
23
+ @pages.push(InternationalIdV1Page.new(page))
24
+ end
25
+ end
26
+ end
27
+
28
+ class << self
29
+ # Name of the endpoint for this product.
30
+ # @return [String]
31
+ attr_reader :endpoint_name
32
+ # Version for this product.
33
+ # @return [String]
34
+ attr_reader :endpoint_version
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,109 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../parsing'
4
+
5
+ module Mindee
6
+ module Product
7
+ module InternationalId
8
+ # International ID V1 document prediction.
9
+ class InternationalIdV1Document < Mindee::Parsing::Common::Prediction
10
+ include Mindee::Parsing::Standard
11
+ # The physical location of the document holder's residence.
12
+ # @return [Mindee::Parsing::Standard::StringField]
13
+ attr_reader :address
14
+ # The date of birth of the document holder.
15
+ # @return [Mindee::Parsing::Standard::DateField]
16
+ attr_reader :birth_date
17
+ # The location where the document holder was born.
18
+ # @return [Mindee::Parsing::Standard::StringField]
19
+ attr_reader :birth_place
20
+ # The country that issued the identification document.
21
+ # @return [Mindee::Parsing::Standard::StringField]
22
+ attr_reader :country_of_issue
23
+ # The unique identifier assigned to the identification document.
24
+ # @return [Mindee::Parsing::Standard::StringField]
25
+ attr_reader :document_number
26
+ # The type of identification document being used.
27
+ # @return [Mindee::Parsing::Standard::ClassificationField]
28
+ attr_reader :document_type
29
+ # The date when the document will no longer be valid for use.
30
+ # @return [Mindee::Parsing::Standard::DateField]
31
+ attr_reader :expiry_date
32
+ # The first names or given names of the document holder.
33
+ # @return [Array<Mindee::Parsing::Standard::StringField>]
34
+ attr_reader :given_names
35
+ # The date when the document was issued.
36
+ # @return [Mindee::Parsing::Standard::DateField]
37
+ attr_reader :issue_date
38
+ # First line of information in a standardized format for easy machine reading and processing.
39
+ # @return [Mindee::Parsing::Standard::StringField]
40
+ attr_reader :mrz1
41
+ # Second line of information in a standardized format for easy machine reading and processing.
42
+ # @return [Mindee::Parsing::Standard::StringField]
43
+ attr_reader :mrz2
44
+ # Third line of information in a standardized format for easy machine reading and processing.
45
+ # @return [Mindee::Parsing::Standard::StringField]
46
+ attr_reader :mrz3
47
+ # Indicates the country of citizenship or nationality of the document holder.
48
+ # @return [Mindee::Parsing::Standard::StringField]
49
+ attr_reader :nationality
50
+ # The document holder's biological sex, such as male or female.
51
+ # @return [Mindee::Parsing::Standard::StringField]
52
+ attr_reader :sex
53
+ # The surnames of the document holder.
54
+ # @return [Array<Mindee::Parsing::Standard::StringField>]
55
+ attr_reader :surnames
56
+
57
+ # @param prediction [Hash]
58
+ # @param page_id [Integer, nil]
59
+ def initialize(prediction, page_id)
60
+ super()
61
+ @address = StringField.new(prediction['address'], page_id)
62
+ @birth_date = DateField.new(prediction['birth_date'], page_id)
63
+ @birth_place = StringField.new(prediction['birth_place'], page_id)
64
+ @country_of_issue = StringField.new(prediction['country_of_issue'], page_id)
65
+ @document_number = StringField.new(prediction['document_number'], page_id)
66
+ @document_type = ClassificationField.new(prediction['document_type'], page_id)
67
+ @expiry_date = DateField.new(prediction['expiry_date'], page_id)
68
+ @given_names = []
69
+ prediction['given_names'].each do |item|
70
+ @given_names.push(StringField.new(item, page_id))
71
+ end
72
+ @issue_date = DateField.new(prediction['issue_date'], page_id)
73
+ @mrz1 = StringField.new(prediction['mrz1'], page_id)
74
+ @mrz2 = StringField.new(prediction['mrz2'], page_id)
75
+ @mrz3 = StringField.new(prediction['mrz3'], page_id)
76
+ @nationality = StringField.new(prediction['nationality'], page_id)
77
+ @sex = StringField.new(prediction['sex'], page_id)
78
+ @surnames = []
79
+ prediction['surnames'].each do |item|
80
+ @surnames.push(StringField.new(item, page_id))
81
+ end
82
+ end
83
+
84
+ # @return [String]
85
+ def to_s
86
+ surnames = @surnames.join("\n #{' ' * 10}")
87
+ given_names = @given_names.join("\n #{' ' * 13}")
88
+ out_str = String.new
89
+ out_str << "\n:Document Type: #{@document_type}".rstrip
90
+ out_str << "\n:Document Number: #{@document_number}".rstrip
91
+ out_str << "\n:Country of Issue: #{@country_of_issue}".rstrip
92
+ out_str << "\n:Surnames: #{surnames}".rstrip
93
+ out_str << "\n:Given Names: #{given_names}".rstrip
94
+ out_str << "\n:Gender: #{@sex}".rstrip
95
+ out_str << "\n:Birth date: #{@birth_date}".rstrip
96
+ out_str << "\n:Birth Place: #{@birth_place}".rstrip
97
+ out_str << "\n:Nationality: #{@nationality}".rstrip
98
+ out_str << "\n:Issue Date: #{@issue_date}".rstrip
99
+ out_str << "\n:Expiry Date: #{@expiry_date}".rstrip
100
+ out_str << "\n:Address: #{@address}".rstrip
101
+ out_str << "\n:Machine Readable Zone Line 1: #{@mrz1}".rstrip
102
+ out_str << "\n:Machine Readable Zone Line 2: #{@mrz2}".rstrip
103
+ out_str << "\n:Machine Readable Zone Line 3: #{@mrz3}".rstrip
104
+ out_str[1..].to_s
105
+ end
106
+ end
107
+ end
108
+ end
109
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../parsing'
4
+ require_relative 'international_id_v1_document'
5
+
6
+ module Mindee
7
+ module Product
8
+ module InternationalId
9
+ # International ID V1 page.
10
+ class InternationalIdV1Page < Mindee::Parsing::Common::Page
11
+ # @param prediction [Hash]
12
+ def initialize(prediction)
13
+ super(prediction)
14
+ @prediction = InternationalIdV1PagePrediction.new(
15
+ prediction['prediction'],
16
+ prediction['id']
17
+ )
18
+ end
19
+ end
20
+
21
+ # International ID V1 page prediction.
22
+ class InternationalIdV1PagePrediction < InternationalIdV1Document
23
+ # @return [String]
24
+ def to_s
25
+ out_str = String.new
26
+ out_str << "\n#{super}"
27
+ out_str
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../parsing'
4
+ require_relative 'international_id_v2_document'
5
+ require_relative 'international_id_v2_page'
6
+
7
+ module Mindee
8
+ module Product
9
+ # International ID module.
10
+ module InternationalId
11
+ # International ID V2 prediction inference.
12
+ class InternationalIdV2 < Mindee::Parsing::Common::Inference
13
+ @endpoint_name = 'international_id'
14
+ @endpoint_version = '2'
15
+
16
+ # @param prediction [Hash]
17
+ def initialize(prediction)
18
+ super
19
+ @prediction = InternationalIdV2Document.new(prediction['prediction'], nil)
20
+ @pages = []
21
+ prediction['pages'].each do |page|
22
+ if page.key?('prediction') && !page['prediction'].nil? && !page['prediction'].empty?
23
+ @pages.push(InternationalIdV2Page.new(page))
24
+ end
25
+ end
26
+ end
27
+
28
+ class << self
29
+ # Name of the endpoint for this product.
30
+ # @return [String]
31
+ attr_reader :endpoint_name
32
+ # Version for this product.
33
+ # @return [String]
34
+ attr_reader :endpoint_version
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end