mindee 3.0.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (27) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +12 -3
  3. data/docs/code_samples/carte_vitale_v1.txt +1 -1
  4. data/docs/code_samples/us_driver_license_v1.txt +19 -0
  5. data/lib/mindee/http/endpoint.rb +4 -12
  6. data/lib/mindee/input/sources.rb +5 -2
  7. data/lib/mindee/parsing/common/document.rb +1 -1
  8. data/lib/mindee/parsing/standard/position_field.rb +6 -3
  9. data/lib/mindee/product/financial_document/financial_document_v1_document.rb +15 -1
  10. data/lib/mindee/product/financial_document/financial_document_v1_line_item.rb +8 -8
  11. data/lib/mindee/product/fr/bank_account_details/bank_account_details_v2_document.rb +1 -8
  12. data/lib/mindee/product/passport/passport_v1.rb +1 -1
  13. data/lib/mindee/product/passport/passport_v1_document.rb +1 -1
  14. data/lib/mindee/product/passport/passport_v1_page.rb +2 -2
  15. data/lib/mindee/product/receipt/receipt_v5.rb +1 -1
  16. data/lib/mindee/product/receipt/receipt_v5_document.rb +13 -2
  17. data/lib/mindee/product/receipt/receipt_v5_line_item.rb +5 -5
  18. data/lib/mindee/product/receipt/receipt_v5_page.rb +2 -2
  19. data/lib/mindee/product/us/bank_check/bank_check_v1.rb +1 -1
  20. data/lib/mindee/product/us/bank_check/bank_check_v1_document.rb +16 -27
  21. data/lib/mindee/product/us/bank_check/bank_check_v1_page.rb +23 -0
  22. data/lib/mindee/product/us/driver_license/driver_license_v1.rb +38 -0
  23. data/lib/mindee/product/us/driver_license/driver_license_v1_document.rb +113 -0
  24. data/lib/mindee/product/us/driver_license/driver_license_v1_page.rb +53 -0
  25. data/lib/mindee/product.rb +2 -1
  26. data/lib/mindee/version.rb +1 -1
  27. metadata +6 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c81762ec2e42847a182b6b864355ba0268ad22995c24b361e54fd5380f8191f3
4
- data.tar.gz: 771736fbe9d28b5d7a91c7cfee9a687da116f176c8226f866ab8bf175cab7b7f
3
+ metadata.gz: c9ab3a3a82fc00bfcd0519d528c231face1134d38b3935dad152773cdb051422
4
+ data.tar.gz: a1a81837382eed829d5d413408a6f5cdc7bc6fbab1fcc0e4d87fde2673f957e7
5
5
  SHA512:
6
- metadata.gz: 145a65bda997dc06a3ffafee6123d38195f66e6907c74097efca1a7d5bec9c8d70c041a7a58428e24be22a4850ff36e994a92024252735a815180032fe89f7a5
7
- data.tar.gz: 605b1a9b1ffa2c0948581632eeca05e6462ce7f2280281740255183659648c7feb56ace62ec466cb69716f199a6a6467d4c5f1fa27e304fd83899b9a4dcfb2d9
6
+ metadata.gz: 34807307fe16dadbe2f4aa5e5bebdd8c14f7a1b43ffc6655f0f617fc0255e2cca070f27c53649f6b5f9a0c39c215c184ea48f62da369c17730a1a9c9ae026d4c
7
+ data.tar.gz: a0b61030ee533e949359516b440021ac4194440b4f138bb67d2aaf99dab86ad740523237677fd12d1be4a27409948802fe32a7c6e9ca1f37f06b29f2453c1872
data/CHANGELOG.md CHANGED
@@ -1,8 +1,19 @@
1
1
  # Mindee Ruby API Library Changelog
2
2
 
