mindee 4.7.1 → 4.8.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 (69) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +13 -0
  3. data/README.md +6 -6
  4. data/Rakefile +1 -0
  5. data/lib/mindee/errors/mindee_http_error_v2.rb +23 -4
  6. data/lib/mindee/errors/mindee_http_unknown_error_v2.rb +18 -0
  7. data/lib/mindee/http/endpoint.rb +1 -0
  8. data/lib/mindee/input/sources/local_input_source.rb +9 -1
  9. data/lib/mindee/parsing/v2/error_item.rb +21 -0
  10. data/lib/mindee/parsing/v2/error_response.rb +18 -3
  11. data/lib/mindee/parsing/v2/inference_result.rb +4 -0
  12. data/lib/mindee/parsing/v2/rag_metadata.rb +17 -0
  13. data/lib/mindee/product.rb +0 -1
  14. data/lib/mindee/version.rb +1 -1
  15. data/mindee.gemspec +1 -0
  16. data/sig/mindee/errors/mindee_http_error_v2.rbs +4 -1
  17. data/sig/mindee/errors/mindee_http_unknown_error_v2.rbs +9 -0
  18. data/sig/mindee/http/endpoint.rbs +1 -0
  19. data/sig/mindee/input/sources/local_input_source.rbs +1 -1
  20. data/sig/mindee/parsing/v2/error_item.rbs +13 -0
  21. data/sig/mindee/parsing/v2/error_response.rbs +3 -0
  22. data/sig/mindee/parsing/v2/inference_result.rbs +1 -0
  23. data/sig/mindee/parsing/v2/rag_metadata.rbs +13 -0
  24. metadata +22 -47
  25. data/docs/advanced_file_operations.md +0 -109
  26. data/docs/code_samples/us_mail_v2_async.txt +0 -24
  27. data/docs/getting_started.md +0 -257
  28. data/docs/global_products/barcode_reader_v1.md +0 -125
  29. data/docs/global_products/bill_of_lading_v1.md +0 -276
  30. data/docs/global_products/business_card_v1.md +0 -194
  31. data/docs/global_products/cropper_v1.md +0 -123
  32. data/docs/global_products/delivery_notes_v1.md +0 -168
  33. data/docs/global_products/driver_license_v1.md +0 -212
  34. data/docs/global_products/expense_receipts_v5.md +0 -415
  35. data/docs/global_products/financial_document_v1.md +0 -615
  36. data/docs/global_products/international_id_v2.md +0 -264
  37. data/docs/global_products/invoice_splitter_v1.md +0 -127
  38. data/docs/global_products/invoices_v4.md +0 -576
  39. data/docs/global_products/multi_receipts_detector_v1.md +0 -131
  40. data/docs/global_products/nutrition_facts_v1.md +0 -399
  41. data/docs/global_products/passport_v1.md +0 -207
  42. data/docs/global_products/resume_v1.md +0 -384
  43. data/docs/global_products/universal.md +0 -113
  44. data/docs/global_products.md +0 -6
  45. data/docs/loading_a_document.md +0 -330
  46. data/docs/localized_products/bank_account_details_v2.md +0 -158
  47. data/docs/localized_products/bank_check_v1.md +0 -205
  48. data/docs/localized_products/bank_statement_fr_v2.md +0 -269
  49. data/docs/localized_products/carte_grise_v1.md +0 -475
  50. data/docs/localized_products/energy_bill_fra_v1.md +0 -342
  51. data/docs/localized_products/french_healthcard_v1.md +0 -142
  52. data/docs/localized_products/idcard_fr_v2.md +0 -284
  53. data/docs/localized_products/ind_passport_v1.md +0 -307
  54. data/docs/localized_products/payslip_fra_v3.md +0 -344
  55. data/docs/localized_products/us_healthcare_cards_v1.md +0 -258
  56. data/docs/localized_products/us_mail_v3.md +0 -152
  57. data/docs/localized_products.md +0 -6
  58. data/lib/mindee/product/us/us_mail/us_mail_v2.rb +0 -47
  59. data/lib/mindee/product/us/us_mail/us_mail_v2_document.rb +0 -105
  60. data/lib/mindee/product/us/us_mail/us_mail_v2_page.rb +0 -38
  61. data/lib/mindee/product/us/us_mail/us_mail_v2_recipient_address.rb +0 -105
  62. data/lib/mindee/product/us/us_mail/us_mail_v2_recipient_addresses.rb +0 -63
  63. data/lib/mindee/product/us/us_mail/us_mail_v2_sender_address.rb +0 -66
  64. data/sig/mindee/product/us/us_mail/us_mail_v2.rbs +0 -13
  65. data/sig/mindee/product/us/us_mail/us_mail_v2_document.rbs +0 -20
  66. data/sig/mindee/product/us/us_mail/us_mail_v2_page.rbs +0 -17
  67. data/sig/mindee/product/us/us_mail/us_mail_v2_recipient_address.rbs +0 -22
  68. data/sig/mindee/product/us/us_mail/us_mail_v2_recipient_addresses.rbs +0 -15
  69. data/sig/mindee/product/us/us_mail/us_mail_v2_sender_address.rbs +0 -18
