mindee 3.19.1 → 4.0.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 (600) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +2 -1
  3. data/CHANGELOG.md +28 -0
  4. data/README.md +42 -52
  5. data/Steepfile +31 -0
  6. data/bin/mindee.rb +30 -62
  7. data/docs/advanced_file_operations.md +111 -0
  8. data/docs/code_samples/bank_account_details_v1.txt +5 -0
  9. data/docs/code_samples/bank_account_details_v2.txt +5 -0
  10. data/docs/code_samples/bank_check_v1.txt +5 -0
  11. data/docs/code_samples/{us_driver_license_v1.txt → bank_statement_fr_v2_async.txt} +6 -1
  12. data/docs/code_samples/barcode_reader_v1.txt +5 -0
  13. data/docs/code_samples/bill_of_lading_v1_async.txt +6 -1
  14. data/docs/code_samples/business_card_v1_async.txt +6 -1
  15. data/docs/code_samples/carte_grise_v1.txt +5 -0
  16. data/docs/code_samples/cropper_v1.txt +5 -0
  17. data/docs/code_samples/default.txt +8 -2
  18. data/docs/code_samples/default_async.txt +7 -2
  19. data/docs/code_samples/delivery_notes_v1_async.txt +6 -1
  20. data/docs/code_samples/driver_license_v1_async.txt +6 -1
  21. data/docs/code_samples/energy_bill_fra_v1_async.txt +6 -1
  22. data/docs/code_samples/expense_receipts_v5.txt +7 -1
  23. data/docs/code_samples/expense_receipts_v5_async.txt +6 -1
  24. data/docs/code_samples/financial_document_v1.txt +7 -1
  25. data/docs/code_samples/financial_document_v1_async.txt +6 -1
  26. data/docs/code_samples/french_healthcard_v1_async.txt +6 -1
  27. data/docs/code_samples/idcard_fr_v1.txt +5 -0
  28. data/docs/code_samples/idcard_fr_v2.txt +5 -0
  29. data/docs/code_samples/ind_passport_v1_async.txt +6 -1
  30. data/docs/code_samples/international_id_v2_async.txt +6 -1
  31. data/docs/code_samples/invoice_splitter_v1_async.txt +6 -1
  32. data/docs/code_samples/invoices_v4.txt +7 -1
  33. data/docs/code_samples/invoices_v4_async.txt +6 -1
  34. data/docs/code_samples/license_plates_v1.txt +5 -0
  35. data/docs/code_samples/multi_receipts_detector_v1.txt +5 -0
  36. data/docs/code_samples/nutrition_facts_v1_async.txt +6 -1
  37. data/docs/code_samples/passport_v1.txt +5 -0
  38. data/docs/code_samples/payslip_fra_v2_async.txt +6 -1
  39. data/docs/code_samples/payslip_fra_v3_async.txt +6 -1
  40. data/docs/code_samples/resume_v1_async.txt +6 -1
  41. data/docs/code_samples/us_healthcare_cards_v1_async.txt +6 -1
  42. data/docs/code_samples/us_mail_v3_async.txt +6 -1
  43. data/docs/code_samples/us_w9_v1.txt +5 -0
  44. data/docs/getting_started.md +50 -118
  45. data/docs/{barcode_reader_v1.md → global_products/barcode_reader_v1.md} +26 -9
  46. data/docs/{bill_of_lading_v1.md → global_products/bill_of_lading_v1.md} +62 -37
  47. data/docs/{business_card_v1.md → global_products/business_card_v1.md} +35 -10
  48. data/docs/{cropper_v1.md → global_products/cropper_v1.md} +32 -13
  49. data/docs/{delivery_notes_v1.md → global_products/delivery_notes_v1.md} +35 -10
  50. data/docs/{driver_license_v1.md → global_products/driver_license_v1.md} +65 -9
  51. data/docs/{expense_receipts_v5.md → global_products/expense_receipts_v5.md} +57 -21
  52. data/docs/{financial_document_v1.md → global_products/financial_document_v1.md} +70 -33
  53. data/docs/{international_id_v2.md → global_products/international_id_v2.md} +39 -13
  54. data/docs/{invoice_splitter_v1.md → global_products/invoice_splitter_v1.md} +25 -6
  55. data/docs/{invoices_v4.md → global_products/invoices_v4.md} +70 -33
  56. data/docs/{multi_receipts_detector_v1.md → global_products/multi_receipts_detector_v1.md} +32 -13
  57. data/docs/{nutrition_facts_v1.md → global_products/nutrition_facts_v1.md} +103 -78
  58. data/docs/{passport_v1.md → global_products/passport_v1.md} +26 -9
  59. data/docs/{resume_v1.md → global_products/resume_v1.md} +72 -46
  60. data/docs/{generated_v1.md → global_products/universal.md} +39 -19
  61. data/docs/global_products.md +6 -0
  62. data/docs/loading_a_document.md +316 -0
  63. data/docs/{bank_account_details_v2.md → localized_products/bank_account_details_v2.md} +24 -7
  64. data/docs/{bank_check_v1.md → localized_products/bank_check_v1.md} +37 -18
  65. data/docs/localized_products/bank_statement_fr_v2.md +269 -0
  66. data/docs/{carte_grise_v1.md → localized_products/carte_grise_v1.md} +25 -8
  67. data/docs/{energy_bill_fra_v1.md → localized_products/energy_bill_fra_v1.md} +70 -45
  68. data/docs/{french_healthcard_v1.md → localized_products/french_healthcard_v1.md} +36 -11
  69. data/docs/{idcard_fr_v2.md → localized_products/idcard_fr_v2.md} +34 -16
  70. data/docs/{ind_passport_v1.md → localized_products/ind_passport_v1.md} +37 -11
  71. data/docs/{license_plates_v1.md → localized_products/license_plates_v1.md} +25 -8
  72. data/docs/{payslip_fra_v3.md → localized_products/payslip_fra_v3.md} +80 -55
  73. data/docs/{us_healthcare_cards_v1.md → localized_products/us_healthcare_cards_v1.md} +37 -12
  74. data/docs/{us_mail_v3.md → localized_products/us_mail_v3.md} +49 -24
  75. data/docs/{us_w9_v1.md → localized_products/us_w9_v1.md} +64 -45
  76. data/docs/localized_products.md +6 -0
  77. data/examples/auto_invoice_splitter_extraction.rb +5 -5
  78. data/examples/auto_multi_receipts_detector_extraction.rb +4 -5
  79. data/lib/mindee/client.rb +354 -209
  80. data/lib/mindee/errors/mindee_error.rb +17 -0
  81. data/lib/mindee/errors/mindee_http_error.rb +36 -0
  82. data/lib/mindee/errors/mindee_input_error.rb +30 -0
  83. data/lib/mindee/errors.rb +5 -0
  84. data/lib/mindee/extraction/multi_receipts_extractor.rb +28 -1
  85. data/lib/mindee/extraction.rb +0 -3
  86. data/lib/mindee/geometry/polygon.rb +1 -1
  87. data/lib/mindee/geometry/utils.rb +1 -1
  88. data/lib/mindee/http/endpoint.rb +48 -40
  89. data/lib/mindee/http/{error.rb → http_error_handler.rb} +5 -35
  90. data/lib/mindee/http/response_validation.rb +2 -2
  91. data/lib/mindee/http/workflow_endpoint.rb +12 -12
  92. data/lib/mindee/http.rb +1 -1
  93. data/lib/mindee/{extraction/common → image}/extracted_image.rb +22 -18
  94. data/lib/mindee/{extraction/common → image}/image_extractor.rb +20 -78
  95. data/lib/mindee/image/image_utils.rb +68 -7
  96. data/lib/mindee/image.rb +2 -0
  97. data/lib/mindee/input/local_response.rb +8 -8
  98. data/lib/mindee/input/sources/base64_input_source.rb +6 -6
  99. data/lib/mindee/input/sources/bytes_input_source.rb +3 -3
  100. data/lib/mindee/input/sources/file_input_source.rb +3 -3
  101. data/lib/mindee/input/sources/local_input_source.rb +43 -41
  102. data/lib/mindee/input/sources/path_input_source.rb +3 -3
  103. data/lib/mindee/input/sources/url_input_source.rb +11 -8
  104. data/lib/mindee/logging/logger.rb +16 -0
  105. data/lib/mindee/logging.rb +3 -0
  106. data/lib/mindee/parsing/common/api_request.rb +36 -0
  107. data/lib/mindee/parsing/common/api_response.rb +6 -96
  108. data/lib/mindee/parsing/common/document.rb +12 -8
  109. data/lib/mindee/parsing/common/execution.rb +4 -2
  110. data/lib/mindee/parsing/common/execution_priority.rb +6 -0
  111. data/lib/mindee/parsing/common/extras/cropper_extra.rb +2 -1
  112. data/lib/mindee/parsing/common/extras/extras.rb +9 -4
  113. data/lib/mindee/parsing/common/extras/full_text_ocr_extra.rb +1 -0
  114. data/lib/mindee/parsing/common/inference.rb +23 -4
  115. data/lib/mindee/parsing/common/job.rb +46 -0
  116. data/lib/mindee/parsing/common/ocr/mvision_v1.rb +6 -6
  117. data/lib/mindee/parsing/common/ocr/ocr.rb +29 -29
  118. data/lib/mindee/parsing/common/page.rb +5 -3
  119. data/lib/mindee/parsing/common/prediction.rb +2 -0
  120. data/lib/mindee/parsing/common/workflow_response.rb +28 -0
  121. data/lib/mindee/parsing/common.rb +3 -0
  122. data/lib/mindee/parsing/standard/abstract_field.rb +72 -0
  123. data/lib/mindee/parsing/standard/amount_field.rb +2 -2
  124. data/lib/mindee/parsing/standard/base_field.rb +5 -84
  125. data/lib/mindee/parsing/standard/boolean_field.rb +4 -3
  126. data/lib/mindee/parsing/standard/classification_field.rb +1 -1
  127. data/lib/mindee/parsing/standard/company_registration_field.rb +7 -2
  128. data/lib/mindee/parsing/standard/date_field.rb +2 -2
  129. data/lib/mindee/parsing/standard/feature_field.rb +24 -0
  130. data/lib/mindee/parsing/standard/payment_details_field.rb +2 -2
  131. data/lib/mindee/parsing/standard/position_field.rb +3 -1
  132. data/lib/mindee/parsing/standard/string_field.rb +1 -1
  133. data/lib/mindee/parsing/standard/tax_field.rb +1 -1
  134. data/lib/mindee/parsing/standard.rb +1 -0
  135. data/lib/mindee/parsing/{generated/generated_list_field.rb → universal/universal_list_field.rb} +12 -12
  136. data/lib/mindee/parsing/{generated/generated_object_field.rb → universal/universal_object_field.rb} +23 -14
  137. data/lib/mindee/parsing/universal.rb +4 -0
  138. data/lib/mindee/parsing.rb +1 -2
  139. data/lib/mindee/{extraction/pdf_extractor → pdf}/extracted_pdf.rb +15 -12
  140. data/lib/mindee/pdf/pdf_compressor.rb +12 -10
  141. data/lib/mindee/{extraction/pdf_extractor → pdf}/pdf_extractor.rb +20 -17
  142. data/lib/mindee/pdf/pdf_processor.rb +12 -22
  143. data/lib/mindee/pdf/pdf_tools.rb +52 -6
  144. data/lib/mindee/pdf.rb +2 -0
  145. data/lib/mindee/product/.rubocop.yml +3 -0
  146. data/lib/mindee/product/barcode_reader/barcode_reader_v1.rb +9 -3
  147. data/lib/mindee/product/barcode_reader/barcode_reader_v1_document.rb +5 -5
  148. data/lib/mindee/product/barcode_reader/barcode_reader_v1_page.rb +9 -5
  149. data/lib/mindee/product/bill_of_lading/bill_of_lading_v1.rb +9 -3
  150. data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_carrier.rb +1 -1
  151. data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_carrier_item.rb +13 -7
  152. data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_carrier_items.rb +62 -0
  153. data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_consignee.rb +1 -1
  154. data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_document.rb +44 -17
  155. data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_notify_party.rb +1 -1
  156. data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_page.rb +9 -5
  157. data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_shipper.rb +1 -1
  158. data/lib/mindee/product/business_card/business_card_v1.rb +9 -3
  159. data/lib/mindee/product/business_card/business_card_v1_document.rb +40 -13
  160. data/lib/mindee/product/business_card/business_card_v1_page.rb +9 -5
  161. data/lib/mindee/product/cropper/cropper_v1.rb +10 -4
  162. data/lib/mindee/product/cropper/cropper_v1_page.rb +11 -7
  163. data/lib/mindee/product/delivery_note/delivery_note_v1.rb +9 -3
  164. data/lib/mindee/product/delivery_note/delivery_note_v1_document.rb +29 -8
  165. data/lib/mindee/product/delivery_note/delivery_note_v1_page.rb +9 -5
  166. data/lib/mindee/product/driver_license/driver_license_v1.rb +9 -3
  167. data/lib/mindee/product/driver_license/driver_license_v1_document.rb +44 -14
  168. data/lib/mindee/product/driver_license/driver_license_v1_page.rb +9 -5
  169. data/lib/mindee/product/eu/license_plate/license_plate_v1.rb +9 -3
  170. data/lib/mindee/product/eu/license_plate/license_plate_v1_document.rb +3 -3
  171. data/lib/mindee/product/eu/license_plate/license_plate_v1_page.rb +9 -5
  172. data/lib/mindee/product/financial_document/financial_document_v1.rb +9 -3
  173. data/lib/mindee/product/financial_document/financial_document_v1_document.rb +110 -42
  174. data/lib/mindee/product/financial_document/financial_document_v1_line_item.rb +21 -11
  175. data/lib/mindee/product/financial_document/financial_document_v1_line_items.rb +62 -0
  176. data/lib/mindee/product/financial_document/financial_document_v1_page.rb +9 -5
  177. data/lib/mindee/product/fr/bank_account_details/bank_account_details_v1.rb +9 -3
  178. data/lib/mindee/product/fr/bank_account_details/bank_account_details_v1_document.rb +7 -4
  179. data/lib/mindee/product/fr/bank_account_details/bank_account_details_v1_page.rb +9 -5
  180. data/lib/mindee/product/fr/bank_account_details/bank_account_details_v2.rb +9 -3
  181. data/lib/mindee/product/fr/bank_account_details/bank_account_details_v2_bban.rb +1 -1
  182. data/lib/mindee/product/fr/bank_account_details/bank_account_details_v2_document.rb +11 -5
  183. data/lib/mindee/product/fr/bank_account_details/bank_account_details_v2_page.rb +9 -5
  184. data/lib/mindee/product/fr/bank_statement/bank_statement_v2.rb +47 -0
  185. data/lib/mindee/product/fr/bank_statement/{bank_statement_v1_document.rb → bank_statement_v2_document.rb} +62 -26
  186. data/lib/mindee/product/fr/bank_statement/bank_statement_v2_page.rb +38 -0
  187. data/lib/mindee/product/fr/bank_statement/{bank_statement_v1_transaction.rb → bank_statement_v2_transaction.rb} +17 -6
  188. data/lib/mindee/product/fr/bank_statement/bank_statement_v2_transactions.rb +54 -0
  189. data/lib/mindee/product/fr/carte_grise/carte_grise_v1.rb +9 -3
  190. data/lib/mindee/product/fr/carte_grise/carte_grise_v1_document.rb +51 -42
  191. data/lib/mindee/product/fr/carte_grise/carte_grise_v1_page.rb +9 -5
  192. data/lib/mindee/product/fr/energy_bill/energy_bill_v1.rb +9 -3
  193. data/lib/mindee/product/fr/energy_bill/energy_bill_v1_document.rb +56 -30
  194. data/lib/mindee/product/fr/energy_bill/energy_bill_v1_energy_consumer.rb +1 -1
  195. data/lib/mindee/product/fr/energy_bill/energy_bill_v1_energy_supplier.rb +1 -1
  196. data/lib/mindee/product/fr/energy_bill/energy_bill_v1_energy_usage.rb +13 -7
  197. data/lib/mindee/product/fr/energy_bill/energy_bill_v1_energy_usages.rb +65 -0
  198. data/lib/mindee/product/fr/energy_bill/energy_bill_v1_meter_detail.rb +1 -1
  199. data/lib/mindee/product/fr/energy_bill/energy_bill_v1_page.rb +9 -5
  200. data/lib/mindee/product/fr/energy_bill/energy_bill_v1_subscription.rb +13 -7
  201. data/lib/mindee/product/fr/energy_bill/energy_bill_v1_subscriptions.rb +65 -0
  202. data/lib/mindee/product/fr/energy_bill/energy_bill_v1_taxes_and_contribution.rb +13 -7
  203. data/lib/mindee/product/fr/energy_bill/energy_bill_v1_taxes_and_contributions.rb +65 -0
  204. data/lib/mindee/product/fr/health_card/health_card_v1.rb +9 -3
  205. data/lib/mindee/product/fr/health_card/health_card_v1_document.rb +15 -6
  206. data/lib/mindee/product/fr/health_card/health_card_v1_page.rb +9 -5
  207. data/lib/mindee/product/fr/id_card/id_card_v1.rb +9 -3
  208. data/lib/mindee/product/fr/id_card/id_card_v1_document.rb +33 -12
  209. data/lib/mindee/product/fr/id_card/id_card_v1_page.rb +14 -7
  210. data/lib/mindee/product/fr/id_card/id_card_v2.rb +9 -3
  211. data/lib/mindee/product/fr/id_card/id_card_v2_document.rb +50 -17
  212. data/lib/mindee/product/fr/id_card/id_card_v2_page.rb +18 -8
  213. data/lib/mindee/product/fr/payslip/payslip_v2.rb +9 -3
  214. data/lib/mindee/product/fr/payslip/payslip_v2_bank_account_detail.rb +1 -1
  215. data/lib/mindee/product/fr/payslip/payslip_v2_document.rb +29 -14
  216. data/lib/mindee/product/fr/payslip/payslip_v2_employee.rb +1 -1
  217. data/lib/mindee/product/fr/payslip/payslip_v2_employer.rb +1 -1
  218. data/lib/mindee/product/fr/payslip/payslip_v2_employment.rb +3 -2
  219. data/lib/mindee/product/fr/payslip/payslip_v2_page.rb +9 -5
  220. data/lib/mindee/product/fr/payslip/payslip_v2_pay_detail.rb +33 -11
  221. data/lib/mindee/product/fr/payslip/payslip_v2_pay_period.rb +1 -1
  222. data/lib/mindee/product/fr/payslip/payslip_v2_pto.rb +13 -4
  223. data/lib/mindee/product/fr/payslip/payslip_v2_salary_detail.rb +13 -7
  224. data/lib/mindee/product/fr/payslip/payslip_v2_salary_details.rb +63 -0
  225. data/lib/mindee/product/fr/payslip/payslip_v3.rb +9 -3
  226. data/lib/mindee/product/fr/payslip/payslip_v3_bank_account_detail.rb +1 -1
  227. data/lib/mindee/product/fr/payslip/payslip_v3_document.rb +31 -19
  228. data/lib/mindee/product/fr/payslip/payslip_v3_employee.rb +1 -1
  229. data/lib/mindee/product/fr/payslip/payslip_v3_employer.rb +1 -1
  230. data/lib/mindee/product/fr/payslip/payslip_v3_employment.rb +1 -1
  231. data/lib/mindee/product/fr/payslip/payslip_v3_page.rb +9 -5
  232. data/lib/mindee/product/fr/payslip/payslip_v3_paid_time_off.rb +13 -7
  233. data/lib/mindee/product/fr/payslip/payslip_v3_paid_time_offs.rb +65 -0
  234. data/lib/mindee/product/fr/payslip/payslip_v3_pay_detail.rb +33 -11
  235. data/lib/mindee/product/fr/payslip/payslip_v3_pay_period.rb +1 -1
  236. data/lib/mindee/product/fr/payslip/payslip_v3_salary_detail.rb +17 -9
  237. data/lib/mindee/product/fr/payslip/payslip_v3_salary_details.rb +65 -0
  238. data/lib/mindee/product/ind/indian_passport/indian_passport_v1.rb +9 -3
  239. data/lib/mindee/product/ind/indian_passport/indian_passport_v1_document.rb +87 -24
  240. data/lib/mindee/product/ind/indian_passport/indian_passport_v1_page.rb +9 -5
  241. data/lib/mindee/product/international_id/international_id_v2.rb +9 -3
  242. data/lib/mindee/product/international_id/international_id_v2_document.rb +62 -20
  243. data/lib/mindee/product/international_id/international_id_v2_page.rb +9 -5
  244. data/lib/mindee/product/invoice/invoice_v4.rb +9 -3
  245. data/lib/mindee/product/invoice/invoice_v4_document.rb +90 -36
  246. data/lib/mindee/product/invoice/invoice_v4_line_item.rb +21 -11
  247. data/lib/mindee/product/invoice/invoice_v4_line_items.rb +62 -0
  248. data/lib/mindee/product/invoice/invoice_v4_page.rb +9 -5
  249. data/lib/mindee/product/invoice_splitter/invoice_splitter_v1.rb +8 -0
  250. data/lib/mindee/product/invoice_splitter/invoice_splitter_v1_document.rb +2 -2
  251. data/lib/mindee/product/invoice_splitter/invoice_splitter_v1_page.rb +1 -1
  252. data/lib/mindee/product/multi_receipts_detector/multi_receipts_detector_v1.rb +9 -3
  253. data/lib/mindee/product/multi_receipts_detector/multi_receipts_detector_v1_document.rb +3 -3
  254. data/lib/mindee/product/multi_receipts_detector/multi_receipts_detector_v1_page.rb +9 -5
  255. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1.rb +9 -3
  256. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_added_sugar.rb +7 -4
  257. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_calorie.rb +7 -4
  258. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_cholesterol.rb +7 -4
  259. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_dietary_fiber.rb +7 -4
  260. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_document.rb +58 -20
  261. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_nutrient.rb +13 -7
  262. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_nutrients.rb +68 -0
  263. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_page.rb +9 -5
  264. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_protein.rb +7 -4
  265. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_saturated_fat.rb +7 -4
  266. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_serving_size.rb +3 -2
  267. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_sodium.rb +7 -4
  268. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_total_carbohydrate.rb +7 -4
  269. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_total_fat.rb +7 -4
  270. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_total_sugar.rb +7 -4
  271. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_trans_fat.rb +7 -4
  272. data/lib/mindee/product/passport/passport_v1.rb +9 -3
  273. data/lib/mindee/product/passport/passport_v1_document.rb +37 -13
  274. data/lib/mindee/product/passport/passport_v1_page.rb +9 -5
  275. data/lib/mindee/product/receipt/receipt_v5.rb +9 -3
  276. data/lib/mindee/product/receipt/receipt_v5_document.rb +54 -24
  277. data/lib/mindee/product/receipt/receipt_v5_line_item.rb +13 -7
  278. data/lib/mindee/product/receipt/receipt_v5_line_items.rb +54 -0
  279. data/lib/mindee/product/receipt/receipt_v5_page.rb +9 -5
  280. data/lib/mindee/product/resume/resume_v1.rb +9 -3
  281. data/lib/mindee/product/resume/resume_v1_certificate.rb +1 -1
  282. data/lib/mindee/product/resume/resume_v1_certificates.rb +58 -0
  283. data/lib/mindee/product/resume/resume_v1_document.rb +60 -47
  284. data/lib/mindee/product/resume/resume_v1_education.rb +1 -1
  285. data/lib/mindee/product/resume/resume_v1_educations.rb +64 -0
  286. data/lib/mindee/product/resume/resume_v1_language.rb +1 -1
  287. data/lib/mindee/product/resume/resume_v1_languages.rb +54 -0
  288. data/lib/mindee/product/resume/resume_v1_page.rb +9 -5
  289. data/lib/mindee/product/resume/resume_v1_professional_experience.rb +1 -1
  290. data/lib/mindee/product/resume/resume_v1_professional_experiences.rb +68 -0
  291. data/lib/mindee/product/resume/resume_v1_social_networks_url.rb +1 -1
  292. data/lib/mindee/product/resume/resume_v1_social_networks_urls.rb +54 -0
  293. data/lib/mindee/product/universal/universal.rb +46 -0
  294. data/lib/mindee/product/universal/universal_document.rb +32 -0
  295. data/lib/mindee/product/{generated/generated_v1_page.rb → universal/universal_page.rb} +14 -14
  296. data/lib/mindee/product/{generated/generated_v1_prediction.rb → universal/universal_prediction.rb} +32 -24
  297. data/lib/mindee/product/us/bank_check/bank_check_v1.rb +9 -3
  298. data/lib/mindee/product/us/bank_check/bank_check_v1_document.rb +20 -8
  299. data/lib/mindee/product/us/bank_check/bank_check_v1_page.rb +15 -8
  300. data/lib/mindee/product/us/healthcare_card/healthcare_card_v1.rb +9 -3
  301. data/lib/mindee/product/us/healthcare_card/healthcare_card_v1_copay.rb +5 -3
  302. data/lib/mindee/product/us/healthcare_card/healthcare_card_v1_copays.rb +52 -0
  303. data/lib/mindee/product/us/healthcare_card/healthcare_card_v1_document.rb +46 -19
  304. data/lib/mindee/product/us/healthcare_card/healthcare_card_v1_page.rb +9 -5
  305. data/lib/mindee/product/us/us_mail/us_mail_v3.rb +9 -3
  306. data/lib/mindee/product/us/us_mail/us_mail_v3_document.rb +20 -12
  307. data/lib/mindee/product/us/us_mail/us_mail_v3_page.rb +9 -5
  308. data/lib/mindee/product/us/us_mail/us_mail_v3_recipient_address.rb +2 -2
  309. data/lib/mindee/product/us/us_mail/us_mail_v3_recipient_addresses.rb +65 -0
  310. data/lib/mindee/product/us/us_mail/us_mail_v3_sender_address.rb +1 -1
  311. data/lib/mindee/product/us/w9/w9_v1.rb +10 -4
  312. data/lib/mindee/product/us/w9/w9_v1_page.rb +49 -18
  313. data/lib/mindee/product.rb +2 -8
  314. data/lib/mindee/version.rb +2 -2
  315. data/lib/mindee.rb +22 -9
  316. data/mindee.gemspec +19 -17
  317. data/sig/custom/marcel.rbs +3 -0
  318. data/sig/custom/mini_magick.rbs +24 -0
  319. data/sig/custom/net_http.rbs +34 -0
  320. data/sig/custom/origami.rbs +54 -0
  321. data/sig/mindee/client.rbs +63 -0
  322. data/sig/mindee/errors/mindee_error.rbs +13 -0
  323. data/sig/mindee/errors/mindee_http_error.rbs +16 -0
  324. data/sig/mindee/errors/mindee_input_error.rbs +17 -0
  325. data/sig/mindee/extraction/multi_receipts_extractor.rbs +6 -0
  326. data/sig/mindee/geometry/min_max.rbs +10 -0
  327. data/sig/mindee/geometry/point.rbs +13 -0
  328. data/sig/mindee/geometry/polygon.rbs +9 -0
  329. data/sig/mindee/geometry/quadrilateral.rbs +18 -0
  330. data/sig/mindee/geometry/utils.rbs +13 -0
  331. data/sig/mindee/http/endpoint.rbs +26 -0
  332. data/sig/mindee/http/http_error_handler.rbs +10 -0
  333. data/sig/mindee/http/response_validation.rbs +10 -0
  334. data/sig/mindee/http/workflow_endpoint.rbs +14 -0
  335. data/sig/mindee/image/extracted_image.rbs +15 -0
  336. data/sig/mindee/image/image_compressor.rbs +8 -0
  337. data/sig/mindee/image/image_extractor.rbs +13 -0
  338. data/sig/mindee/image/image_utils.rbs +19 -0
  339. data/sig/mindee/input/local_response.rbs +13 -0
  340. data/sig/mindee/input/sources/base64_input_source.rbs +11 -0
  341. data/sig/mindee/input/sources/bytes_input_source.rbs +10 -0
  342. data/sig/mindee/input/sources/file_input_source.rbs +10 -0
  343. data/sig/mindee/input/sources/local_input_source.rbs +24 -0
  344. data/sig/mindee/input/sources/path_input_source.rbs +10 -0
  345. data/sig/mindee/input/sources/url_input_source.rbs +20 -0
  346. data/sig/mindee/logging/logger.rbs +9 -0
  347. data/sig/mindee/parsing/common/api_request.rbs +15 -0
  348. data/sig/mindee/parsing/common/api_response.rbs +27 -0
  349. data/sig/mindee/parsing/common/document.rbs +20 -0
  350. data/sig/mindee/parsing/common/execution.rbs +23 -0
  351. data/sig/mindee/parsing/common/execution_file.rbs +12 -0
  352. data/sig/mindee/parsing/common/execution_priority.rbs +13 -0
  353. data/sig/mindee/parsing/common/extras/cropper_extra.rbs +14 -0
  354. data/sig/mindee/parsing/common/extras/extras.rbs +18 -0
  355. data/sig/mindee/parsing/common/extras/full_text_ocr_extra.rbs +15 -0
  356. data/sig/mindee/parsing/common/inference.rbs +19 -0
  357. data/sig/mindee/parsing/common/job.rbs +16 -0
  358. data/sig/mindee/parsing/common/ocr/mvision_v1.rbs +15 -0
  359. data/sig/mindee/parsing/common/ocr/ocr.rbs +39 -0
  360. data/sig/mindee/parsing/common/orientation.rbs +12 -0
  361. data/sig/mindee/parsing/common/page.rbs +15 -0
  362. data/sig/mindee/parsing/common/prediction.rbs +11 -0
  363. data/sig/mindee/parsing/common/product.rbs +13 -0
  364. data/sig/mindee/parsing/common/workflow_response.rbs +13 -0
  365. data/sig/mindee/parsing/standard/abstract_field.rbs +19 -0
  366. data/sig/mindee/parsing/standard/amount_field.rbs +12 -0
  367. data/sig/mindee/parsing/standard/base_field.rbs +12 -0
  368. data/sig/mindee/parsing/standard/boolean_field.rbs +12 -0
  369. data/sig/mindee/parsing/standard/classification_field.rbs +10 -0
  370. data/sig/mindee/parsing/standard/company_registration_field.rbs +14 -0
  371. data/sig/mindee/parsing/standard/date_field.rbs +14 -0
  372. data/sig/mindee/parsing/standard/feature_field.rbs +10 -0
  373. data/sig/mindee/parsing/standard/locale_field.rbs +16 -0
  374. data/sig/mindee/parsing/standard/payment_details_field.rbs +15 -0
  375. data/sig/mindee/parsing/standard/position_field.rbs +17 -0
  376. data/sig/mindee/parsing/standard/string_field.rbs +12 -0
  377. data/sig/mindee/parsing/standard/tax_field.rbs +23 -0
  378. data/sig/mindee/parsing/universal/universal_list_field.rbs +17 -0
  379. data/sig/mindee/parsing/universal/universal_object_field.rbs +23 -0
  380. data/sig/mindee/pdf/extracted_pdf.rbs +15 -0
  381. data/sig/mindee/pdf/pdf_compressor.rbs +15 -0
  382. data/sig/mindee/pdf/pdf_extractor.rbs +16 -0
  383. data/sig/mindee/pdf/pdf_processor.rbs +12 -0
  384. data/sig/mindee/pdf/pdf_tools.rbs +23 -0
  385. data/sig/mindee/product/barcode_reader/barcode_reader_v1.rbs +11 -0
  386. data/sig/mindee/product/barcode_reader/barcode_reader_v1_document.rbs +14 -0
  387. data/sig/mindee/product/barcode_reader/barcode_reader_v1_page.rbs +15 -0
  388. data/sig/mindee/product/bill_of_lading/bill_of_lading_v1.rbs +11 -0
  389. data/sig/mindee/product/bill_of_lading/bill_of_lading_v1_carrier.rbs +14 -0
  390. data/sig/mindee/product/bill_of_lading/bill_of_lading_v1_carrier_item.rbs +19 -0
  391. data/sig/mindee/product/bill_of_lading/bill_of_lading_v1_carrier_items.rbs +13 -0
  392. data/sig/mindee/product/bill_of_lading/bill_of_lading_v1_consignee.rbs +15 -0
  393. data/sig/mindee/product/bill_of_lading/bill_of_lading_v1_document.rbs +25 -0
  394. data/sig/mindee/product/bill_of_lading/bill_of_lading_v1_notify_party.rbs +15 -0
  395. data/sig/mindee/product/bill_of_lading/bill_of_lading_v1_page.rbs +15 -0
  396. data/sig/mindee/product/bill_of_lading/bill_of_lading_v1_shipper.rbs +15 -0
  397. data/sig/mindee/product/business_card/business_card_v1.rbs +11 -0
  398. data/sig/mindee/product/business_card/business_card_v1_document.rbs +23 -0
  399. data/sig/mindee/product/business_card/business_card_v1_page.rbs +15 -0
  400. data/sig/mindee/product/cropper/cropper_v1.rbs +11 -0
  401. data/sig/mindee/product/cropper/cropper_v1_document.rbs +12 -0
  402. data/sig/mindee/product/cropper/cropper_v1_page.rbs +16 -0
  403. data/sig/mindee/product/delivery_note/delivery_note_v1.rbs +11 -0
  404. data/sig/mindee/product/delivery_note/delivery_note_v1_document.rbs +19 -0
  405. data/sig/mindee/product/delivery_note/delivery_note_v1_page.rbs +15 -0
  406. data/sig/mindee/product/driver_license/driver_license_v1.rbs +11 -0
  407. data/sig/mindee/product/driver_license/driver_license_v1_document.rbs +25 -0
  408. data/sig/mindee/product/driver_license/driver_license_v1_page.rbs +15 -0
  409. data/sig/mindee/product/eu/license_plate/license_plate_v1.rbs +13 -0
  410. data/sig/mindee/product/eu/license_plate/license_plate_v1_document.rbs +15 -0
  411. data/sig/mindee/product/eu/license_plate/license_plate_v1_page.rbs +17 -0
  412. data/sig/mindee/product/financial_document/financial_document_v1.rbs +11 -0
  413. data/sig/mindee/product/financial_document/financial_document_v1_document.rbs +46 -0
  414. data/sig/mindee/product/financial_document/financial_document_v1_line_item.rbs +21 -0
  415. data/sig/mindee/product/financial_document/financial_document_v1_line_items.rbs +13 -0
  416. data/sig/mindee/product/financial_document/financial_document_v1_page.rbs +15 -0
  417. data/sig/mindee/product/fr/bank_account_details/bank_account_details_v1.rbs +13 -0
  418. data/sig/mindee/product/fr/bank_account_details/bank_account_details_v1_document.rbs +17 -0
  419. data/sig/mindee/product/fr/bank_account_details/bank_account_details_v1_page.rbs +17 -0
  420. data/sig/mindee/product/fr/bank_account_details/bank_account_details_v2.rbs +13 -0
  421. data/sig/mindee/product/fr/bank_account_details/bank_account_details_v2_bban.rbs +17 -0
  422. data/sig/mindee/product/fr/bank_account_details/bank_account_details_v2_document.rbs +18 -0
  423. data/sig/mindee/product/fr/bank_account_details/bank_account_details_v2_page.rbs +17 -0
  424. data/sig/mindee/product/fr/bank_statement/bank_statement_v2.rbs +13 -0
  425. data/sig/mindee/product/fr/bank_statement/bank_statement_v2_document.rbs +29 -0
  426. data/sig/mindee/product/fr/bank_statement/bank_statement_v2_page.rbs +17 -0
  427. data/sig/mindee/product/fr/bank_statement/bank_statement_v2_transaction.rbs +18 -0
  428. data/sig/mindee/product/fr/bank_statement/bank_statement_v2_transactions.rbs +15 -0
  429. data/sig/mindee/product/fr/carte_grise/carte_grise_v1.rbs +13 -0
  430. data/sig/mindee/product/fr/carte_grise/carte_grise_v1_document.rbs +55 -0
  431. data/sig/mindee/product/fr/carte_grise/carte_grise_v1_page.rbs +17 -0
  432. data/sig/mindee/product/fr/energy_bill/energy_bill_v1.rbs +13 -0
  433. data/sig/mindee/product/fr/energy_bill/energy_bill_v1_document.rbs +34 -0
  434. data/sig/mindee/product/fr/energy_bill/energy_bill_v1_energy_consumer.rbs +15 -0
  435. data/sig/mindee/product/fr/energy_bill/energy_bill_v1_energy_supplier.rbs +15 -0
  436. data/sig/mindee/product/fr/energy_bill/energy_bill_v1_energy_usage.rbs +21 -0
  437. data/sig/mindee/product/fr/energy_bill/energy_bill_v1_energy_usages.rbs +15 -0
  438. data/sig/mindee/product/fr/energy_bill/energy_bill_v1_meter_detail.rbs +16 -0
  439. data/sig/mindee/product/fr/energy_bill/energy_bill_v1_page.rbs +17 -0
  440. data/sig/mindee/product/fr/energy_bill/energy_bill_v1_subscription.rbs +21 -0
  441. data/sig/mindee/product/fr/energy_bill/energy_bill_v1_subscriptions.rbs +15 -0
  442. data/sig/mindee/product/fr/energy_bill/energy_bill_v1_taxes_and_contribution.rbs +21 -0
  443. data/sig/mindee/product/fr/energy_bill/energy_bill_v1_taxes_and_contributions.rbs +15 -0
  444. data/sig/mindee/product/fr/health_card/health_card_v1.rbs +13 -0
  445. data/sig/mindee/product/fr/health_card/health_card_v1_document.rbs +18 -0
  446. data/sig/mindee/product/fr/health_card/health_card_v1_page.rbs +17 -0
  447. data/sig/mindee/product/fr/id_card/id_card_v1.rbs +13 -0
  448. data/sig/mindee/product/fr/id_card/id_card_v1_document.rbs +24 -0
  449. data/sig/mindee/product/fr/id_card/id_card_v1_page.rbs +18 -0
  450. data/sig/mindee/product/fr/id_card/id_card_v2.rbs +13 -0
  451. data/sig/mindee/product/fr/id_card/id_card_v2_document.rbs +29 -0
  452. data/sig/mindee/product/fr/id_card/id_card_v2_page.rbs +19 -0
  453. data/sig/mindee/product/fr/payslip/payslip_v2.rbs +13 -0
  454. data/sig/mindee/product/fr/payslip/payslip_v2_bank_account_detail.rbs +16 -0
  455. data/sig/mindee/product/fr/payslip/payslip_v2_document.rbs +24 -0
  456. data/sig/mindee/product/fr/payslip/payslip_v2_employee.rbs +20 -0
  457. data/sig/mindee/product/fr/payslip/payslip_v2_employer.rbs +20 -0
  458. data/sig/mindee/product/fr/payslip/payslip_v2_employment.rbs +19 -0
  459. data/sig/mindee/product/fr/payslip/payslip_v2_page.rbs +17 -0
  460. data/sig/mindee/product/fr/payslip/payslip_v2_pay_detail.rbs +23 -0
  461. data/sig/mindee/product/fr/payslip/payslip_v2_pay_period.rbs +18 -0
  462. data/sig/mindee/product/fr/payslip/payslip_v2_pto.rbs +16 -0
  463. data/sig/mindee/product/fr/payslip/payslip_v2_salary_detail.rbs +19 -0
  464. data/sig/mindee/product/fr/payslip/payslip_v2_salary_details.rbs +15 -0
  465. data/sig/mindee/product/fr/payslip/payslip_v3.rbs +13 -0
  466. data/sig/mindee/product/fr/payslip/payslip_v3_bank_account_detail.rbs +16 -0
  467. data/sig/mindee/product/fr/payslip/payslip_v3_document.rbs +26 -0
  468. data/sig/mindee/product/fr/payslip/payslip_v3_employee.rbs +20 -0
  469. data/sig/mindee/product/fr/payslip/payslip_v3_employer.rbs +20 -0
  470. data/sig/mindee/product/fr/payslip/payslip_v3_employment.rbs +20 -0
  471. data/sig/mindee/product/fr/payslip/payslip_v3_page.rbs +17 -0
  472. data/sig/mindee/product/fr/payslip/payslip_v3_paid_time_off.rbs +20 -0
  473. data/sig/mindee/product/fr/payslip/payslip_v3_paid_time_offs.rbs +15 -0
  474. data/sig/mindee/product/fr/payslip/payslip_v3_pay_detail.rbs +23 -0
  475. data/sig/mindee/product/fr/payslip/payslip_v3_pay_period.rbs +18 -0
  476. data/sig/mindee/product/fr/payslip/payslip_v3_salary_detail.rbs +20 -0
  477. data/sig/mindee/product/fr/payslip/payslip_v3_salary_details.rbs +15 -0
  478. data/sig/mindee/product/ind/indian_passport/indian_passport_v1.rbs +13 -0
  479. data/sig/mindee/product/ind/indian_passport/indian_passport_v1_document.rbs +37 -0
  480. data/sig/mindee/product/ind/indian_passport/indian_passport_v1_page.rbs +17 -0
  481. data/sig/mindee/product/international_id/international_id_v2.rbs +11 -0
  482. data/sig/mindee/product/international_id/international_id_v2_document.rbs +29 -0
  483. data/sig/mindee/product/international_id/international_id_v2_page.rbs +15 -0
  484. data/sig/mindee/product/invoice/invoice_v4.rbs +11 -0
  485. data/sig/mindee/product/invoice/invoice_v4_document.rbs +40 -0
  486. data/sig/mindee/product/invoice/invoice_v4_line_item.rbs +21 -0
  487. data/sig/mindee/product/invoice/invoice_v4_line_items.rbs +13 -0
  488. data/sig/mindee/product/invoice/invoice_v4_page.rbs +15 -0
  489. data/sig/mindee/product/invoice_splitter/invoice_splitter_v1.rbs +14 -0
  490. data/sig/mindee/product/invoice_splitter/invoice_splitter_v1_document.rbs +19 -0
  491. data/sig/mindee/product/invoice_splitter/invoice_splitter_v1_page.rbs +13 -0
  492. data/sig/mindee/product/multi_receipts_detector/multi_receipts_detector_v1.rbs +11 -0
  493. data/sig/mindee/product/multi_receipts_detector/multi_receipts_detector_v1_document.rbs +13 -0
  494. data/sig/mindee/product/multi_receipts_detector/multi_receipts_detector_v1_page.rbs +15 -0
  495. data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1.rbs +11 -0
  496. data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_added_sugar.rbs +14 -0
  497. data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_calorie.rbs +14 -0
  498. data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_cholesterol.rbs +14 -0
  499. data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_dietary_fiber.rbs +14 -0
  500. data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_document.rbs +28 -0
  501. data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_nutrient.rbs +18 -0
  502. data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_nutrients.rbs +13 -0
  503. data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_page.rbs +15 -0
  504. data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_protein.rbs +14 -0
  505. data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_saturated_fat.rbs +14 -0
  506. data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_serving_size.rbs +13 -0
  507. data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_sodium.rbs +15 -0
  508. data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_total_carbohydrate.rbs +14 -0
  509. data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_total_fat.rbs +14 -0
  510. data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_total_sugar.rbs +14 -0
  511. data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_trans_fat.rbs +14 -0
  512. data/sig/mindee/product/passport/passport_v1.rbs +11 -0
  513. data/sig/mindee/product/passport/passport_v1_document.rbs +23 -0
  514. data/sig/mindee/product/passport/passport_v1_page.rbs +15 -0
  515. data/sig/mindee/product/receipt/receipt_v5.rbs +11 -0
  516. data/sig/mindee/product/receipt/receipt_v5_document.rbs +31 -0
  517. data/sig/mindee/product/receipt/receipt_v5_line_item.rbs +17 -0
  518. data/sig/mindee/product/receipt/receipt_v5_line_items.rbs +13 -0
  519. data/sig/mindee/product/receipt/receipt_v5_page.rbs +15 -0
  520. data/sig/mindee/product/resume/resume_v1.rbs +11 -0
  521. data/sig/mindee/product/resume/resume_v1_certificate.rbs +17 -0
  522. data/sig/mindee/product/resume/resume_v1_certificates.rbs +13 -0
  523. data/sig/mindee/product/resume/resume_v1_document.rbs +39 -0
  524. data/sig/mindee/product/resume/resume_v1_education.rbs +20 -0
  525. data/sig/mindee/product/resume/resume_v1_educations.rbs +13 -0
  526. data/sig/mindee/product/resume/resume_v1_language.rbs +15 -0
  527. data/sig/mindee/product/resume/resume_v1_languages.rbs +13 -0
  528. data/sig/mindee/product/resume/resume_v1_page.rbs +15 -0
  529. data/sig/mindee/product/resume/resume_v1_professional_experience.rbs +22 -0
  530. data/sig/mindee/product/resume/resume_v1_professional_experiences.rbs +13 -0
  531. data/sig/mindee/product/resume/resume_v1_social_networks_url.rbs +15 -0
  532. data/sig/mindee/product/resume/resume_v1_social_networks_urls.rbs +13 -0
  533. data/sig/mindee/product/universal/universal.rbs +14 -0
  534. data/sig/mindee/product/universal/universal_document.rbs +10 -0
  535. data/sig/mindee/product/universal/universal_page.rbs +14 -0
  536. data/sig/mindee/product/universal/universal_prediction.rbs +19 -0
  537. data/sig/mindee/product/us/bank_check/bank_check_v1.rbs +13 -0
  538. data/sig/mindee/product/us/bank_check/bank_check_v1_document.rbs +20 -0
  539. data/sig/mindee/product/us/bank_check/bank_check_v1_page.rbs +19 -0
  540. data/sig/mindee/product/us/healthcare_card/healthcare_card_v1.rbs +13 -0
  541. data/sig/mindee/product/us/healthcare_card/healthcare_card_v1_copay.rbs +17 -0
  542. data/sig/mindee/product/us/healthcare_card/healthcare_card_v1_copays.rbs +15 -0
  543. data/sig/mindee/product/us/healthcare_card/healthcare_card_v1_document.rbs +28 -0
  544. data/sig/mindee/product/us/healthcare_card/healthcare_card_v1_page.rbs +17 -0
  545. data/sig/mindee/product/us/us_mail/us_mail_v3.rbs +13 -0
  546. data/sig/mindee/product/us/us_mail/us_mail_v3_document.rbs +21 -0
  547. data/sig/mindee/product/us/us_mail/us_mail_v3_page.rbs +17 -0
  548. data/sig/mindee/product/us/us_mail/us_mail_v3_recipient_address.rbs +23 -0
  549. data/sig/mindee/product/us/us_mail/us_mail_v3_recipient_addresses.rbs +15 -0
  550. data/sig/mindee/product/us/us_mail/us_mail_v3_sender_address.rbs +18 -0
  551. data/sig/mindee/product/us/w9/w9_v1.rbs +13 -0
  552. data/sig/mindee/product/us/w9/w9_v1_document.rbs +14 -0
  553. data/sig/mindee/product/us/w9/w9_v1_page.rbs +29 -0
  554. data/sig/mindee/version.rbs +6 -0
  555. data/sig/mindee.rbs +59 -0
  556. metadata +395 -103
  557. data/docs/bank_statement_fr_v1.md +0 -178
  558. data/docs/code_samples/bank_statement_fr_v1_async.txt +0 -19
  559. data/docs/code_samples/custom_v1.txt +0 -33
  560. data/docs/code_samples/eu_driver_license_v1.txt +0 -19
  561. data/docs/code_samples/expense_receipts_v4.txt +0 -19
  562. data/docs/code_samples/proof_of_address_v1.txt +0 -19
  563. data/docs/code_samples/us_mail_v2_async.txt +0 -19
  564. data/docs/code_samples/workflow_execution.txt +0 -29
  565. data/docs/custom_v1.md +0 -111
  566. data/docs/payslip_fra_v2.md +0 -294
  567. data/lib/mindee/extraction/common.rb +0 -4
  568. data/lib/mindee/extraction/multi_receipts_extractor/multi_receipts_extractor.rb +0 -32
  569. data/lib/mindee/extraction/pdf_extractor.rb +0 -4
  570. data/lib/mindee/extraction/tax_extractor/ocr_extractor.rb +0 -110
  571. data/lib/mindee/extraction/tax_extractor/tax_extractor.rb +0 -338
  572. data/lib/mindee/extraction/tax_extractor.rb +0 -3
  573. data/lib/mindee/parsing/custom/classification_field.rb +0 -28
  574. data/lib/mindee/parsing/custom/list_field.rb +0 -78
  575. data/lib/mindee/parsing/custom.rb +0 -4
  576. data/lib/mindee/parsing/generated.rb +0 -4
  577. data/lib/mindee/product/custom/custom_v1.rb +0 -36
  578. data/lib/mindee/product/custom/custom_v1_document.rb +0 -60
  579. data/lib/mindee/product/custom/custom_v1_page.rb +0 -32
  580. data/lib/mindee/product/eu/driver_license/driver_license_v1.rb +0 -41
  581. data/lib/mindee/product/eu/driver_license/driver_license_v1_document.rb +0 -88
  582. data/lib/mindee/product/eu/driver_license/driver_license_v1_page.rb +0 -53
  583. data/lib/mindee/product/fr/bank_statement/bank_statement_v1.rb +0 -41
  584. data/lib/mindee/product/fr/bank_statement/bank_statement_v1_page.rb +0 -34
  585. data/lib/mindee/product/generated/generated_v1.rb +0 -38
  586. data/lib/mindee/product/generated/generated_v1_document.rb +0 -35
  587. data/lib/mindee/product/proof_of_address/proof_of_address_v1.rb +0 -39
  588. data/lib/mindee/product/proof_of_address/proof_of_address_v1_document.rb +0 -83
  589. data/lib/mindee/product/proof_of_address/proof_of_address_v1_page.rb +0 -32
  590. data/lib/mindee/product/receipt/receipt_v4.rb +0 -36
  591. data/lib/mindee/product/receipt/receipt_v4_document.rb +0 -86
  592. data/lib/mindee/product/receipt/receipt_v4_page.rb +0 -32
  593. data/lib/mindee/product/us/driver_license/driver_license_v1.rb +0 -41
  594. data/lib/mindee/product/us/driver_license/driver_license_v1_document.rb +0 -113
  595. data/lib/mindee/product/us/driver_license/driver_license_v1_page.rb +0 -53
  596. data/lib/mindee/product/us/us_mail/us_mail_v2.rb +0 -41
  597. data/lib/mindee/product/us/us_mail/us_mail_v2_document.rb +0 -100
  598. data/lib/mindee/product/us/us_mail/us_mail_v2_page.rb +0 -34
  599. data/lib/mindee/product/us/us_mail/us_mail_v2_recipient_address.rb +0 -105
  600. data/lib/mindee/product/us/us_mail/us_mail_v2_sender_address.rb +0 -66
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mindee
4
+ module Errors
5
+ # Base class for all custom mindee errors.
6
+ class MindeeError < StandardError; end
7
+
8
+ # Errors relating to library issues.
9
+ class MindeeAPIError < MindeeError; end
10
+
11
+ # Errors relating to misuse of the library.
12
+ class MindeeConfigurationError < MindeeError; end
13
+
14
+ # Errors relating to geometric manipulation issues.
15
+ class MindeeGeometryError < MindeeError; end
16
+ end
17
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'mindee_error'
4
+
5
+ module Mindee
6
+ module Errors
7
+ # API HttpError
8
+ class MindeeHTTPError < MindeeError
9
+ # @return [String]
10
+ attr_reader :status_code
11
+ # @return [Integer]
12
+ attr_reader :api_code
13
+ # @return [String]
14
+ attr_reader :api_details
15
+ # @return [String]
16
+ attr_reader :api_message
17
+
18
+ # @param http_error [Hash]
19
+ # @param url [String]
20
+ # @param code [Integer]
21
+ def initialize(http_error, url, code)
22
+ @status_code = code
23
+ @api_code = http_error['code']
24
+ @api_details = http_error['details']
25
+ @api_message = http_error['message']
26
+ super("#{url} #{@status_code} HTTP error: #{@api_details} - #{@api_message}")
27
+ end
28
+ end
29
+
30
+ # Base class for all client-side errors.
31
+ class MindeeHTTPClientError < MindeeHTTPError; end
32
+
33
+ # Base class for all server-side errors.
34
+ class MindeeHTTPServerError < MindeeHTTPError; end
35
+ end
36
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mindee
4
+ module Errors
5
+ # Base class for errors relating to input documents.
6
+ class MindeeInputError < MindeeError; end
7
+
8
+ # Errors relating to sources (documents) handling.
9
+ class MindeeSourceError < MindeeInputError; end
10
+
11
+ # Errors relating to mime type issues.
12
+ class MindeeMimeTypeError < MindeeSourceError
13
+ # @return [String]
14
+ attr_reader :invalid_mimetype
15
+
16
+ # @param mime_type [String]
17
+ def initialize(mime_type)
18
+ @invalid_mimetype = mime_type
19
+ super("'#{@invalid_mimetype}' mime type not allowed, must be one of" \
20
+ "#{Mindee::Input::Source::ALLOWED_MIME_TYPES.join(', ')}")
21
+ end
22
+ end
23
+
24
+ # Errors relating to the handling of images.
25
+ class MindeeImageError < MindeeInputError; end
26
+
27
+ # Errors relating to the handling of PDF documents.
28
+ class MindeePDFError < MindeeInputError; end
29
+ end
30
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'errors/mindee_error'
4
+ require_relative 'errors/mindee_http_error'
5
+ require_relative 'errors/mindee_input_error'
@@ -1,3 +1,30 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'multi_receipts_extractor/multi_receipts_extractor'
3
+ module Mindee
4
+ # Custom extraction module
5
+ module Extraction
6
+ # Multi-receipts extraction
7
+ # Extracts individual receipts from multi-receipts documents.
8
+ #
9
+ # @param input_source [LocalInputSource] Local Input Source to extract sub-receipts from.
10
+ # @param inference [Inference] Results of the inference.
11
+ # @return [Array<ExtractedImage>] Individual extracted receipts as an array of ExtractedMultiReceiptsImage.
12
+ def self.extract_receipts(input_source, inference)
13
+ images = []
14
+ unless inference.prediction.receipts
15
+ raise Errors::MindeeInputError,
16
+ 'No possible receipts candidates found for Multi-Receipts extraction.'
17
+ end
18
+
19
+ (0...input_source.count_pages).each do |page_id|
20
+ receipt_positions = inference.pages[page_id].prediction.receipts.map(&:bounding_box)
21
+ images.concat(
22
+ Mindee::Image::ImageExtractor.extract_multiple_images_from_source(input_source, page_id + 1,
23
+ receipt_positions)
24
+ )
25
+ end
26
+
27
+ images
28
+ end
29
+ end
30
+ end
@@ -1,6 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'extraction/tax_extractor'
4
3
  require_relative 'extraction/multi_receipts_extractor'