3
+ ## v3.1.0 - 2023-08-08
4
+ ### Changes
5
+ * :sparkles: add support for US Driver License
6
+ * :recycle: update unit tests & dependencies
7
+ * :arrow_up: update Bank Checks (#46)
8
+
9
+ ### Fixes
10
+ * :bug: fix `all_words` display (#47)
11
+ * :bug: fix empty `position_field` (#47)
12
+ * :bug: fix byte repacking issues for PDF files (#45)
13
+
14
+
3
15
  ## v3.0.0 - 2023-06-29
4
16
  ### ¡Breaking Changes!
5
-
6
17
  * :boom: update `Client` creation & document upload
7
18
  * :boom: update custom `Endpoint` creation syntax
8
19
  * :art: improve product class syntax & structure
@@ -11,7 +22,6 @@
11
22
  * :art: separated common, standard & custom parsing features into their own modules
12
23
 
13
24
  ### Changes
14
-
15
25
  * :sparkles: add support for asynchronous endpoints
16
26
  * :sparkles: add support for Invoice Splitter V1
17
27
  * :sparkles: add support for OCR Full-text parsing on compatible APIs
@@ -26,7 +36,6 @@
26
36
  * :recycle: rewrite tutorials to match new syntax
27
37
 
28
38
  ### Fixes
29
-
30
39
  * :bug: fix: pages now use the proper `orientation` property
31
40
  * :zap: optimize: only a single endpoint is now created on document upload
32
41
 
@@ -16,4 +16,4 @@ result = mindee_client.parse(
16
16
  puts result.document
17
17
 
18
18
  # Print the document-level parsed data
19
- # puts result.document.inference.prediction
19
+ # puts result.document.inference.prediction
@@ -0,0 +1,19 @@
1
+ require 'mindee'
2
+
3
+ # Init a new client
4
+ mindee_client = Mindee::Client.new(api_key: 'my-api-key')
5
+
6
+ # Load a file from disk
7
+ input_source = mindee_client.source_from_path('/path/to/the/file.ext')
8
+
9
+ # Parse the file
10
+ result = mindee_client.parse(
11
+ input_source,
12
+ Mindee::Product::US::DriverLicense::DriverLicenseV1
13
+ )
14
+
15
+ # Print a full summary of the parsed data in RST format
16
+ puts result.document
17
+
18
+ # Print the document-level parsed data
19
+ # puts result.document.inference.prediction
@@ -97,13 +97,9 @@ module Mindee
97
97
  }
98
98
  req = Net::HTTP::Post.new(uri, headers)
99
99
  form_data = if input_source.is_a?(Mindee::Input::Source::UrlInputSource)
100
- {
101
- 'document' => input_source.url,
102
- }
100
+ [['document', input_source.url]]
103
101
  else
104
- {
105
- 'document' => input_source.read_document(close: close_file),
106
- }
102
+ [input_source.read_document(close: close_file)]
107
103
  end
108
104
  form_data.push ['include_mvision', 'true'] if all_words
109
105
 
@@ -132,13 +128,9 @@ module Mindee
132
128
  }
133
129
  req = Net::HTTP::Post.new(uri, headers)
134
130
  form_data = if input_source.is_a?(Mindee::Input::Source::UrlInputSource)
135
- {
136
- 'document' => input_source.url,
137
- }
131
+ [['document', input_source.url]]
138
132
  else
139
- {
140
- 'document' => input_source.read_document(close: close_file),
141
- }
133
+ [input_source.read_document(close: close_file)]
142
134
  end
143
135
  form_data.push ['include_mvision', 'true'] if all_words
144
136
 
@@ -38,7 +38,7 @@ module Mindee
38
38
  end
39
39
 
40
40
  def pdf?
41
- @file_mimetype == 'application/pdf'
41
+ @file_mimetype.to_s == 'application/pdf'
42
42
  end
43
43
 
44
44
  def process_pdf(options)
@@ -49,9 +49,12 @@ module Mindee
49
49
  # @param close [Boolean]
50
50
  def read_document(close: true)
51
51
  @io_stream.seek(0)
52
+ # Avoids needlessly re-packing some files
52
53
  data = @io_stream.read
53
54
  @io_stream.close if close
54
- [data].pack('m')
55
+ return ['document', data, { filename: @filename }] if pdf?
56
+
57
+ ['document', [data].pack('m'), { filename: @filename }]
55
58
  end
56
59
  end
57
60
 
@@ -22,7 +22,7 @@ module Mindee
22
22
  ocr_prediction = http_response.fetch('ocr', nil)
23
23
  return nil if ocr_prediction.nil? || ocr_prediction.fetch('mvision-v1', nil).nil?
24
24
 
25
- Ocr(ocr_prediction)
25
+ Ocr::Ocr.new(ocr_prediction)
26
26
  end
27
27
 
28
28
  # @param product_class [Class<Mindee::Product>]
@@ -19,7 +19,9 @@ module Mindee
19
19
  # @param prediction [Hash]
20
20
  # @param page_id [Integer, nil]
21
21
  def initialize(prediction, page_id)
22
- @polygon = Geometry.polygon_from_prediction(prediction['polygon']) unless prediction['polygon'].empty?
22
+ unless prediction['polygon'].nil? || prediction['polygon'].empty?
23
+ @polygon = Geometry.polygon_from_prediction(prediction['polygon'])
24
+ end
23
25
  @quadrangle = to_quadrilateral(prediction, 'quadrangle')
24
26
  @rectangle = to_quadrilateral(prediction, 'rectangle')
25
27
  @bounding_box = to_quadrilateral(prediction, 'bounding_box')
@@ -30,13 +32,14 @@ module Mindee
30
32
  # @return [String]
31
33
  def to_s
32
34
  out_str = String.new
33
- out_str << "Polygon with #{@polygon.size} points."
35
+ out_str << "Polygon with #{@polygon.size} points." if @polygon
36
+ out_str
34
37
  end
35
38
 
36
39
  private
37
40
 
38
41
  def to_quadrilateral(prediction, key)
39
- Geometry.quadrilateral_from_prediction(prediction[key]) unless prediction[key].empty?
42
+ Geometry.quadrilateral_from_prediction(prediction[key]) unless prediction[key].nil? || prediction[key].empty?
40
43
  end
41
44
  end
42
45
  end
@@ -160,10 +160,23 @@ module Mindee
160
160
 
161
161
  private
162
162
 
163
+ # @param char [String]
164
+ # @return [String]
163
165
  def line_items_separator(char)
164
- " +#{char * 38}+#{char * 14}+#{char * 10}+#{char * 12}+#{char * 14}+#{char * 14}+#{char * 12}+"
166
+ out_str = String.new
167
+ out_str << ' '
168
+ out_str << "+#{char * 38}"
169
+ out_str << "+#{char * 14}"
170
+ out_str << "+#{char * 10}"
171
+ out_str << "+#{char * 12}"
172
+ out_str << "+#{char * 14}"
173
+ out_str << "+#{char * 14}"
174
+ out_str << "+#{char * 12}"
175
+ out_str << '+'
176
+ out_str
165
177
  end
166
178
 
179
+ # @return [String]
167
180
  def line_items_to_s
168
181
  return '' if @line_items.empty?
169
182
 
@@ -181,6 +194,7 @@ module Mindee
181
194
  out_str << "\n#{line_items_separator('=')}"
182
195
  out_str << "\n #{line_items}"
183
196
  out_str << "\n#{line_items_separator('-')}"
197
+ out_str
184
198
  end
185
199
  end
186
200
  end
@@ -75,14 +75,14 @@ module Mindee
75
75
  def to_s
76
76
  printable = printable_values
77
77
  out_str = String.new
78
- out_str << printable[:description]
79
- out_str << printable[:product_code]
80
- out_str << printable[:quantity]
81
- out_str << printable[:tax_amount]
82
- out_str << printable[:tax_rate]
83
- out_str << printable[:total_amount]
84
- out_str << printable[:unit_price]
85
- out_str.strip
78
+ out_str << "\n :Description: #{printable[:description]}"
79
+ out_str << "\n :Product code: #{printable[:product_code]}"
80
+ out_str << "\n :Quantity: #{printable[:quantity]}"
81
+ out_str << "\n :Tax Amount: #{printable[:tax_amount]}"
82
+ out_str << "\n :Tax Rate (%): #{printable[:tax_rate]}"
83
+ out_str << "\n :Total Amount: #{printable[:total_amount]}"
84
+ out_str << "\n :Unit Price: #{printable[:unit_price]}"
85
+ out_str
86
86
  end
87
87
  end
88
88
  end
@@ -35,7 +35,7 @@ module Mindee
35
35
 
36
36
  # @return [String]
37
37
  def to_s
38
- bban = bban_to_s
38
+ bban = @bban.to_s
39
39
  out_str = String.new
40
40
  out_str << "\n:Account Holder's Names: #{@account_holders_names}".rstrip
41
41
  out_str << "\n:Basic Bank Account Number:"
@@ -44,13 +44,6 @@ module Mindee
44
44
  out_str << "\n:SWIFT Code: #{@swift_code}".rstrip
45
45
  out_str[1..].to_s
46
46
  end
47
-
48
- private
49
-
50
- # @return [String]
51
- def bban_to_s
52
- @bban.to_s
53
- end
54
47
  end
55
48
  end
56
49
  end
@@ -7,7 +7,7 @@ require_relative 'passport_v1_page'
7
7
  module Mindee
8
8
  module Product
9
9
  module Passport
10
- # International Passport V1 prediction inference.
10
+ # Passport V1 prediction inference.
11
11
  class PassportV1 < Mindee::Parsing::Common::Inference
12
12
  @endpoint_name = 'passport'
13
13
  @endpoint_version = '1'
@@ -5,7 +5,7 @@ require_relative '../../parsing'
5
5
  module Mindee
6
6
  module Product
7
7
  module Passport
8
- # International Passport V1 document prediction.
8
+ # Passport V1 document prediction.
9
9
  class PassportV1Document < Mindee::Parsing::Common::Prediction
10
10
  include Mindee::Parsing::Standard
11
11
  # The date of birth of the passport holder.
@@ -6,7 +6,7 @@ require_relative 'passport_v1_document'
6
6
  module Mindee
7
7
  module Product
8
8
  module Passport
9
- # International Passport V1 page.
9
+ # Passport V1 page.
10
10
  class PassportV1Page < Mindee::Parsing::Common::Page
11
11
  # @param prediction [Hash]
12
12
  def initialize(prediction)
@@ -18,7 +18,7 @@ module Mindee
18
18
  end
19
19
  end
20
20
 
21
- # International Passport V1 page prediction.
21
+ # Passport V1 page prediction.
22
22
  class PassportV1PagePrediction < PassportV1Document
23
23
  # @return [String]
24
24
  def to_s
@@ -7,7 +7,7 @@ require_relative 'receipt_v5_page'
7
7
  module Mindee
8
8
  module Product
9
9
  module Receipt
10
- # Expense Receipt V5 prediction inference.
10
+ # Receipt V5 prediction inference.
11
11
  class ReceiptV5 < Mindee::Parsing::Common::Inference
12
12
  @endpoint_name = 'expense_receipts'
13
13
  @endpoint_version = '5'
@@ -6,7 +6,7 @@ require_relative 'receipt_v5_line_item'
6
6
  module Mindee
7
7
  module Product
8
8
  module Receipt
9
- # Expense Receipt V5 document prediction.
9
+ # Receipt V5 document prediction.
10
10
  class ReceiptV5Document < Mindee::Parsing::Common::Prediction
11
11
  include Mindee::Parsing::Standard
12
12
  # The purchase category among predefined classes.
@@ -113,10 +113,20 @@ module Mindee
113
113
 
114
114
  private
115
115
 
116
+ # @param char [String]
117
+ # @return [String]
116
118
  def line_items_separator(char)
117
- " +#{char * 38}+#{char * 10}+#{char * 14}+#{char * 12}+"
119
+ out_str = String.new
120
+ out_str << ' '
121
+ out_str << "+#{char * 38}"
122
+ out_str << "+#{char * 10}"
123
+ out_str << "+#{char * 14}"
124
+ out_str << "+#{char * 12}"
125
+ out_str << '+'
126
+ out_str
118
127
  end
119
128
 
129
+ # @return [String]
120
130
  def line_items_to_s
121
131
  return '' if @line_items.empty?
122
132
 
@@ -131,6 +141,7 @@ module Mindee
131
141
  out_str << "\n#{line_items_separator('=')}"
132
142
  out_str << "\n #{line_items}"
133
143
  out_str << "\n#{line_items_separator('-')}"
144
+ out_str
134
145
  end
135
146
  end
136
147
  end
@@ -57,11 +57,11 @@ module Mindee
57
57
  def to_s
58
58
  printable = printable_values
59
59
  out_str = String.new
60
- out_str << printable[:description]
61
- out_str << printable[:quantity]
62
- out_str << printable[:total_amount]
63
- out_str << printable[:unit_price]
64
- out_str.strip
60
+ out_str << "\n :Description: #{printable[:description]}"
61
+ out_str << "\n :Quantity: #{printable[:quantity]}"
62
+ out_str << "\n :Total Amount: #{printable[:total_amount]}"
63
+ out_str << "\n :Unit Price: #{printable[:unit_price]}"
64
+ out_str
65
65
  end
66
66
  end
67
67
  end
@@ -6,7 +6,7 @@ require_relative 'receipt_v5_document'
6
6
  module Mindee
7
7
  module Product
8
8
  module Receipt
9
- # Expense Receipt V5 page.
9
+ # Receipt V5 page.
10
10
  class ReceiptV5Page < Mindee::Parsing::Common::Page
11
11
  # @param prediction [Hash]
12
12
  def initialize(prediction)
@@ -18,7 +18,7 @@ module Mindee
18
18
  end
19
19
  end
20
20
 
21
- # Expense Receipt V5 page prediction.
21
+ # Receipt V5 page prediction.
22
22
  class ReceiptV5PagePrediction < ReceiptV5Document
23
23
  # @return [String]
24
24
  def to_s
@@ -8,7 +8,7 @@ module Mindee
8
8
  module Product
9
9
  module US
10
10
  module BankCheck
11
- # Bank Check Inference
11
+ # Bank Check V1 prediction inference.
12
12
  class BankCheckV1 < Mindee::Parsing::Common::Inference
13
13
  @endpoint_name = 'bank_check'
14
14
  @endpoint_version = '1'
@@ -9,30 +9,24 @@ module Mindee
9
9
  # Bank Check V1 document prediction.
10
10
  class BankCheckV1Document < Mindee::Parsing::Common::Prediction
11
11
  include Mindee::Parsing::Standard
12
- # Payer's bank account number.
13
- # @return [Array<Mindee::Parsing::Standard::TextField>]
12
+ # The check payer's account number.
13
+ # @return [Mindee::Parsing::Standard::TextField]
14
14
  attr_reader :account_number
15
- # Amount to be paid.
16
- # @return [Array<Mindee::Parsing::Standard::AmountField>]
15
+ # The amount of the check.
16
+ # @return [Mindee::Parsing::Standard::AmountField]
17
17
  attr_reader :amount
18
- # The check number.
18
+ # The issuer's check number.
19
19
  # @return [Mindee::Parsing::Standard::TextField]
20
20
  attr_reader :check_number
21
- # Payer's bank account routing number.
22
- # @return [Mindee::Parsing::Standard::TextField]
23
- attr_reader :routing_number
24
- # Date the check was issued.
21
+ # The date the check was issued.
25
22
  # @return [Mindee::Parsing::Standard::DateField]
26
23
  attr_reader :date
27
- # The positions of the signatures on the image.
28
- # @return [Array<Parsing::Standard::PositionField>]
29
- attr_reader :signatures_positions
30
- # Check's position in the image.
31
- # @return [Parsing::Standard::PositionField]
32
- attr_reader :check_position
33
- # List of payees (full name or company name).
24
+ # List of the check's payees (recipients).
34
25
  # @return [Array<Mindee::Parsing::Standard::TextField>]
35
26
  attr_reader :payees
27
+ # The check issuer's routing number.
28
+ # @return [Mindee::Parsing::Standard::TextField]
29
+ attr_reader :routing_number
36
30
 
37
31
  # @param prediction [Hash]
38
32
  # @param page_id [Integer, nil]
@@ -42,28 +36,23 @@ module Mindee
42
36
  @amount = AmountField.new(prediction['amount'], page_id)
43
37
  @check_number = TextField.new(prediction['check_number'], page_id)
44
38
  @date = DateField.new(prediction['date'], page_id)
45
- @check_position = PositionField.new(prediction['check_position'], page_id)
46
- @routing_number = TextField.new(prediction['routing_number'], page_id)
47
- @signatures_positions = []
48
- prediction['signatures_positions'].each do |item|
49
- @signatures_positions.push(PositionField.new(item, page_id))
50
- end
51
39
  @payees = []
52
40
  prediction['payees'].each do |item|
53
41
  @payees.push(TextField.new(item, page_id))
54
42
  end
43
+ @routing_number = TextField.new(prediction['routing_number'], page_id)
55
44
  end
56
45
 
57
46
  # @return [String]
58
47
  def to_s
59
- payees = @payees.map(&:value).join(', ')
48
+ payees = @payees.join("\n #{' ' * 8}")
60
49
  out_str = String.new
61
- out_str << "\n:Routing number: #{@routing_number}".rstrip
62
- out_str << "\n:Account number: #{@account_number}".rstrip
63
- out_str << "\n:Check number: #{@check_number}".rstrip
64
- out_str << "\n:Date: #{@date}".rstrip
50
+ out_str << "\n:Check Issue Date: #{@date}".rstrip
65
51
  out_str << "\n:Amount: #{@amount}".rstrip
66
52
  out_str << "\n:Payees: #{payees}".rstrip
53
+ out_str << "\n:Routing Number: #{@routing_number}".rstrip
54
+ out_str << "\n:Account Number: #{@account_number}".rstrip
55
+ out_str << "\n:Check Number: #{@check_number}".rstrip
67
56
  out_str[1..].to_s
68
57
  end
69
58
  end
@@ -21,9 +21,32 @@ module Mindee
21
21
 
22
22
  # Bank Check V1 page prediction.
23
23
  class BankCheckV1PagePrediction < BankCheckV1Document
24
+ include Mindee::Parsing::Standard
25
+
26
+ # The position of the check on the document.
27
+ # @return [Mindee::Parsing::Standard::PositionField]
28
+ attr_reader :check_position
29
+ # List of signature positions
30
+ # @return [Array<Mindee::Parsing::Standard::PositionField>]
31
+ attr_reader :signatures_positions
32
+
33
+ # @param prediction [Hash]
34
+ # @param page_id [Integer, nil]
35
+ def initialize(prediction, page_id)
36
+ @check_position = PositionField.new(prediction['check_position'], page_id)
37
+ @signatures_positions = []
38
+ prediction['signatures_positions'].each do |item|
39
+ @signatures_positions.push(PositionField.new(item, page_id))
40
+ end
41
+ super(prediction, page_id)
42
+ end
43
+
24
44
  # @return [String]
25
45
  def to_s
46
+ signatures_positions = @signatures_positions.join("\n #{' ' * 21}")
26
47
  out_str = String.new
48
+ out_str << "\n:Check Position: #{@check_position}".rstrip
49
+ out_str << "\n:Signature Positions: #{signatures_positions}".rstrip
27
50
  out_str << "\n#{super}"
28
51
  out_str
29
52
  end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../parsing'
4
+ require_relative 'driver_license_v1_document'
5
+ require_relative 'driver_license_v1_page'
6
+
7
+ module Mindee
8
+ module Product
9
+ module US
10
+ module DriverLicense
11
+ # Driver License V1 prediction inference.
12
+ class DriverLicenseV1 < Mindee::Parsing::Common::Inference
13
+ @endpoint_name = 'us_driver_license'
14
+ @endpoint_version = '1'
15
+
16
+ # @param prediction [Hash]
17
+ def initialize(prediction)
18
+ super
19
+ @prediction = DriverLicenseV1Document.new(prediction['prediction'], nil)
20
+ @pages = []
21
+ prediction['pages'].each do |page|
22
+ @pages.push(DriverLicenseV1Page.new(page))
23
+ end
24
+ end
25
+
26
+ class << self
27
+ # Name of the endpoint for this product.
28
+ # @return [String]
29
+ attr_reader :endpoint_name
30
+ # Version for this product.
31
+ # @return [String]
32
+ attr_reader :endpoint_version
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,113 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../parsing'
4
+
5
+ module Mindee
6
+ module Product
7
+ module US
8
+ module DriverLicense
9
+ # Driver License V1 document prediction.
10
+ class DriverLicenseV1Document < Mindee::Parsing::Common::Prediction
11
+ include Mindee::Parsing::Standard
12
+ # US driver license holders address
13
+ # @return [Mindee::Parsing::Standard::TextField]
14
+ attr_reader :address
15
+ # US driver license holders date of birth
16
+ # @return [Mindee::Parsing::Standard::DateField]
17
+ attr_reader :date_of_birth
18
+ # Document Discriminator Number of the US Driver License
19
+ # @return [Mindee::Parsing::Standard::TextField]
20
+ attr_reader :dd_number
21
+ # US driver license holders class
22
+ # @return [Mindee::Parsing::Standard::TextField]
23
+ attr_reader :dl_class
24
+ # ID number of the US Driver License.
25
+ # @return [Mindee::Parsing::Standard::TextField]
26
+ attr_reader :driver_license_id
27
+ # US driver license holders endorsements
28
+ # @return [Mindee::Parsing::Standard::TextField]
29
+ attr_reader :endorsements
30
+ # Date on which the documents expires.
31
+ # @return [Mindee::Parsing::Standard::DateField]
32
+ attr_reader :expiry_date
33
+ # US driver license holders eye colour
34
+ # @return [Mindee::Parsing::Standard::TextField]
35
+ attr_reader :eye_color
36
+ # US driver license holders first name(s)
37
+ # @return [Mindee::Parsing::Standard::TextField]
38
+ attr_reader :first_name
39
+ # US driver license holders hair colour
40
+ # @return [Mindee::Parsing::Standard::TextField]
41
+ attr_reader :hair_color
42
+ # US driver license holders hight
43
+ # @return [Mindee::Parsing::Standard::TextField]
44
+ attr_reader :height
45
+ # Date on which the documents was issued.
46
+ # @return [Mindee::Parsing::Standard::DateField]
47
+ attr_reader :issued_date
48
+ # US driver license holders last name
49
+ # @return [Mindee::Parsing::Standard::TextField]
50
+ attr_reader :last_name
51
+ # US driver license holders restrictions
52
+ # @return [Mindee::Parsing::Standard::TextField]
53
+ attr_reader :restrictions
54
+ # US driver license holders gender
55
+ # @return [Mindee::Parsing::Standard::TextField]
56
+ attr_reader :sex
57
+ # US State
58
+ # @return [Mindee::Parsing::Standard::TextField]
59
+ attr_reader :state
60
+ # US driver license holders weight
61
+ # @return [Mindee::Parsing::Standard::TextField]
62
+ attr_reader :weight
63
+
64
+ # @param prediction [Hash]
65
+ # @param page_id [Integer, nil]
66
+ def initialize(prediction, page_id)
67
+ super()
68
+ @address = TextField.new(prediction['address'], page_id)
69
+ @date_of_birth = DateField.new(prediction['date_of_birth'], page_id)
70
+ @dd_number = TextField.new(prediction['dd_number'], page_id)
71
+ @dl_class = TextField.new(prediction['dl_class'], page_id)
72
+ @driver_license_id = TextField.new(prediction['driver_license_id'], page_id)
73
+ @endorsements = TextField.new(prediction['endorsements'], page_id)
74
+ @expiry_date = DateField.new(prediction['expiry_date'], page_id)
75
+ @eye_color = TextField.new(prediction['eye_color'], page_id)
76
+ @first_name = TextField.new(prediction['first_name'], page_id)
77
+ @hair_color = TextField.new(prediction['hair_color'], page_id)
78
+ @height = TextField.new(prediction['height'], page_id)
79
+ @issued_date = DateField.new(prediction['issued_date'], page_id)
80
+ @last_name = TextField.new(prediction['last_name'], page_id)
81
+ @restrictions = TextField.new(prediction['restrictions'], page_id)
82
+ @sex = TextField.new(prediction['sex'], page_id)
83
+ @state = TextField.new(prediction['state'], page_id)
84
+ @weight = TextField.new(prediction['weight'], page_id)
85
+ end
86
+
87
+ # @return [String]
88
+ def to_s
89
+ out_str = String.new
90
+ out_str << "\n:State: #{@state}".rstrip
91
+ out_str << "\n:Driver License ID: #{@driver_license_id}".rstrip
92
+ out_str << "\n:Expiry Date: #{@expiry_date}".rstrip
93
+ out_str << "\n:Date Of Issue: #{@issued_date}".rstrip
94
+ out_str << "\n:Last Name: #{@last_name}".rstrip
95
+ out_str << "\n:First Name: #{@first_name}".rstrip
96
+ out_str << "\n:Address: #{@address}".rstrip
97
+ out_str << "\n:Date Of Birth: #{@date_of_birth}".rstrip
98
+ out_str << "\n:Restrictions: #{@restrictions}".rstrip
99
+ out_str << "\n:Endorsements: #{@endorsements}".rstrip
100
+ out_str << "\n:Driver License Class: #{@dl_class}".rstrip
101
+ out_str << "\n:Sex: #{@sex}".rstrip
102
+ out_str << "\n:Height: #{@height}".rstrip
103
+ out_str << "\n:Weight: #{@weight}".rstrip
104
+ out_str << "\n:Hair Color: #{@hair_color}".rstrip
105
+ out_str << "\n:Eye Color: #{@eye_color}".rstrip
106
+ out_str << "\n:Document Discriminator: #{@dd_number}".rstrip
107
+ out_str[1..].to_s
108
+ end
109
+ end
110
+ end
111
+ end
112
+ end
113
+ end
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../parsing'
4
+ require_relative 'driver_license_v1_document'
5
+
6
+ module Mindee
7
+ module Product
8
+ module US
9
+ module DriverLicense
10
+ # Driver License V1 page.
11
+ class DriverLicenseV1Page < Mindee::Parsing::Common::Page
12
+ # @param prediction [Hash]
13
+ def initialize(prediction)
14
+ super(prediction)
15
+ @prediction = DriverLicenseV1PagePrediction.new(
16
+ prediction['prediction'],
17
+ prediction['id']
18
+ )
19
+ end
20
+ end
21
+
22
+ # Driver License V1 page prediction.
23
+ class DriverLicenseV1PagePrediction < DriverLicenseV1Document
24
+ include Mindee::Parsing::Standard
25
+
26
+ # Has a photo of the US driver license holder
27
+ # @return [Mindee::Parsing::Standard::PositionField]
28
+ attr_reader :photo
29
+ # Has a signature of the US driver license holder
30
+ # @return [Mindee::Parsing::Standard::PositionField]
31
+ attr_reader :signature
32
+
33
+ # @param prediction [Hash]
34
+ # @param page_id [Integer, nil]
35
+ def initialize(prediction, page_id)
36
+ @photo = PositionField.new(prediction['photo'], page_id)
37
+ @signature = PositionField.new(prediction['signature'], page_id)
38
+ super(prediction, page_id)
39
+ end
40
+
41
+ # @return [String]
42
+ def to_s
43
+ out_str = String.new
44
+ out_str << "\n:Photo: #{@photo}".rstrip
45
+ out_str << "\n:Signature: #{@signature}".rstrip
46
+ out_str << "\n#{super}"
47
+ out_str
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -8,9 +8,10 @@ require_relative 'product/passport/passport_v1'
8
8
  require_relative 'product/receipt/receipt_v4'
9
9
  require_relative 'product/receipt/receipt_v5'
10
10
  require_relative 'product/eu/license_plate/license_plate_v1'
11
- require_relative 'product/us/bank_check/bank_check_v1'
12
11
  require_relative 'product/fr/bank_account_details/bank_account_details_v1'
13
12
  require_relative 'product/fr/bank_account_details/bank_account_details_v2'
14
13
  require_relative 'product/fr/carte_vitale/carte_vitale_v1'
15
14
  require_relative 'product/fr/id_card/id_card_v1'
16
15
  require_relative 'product/invoice_splitter/invoice_splitter_v1'
16
+ require_relative 'product/us/bank_check/bank_check_v1'
17
+ require_relative 'product/us/driver_license/driver_license_v1'
@@ -2,7 +2,7 @@
2
2
 
3
3
  # Mindee
4
4
  module Mindee
5
- VERSION = '3.0.0'
5
+ VERSION = '3.1.0'
6
6
 
7
7
  # @return [String]
8
8
  def self.find_platform
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mindee
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mindee, SA
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-29 00:00:00.000000000 Z
11
+ date: 2023-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: marcel
@@ -132,6 +132,7 @@ files:
132
132
  - docs/code_samples/license_plates_v1.txt
133
133
  - docs/code_samples/passport_v1.txt
134
134
  - docs/code_samples/proof_of_address_v1.txt
135
+ - docs/code_samples/us_driver_license_v1.txt
135
136
  - docs/ruby-api-builder.md
136
137
  - docs/ruby-getting-started.md
137
138
  - docs/ruby-invoice-ocr.md
@@ -227,6 +228,9 @@ files:
227
228
  - lib/mindee/product/us/bank_check/bank_check_v1.rb
228
229
  - lib/mindee/product/us/bank_check/bank_check_v1_document.rb
229
230
  - lib/mindee/product/us/bank_check/bank_check_v1_page.rb
231
+ - lib/mindee/product/us/driver_license/driver_license_v1.rb
232
+ - lib/mindee/product/us/driver_license/driver_license_v1_document.rb
233
+ - lib/mindee/product/us/driver_license/driver_license_v1_page.rb
230
234
  - lib/mindee/version.rb
231
235
  - mindee.gemspec
232
236
  homepage: https://github.com/mindee/mindee-api-ruby