mindee 3.2.0 → 3.3.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 (35) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +1 -0
  4. data/CHANGELOG.md +10 -0
  5. data/bin/mindee.rb +1 -1
  6. data/docs/barcode_reader_v1.md +2 -2
  7. data/docs/carte_grise_v1.md +454 -0
  8. data/docs/code_samples/carte_grise_v1.txt +19 -0
  9. data/docs/cropper_v1.md +1 -1
  10. data/docs/custom_v1.md +9 -1
  11. data/docs/expense_receipts_v5.md +1 -1
  12. data/docs/financial_document_v1.md +6 -6
  13. data/docs/invoices_v4.md +68 -99
  14. data/docs/multi_receipts_detector_v1.md +1 -1
  15. data/docs/us_w9_v1.md +3 -3
  16. data/lib/mindee/http/endpoint.rb +5 -1
  17. data/lib/mindee/http/error.rb +1 -1
  18. data/lib/mindee/parsing/common/api_response.rb +3 -2
  19. data/lib/mindee/parsing/common/document.rb +4 -1
  20. data/lib/mindee/parsing/custom/list_field.rb +7 -5
  21. data/lib/mindee/parsing/standard/base_field.rb +1 -1
  22. data/lib/mindee/product/financial_document/financial_document_v1_document.rb +2 -2
  23. data/lib/mindee/product/fr/carte_grise/carte_grise_v1.rb +39 -0
  24. data/lib/mindee/product/fr/carte_grise/carte_grise_v1_document.rb +235 -0
  25. data/lib/mindee/product/fr/carte_grise/carte_grise_v1_page.rb +34 -0
  26. data/lib/mindee/product/invoice/invoice_v4.rb +1 -2
  27. data/lib/mindee/product/invoice/invoice_v4_document.rb +105 -145
  28. data/lib/mindee/product/invoice/invoice_v4_line_item.rb +54 -30
  29. data/lib/mindee/product/us/w9/w9_v1.rb +2 -2
  30. data/lib/mindee/product/us/w9/w9_v1_document.rb +1 -1
  31. data/lib/mindee/product/us/w9/w9_v1_page.rb +2 -2
  32. data/lib/mindee/product.rb +1 -0
  33. data/lib/mindee/version.rb +1 -1
  34. data/lib/mindee.rb +0 -3
  35. metadata +7 -2
data/docs/invoices_v4.md CHANGED
@@ -34,123 +34,84 @@ puts result.document
34
34
  ########
35
35
  Document
36
36
  ########
37
- :Mindee ID: 656c2ec1-0920-4556-9bc2-772162bc698a
38
- :Filename: invoice.pdf
37
+ :Mindee ID: 16bd8752-8c4d-450f-8213-f33b2097504c
38
+ :Filename: default_sample.jpg
39
39
 
40
40
  Inference
41
41
  #########
42
- :Product: mindee/invoices v4.1
42
+ :Product: mindee/invoices v4.2
43
43
  :Rotation applied: Yes
44
44
 
45
45
  Prediction
46
46
  ==========
47
- :Locale: fr; fr; EUR;
48
- :Document type: INVOICE
49
- :Invoice number: 0042004801351
50
- :Reference numbers: AD29094
51
- :Invoice date: 2020-02-17
52
- :Invoice due date: 2020-02-17
53
- :Supplier name: TURNPIKE DESIGNS CO.
54
- :Supplier address: 156 University Ave, Toronto ON, Canada M5H 2H7
55
- :Supplier company registrations: 501124705; FR33501124705
56
- :Supplier payment details: FR7640254025476501124705368;
57
- :Customer name: JIRO DOI
58
- :Customer address: 1954 Bloon Street West Toronto, ON, M6P 3K9 Canada
59
- :Customer company registrations: FR00000000000; 111222333
47
+ :Locale: en; en; CAD;
48
+ :Invoice Number: 14
49
+ :Reference Numbers: AD29094
50
+ :Purchase Date: 2018-09-25
51
+ :Due Date: 2018-09-25
52
+ :Total Net:
53
+ :Total Amount: 2608.20
60
54
  :Taxes:
61
55
  +---------------+--------+----------+---------------+
62
56
  | Base | Code | Rate (%) | Amount |
63
57
  +===============+========+==========+===============+
64
- | | | 20.00 | 97.98 |
58
+ | | | 8.00 | 193.20 |
65
59
  +---------------+--------+----------+---------------+