5
- require_relative 'extraction/common'
6
- require_relative 'extraction/pdf_extractor'
@@ -13,7 +13,7 @@ module Mindee
13
13
 
14
14
  # Determine if the Point is in the Polygon's Y-axis.
15
15
  # @param point [Mindee::Geometry::Point]
16
- # @return [Boolean]
16
+ # @return [bool]
17
17
  def point_in_y?(point)
18
18
  min_max = Geometry.get_min_max_y(self)
19
19
  min_max.min <= point.y && point.y <= min_max.max
@@ -4,7 +4,7 @@ module Mindee
4
4
  # Various helper functions for geometry.
5
5
  module Geometry
6
6
  # Transform a prediction into a Quadrilateral.
7
- # @param prediction [Hash]
7
+ # @param prediction [Array<Array<Float>>]
8
8
  # @return [Mindee::Geometry::Quadrilateral]
9
9
  def self.quadrilateral_from_prediction(prediction)
10
10
  throw "Prediction must have exactly 4 points, found #{prediction.size}" if prediction.size != 4
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'json'
4
4
  require 'net/http'
5
- require_relative 'error'
5
+ require_relative 'http_error_handler'
6
6
  require_relative '../version'
7
7
  require_relative 'response_validation'
8
8
 
@@ -24,7 +24,7 @@ module Mindee
24
24
  TIMEOUT_DEFAULT = 120