@@ -1,330 +0,0 @@
1
- ---
2
- title: Document Loading
3
- category: 622b805aaec68102ea7fcbc2
4
- slug: ruby-document-loading
5
- parentDoc: 6294d97ee723f1008d2ab28e
6
- ---
7
-
8
- ## Calling the Mindee API using webhooks
9
-
10
- > 🚧 This feature is only available for compatible products.
11
- >
12
- > See the `Supports Polling/Webhooks` section on the product's documentation.
13
-
14
- After [setting up a webhook for your account](https://developers.mindee.com/docs/webhooks), you can send a document,
15
- and then retrieve the results from an API call in the following fashion:
16
-
17
- ```rb
18
- # Load a file from disk
19
- input_source = mindee_client.source_from_path('/path/to/the/file.ext')
20
-
21
- # Send the file to the server
22
- enqueue_response = mindee_client.enqueue(
23
- input_source,
24
- Mindee::Product::Receipt::ReceiptV5 # ReceiptV5 supports asynchronous polling
25
- )
26
- ```
27
-
28
- Once your prediction is ready, the server will send it to your webhook. You can then use the payload as a regular
29
- prediction:
30
-
31
- ```rb
32
- # Load the JSON string sent by the Mindee webhook POST callback.
33
- # Reading the callback data will vary greatly depending on your HTTP server.
34
- # This is therefore beyond the scope of this example.
35
-
36
- local_response = Mindee::Input::LocalResponse.new(request.body.string)
37
-
38
- # You can also use a File object as the input.
39
- # FILE_PATH = File.join('path', 'to', 'file.json').freeze
40
- # local_response = Mindee::Input::LocalResponse.new(FILE_PATH);
41
-
42
- # Optional: verify the HMAC signature.
43
- unless local_response.valid_hmac_signature?(my_secret_key, 'invalid signature')
44
- raise "Invalid HMAC signature!"
45
- end
46
-
47
-
48
- # Deserialize the response:
49
- result = mindee_client.load_prediction(
50
- Mindee::Product::Receipt::ReceiptV5, # The prediction type must match the initial enqueuing to work properly.
51
- local_response
52
- )
53
-
54
- # Print a summary of the parsed data in RST format
55
- puts result.document
56
- ```
57
-
58
- ## Parsing operations
59
-
60
- Operations pertaining to the Client's `parse()` method.
61
- The parsing process supports both synchronous and asynchronous modes, and you can fine-tune its behavior using several options.
62
-
63
- ### Polling options
64
-
65
- When performing an asynchronous parse (i.e. when the document is enqueued), the client will poll the API for the result.
66
- The following options control the polling behavior:
67
-
68
- * `initial_delay_sec`: The initial delay (in seconds) before the first polling attempt.
69
- * `delay_sec`: The delay (in seconds) between subsequent polls.
70
- * `max_retries`: The maximum number of polling attempts before timing out.
71
-
72
- These parameters ensure that the client does not overload the API with too-frequent requests and also avoid premature
73
- timeouts.
74
-
75
- Example:
76
-
77
- ```rb
78
- result = mindee_client.parse(
79
- input_source,
80
- Mindee::Product::Invoice::InvoiceV4,
81
- options: {
82
- initial_delay_sec: 2, # Wait 2 seconds before the first poll.
83
- delay_sec: 1.5, # Wait 1.5 seconds between polls.
84
- max_retries: 80 # Try polling a maximum of 80 times.
85
- }
86
- )
87
- ```
88
-
89
- > ⚠️ Warning: Setting `delay_sec` too low might lead to insufficient wait time between polls.
90
- >
91
- > This will cause the server to block your API calls for a short time (HTTP 429 errors).
92
-
93
- ### Page operations
94
-
95
- When parsing PDFs, you can preprocess the document using page operations.
96
- Using the `page_options` parameter, you can specify which pages to keep or remove even before the file is sent to the server.
97
- This is especially useful if your document contains extraneous pages that you do not want to process.
98
-
99
- The available options are:
100
-
101
- * `page_indexes`: An array of zero-based page indexes.
102
- * `operation`: The operation to perform—either:
103
- * `:KEEP_ONLY` (keep only the specified pages)
104
- * `:REMOVE` (remove the specified pages).
105
- * `on_min_pages`: Apply the operation only if the document has at least the specified number of pages.
106
-
107
- Example:
108
-
109
- ```rb
110
- page_options = {
111
- page_indexes:[1, 3], # Only target pages 1 and 3.
112
- operation: :KEEP_ONLY, # Remove all other pages.
113
- on_min_pages: 3 # Only apply if the document has at least 3 pages.
114
- }
115
-
116
- result = mindee_client.parse(
117
- input_source,
118
- Mindee::Product::Invoice::InvoiceV4,
119
- options: {
120
- page_options: page_options
121
- }
122
- )
123
- ```
124
-
125
- > ⚠️ Warning: Page operations alter the document's content.
126
- >
127
- > Ensure that this behavior is acceptable for your use case, as there is no undo once the pages are modified.
128
-
129
- ## Workflow operations
130
-
131
- Workflow operations are similar to parsing operations, but they apply to calls made through the workflow feature.
132
-
133
- Example:
134
-
135
- ```rb
136
- workflow_options = {
137
- document_alias: "my_document",
138
- priority: :high,
139
- page_options: {
140
- page_indexes:[0, 1],
141
- operation: :REMOVE
142
- }
143
- }
144
-
145
- result = mindee_client.execute_workflow(
146
- input_source,
147
- "workflow_id",
148
- options: workflow_options
149
- )
150
- ```
151
-
152
- ## Enqueueing and polling manually
153
-
154
- > ❗️ We _strongly_ recommend you use a webhook setup, or a simple`parse()` call for most operations.
155
- >
156
- > Only use manual polling if you are **certain** that it is the best solution for you.
157
-
158
- > 🚧 This feature is only available for compatible products.
159
- >
160
- > See the `Supports Polling/Webhooks` section on the product's documentation.
161
-
162
- Instead of relying on the `parse()` method, you can enqueue documents and poll
163
- the server manually:
164
-
165
- ```rb
166
- # Load a file from disk
167
- input_source = mindee_client.source_from_path('/path/to/the/file.ext')
168
-
169
- # Send the file to the server
170
- enqueue_response = mindee_client.enqueue(
171
- input_source,
172
- Mindee::Product::Invoice::InvoiceV4 # InvoiceV4 supports asynchronous polling
173
- )
174
-
175
- job_id = enqueue_response.job.id
176
-
177
- queue_res = parse_queued(job_id, Mindee::Product::Invoice::InvoiceV4, endpoint: endpoint)
178
- polling_attempts = 0
179
-
180
- while [Mindee::Parsing::Common::JobStatus::PROCESSING, Mindee::Parsing::Common::JobStatus::WAITING].include?(
181
- queue_res.job.status) && polling_attempts < 80 # Recommended amounts of total retries for asynchronous polling.
182
- sleep(1.5) # Recommended waiting time for re-attempts
183
- queue_res = parse_queued(job_id, Mindee::Product::Invoice::InvoiceV4)
184
- polling_attempts += 1
185
- end
186
-
187
- # If all went well, print a short summary of the result.
188
- if queue_res.job.status == Mindee::Parsing::Common::JobStatus::COMPLETED
189
- puts queue_res.document
190
- end
191
- ```
192
-
193
- ## Loading a Document File
194
-
195
- Before sending a document to Mindee’s API, you first need to load the file into one of our input source wrappers.
196
- These wrappers not only validate the file type (using a trusted MIME type check) but also give you access the following helper methods:
197
-
198
- * [image compression](https://developers.mindee.com/docs/ruby-advanced-file-operations#image-compression)
199
- * [pdf compression](https://developers.mindee.com/docs/ruby-advanced-file-operations#pdf-compression)
200
- * [PDF fixing](https://developers.mindee.com/docs/ruby-advanced-file-operations#pdf-fixing)
201
-
202
- > 📘 Regardless of how a document is loaded, the subsequent parsing or workflow operations remain the same.
203
-
204
- Mindee’s Ruby client supports several methods for loading a document.
205
-
206
- These can either be done locally:
207
-
208
- * Loading from a [local path](#loading-from-a-local-path)
209
- * Loading from a [File object](#loading-from-a-file-object)
210
- * Loading from a [Base64-encoded string](#loading-from-a-base64-encoded-string)
211
- * Loading from a [raw sequence of bytes](#loading-from-raw-bytes)
212
-
213
- These four methods inherit from the `LocalInputSource` class, which provides a few common utility features described
214
- [here](#under-the-hood---local-input-source-details).
215
-
216
- Or loading from a [URL](#loading-by-url).
217
-
218
- ### Loading from a Local Path
219
-
220
- The most straightforward way of loading a document: load a file directly from disk by providing its path.
221
-
222
- Example:
223
-
224
- ```rb
225
- # Initialize the client.
226
- mindee_client = Mindee::Client.new(api_key: 'my-api-key')
227
-
228
- # Load a file from disk using its absolute path.
229
- input_source = mindee_client.source_from_path('/absolute/path/to/file.ext')
230
- ```
231
-
232
- ### Loading from a File Object
233
-
234
- When you already have an open file (in binary mode), you can pass it along with its original filename.
235
-
236
- Example:
237
-
238
- ```rb
239
- File.open('invoice.jpg', 'rb') do |file_obj|
240
- # Creating a local input source from the file object.
241
- input_source = mindee_client.source_from_file(file_obj, "invoice.jpg")
242
- # Parsing happens similarly.
243
- end
244
- ```
245
-
246
- ### Loading from a Base64-Encoded String
247
-
248
- For cases where you have file data encoded in Base64, load the document by providing the encoded string along with the
249
- original filename. This converts the Base64 string into a local input source for further processing.
250
-
251
- Example:
252
-
253
- ```rb
254
- b64_string = "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAgGBgcGB..." # Example dummy b64_string.
255
-
256
- input_source = mindee_client.source_from_b64string(b64_string, "receipt.jpg")
257
- ```
258
-
259
- ### Loading from Raw Bytes
260
-
261
- If you have the file’s raw binary data (as bytes), create an input source by passing the bytes and the original
262
- filename.
263
-
264
- Example:
265
-
266
- ```rb
267
- raw_bytes = b"%PDF-1.3\n%\xbf\xf7\xa2\xfe\n1 0 obj..." # Example dummy raw bytes sequence.
268
-
269
- input_source = mindee_client.source_from_bytes(raw_bytes, "invoice.pdf")
270
- ```
271
-
272
- ### Loading by URL
273
-
274
- For remote documents, you can load a file through its URL. The server will accept direct urls if:
275
-
276
- * They begin with "https\://".
277
- * They point to a valid file.
278
- * They do not redirect the request (e.g. Google Drive documents or proxies).
279
-
280
- Under the hood, the
281
- [Mindee::Input::Source::URLInputSource](https://mindee.github.io/mindee-api-ruby/Mindee/Input/Source/URLInputSource.html)
282
- class validates the URL, but won't perform an HTTP GET request unless specifically requested (using Ruby’s Net::HTTP).
283
-
284
- Example:
285
-
286
- ```rb
287
- input_source = mindee_client.source_from_url("https://www.example.com/invoice.pdf")
288
- result = mindee_client.parse(input_source, Mindee::Product::Invoice::InvoiceV4)
289
- ```
290
-
291
- To download the files before sending them, you can use the `as_local_input_source` method.
292
- It allows to follow redirects, and supports optional authentication (via basic auth or JWT tokens).
293
- You can optionally download and save the file locally or convert it into a local input source for further processing—thus benefiting from the same processing methods as local files.
294
-
295
- Additional URL features include:
296
-
297
- * Validation: The URLInputSource throws an error if the URL does not start with “https\://”.
298
- * Authentication: You can supply basic authentication (username/password) or a bearer token.
299
- * Local Conversion: Methods such as `write_to_file` let you download and inspect the file locally. Alternatively,
300
- * `as_local_input_source` converts the downloaded content into a LocalInputSource so you can apply operations like
301
- * compression.
302
-
303
- Example:
304
-
305
- ```rb
306
- # Load the URL input normally:
307
- remote_input_source = mindee_client.source_from_url("https://www.example.com/invoice.pdf")
308
-
309
- # Download the file and convert it to a `BytesInputSource` (type of `LocalInputSource`):
310
- local_input_source = remote_input_source.as_local_input_source(filename: 'my_downloaded_invoice.pdf')
311
-
312
- # Download the file and save it to the specified directory:
313
- local_downloaded_file_path = remote_input_source.write_to_file("path/to/my/downloaded/invoice.pdf")
314
- ```
315
-
316
- ### Under the Hood - Local Input Source Details
317
-
318
- When loading using from either a path, file, raw byte sequence or base64 string, the created object inherits from
319
- [Mindee::Input::Source::LocalInputSource](https://mindee.github.io/mindee-api-ruby/Mindee/Input/Source/LocalInputSource.html). Key features include:
320
-
321
- * Automatic MIME Type Validation using Marcel to check for server file format compliance.
322
- * An option ([repair_pdf](https://mindee.github.io/mindee-api-ruby/Mindee/Input/Source/LocalInputSource.html#initialize-instance_method)) to attempt recovery of PDFs with broken header information.
323
- * File Operations:
324
- * [compress!](https://mindee.github.io/mindee-api-ruby/Mindee/Input/Source/LocalInputSource.html#compress!-instance_method) – Compresses the file by invoking either the PDFCompressor for PDFs or the ImageCompressor for images. Parameters such as quality, max dimensions, and options to force or disable source text (for PDFs) are available.
325
- * `write_to_file` ([URLInputSource version](https://mindee.github.io/mindee-api-ruby/Mindee/Input/Source/URLInputSource.html#write_to_file-instance_method), [LocalInputSource version](https://mindee.github.io/mindee-api-ruby/Mindee/Input/Source/LocalInputSource.html#write_to_file-instance_method)) – Saves the current state of the input (after possible operations) to disk. This is handy for inspection before parsing.
326
- * [count_pages](https://mindee.github.io/mindee-api-ruby/Mindee/Input/Source/LocalInputSource.html#count_pages-instance_method) – For PDF files, returns the total page count; by default, non-PDF files are assumed to be single-page documents.
327
-
328
- ## Questions?
329
-
330
- [Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g)
@@ -1,158 +0,0 @@
1
- ---
2
- title: FR Bank Account Details
3
- category: 622b805aaec68102ea7fcbc2
4
- slug: ruby-fr-bank-account-details-ocr
5
- parentDoc: 67b49e29a2cd6f08d69a40d8
6
- ---
7
- The Ruby Client Library supports the [Bank Account Details API](https://platform.mindee.com/mindee/bank_account_details).
8
-
9
-
10
- > 📝 Product Specs
11
- >
12
- > | Specification | Details |
13
- > | ------------------------------ | -------------------------------------------------- |
14
- > | Endpoint Name | `bank_account_details` |
15
- > | Recommended Version | `v2.0` |
16
- > | Supports Polling/Webhooks | ❌ No |
17
- > | Support Synchronous HTTP Calls | ✔️ Yes |
18
- > | Geography | 🇫🇷 France |
19
-
20
-
21
- Using the [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/bank_account_details/default_sample.jpg),
22
- we are going to illustrate how to extract the data that we want using the Ruby Client Library.
23
- ![Bank Account Details sample](https://github.com/mindee/client-lib-test-data/blob/main/products/bank_account_details/default_sample.jpg?raw=true)
24
-
25
- # Quick-Start
26
- ```rb
27
- #
28
- # Install the Ruby client library by running:
29
- # gem install mindee
30
- #
31
-
32
- require 'mindee'
33
-
34
- # Init a new client
35
- mindee_client = Mindee::Client.new(api_key: 'my-api-key')
36
-
37
- # Load a file from disk
38
- input_source = mindee_client.source_from_path('/path/to/the/file.ext')
39
-
40
- # Parse the file
41
- result = mindee_client.parse(
42
- input_source,
43
- Mindee::Product::FR::BankAccountDetails::BankAccountDetailsV2
44
- )
45
-
46
- # Print a full summary of the parsed data in RST format
47
- puts result.document
48
-
49
- # Print the document-level parsed data
50
- # puts result.document.inference.prediction
51
- ```
52
-
53
- **Output (RST):**
54
- ```rst
55
- ########
56
- Document
57
- ########
58
- :Mindee ID: bc8f7265-8dab-49fe-810c-d50049605578
59
- :Filename: default_sample.jpg
60
-
61
- Inference
62
- #########
63
- :Product: mindee/bank_account_details v2.0
64
- :Rotation applied: Yes
65
-
66
- Prediction
67
- ==========
68
- :Account Holder's Names: MME HEGALALDIA L ENVOL
69
- :Basic Bank Account Number:
70
- :Bank Code: 13335
71
- :Branch Code: 00040
72
- :Key: 06
73
- :Account Number: 08932891361
74
- :IBAN: FR7613335000400893289136106
75
- :SWIFT Code: CEPAFRPP333
76
-
77
- Page Predictions
78
- ================
79
-
80
- Page 0
81
- ------
82
- :Account Holder's Names: MME HEGALALDIA L ENVOL
83
- :Basic Bank Account Number:
84
- :Bank Code: 13335
85
- :Branch Code: 00040
86
- :Key: 06
87
- :Account Number: 08932891361
88
- :IBAN: FR7613335000400893289136106
89
- :SWIFT Code: CEPAFRPP333
90
- ```
91
-
92
- # Field Types
93
- ## Standard Fields
94
- These fields are generic and used in several products.
95
-
96
- ### Basic Field
97
- Each prediction object contains a set of fields that inherit from the generic `Field` class.
98
- A typical `Field` object will have the following attributes:
99
-
100
- * **value** (`String`, `Float`, `Integer`, `bool`): corresponds to the field value. Can be `nil` if no value was extracted.
101
- * **confidence** (Float, nil): the confidence score of the field prediction.
102
- * **bounding_box** (`Mindee::Geometry::Quadrilateral`, `nil`): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document.
103
- * **polygon** (`Mindee::Geometry::Polygon`, `nil`): contains the relative vertices coordinates (`Point`) of a polygon containing the field in the image.
104
- * **page_id** (`Integer`, `nil`): the ID of the page, always `nil` when at document-level.
105
- * **reconstructed** (`bool`): indicates whether an object was reconstructed (not extracted as the API gave it).
106
-
107
-
108
- Aside from the previous attributes, all basic fields have access to a `to_s` method that can be used to print their value as a string.
109
-
110
- ### String Field
111
- The text field `StringField` only has one constraint: it's **value** is a `String` (or `nil`).
112
-
113
- ## Specific Fields
114
- Fields which are specific to this product; they are not used in any other product.
115
-
116
- ### Basic Bank Account Number Field
117
- Full extraction of BBAN, including: branch code, bank code, account and key.
118
-
119
- A `BankAccountDetailsV2Bban` implements the following attributes:
120
-
121
- * `bban_bank_code` (String): The BBAN bank code outputted as a string.
122
- * `bban_branch_code` (String): The BBAN branch code outputted as a string.
123
- * `bban_key` (String): The BBAN key outputted as a string.
124
- * `bban_number` (String): The BBAN Account number outputted as a string.
125
-
126
- # Attributes
127
- The following fields are extracted for Bank Account Details V2:
128
-
129
- ## Account Holder's Names
130
- **account_holders_names** ([StringField](#string-field)): Full extraction of the account holders names.
131
-
132
- ```rb
133
- puts result.document.inference.prediction.account_holders_names.value
134
- ```
135
-
136
- ## Basic Bank Account Number
137
- **bban** ([BankAccountDetailsV2Bban](#basic-bank-account-number-field)): Full extraction of BBAN, including: branch code, bank code, account and key.
138
-
139
- ```rb
140
- puts result.document.inference.prediction.bban.value
141
- ```
142
-
143
- ## IBAN
144
- **iban** ([StringField](#string-field)): Full extraction of the IBAN number.
145
-
146
- ```rb
147
- puts result.document.inference.prediction.iban.value
148
- ```
149
-
150
- ## SWIFT Code
151
- **swift_code** ([StringField](#string-field)): Full extraction of the SWIFT code.
152
-
153
- ```rb
154
- puts result.document.inference.prediction.swift_code.value
155
- ```
156
-
157
- # Questions?
158
- [Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g)
@@ -1,205 +0,0 @@
1
- ---
2
- title: US Bank Check
3
- category: 622b805aaec68102ea7fcbc2
4
- slug: ruby-us-bank-check-ocr
5
- parentDoc: 67b49e29a2cd6f08d69a40d8
6
- ---
7
- The Ruby Client Library supports the [Bank Check API](https://platform.mindee.com/mindee/bank_check).
8
-
9
-
10
- > 📝 Product Specs
11
- >
12
- > | Specification | Details |
13
- > | ------------------------------ | -------------------------------------------------- |
14
- > | Endpoint Name | `bank_check` |
15
- > | Recommended Version | `v1.1` |
16
- > | Supports Polling/Webhooks | ❌ No |
17
- > | Support Synchronous HTTP Calls | ✔️ Yes |
18
- > | Geography | 🇺🇸 United States |
19
-
20
-
21
- Using the [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/bank_check/default_sample.jpg),
22
- we are going to illustrate how to extract the data that we want using the Ruby Client Library.
23
- ![Bank Check sample](https://github.com/mindee/client-lib-test-data/blob/main/products/bank_check/default_sample.jpg?raw=true)
24
-
25
- # Quick-Start
26
- ```rb
27
- #
28
- # Install the Ruby client library by running:
29
- # gem install mindee
30
- #
31
-
32
- require 'mindee'
33
-
34
- # Init a new client
35
- mindee_client = Mindee::Client.new(api_key: 'my-api-key')
36
-
37
- # Load a file from disk
38
- input_source = mindee_client.source_from_path('/path/to/the/file.ext')
39
-
40
- # Parse the file
41
- result = mindee_client.parse(
42
- input_source,
43
- Mindee::Product::US::BankCheck::BankCheckV1
44
- )
45
-
46
- # Print a full summary of the parsed data in RST format
47
- puts result.document
48
-
49
- # Print the document-level parsed data
50
- # puts result.document.inference.prediction
51
- ```
52
-
53
- **Output (RST):**
54
- ```rst
55
- ########
56
- Document
57
- ########
58
- :Mindee ID: b9809586-57ae-4f84-a35d-a85b2be1f2a2
59
- :Filename: default_sample.jpg
60
-
61
- Inference
62
- #########
63
- :Product: mindee/bank_check v1.0
64
- :Rotation applied: Yes
65
-
66
- Prediction
67
- ==========
68
- :Check Issue Date: 2022-03-29
69
- :Amount: 15332.90
70
- :Payees: JOHN DOE
71
- JANE DOE
72
- :Routing Number:
73
- :Account Number: 7789778136
74
- :Check Number: 0003401
75
-
76
- Page Predictions
77
- ================
78
-
79
- Page 0
80
- ------
81
- :Check Position: Polygon with 21 points.
82
- :Signature Positions: Polygon with 6 points.
83
- :Check Issue Date: 2022-03-29
84
- :Amount: 15332.90
85
- :Payees: JOHN DOE
86
- JANE DOE
87
- :Routing Number:
88
- :Account Number: 7789778136
89
- :Check Number: 0003401
90
- ```
91
-
92
- # Field Types
93
- ## Standard Fields
94
- These fields are generic and used in several products.
95
-
96
- ### Basic Field
97
- Each prediction object contains a set of fields that inherit from the generic `Field` class.
98
- A typical `Field` object will have the following attributes:
99
-
100
- * **value** (`String`, `Float`, `Integer`, `bool`): corresponds to the field value. Can be `nil` if no value was extracted.
101
- * **confidence** (Float, nil): the confidence score of the field prediction.
102
- * **bounding_box** (`Mindee::Geometry::Quadrilateral`, `nil`): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document.
103
- * **polygon** (`Mindee::Geometry::Polygon`, `nil`): contains the relative vertices coordinates (`Point`) of a polygon containing the field in the image.
104
- * **page_id** (`Integer`, `nil`): the ID of the page, always `nil` when at document-level.
105
- * **reconstructed** (`bool`): indicates whether an object was reconstructed (not extracted as the API gave it).
106
-
107
-
108
- Aside from the previous attributes, all basic fields have access to a `to_s` method that can be used to print their value as a string.
109
-
110
-
111
- ### Amount Field
112
- The amount field `AmountField` only has one constraint: its **value** is a `Float` (or `nil`).
113
-
114
- ### Date Field
115
- Aside from the basic `Field` attributes, the date field `DateField` also implements the following:
116
-
117
- * **date_object** (`Date`): an accessible representation of the value as a JavaScript object.
118
-
119
-
120
- ### Position Field
121
- The position field `PositionField` does not implement all the basic `Field` attributes, only **bounding_box**,
122
- **polygon** and **page_id**. On top of these, it has access to:
123
-
124
- * **rectangle** (`Mindee::Geometry::Quadrilateral`): a Polygon with four points that may be oriented (even beyond
125
- canvas).
126
- * **quadrangle** (`Mindee::Geometry::Quadrilateral`): a free polygon made up of four points.
127
-
128
- ### String Field
129
- The text field `StringField` only has one constraint: it's **value** is a `String` (or `nil`).
130
-
131
- ## Page-Level Fields
132
- Some fields are constrained to the page level, and so will not be retrievable at document level.
133
-
134
- # Attributes
135
- The following fields are extracted for Bank Check V1:
136
-
137
- ## Account Number
138
- **account_number** ([StringField](#string-field)): The check payer's account number.
139
-
140
- ```rb
141
- puts result.document.inference.prediction.account_number.value
142
- ```
143
-
144
- ## Amount
145
- **amount** ([AmountField](#amount-field)): The amount of the check.
146
-
147
- ```rb
148
- puts result.document.inference.prediction.amount.value
149
- ```
150
-
151
- ## Check Number
152
- **check_number** ([StringField](#string-field)): The issuer's check number.
153
-
154
- ```rb
155
- puts result.document.inference.prediction.check_number.value
156
- ```
157
-
158
- ## Check Position
159
- [📄](#page-level-fields "This field is only present on individual pages.")**check_position** ([PositionField](#position-field)): The position of the check on the document.
160
-
161
- ```rb
162
- result.document.check_position.each do |check_position_elem|
163
- puts check_position_elem.polygon
164
- end
165
- ```
166
-
167
- ## Check Issue Date
168
- **date** ([DateField](#date-field)): The date the check was issued.
169
-
170
- ```rb
171
- puts result.document.inference.prediction.date.value
172
- ```
173
-
174
- ## Payees
175
- **payees** (Array<[StringField](#string-field)>): List of the check's payees (recipients).
176
-
177
- ```rb
178
- result.document.inference.prediction.payees do |payees_elem|
179
- puts payees_elem.value
180
- end
181
- ```
182
-
183
- ## Routing Number
184
- **routing_number** ([StringField](#string-field)): The check issuer's routing number.
185
-
186
- ```rb
187
- puts result.document.inference.prediction.routing_number.value
188
- ```
189
-
190
- ## Signature Positions
191
- [📄](#page-level-fields "This field is only present on individual pages.")**signatures_positions** (Array<[PositionField](#position-field)>): List of signature positions
192
-
193
- ```rb
194
- result.document.inference.pages do |page|
195
- page.prediction.signatures_positions do |signatures_positions_elem|
196
- puts signatures_positions_elem.polygon.to_s
197
- puts signatures_positions_elem.quadrangle.to_s
198
- puts signatures_positions_elem.rectangle.to_s
199
- puts signatures_positions_elem.boundingBox.to_s
200
- end
201
- end
202
- ```
203
-
204
- # Questions?
205
- [Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g)