66
- :Total net: 489.97
67
- :Total tax: 97.98
68
- :Total amount: 587.95
60
+ :Supplier Payment Details:
61
+ :Supplier Name: TURNPIKE DESIGNS CO.
62
+ :Supplier Company Registrations:
63
+ :Supplier Address: 156 University Ave, Toronto ON, Canada M5H 2H7
64
+ :Customer Name: JIRO DOI
65
+ :Customer Company Registrations:
66
+ :Customer Address: 1954 Bloor Street West Toronto, ON, M6P 3K9 Canada
67
+ :Document Type: INVOICE
69
68
  :Line Items:
70
- +----------------------+---------+---------+----------+------------------+--------------------------------------+
71
- | Code | QTY | Price | Amount | Tax (Rate) | Description |
72
- +======================+=========+=========+==========+==================+======================================+
73
- | | | | 4.31 | (2.10%) | PQ20 ETIQ ULTRA RESIS METAXXDC |
74
- +----------------------+---------+---------+----------+------------------+--------------------------------------+
75
- | | 1.00 | 65.00 | 75.00 | 10.00 | Platinum web hosting package Down... |
76
- +----------------------+---------+---------+----------+------------------+--------------------------------------+
77
- | XXX81125600010 | 1.00 | 250.01 | 275.51 | 25.50 (10.20%) | a long string describing the item |
78
- +----------------------+---------+---------+----------+------------------+--------------------------------------+
79
- | ABC456 | 200.30 | 8.101 | 1622.63 | 121.70 (7.50%) | Liquid perfection |
80
- +----------------------+---------+---------+----------+------------------+--------------------------------------+
81
- | | | | | | CARTOUCHE L NR BROTHER TN247BK |
82
- +----------------------+---------+---------+----------+------------------+--------------------------------------+
69
+ +--------------------------------------+--------------+----------+------------+--------------+--------------+------------+
70
+ | Description | Product code | Quantity | Tax Amount | Tax Rate (%) | Total Amount | Unit Price |
71
+ +======================================+==============+==========+============+==============+==============+============+
72
+ | Platinum web hosting package Down... | | 1.00 | | | 65.00 | 65.00 |
73
+ +--------------------------------------+--------------+----------+------------+--------------+--------------+------------+
74
+ | 2 page website design Includes ba... | | 3.00 | | | 2100.00 | 2100.00 |
75
+ +--------------------------------------+--------------+----------+------------+--------------+--------------+------------+
76
+ | Mobile designs Includes responsiv... | | 1.00 | | | 250.00 | 250.00 |
77
+ +--------------------------------------+--------------+----------+------------+--------------+--------------+------------+
83
78
 
84
79
  Page Predictions
85
80
  ================
86
81
 
87
82
  Page 0
88
83
  ------
89
- :Locale: fr; fr; EUR;
90
- :Document type: INVOICE
91
- :Invoice number: 0042004801351
92
- :Reference numbers:
93
- :Invoice date: 2020-02-17
94
- :Invoice due date: 2020-02-17
95
- :Supplier name:
96
- :Supplier address:
97
- :Supplier company registrations: 501124705; FR33501124705
98
- :Supplier payment details: FR7640254025476501124705368;
99
- :Customer name:
100
- :Customer address:
101
- :Customer company registrations:
102
- :Taxes:
103
- +---------------+--------+----------+---------------+
104
- | Base | Code | Rate (%) | Amount |
105
- +===============+========+==========+===============+
106
- | | | 20.00 | 97.98 |
107
- +---------------+--------+----------+---------------+
108
- :Total net: 489.97
109
- :Total tax: 97.98
110
- :Total amount: 587.95
111
- :Line Items:
112
- +----------------------+---------+---------+----------+------------------+--------------------------------------+
113
- | Code | QTY | Price | Amount | Tax (Rate) | Description |
114
- +======================+=========+=========+==========+==================+======================================+
115
- | | | | 4.31 | (2.10%) | PQ20 ETIQ ULTRA RESIS METAXXDC |
116
- +----------------------+---------+---------+----------+------------------+--------------------------------------+
117
- | | 1.00 | 65.00 | 75.00 | 10.00 | Platinum web hosting package Down... |
118
- +----------------------+---------+---------+----------+------------------+--------------------------------------+
119
-
120
- Page 1
121
- ------
122
- :Locale: fr; fr; EUR;
123
- :Document type: INVOICE
124
- :Invoice number:
125
- :Reference numbers: AD29094
126
- :Invoice date:
127
- :Invoice due date: 2020-02-17
128
- :Supplier name: TURNPIKE DESIGNS CO.
129
- :Supplier address: 156 University Ave, Toronto ON, Canada M5H 2H7
130
- :Supplier company registrations:
131
- :Supplier payment details:
132
- :Customer name: JIRO DOI
133
- :Customer address: 1954 Bloon Street West Toronto, ON, M6P 3K9 Canada
134
- :Customer company registrations:
84
+ :Locale: en; en; CAD;
85
+ :Invoice Number: 14
86
+ :Reference Numbers: AD29094
87
+ :Purchase Date: 2018-09-25
88
+ :Due Date: 2018-09-25
89
+ :Total Net:
90
+ :Total Amount: 2608.20
135
91
  :Taxes:
136
92
  +---------------+--------+----------+---------------+
137
93
  | Base | Code | Rate (%) | Amount |
138
94
  +===============+========+==========+===============+
139
95
  | | | 8.00 | 193.20 |
140
96
  +---------------+--------+----------+---------------+
141
- :Total net:
142
- :Total tax: 193.20
143
- :Total amount: 2608.20
97
+ :Supplier Payment Details:
98
+ :Supplier Name: TURNPIKE DESIGNS CO.
99
+ :Supplier Company Registrations:
100
+ :Supplier Address: 156 University Ave, Toronto ON, Canada M5H 2H7
101
+ :Customer Name: JIRO DOI
102
+ :Customer Company Registrations:
103
+ :Customer Address: 1954 Bloor Street West Toronto, ON, M6P 3K9 Canada
104
+ :Document Type: INVOICE
144
105
  :Line Items:
145
- +----------------------+---------+---------+----------+------------------+--------------------------------------+
146
- | Code | QTY | Price | Amount | Tax (Rate) | Description |
147
- +======================+=========+=========+==========+==================+======================================+
148
- | XXX81125600010 | 1.00 | 250.00 | 250.00 | (10.00%) | a long string describing the item |
149
- +----------------------+---------+---------+----------+------------------+--------------------------------------+
150
- | ABC456 | 200.30 | 8.101 | 1622.63 | 121.70 (7.50%) | Liquid perfection |
151
- +----------------------+---------+---------+----------+------------------+--------------------------------------+
152
- | | | | | | CARTOUCHE L NR BROTHER TN247BK |
153
- +----------------------+---------+---------+----------+------------------+--------------------------------------+
106
+ +--------------------------------------+--------------+----------+------------+--------------+--------------+------------+
107
+ | Description | Product code | Quantity | Tax Amount | Tax Rate (%) | Total Amount | Unit Price |
108
+ +======================================+==============+==========+============+==============+==============+============+
109
+ | Platinum web hosting package Down... | | 1.00 | | | 65.00 | 65.00 |
110
+ +--------------------------------------+--------------+----------+------------+--------------+--------------+------------+
111
+ | 2 page website design Includes ba... | | 3.00 | | | 2100.00 | 2100.00 |
112
+ +--------------------------------------+--------------+----------+------------+--------------+--------------+------------+
113
+ | Mobile designs Includes responsiv... | | 1.00 | | | 250.00 | 250.00 |
114
+ +--------------------------------------+--------------+----------+------------+--------------+--------------+------------+
154
115
  ```
155
116
 
156
117
  # Field Types
@@ -199,6 +160,14 @@ The locale field `LocaleField` only implements the **value**, **confidence** and
199
160
  * **country** (`String`): ISO 3166-1 alpha-2 or ISO 3166-1 alpha-3 code for countries (e.g.: `GRB` or `GB` for "Great Britain"). Can be `nil`.
200
161
  * **currency** (`String`): ISO 4217 code for currencies (e.g.: `USD` for "US Dollars"). Can be `nil`.
201
162
 
163
+ ### Payment Details Field
164
+ Aside from the basic `Field` attributes, the payment details field `PaymentDetailsField` also implements the following:
165
+
166
+ * **account_number** (`String`): number of an account, expressed as a string. Can be `nil`.
167
+ * **iban** (`String`): International Bank Account Number. Can be `nil`.
168
+ * **routing_number** (`String`): routing number of an account. Can be `nil`.
169
+ * **swift** (`String`): the account holder's bank's SWIFT Business Identifier Code (BIC). Can be `nil`.
170
+
202
171
  ### String Field
203
172
  The text field `StringField` only has one constraint: it's **value** is a `String` (or `nil`).
204
173
 
@@ -206,7 +175,7 @@ The text field `StringField` only has one constraint: it's **value** is a `Strin
206
175
  #### Tax