25
25
 
26
26
  # Default value for the user agent.
27
- USER_AGENT = "mindee-api-ruby@v#{Mindee::VERSION} ruby-v#{RUBY_VERSION} #{Mindee::PLATFORM}"
27
+ USER_AGENT = "mindee-api-ruby@v#{Mindee::VERSION} ruby-v#{RUBY_VERSION} #{Mindee::PLATFORM}".freeze
28
28
 
29
29
  # Generic API endpoint for a product.
30
30
  class Endpoint
@@ -40,17 +40,20 @@ module Mindee
40
40
  @url_name = url_name
41
41
  @version = version
42
42
  @request_timeout = ENV.fetch(REQUEST_TIMEOUT_ENV_NAME, TIMEOUT_DEFAULT).to_i
43
+ if api_key.nil? && !ENV.fetch(API_KEY_ENV_NAME, API_KEY_DEFAULT).to_s.empty?
44
+ logger.debug('API key set from environment')
45
+ end
43
46
  @api_key = api_key.nil? || api_key.empty? ? ENV.fetch(API_KEY_ENV_NAME, API_KEY_DEFAULT) : api_key
44
47
  base_url = ENV.fetch(BASE_URL_ENV_NAME, BASE_URL_DEFAULT)
45
48
  @url_root = "#{base_url.chomp('/')}/products/#{@owner}/#{@url_name}/v#{@version}"
46
49
  end
47
50
 
48
51
  # Call the prediction API.
49
- # @param input_source [Mindee::Input::Source::LocalInputSource, Mindee::Input::Source::UrlInputSource]
50
- # @param all_words [Boolean] Whether the full word extraction needs to be performed
51
- # @param full_text [Boolean] Whether to include the full OCR text response in compatible APIs
52
- # @param close_file [Boolean] Whether the file will be closed after reading
53
- # @param cropper [Boolean] Whether a cropping operation will be applied
52
+ # @param input_source [Mindee::Input::Source::LocalInputSource, Mindee::Input::Source::URLInputSource]
53
+ # @param all_words [bool] Whether the full word extraction needs to be performed
54
+ # @param full_text [bool] Whether to include the full OCR text response in compatible APIs
55
+ # @param close_file [bool] Whether the file will be closed after reading
56
+ # @param cropper [bool] Whether a cropping operation will be applied
54
57
  # @return [Array]
55
58
  def predict(input_source, all_words, full_text, close_file, cropper)
56
59
  check_api_key
@@ -61,29 +64,34 @@ module Mindee
61
64
  close_file: close_file,
62
65
  cropper: cropper
63
66
  )
64
- hashed_response = JSON.parse(response.body, object_class: Hash)
65
- return [hashed_response, response.body] if ResponseValidation.valid_sync_response?(response)
67
+ if !response.nil? && response.respond_to?(:body)
68
+ hashed_response = JSON.parse(response.body, object_class: Hash)
69
+ return [hashed_response, response.body] if ResponseValidation.valid_sync_response?(response)
66
70
 