207
176
  Aside from the basic `Field` attributes, the tax field `TaxField` also implements the following:
208
177
 
209
- * **rate** (`Float`): the tax rate applied to an item can be undefined. Expressed as a percentage. Can be `nil`.
178
+ * **rate** (`Float`): the tax rate applied to an item can be expressed as a percentage. Can be `nil`.
210
179
  * **code** (`String`): tax code (or equivalent, depending on the origin of the document). Can be `nil`.
211
180
  * **base** (`Float`): base amount used for the tax. Can be `nil`.
212
181
 
@@ -225,7 +194,7 @@ A `InvoiceV4LineItem` implements the following attributes:
225
194
 
226
195
  * `description` (String): The item description.
227
196
  * `product_code` (String): The product code referring to the item.
228
- * `quantity` (Integer): The item quantity
197
+ * `quantity` (Float): The item quantity
229
198
  * `tax_amount` (Float): The item tax amount.
230
199
  * `tax_rate` (Float): The item tax rate in percentage.
231
200
  * `total_amount` (Float): The item total amount.
@@ -235,7 +204,7 @@ A `InvoiceV4LineItem` implements the following attributes:
235
204
  The following fields are extracted for Invoice V4:
236
205
 
237
206
  ## Customer Address
238
- **customerAddress** ([StringField](#string-field)): The address of the customer.
207
+ **customer_address** ([StringField](#string-field)): The address of the customer.
239
208
 
240
209
  ```rb
241
210
  puts result.document.inference.prediction.customer_address.value
@@ -245,13 +214,13 @@ puts result.document.inference.prediction.customer_address.value
245
214
  **customer_company_registrations** (Array<[CompanyRegistrationField](#company-registration-field)>): List of company registrations associated to the customer.
246
215
 
247
216
  ```rb
248
- for customer_company_registration_elem in result.document.inference.prediction.customer_company_registration do
249
- puts customer_company_registration_elem.value
217
+ for customer_company_registrations_elem in result.document.inference.prediction.customer_company_registrations do
218
+ puts customer_company_registrations_elem.value
250
219
  end
251
220
  ```
252
221
 
253
222
  ## Customer Name
254
- **customer_name** ([StringField](#string-field)): The name of the customer.
223
+ **customer_name** ([StringField](#string-field)): The name of the customer or client.
255
224
 
256
225
  ```rb
257
226
  puts result.document.inference.prediction.customer_name.value
@@ -314,7 +283,7 @@ end
314
283
  **supplier_address** ([StringField](#string-field)): The address of the supplier or merchant.
315
284
 
316
285
  ```rb
317
- result.document.inference.prediction.supplier_address.value
286
+ puts result.document.inference.prediction.supplier_address.value
318
287
  ```
319
288
 
320
289
  ## Supplier Company Registrations
@@ -343,7 +312,7 @@ end
343
312
  ```
344
313
 
345
314
  ## Taxes
346
- **taxes** (Array<[TaxField](#taxes-field)>): List of tax lines information.
315
+ **taxes** (Array<[TaxField](#taxes-field)>): List of tax line details.
347
316
 
348
317
  ```rb
349
318
  for taxes_elem in result.document.inference.prediction.taxes do
@@ -1,5 +1,5 @@
1
1
  ---
2
- title: Multi Receipts Detector API Ruby
2
+ title: Multi Receipts Detector OCR Ruby
3
3
  ---
4
4
  The Ruby OCR SDK supports the [Multi Receipts Detector API](https://platform.mindee.com/mindee/multi_receipts_detector).
5
5
 
data/docs/us_w9_v1.md CHANGED
@@ -1,10 +1,10 @@
1
1
  ---
2
2
  title: US W9 OCR Ruby
3
3
  ---
4
- The Ruby OCR SDK supports the [US W9 API](https://platform.mindee.com/mindee/us_w9).
4
+ The Ruby OCR SDK supports the [W9 API](https://platform.mindee.com/mindee/us_w9).
5
5
 
6
6
  Using the [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/us_w9/default_sample.jpg), we are going to illustrate how to extract the data that we want using the OCR SDK.
7
- ![US W9 sample](https://github.com/mindee/client-lib-test-data/blob/main/products/us_w9/default_sample.jpg?raw=true)
7
+ ![W9 sample](https://github.com/mindee/client-lib-test-data/blob/main/products/us_w9/default_sample.jpg?raw=true)
8
8
 
9
9
  # Quick-Start
10
10
  ```rb
@@ -93,7 +93,7 @@ The text field `StringField` only has one constraint: it's **value** is a `Strin
93
93
  Some fields are constrained to the page level, and so will not be retrievable to through the document.
94
94
 
95
95
  # Attributes
96
- The following fields are extracted for US W9 V1:
96
+ The following fields are extracted for W9 V1:
97
97
 
98
98
  ## Address
99
99
  [📄](#page-level-fields "This field is only present on individual pages.")**address** ([StringField](#string-field)): The street address (number, street, and apt. or suite no.) of the applicant.
@@ -31,6 +31,8 @@ module Mindee
31
31
  attr_reader :api_key
32
32
  # @return [Integer]
33
33
  attr_reader :request_timeout
34
+ # @return [String]
35
+ attr_reader :url_root
34
36
 
35
37
  def initialize(owner, url_name, version, api_key: '')
36
38
  @owner = owner
@@ -38,7 +40,8 @@ module Mindee
38
40
  @version = version
39
41
  @request_timeout = ENV.fetch(REQUEST_TIMEOUT_ENV_NAME, TIMEOUT_DEFAULT).to_i
40
42
  @api_key = api_key.nil? || api_key.empty? ? ENV.fetch(API_KEY_ENV_NAME, API_KEY_DEFAULT) : api_key
41
- @url_root = "#{BASE_URL_DEFAULT}/products/#{@owner}/#{@url_name}/v#{@version}"
43
+ base_url = ENV.fetch(BASE_URL_ENV_NAME, BASE_URL_DEFAULT)
44
+ @url_root = "#{base_url.chomp('/')}/products/#{@owner}/#{@url_name}/v#{@version}"
42
45
  end
43
46
 
44
47
  # Call the prediction API.
@@ -174,6 +177,7 @@ module Mindee
174
177
  response
175
178
  end
176
179
 
180
+ # Checks API key
177
181
  def check_api_key
178
182
  return unless @api_key.nil? || @api_key.empty?
179
183
 
@@ -73,7 +73,7 @@ module Mindee
73
73
  class MindeeHttpError < StandardError
74
74
  # @return [String]
75
75
  attr_reader :status_code
76
- # @return [String]
76
+ # @return [Integer]
77
77
  attr_reader :api_code
78
78
  # @return [String]
79
79
  attr_reader :api_details
@@ -95,13 +95,14 @@ module Mindee
95
95
  attr_reader :job
96
96
  # @return [Mindee::Parsing::Common::ApiRequest]
97
97
  attr_reader :api_request
98
- # @return [String]
98
+ # @return [Hash]
99
99
  attr_reader :raw_http
100
100
 
101
101
  # @param product_class [Class<Mindee::Product>]
102
102
  # @param http_response [Hash]
103
+ # @param raw_http [String]
103
104
  def initialize(product_class, http_response, raw_http)
104
- @raw_http = raw_http
105
+ @raw_http = raw_http.to_s
105
106
  if http_response.key?('api_request')
106
107
  @api_request = Mindee::Parsing::Common::ApiRequest.new(http_response['api_request'])
107
108
  end
@@ -13,8 +13,10 @@ module Mindee
13
13
  attr_reader :name
14
14
  # @return [String] Mindee ID of the document
15
15
  attr_reader :id
16
- # @return [Mindee::Parsing::Common::Ocr::Ocr, nil]
16
+ # @return [Mindee::Parsing::Common::Ocr::Ocr, nil] OCR text results (limited availability)
17
17
  attr_reader :ocr
18
+ # @return [Integer] Amount of pages of the document
19
+ attr_reader :n_pages
18
20
 
19
21
  # @param http_response [Hash]
20
22
  # @return [Mindee::Parsing::Common::Ocr::Ocr]
@@ -32,6 +34,7 @@ module Mindee
32
34
  @name = http_response['name']
33
35
  @inference = product_class.new(http_response['inference'])
34
36
  @ocr = self.class.load_ocr(http_response)
37
+ @n_pages = http_response['n_pages']
35
38
  end
36
39
 
37
40
  # @return [String]
@@ -14,13 +14,16 @@ module Mindee
14
14
  attr_reader :polygon
15
15
  # @return [Array, Hash, String, nil]
16
16
  attr_reader :content
17
+ # @return [Integer, nil]
18
+ attr_reader :page_id
17
19
 
18
20
  # @param prediction [Hash]
19
- def initialize(prediction)
21
+ def initialize(prediction, page_id: nil)
20
22
  @content = prediction['content']
21
23
  @confidence = prediction['confidence']
22
24
  @polygon = Geometry.polygon_from_prediction(prediction['polygon'])
23
25
  @bounding_box = Geometry.get_bounding_box(@polygon) unless @polygon.nil? || @polygon.empty?
26
+ @page_id = page_id
24
27
  end
25
28
 
26
29
  # @return [String]
@@ -33,8 +36,6 @@ module Mindee
33
36
  class ListField
34
37
  # @return [Array<Mindee::Parsing::Custom::ListFieldItem>]
35
38
  attr_reader :values
36
- # @return [Integer, nil]
37
- attr_reader :page_id
38
39
  # true if the field was reconstructed or computed using other fields.
39
40
  # @return [Boolean]
40
41
  attr_reader :reconstructed
@@ -48,11 +49,12 @@ module Mindee
48
49
  def initialize(prediction, page_id, reconstructed: false)
49
50
  @values = []
50
51
  @confidence = prediction['confidence']
51
- @page_id = page_id || prediction['page_id']
52
+ page_id = prediction['page_id'] if page_id.nil? && prediction.include?('page_id')
52
53
  @reconstructed = reconstructed
53
54
 
54
55
  prediction['values'].each do |field|
55
- @values.push(ListFieldItem.new(field))
56
+ page_id = field['page_id'] if field.include?('page_id')
57
+ @values.push(ListFieldItem.new(field, page_id: page_id))
56
58
  end
57
59
  end
58
60
 
@@ -96,7 +96,7 @@ module Mindee
96
96
  return '' if in_str.nil?
97
97
  return in_str if max_col_size.nil?
98
98
 
99
- in_str.length < max_col_size ? in_str : "#{in_str[0..max_col_size - 3]}..."
99
+ in_str.length < max_col_size ? in_str : "#{in_str[0..max_col_size - 4]}..."
100
100
  end
101
101
  end
102
102
  end
@@ -140,11 +140,11 @@ module Mindee
140
140
  out_str << "\n:Total Amount: #{@total_amount}".rstrip
141
141
  out_str << "\n:Taxes:#{@taxes}".rstrip
142
142
  out_str << "\n:Supplier Payment Details: #{supplier_payment_details}".rstrip
143
- out_str << "\n:Supplier name: #{@supplier_name}".rstrip
143
+ out_str << "\n:Supplier Name: #{@supplier_name}".rstrip
144
144
  out_str << "\n:Supplier Company Registrations: #{supplier_company_registrations}".rstrip
145
145
  out_str << "\n:Supplier Address: #{@supplier_address}".rstrip
146
146
  out_str << "\n:Supplier Phone Number: #{@supplier_phone_number}".rstrip
147
- out_str << "\n:Customer name: #{@customer_name}".rstrip
147
+ out_str << "\n:Customer Name: #{@customer_name}".rstrip
148
148
  out_str << "\n:Customer Company Registrations: #{customer_company_registrations}".rstrip
149
149
  out_str << "\n:Customer Address: #{@customer_address}".rstrip
150
150
  out_str << "\n:Document Type: #{@document_type}".rstrip
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../parsing'
4
+ require_relative 'carte_grise_v1_document'
5
+ require_relative 'carte_grise_v1_page'
6
+
7
+ module Mindee
8
+ module Product
9
+ module FR
10
+ # Carte Grise module.
11
+ module CarteGrise
12
+ # Carte Grise V1 prediction inference.
13
+ class CarteGriseV1 < Mindee::Parsing::Common::Inference
14
+ @endpoint_name = 'carte_grise'
15
+ @endpoint_version = '1'
16
+
17
+ # @param prediction [Hash]
18
+ def initialize(prediction)
19
+ super
20
+ @prediction = CarteGriseV1Document.new(prediction['prediction'], nil)
21
+ @pages = []
22
+ prediction['pages'].each do |page|
23
+ @pages.push(CarteGriseV1Page.new(page))
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
39
+ end