67
- ResponseValidation.clean_request!(response)
68
- error = Error.handle_error(@url_name, response)
71
+ ResponseValidation.clean_request!(response)
72
+ end
73
+ error = ErrorHandler.handle_error(@url_name, response)
69
74
  raise error
70
75
  end
71
76
 
72
77
  # Call the prediction API.
73
- # @param input_source [Mindee::Input::Source::LocalInputSource, Mindee::Input::Source::UrlInputSource]
74
- # @param all_words [Boolean] Whether the full word extraction needs to be performed
75
- # @param full_text [Boolean] Whether to include the full OCR text response in compatible APIs.
76
- # @param close_file [Boolean] Whether the file will be closed after reading
77
- # @param cropper [Boolean] Whether a cropping operation will be applied
78
+ # @param input_source [Mindee::Input::Source::LocalInputSource, Mindee::Input::Source::URLInputSource]
79
+ # @param all_words [bool] Whether the full word extraction needs to be performed
80
+ # @param full_text [bool] Whether to include the full OCR text response in compatible APIs.
81
+ # @param close_file [bool] Whether the file will be closed after reading
82
+ # @param cropper [bool] Whether a cropping operation will be applied
78
83
  # @return [Array]
79
84
  def predict_async(input_source, all_words, full_text, close_file, cropper)
80
85
  check_api_key
81
86
  response = document_queue_req_get(input_source, all_words, full_text, close_file, cropper)
82
- hashed_response = JSON.parse(response.body, object_class: Hash)
83
- return [hashed_response, response.body] if ResponseValidation.valid_async_response?(response)
87
+ if !response.nil? && response.respond_to?(:body)
88
+ hashed_response = JSON.parse(response.body, object_class: Hash)
89
+ return [hashed_response, response.body] if ResponseValidation.valid_async_response?(response)
84
90
 
85
- ResponseValidation.clean_request!(response)
86
- error = Error.handle_error(@url_name, response)
91
+ ResponseValidation.clean_request!(response)
92
+ end
93
+
94
+ error = ErrorHandler.handle_error(@url_name, response)
87
95
  raise error
88
96
  end
89
97
 
@@ -97,22 +105,22 @@ module Mindee
97
105
  return [hashed_response, response.body] if ResponseValidation.valid_async_response?(response)
98
106
 
99
107
  ResponseValidation.clean_request!(response)
100
- error = Error.handle_error(@url_name, response)
108
+ error = ErrorHandler.handle_error(@url_name, response)
101
109
  raise error
102
110
  end
103
111
 
104
112
  private
105
113
 
106
- # @param input_source [Mindee::Input::Source::LocalInputSource, Mindee::Input::Source::UrlInputSource]
107
- # @param all_words [Boolean] Whether the full word extraction needs to be performed
108
- # @param full_text [Boolean] Whether to include the full OCR text response in compatible APIs.
109
- # @param close_file [Boolean] Whether the file will be closed after reading
110
- # @param cropper [Boolean] Whether a cropping operation will be applied
114
+ # @param input_source [Mindee::Input::Source::LocalInputSource, Mindee::Input::Source::URLInputSource]
115
+ # @param all_words [bool] Whether the full word extraction needs to be performed
116
+ # @param full_text [bool] Whether to include the full OCR text response in compatible APIs.
117
+ # @param close_file [bool] Whether the file will be closed after reading
118
+ # @param cropper [bool] Whether a cropping operation will be applied
111
119
  # @return [Net::HTTPResponse, nil]
112
120
  def predict_req_post(input_source, all_words: false, full_text: false, close_file: true, cropper: false)
113
121
  uri = URI("#{@url_root}/predict")
114
122
 
115
- params = {}
123
+ params = {} # : Hash[Symbol | String, untyped]
116
124
  params[:cropper] = 'true' if cropper
117
125
  params[:full_text_ocr] = 'true' if full_text
118
126
  uri.query = URI.encode_www_form(params)
@@ -122,10 +130,10 @@ module Mindee
122
130
  'User-Agent' => USER_AGENT,
123
131
  }
124
132
  req = Net::HTTP::Post.new(uri, headers)
125
- form_data = if input_source.is_a?(Mindee::Input::Source::UrlInputSource)
133
+ form_data = if input_source.is_a?(Mindee::Input::Source::URLInputSource)
126
134
  [['document', input_source.url]]
127
135
  else
128
- [input_source.read_document(close: close_file)]
136
+ [input_source.read_contents(close: close_file)]
129
137
  end
130
138
  form_data.push ['include_mvision', 'true'] if all_words
131
139
 
@@ -137,16 +145,16 @@ module Mindee
137
145
  response
138
146
  end
139
147
 
140
- # @param input_source [Mindee::Input::Source::LocalInputSource, Mindee::Input::Source::UrlInputSource]
141
- # @param all_words [Boolean] Whether the full word extraction needs to be performed
142
- # @param full_text [Boolean] Whether to include the full OCR text response in compatible APIs.
143
- # @param close_file [Boolean] Whether the file will be closed after reading
144
- # @param cropper [Boolean] Whether a cropping operation will be applied
148
+ # @param input_source [Mindee::Input::Source::LocalInputSource, Mindee::Input::Source::URLInputSource]
149
+ # @param all_words [bool] Whether the full word extraction needs to be performed
150
+ # @param full_text [bool] Whether to include the full OCR text response in compatible APIs.
151
+ # @param close_file [bool] Whether the file will be closed after reading
152
+ # @param cropper [bool] Whether a cropping operation will be applied
145
153
  # @return [Net::HTTPResponse, nil]
146
154
  def document_queue_req_get(input_source, all_words, full_text, close_file, cropper)
147
155
  uri = URI("#{@url_root}/predict_async")
148
156
 
149
- params = {}
157
+ params = {} # : Hash[Symbol | String, untyped]
150
158
  params[:cropper] = 'true' if cropper
151
159
  params[:full_text_ocr] = 'true' if full_text
152
160
  uri.query = URI.encode_www_form(params)
@@ -156,10 +164,10 @@ module Mindee
156
164
  'User-Agent' => USER_AGENT,
157
165
  }
158
166
  req = Net::HTTP::Post.new(uri, headers)
159
- form_data = if input_source.is_a?(Mindee::Input::Source::UrlInputSource)
167
+ form_data = if input_source.is_a?(Mindee::Input::Source::URLInputSource)
160
168
  [['document', input_source.url]]
161
169
  else
162
- [input_source.read_document(close: close_file)]
170
+ [input_source.read_contents(close: close_file)]
163
171
  end
164
172
  form_data.push ['include_mvision', 'true'] if all_words
165
173
 
@@ -201,9 +209,9 @@ module Mindee
201
209
  def check_api_key
202
210
  return unless @api_key.nil? || @api_key.empty?
203
211
 
204
- raise "Missing API key for product \"'#{@url_name}' v#{@version}\" (belonging to \"#{@owner}\"), " \
205
- "check your Client Configuration.\n" \
206
- 'You can set this using the ' \
212
+ raise Errors::MindeeAPIError,
213
+ "Missing API key for product \"'#{@url_name}' v#{@version}\" (belonging to \"#{@owner}\"), " \
214
+ "check your Client Configuration.\nYou can set this using the " \
207
215
  "'#{HTTP::API_KEY_ENV_NAME}' environment variable."
208
216
  end
209
217
  end
@@ -1,11 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'json'
4
+ require_relative '../errors/mindee_http_error'
4
5
 
5
6
  module Mindee
6
7
  module HTTP
7
8
  # Mindee HTTP error module.
8
- module Error
9
+ module ErrorHandler
9
10
  module_function
10
11
 
11
12
  # Extracts the HTTP error from the response hash, or the job error if there is one.
@@ -80,44 +81,13 @@ module Mindee
80
81
  error_obj = create_error_obj(parsed_hash)
81
82
  case code
82
83
  when 400..499
83
- MindeeHttpClientError.new(error_obj, url, code)
84
+ Errors::MindeeHTTPClientError.new(error_obj, url, code)
84
85
  when 500..599
85
- MindeeHttpServerError.new(error_obj, url, code)
86
+ Errors::MindeeHTTPServerError.new(error_obj, url, code)
86
87
  else
87
- MindeeHttpError.new(error_obj, url, code)
88
+ Errors::MindeeHTTPError.new(error_obj, url, code)
88
89
  end
89
90
  end
90
-
91
- # API HttpError
92
- class MindeeHttpError < StandardError
93
- # @return [String]
94
- attr_reader :status_code
95
- # @return [Integer]
96
- attr_reader :api_code
97
- # @return [String]
98
- attr_reader :api_details
99
- # @return [String]
100
- attr_reader :api_message
101
-
102
- # @param http_error [Hash]
103
- # @param url [String]
104
- # @param code [Integer]
105
- def initialize(http_error, url, code)
106
- @status_code = code
107
- @api_code = http_error['code']
108
- @api_details = http_error['details']
109
- @api_message = http_error['message']
110
- super("#{url} #{@status_code} HTTP error: #{@api_details} - #{@api_message}")
111
- end
112
- end
113
-
114
- # API client HttpError
115
- class MindeeHttpClientError < MindeeHttpError
116
- end
117
-
118
- # API server HttpError
119
- class MindeeHttpServerError < MindeeHttpError
120
- end
121
91
  end
122
92
  end
123
93
  end
@@ -9,7 +9,7 @@ module Mindee
9
9
  module ResponseValidation
10
10
  # Checks if the synchronous response is valid. Returns True if the response is valid.
11
11
  # @param [Net::HTTPResponse] response
12
- # @return [Boolean]
12
+ # @return [bool]
13
13
  def self.valid_sync_response?(response)
14
14
  return false unless (200..399).cover?(response.code.to_i)
15
15
 
@@ -24,7 +24,7 @@ module Mindee
24
24
  # Checks if the asynchronous response is valid. Also checks if it is a valid synchronous response.
25
25
  # Returns true if the response is valid.
26
26
  # @param [Net::HTTPResponse] response
27
- # @return [Boolean]
27
+ # @return [bool]
28
28
  def self.valid_async_response?(response)
29
29
  return false unless valid_sync_response?(response)
30
30
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'json'
4
4
  require 'net/http'
5
- require_relative 'error'
5
+ require_relative 'http_error_handler'
6
6
 
7
7
  module Mindee
8
8
  module HTTP
@@ -23,10 +23,10 @@ module Mindee
23
23
  end
24
24
 
25
25
  # Sends a document to the workflow.
26
- # @param input_source [Mindee::Input::Source::LocalInputSource, Mindee::Input::Source::UrlInputSource]
26
+ # @param input_source [Mindee::Input::Source::LocalInputSource, Mindee::Input::Source::URLInputSource]
27
27
  # @param document_alias [String, nil] Alias to give to the document.
28
28
  # @param priority [Symbol, nil] Priority to give to the document.
29
- # @param full_text [Boolean] Whether to include the full OCR text response in compatible APIs.
29
+ # @param full_text [bool] Whether to include the full OCR text response in compatible APIs.
30
30
  # @param public_url [String, nil] A unique, encrypted URL for accessing the document validation interface without
31
31
  # requiring authentication.
32
32
  # @return [Array]
@@ -37,20 +37,20 @@ module Mindee
37
37
  return [hashed_response, response.body] if ResponseValidation.valid_async_response?(response)
38
38
 
39
39
  ResponseValidation.clean_request!(response)
40
- error = Error.handle_error(@url_name, response)
40
+ error = Mindee::HTTP::ErrorHandler.handle_error(@url_name, response)
41
41
  raise error
42
42
  end
43
43
 
44
- # @param input_source [Mindee::Input::Source::LocalInputSource, Mindee::Input::Source::UrlInputSource]
44
+ # @param input_source [Mindee::Input::Source::LocalInputSource, Mindee::Input::Source::URLInputSource]
45
45
  # @param document_alias [String, nil] Alias to give to the document.
46
46
  # @param priority [Symbol, nil] Priority to give to the document.
47
- # @param full_text [Boolean] Whether to include the full OCR text response in compatible APIs.
47
+ # @param full_text [bool] Whether to include the full OCR text response in compatible APIs.
48
48
  # @param public_url [String, nil] A unique, encrypted URL for accessing the document validation interface without
49
49
  # requiring authentication.
50
50
  # @return [Net::HTTPResponse, nil]
51
51
  def workflow_execution_req_post(input_source, document_alias, priority, full_text, public_url)
52
52
  uri = URI(@url)
53
- params = {}
53
+ params = {} # : Hash[Symbol | String, untyped]
54
54
  params[:full_text_ocr] = 'true' if full_text
55
55
  uri.query = URI.encode_www_form(params)
56
56
 
@@ -59,10 +59,10 @@ module Mindee
59
59
  'User-Agent' => USER_AGENT,
60
60
  }
61
61
  req = Net::HTTP::Post.new(uri, headers)
62
- form_data = if input_source.is_a?(Mindee::Input::Source::UrlInputSource)
62
+ form_data = if input_source.is_a?(Mindee::Input::Source::URLInputSource)
63
63
  [['document', input_source.url]]
64
64
  else
65
- [input_source.read_document]
65
+ [input_source.read_contents]
66
66
  end
67
67
  form_data.push ['alias', document_alias] if document_alias
68
68
  form_data.push ['public_url', public_url] if public_url
@@ -81,9 +81,9 @@ module Mindee
81
81
  def check_api_key
82
82
  return unless @api_key.nil? || @api_key.empty?
83
83
 
84
- raise "Missing API key. Check your Client Configuration.\n" \
85
- 'You can set this using the ' \
86
- "'#{HTTP::API_KEY_ENV_NAME}' environment variable."
84
+ raise Errors::MindeeConfigurationError, "Missing API key. Check your Client Configuration.\n" \
85
+ "You can set this using the '#{HTTP::API_KEY_ENV_NAME}'" \
86
+ 'environment variable.'
87
87
  end
88
88
  end
89
89
  end
data/lib/mindee/http.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'http/endpoint'
4
- require_relative 'http/error'
4
+ require_relative 'http/http_error_handler'
5
5
  require_relative 'http/workflow_endpoint'
@@ -1,16 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../../input/sources'
3
+ require_relative '../input/sources'
4
+ require_relative '../logging'
4
5
 
5
6
  module Mindee
6
7
  # Image Extraction Module.
7
- module Extraction
8
+ module Image
8
9
  # Generic class for image extraction.
9
10
  class ExtractedImage
10
- # Id of the page the image was extracted from.
11
+ # ID of the page the image was extracted from.
11
12
  attr_reader :page_id
12
13
 
13
- # Id of the element on a given page.
14
+ # ID of the element on a given page.
14
15
  attr_reader :element_id
15
16
 
16
17
  # Buffer object of the file's content.
@@ -25,14 +26,15 @@ module Mindee
25
26
  # @param page_id [Integer] ID of the page the element was found on.
26
27
  # @param element_id [Integer, nil] ID of the element in a page.
27
28
  def initialize(input_source, page_id, element_id)
28
- @buffer = StringIO.new(input_source.io_stream.read)
29
+ @buffer = StringIO.new(input_source.io_stream.read.to_s)
29
30
  @buffer.rewind
30
31
  extension = if input_source.pdf?
31
- 'jpg'
32
+ '.jpg'
32
33
  else
33
34
  File.extname(input_source.filename)
34
35
  end
35
- @internal_file_name = "#{input_source.filename}_p#{page_id}_#{element_id}.#{extension}"
36
+ base_name = File.basename(input_source.filename, File.extname(input_source.filename))
37
+ @internal_file_name = "#{base_name}_p#{page_id}_#{element_id}#{extension}"
36
38
  @page_id = page_id
37
39
  @element_id = element_id.nil? ? 0 : element_id
38
40
  end
@@ -43,21 +45,23 @@ module Mindee
43
45
  # @param file_format [String, nil] Optional MiniMagick-compatible format for the file. Inferred from file
44
46
  # extension if not provided.
45
47
  # @raise [MindeeError] If an invalid path or filename is provided.
46
- def save_to_file(output_path, file_format = nil)
47
- resolved_path = Pathname.new(output_path).realpath
48
+ def write_to_file(output_path, file_format = nil)
49
+ resolved_path = Pathname.new(File.expand_path(output_path))
48
50
  if file_format.nil?
49
- raise ArgumentError, 'Invalid file format.' if resolved_path.extname.delete('.').empty?
51
+ raise Errors::MindeeImageError, 'Invalid file format.' if resolved_path.extname.delete('.').empty?
50
52
 
51
53
  file_format = resolved_path.extname.delete('.').upcase
52
54
  end
53
- @buffer.rewind
54
- image = MiniMagick::Image.read(@buffer)
55
- image.format file_format.downcase
56
- image.write resolved_path.to_s
57
- rescue TypeError
58
- raise 'Invalid path/filename provided.'
59
- rescue StandardError
60
- raise "Could not save file #{Pathname.new(output_path).basename}."
55
+ begin
56
+ @buffer.rewind
57
+ image = MiniMagick::Image.read(@buffer)
58
+ image.format file_format.to_s.downcase
59
+ image.write resolved_path.to_s
60
+ logger.info("File saved successfully to '#{resolved_path}'")
61
+ rescue StandardError
62
+ raise Errors::MindeeImageError, "Could not save file '#{output_path}'. " \
63
+ 'Is the provided file path valid?.'
64
+ end
61
65
  end
62
66
 
63
67
  # Return the file as a Mindee-compatible BufferInput source.