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.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -1
- data/CHANGELOG.md +28 -0
- data/README.md +42 -52
- data/Steepfile +31 -0
- data/bin/mindee.rb +30 -62
- data/docs/advanced_file_operations.md +111 -0
- data/docs/code_samples/bank_account_details_v1.txt +5 -0
- data/docs/code_samples/bank_account_details_v2.txt +5 -0
- data/docs/code_samples/bank_check_v1.txt +5 -0
- data/docs/code_samples/{us_driver_license_v1.txt → bank_statement_fr_v2_async.txt} +6 -1
- data/docs/code_samples/barcode_reader_v1.txt +5 -0
- data/docs/code_samples/bill_of_lading_v1_async.txt +6 -1
- data/docs/code_samples/business_card_v1_async.txt +6 -1
- data/docs/code_samples/carte_grise_v1.txt +5 -0
- data/docs/code_samples/cropper_v1.txt +5 -0
- data/docs/code_samples/default.txt +8 -2
- data/docs/code_samples/default_async.txt +7 -2
- data/docs/code_samples/delivery_notes_v1_async.txt +6 -1
- data/docs/code_samples/driver_license_v1_async.txt +6 -1
- data/docs/code_samples/energy_bill_fra_v1_async.txt +6 -1
- data/docs/code_samples/expense_receipts_v5.txt +7 -1
- data/docs/code_samples/expense_receipts_v5_async.txt +6 -1
- data/docs/code_samples/financial_document_v1.txt +7 -1
- data/docs/code_samples/financial_document_v1_async.txt +6 -1
- data/docs/code_samples/french_healthcard_v1_async.txt +6 -1
- data/docs/code_samples/idcard_fr_v1.txt +5 -0
- data/docs/code_samples/idcard_fr_v2.txt +5 -0
- data/docs/code_samples/ind_passport_v1_async.txt +6 -1
- data/docs/code_samples/international_id_v2_async.txt +6 -1
- data/docs/code_samples/invoice_splitter_v1_async.txt +6 -1
- data/docs/code_samples/invoices_v4.txt +7 -1
- data/docs/code_samples/invoices_v4_async.txt +6 -1
- data/docs/code_samples/license_plates_v1.txt +5 -0
- data/docs/code_samples/multi_receipts_detector_v1.txt +5 -0
- data/docs/code_samples/nutrition_facts_v1_async.txt +6 -1
- data/docs/code_samples/passport_v1.txt +5 -0
- data/docs/code_samples/payslip_fra_v2_async.txt +6 -1
- data/docs/code_samples/payslip_fra_v3_async.txt +6 -1
- data/docs/code_samples/resume_v1_async.txt +6 -1
- data/docs/code_samples/us_healthcare_cards_v1_async.txt +6 -1
- data/docs/code_samples/us_mail_v3_async.txt +6 -1
- data/docs/code_samples/us_w9_v1.txt +5 -0
- data/docs/getting_started.md +50 -118
- data/docs/{barcode_reader_v1.md → global_products/barcode_reader_v1.md} +26 -9
- data/docs/{bill_of_lading_v1.md → global_products/bill_of_lading_v1.md} +62 -37
- data/docs/{business_card_v1.md → global_products/business_card_v1.md} +35 -10
- data/docs/{cropper_v1.md → global_products/cropper_v1.md} +32 -13
- data/docs/{delivery_notes_v1.md → global_products/delivery_notes_v1.md} +35 -10
- data/docs/{driver_license_v1.md → global_products/driver_license_v1.md} +65 -9
- data/docs/{expense_receipts_v5.md → global_products/expense_receipts_v5.md} +57 -21
- data/docs/{financial_document_v1.md → global_products/financial_document_v1.md} +70 -33
- data/docs/{international_id_v2.md → global_products/international_id_v2.md} +39 -13
- data/docs/{invoice_splitter_v1.md → global_products/invoice_splitter_v1.md} +25 -6
- data/docs/{invoices_v4.md → global_products/invoices_v4.md} +70 -33
- data/docs/{multi_receipts_detector_v1.md → global_products/multi_receipts_detector_v1.md} +32 -13
- data/docs/{nutrition_facts_v1.md → global_products/nutrition_facts_v1.md} +103 -78
- data/docs/{passport_v1.md → global_products/passport_v1.md} +26 -9
- data/docs/{resume_v1.md → global_products/resume_v1.md} +72 -46
- data/docs/{generated_v1.md → global_products/universal.md} +39 -19
- data/docs/global_products.md +6 -0
- data/docs/loading_a_document.md +316 -0
- data/docs/{bank_account_details_v2.md → localized_products/bank_account_details_v2.md} +24 -7
- data/docs/{bank_check_v1.md → localized_products/bank_check_v1.md} +37 -18
- data/docs/localized_products/bank_statement_fr_v2.md +269 -0
- data/docs/{carte_grise_v1.md → localized_products/carte_grise_v1.md} +25 -8
- data/docs/{energy_bill_fra_v1.md → localized_products/energy_bill_fra_v1.md} +70 -45
- data/docs/{french_healthcard_v1.md → localized_products/french_healthcard_v1.md} +36 -11
- data/docs/{idcard_fr_v2.md → localized_products/idcard_fr_v2.md} +34 -16
- data/docs/{ind_passport_v1.md → localized_products/ind_passport_v1.md} +37 -11
- data/docs/{license_plates_v1.md → localized_products/license_plates_v1.md} +25 -8
- data/docs/{payslip_fra_v3.md → localized_products/payslip_fra_v3.md} +80 -55
- data/docs/{us_healthcare_cards_v1.md → localized_products/us_healthcare_cards_v1.md} +37 -12
- data/docs/{us_mail_v3.md → localized_products/us_mail_v3.md} +49 -24
- data/docs/{us_w9_v1.md → localized_products/us_w9_v1.md} +64 -45
- data/docs/localized_products.md +6 -0
- data/examples/auto_invoice_splitter_extraction.rb +5 -5
- data/examples/auto_multi_receipts_detector_extraction.rb +4 -5
- data/lib/mindee/client.rb +354 -209
- data/lib/mindee/errors/mindee_error.rb +17 -0
- data/lib/mindee/errors/mindee_http_error.rb +36 -0
- data/lib/mindee/errors/mindee_input_error.rb +30 -0
- data/lib/mindee/errors.rb +5 -0
- data/lib/mindee/extraction/multi_receipts_extractor.rb +28 -1
- data/lib/mindee/extraction.rb +0 -3
- data/lib/mindee/geometry/polygon.rb +1 -1
- data/lib/mindee/geometry/utils.rb +1 -1
- data/lib/mindee/http/endpoint.rb +48 -40
- data/lib/mindee/http/{error.rb → http_error_handler.rb} +5 -35
- data/lib/mindee/http/response_validation.rb +2 -2
- data/lib/mindee/http/workflow_endpoint.rb +12 -12
- data/lib/mindee/http.rb +1 -1
- data/lib/mindee/{extraction/common → image}/extracted_image.rb +22 -18
- data/lib/mindee/{extraction/common → image}/image_extractor.rb +20 -78
- data/lib/mindee/image/image_utils.rb +68 -7
- data/lib/mindee/image.rb +2 -0
- data/lib/mindee/input/local_response.rb +8 -8
- data/lib/mindee/input/sources/base64_input_source.rb +6 -6
- data/lib/mindee/input/sources/bytes_input_source.rb +3 -3
- data/lib/mindee/input/sources/file_input_source.rb +3 -3
- data/lib/mindee/input/sources/local_input_source.rb +43 -41
- data/lib/mindee/input/sources/path_input_source.rb +3 -3
- data/lib/mindee/input/sources/url_input_source.rb +11 -8
- data/lib/mindee/logging/logger.rb +16 -0
- data/lib/mindee/logging.rb +3 -0
- data/lib/mindee/parsing/common/api_request.rb +36 -0
- data/lib/mindee/parsing/common/api_response.rb +6 -96
- data/lib/mindee/parsing/common/document.rb +12 -8
- data/lib/mindee/parsing/common/execution.rb +4 -2
- data/lib/mindee/parsing/common/execution_priority.rb +6 -0
- data/lib/mindee/parsing/common/extras/cropper_extra.rb +2 -1
- data/lib/mindee/parsing/common/extras/extras.rb +9 -4
- data/lib/mindee/parsing/common/extras/full_text_ocr_extra.rb +1 -0
- data/lib/mindee/parsing/common/inference.rb +23 -4
- data/lib/mindee/parsing/common/job.rb +46 -0
- data/lib/mindee/parsing/common/ocr/mvision_v1.rb +6 -6
- data/lib/mindee/parsing/common/ocr/ocr.rb +29 -29
- data/lib/mindee/parsing/common/page.rb +5 -3
- data/lib/mindee/parsing/common/prediction.rb +2 -0
- data/lib/mindee/parsing/common/workflow_response.rb +28 -0
- data/lib/mindee/parsing/common.rb +3 -0
- data/lib/mindee/parsing/standard/abstract_field.rb +72 -0
- data/lib/mindee/parsing/standard/amount_field.rb +2 -2
- data/lib/mindee/parsing/standard/base_field.rb +5 -84
- data/lib/mindee/parsing/standard/boolean_field.rb +4 -3
- data/lib/mindee/parsing/standard/classification_field.rb +1 -1
- data/lib/mindee/parsing/standard/company_registration_field.rb +7 -2
- data/lib/mindee/parsing/standard/date_field.rb +2 -2
- data/lib/mindee/parsing/standard/feature_field.rb +24 -0
- data/lib/mindee/parsing/standard/payment_details_field.rb +2 -2
- data/lib/mindee/parsing/standard/position_field.rb +3 -1
- data/lib/mindee/parsing/standard/string_field.rb +1 -1
- data/lib/mindee/parsing/standard/tax_field.rb +1 -1
- data/lib/mindee/parsing/standard.rb +1 -0
- data/lib/mindee/parsing/{generated/generated_list_field.rb → universal/universal_list_field.rb} +12 -12
- data/lib/mindee/parsing/{generated/generated_object_field.rb → universal/universal_object_field.rb} +23 -14
- data/lib/mindee/parsing/universal.rb +4 -0
- data/lib/mindee/parsing.rb +1 -2
- data/lib/mindee/{extraction/pdf_extractor → pdf}/extracted_pdf.rb +15 -12
- data/lib/mindee/pdf/pdf_compressor.rb +12 -10
- data/lib/mindee/{extraction/pdf_extractor → pdf}/pdf_extractor.rb +20 -17
- data/lib/mindee/pdf/pdf_processor.rb +12 -22
- data/lib/mindee/pdf/pdf_tools.rb +52 -6
- data/lib/mindee/pdf.rb +2 -0
- data/lib/mindee/product/.rubocop.yml +3 -0
- data/lib/mindee/product/barcode_reader/barcode_reader_v1.rb +9 -3
- data/lib/mindee/product/barcode_reader/barcode_reader_v1_document.rb +5 -5
- data/lib/mindee/product/barcode_reader/barcode_reader_v1_page.rb +9 -5
- data/lib/mindee/product/bill_of_lading/bill_of_lading_v1.rb +9 -3
- data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_carrier.rb +1 -1
- data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_carrier_item.rb +13 -7
- data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_carrier_items.rb +62 -0
- data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_consignee.rb +1 -1
- data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_document.rb +44 -17
- data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_notify_party.rb +1 -1
- data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_page.rb +9 -5
- data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_shipper.rb +1 -1
- data/lib/mindee/product/business_card/business_card_v1.rb +9 -3
- data/lib/mindee/product/business_card/business_card_v1_document.rb +40 -13
- data/lib/mindee/product/business_card/business_card_v1_page.rb +9 -5
- data/lib/mindee/product/cropper/cropper_v1.rb +10 -4
- data/lib/mindee/product/cropper/cropper_v1_page.rb +11 -7
- data/lib/mindee/product/delivery_note/delivery_note_v1.rb +9 -3
- data/lib/mindee/product/delivery_note/delivery_note_v1_document.rb +29 -8
- data/lib/mindee/product/delivery_note/delivery_note_v1_page.rb +9 -5
- data/lib/mindee/product/driver_license/driver_license_v1.rb +9 -3
- data/lib/mindee/product/driver_license/driver_license_v1_document.rb +44 -14
- data/lib/mindee/product/driver_license/driver_license_v1_page.rb +9 -5
- data/lib/mindee/product/eu/license_plate/license_plate_v1.rb +9 -3
- data/lib/mindee/product/eu/license_plate/license_plate_v1_document.rb +3 -3
- data/lib/mindee/product/eu/license_plate/license_plate_v1_page.rb +9 -5
- data/lib/mindee/product/financial_document/financial_document_v1.rb +9 -3
- data/lib/mindee/product/financial_document/financial_document_v1_document.rb +110 -42
- data/lib/mindee/product/financial_document/financial_document_v1_line_item.rb +21 -11
- data/lib/mindee/product/financial_document/financial_document_v1_line_items.rb +62 -0
- data/lib/mindee/product/financial_document/financial_document_v1_page.rb +9 -5
- data/lib/mindee/product/fr/bank_account_details/bank_account_details_v1.rb +9 -3
- data/lib/mindee/product/fr/bank_account_details/bank_account_details_v1_document.rb +7 -4
- data/lib/mindee/product/fr/bank_account_details/bank_account_details_v1_page.rb +9 -5
- data/lib/mindee/product/fr/bank_account_details/bank_account_details_v2.rb +9 -3
- data/lib/mindee/product/fr/bank_account_details/bank_account_details_v2_bban.rb +1 -1
- data/lib/mindee/product/fr/bank_account_details/bank_account_details_v2_document.rb +11 -5
- data/lib/mindee/product/fr/bank_account_details/bank_account_details_v2_page.rb +9 -5
- data/lib/mindee/product/fr/bank_statement/bank_statement_v2.rb +47 -0
- data/lib/mindee/product/fr/bank_statement/{bank_statement_v1_document.rb → bank_statement_v2_document.rb} +62 -26
- data/lib/mindee/product/fr/bank_statement/bank_statement_v2_page.rb +38 -0
- data/lib/mindee/product/fr/bank_statement/{bank_statement_v1_transaction.rb → bank_statement_v2_transaction.rb} +17 -6
- data/lib/mindee/product/fr/bank_statement/bank_statement_v2_transactions.rb +54 -0
- data/lib/mindee/product/fr/carte_grise/carte_grise_v1.rb +9 -3
- data/lib/mindee/product/fr/carte_grise/carte_grise_v1_document.rb +51 -42
- data/lib/mindee/product/fr/carte_grise/carte_grise_v1_page.rb +9 -5
- data/lib/mindee/product/fr/energy_bill/energy_bill_v1.rb +9 -3
- data/lib/mindee/product/fr/energy_bill/energy_bill_v1_document.rb +56 -30
- data/lib/mindee/product/fr/energy_bill/energy_bill_v1_energy_consumer.rb +1 -1
- data/lib/mindee/product/fr/energy_bill/energy_bill_v1_energy_supplier.rb +1 -1
- data/lib/mindee/product/fr/energy_bill/energy_bill_v1_energy_usage.rb +13 -7
- data/lib/mindee/product/fr/energy_bill/energy_bill_v1_energy_usages.rb +65 -0
- data/lib/mindee/product/fr/energy_bill/energy_bill_v1_meter_detail.rb +1 -1
- data/lib/mindee/product/fr/energy_bill/energy_bill_v1_page.rb +9 -5
- data/lib/mindee/product/fr/energy_bill/energy_bill_v1_subscription.rb +13 -7
- data/lib/mindee/product/fr/energy_bill/energy_bill_v1_subscriptions.rb +65 -0
- data/lib/mindee/product/fr/energy_bill/energy_bill_v1_taxes_and_contribution.rb +13 -7
- data/lib/mindee/product/fr/energy_bill/energy_bill_v1_taxes_and_contributions.rb +65 -0
- data/lib/mindee/product/fr/health_card/health_card_v1.rb +9 -3
- data/lib/mindee/product/fr/health_card/health_card_v1_document.rb +15 -6
- data/lib/mindee/product/fr/health_card/health_card_v1_page.rb +9 -5
- data/lib/mindee/product/fr/id_card/id_card_v1.rb +9 -3
- data/lib/mindee/product/fr/id_card/id_card_v1_document.rb +33 -12
- data/lib/mindee/product/fr/id_card/id_card_v1_page.rb +14 -7
- data/lib/mindee/product/fr/id_card/id_card_v2.rb +9 -3
- data/lib/mindee/product/fr/id_card/id_card_v2_document.rb +50 -17
- data/lib/mindee/product/fr/id_card/id_card_v2_page.rb +18 -8
- data/lib/mindee/product/fr/payslip/payslip_v2.rb +9 -3
- data/lib/mindee/product/fr/payslip/payslip_v2_bank_account_detail.rb +1 -1
- data/lib/mindee/product/fr/payslip/payslip_v2_document.rb +29 -14
- data/lib/mindee/product/fr/payslip/payslip_v2_employee.rb +1 -1
- data/lib/mindee/product/fr/payslip/payslip_v2_employer.rb +1 -1
- data/lib/mindee/product/fr/payslip/payslip_v2_employment.rb +3 -2
- data/lib/mindee/product/fr/payslip/payslip_v2_page.rb +9 -5
- data/lib/mindee/product/fr/payslip/payslip_v2_pay_detail.rb +33 -11
- data/lib/mindee/product/fr/payslip/payslip_v2_pay_period.rb +1 -1
- data/lib/mindee/product/fr/payslip/payslip_v2_pto.rb +13 -4
- data/lib/mindee/product/fr/payslip/payslip_v2_salary_detail.rb +13 -7
- data/lib/mindee/product/fr/payslip/payslip_v2_salary_details.rb +63 -0
- data/lib/mindee/product/fr/payslip/payslip_v3.rb +9 -3
- data/lib/mindee/product/fr/payslip/payslip_v3_bank_account_detail.rb +1 -1
- data/lib/mindee/product/fr/payslip/payslip_v3_document.rb +31 -19
- data/lib/mindee/product/fr/payslip/payslip_v3_employee.rb +1 -1
- data/lib/mindee/product/fr/payslip/payslip_v3_employer.rb +1 -1
- data/lib/mindee/product/fr/payslip/payslip_v3_employment.rb +1 -1
- data/lib/mindee/product/fr/payslip/payslip_v3_page.rb +9 -5
- data/lib/mindee/product/fr/payslip/payslip_v3_paid_time_off.rb +13 -7
- data/lib/mindee/product/fr/payslip/payslip_v3_paid_time_offs.rb +65 -0
- data/lib/mindee/product/fr/payslip/payslip_v3_pay_detail.rb +33 -11
- data/lib/mindee/product/fr/payslip/payslip_v3_pay_period.rb +1 -1
- data/lib/mindee/product/fr/payslip/payslip_v3_salary_detail.rb +17 -9
- data/lib/mindee/product/fr/payslip/payslip_v3_salary_details.rb +65 -0
- data/lib/mindee/product/ind/indian_passport/indian_passport_v1.rb +9 -3
- data/lib/mindee/product/ind/indian_passport/indian_passport_v1_document.rb +87 -24
- data/lib/mindee/product/ind/indian_passport/indian_passport_v1_page.rb +9 -5
- data/lib/mindee/product/international_id/international_id_v2.rb +9 -3
- data/lib/mindee/product/international_id/international_id_v2_document.rb +62 -20
- data/lib/mindee/product/international_id/international_id_v2_page.rb +9 -5
- data/lib/mindee/product/invoice/invoice_v4.rb +9 -3
- data/lib/mindee/product/invoice/invoice_v4_document.rb +90 -36
- data/lib/mindee/product/invoice/invoice_v4_line_item.rb +21 -11
- data/lib/mindee/product/invoice/invoice_v4_line_items.rb +62 -0
- data/lib/mindee/product/invoice/invoice_v4_page.rb +9 -5
- data/lib/mindee/product/invoice_splitter/invoice_splitter_v1.rb +8 -0
- data/lib/mindee/product/invoice_splitter/invoice_splitter_v1_document.rb +2 -2
- data/lib/mindee/product/invoice_splitter/invoice_splitter_v1_page.rb +1 -1
- data/lib/mindee/product/multi_receipts_detector/multi_receipts_detector_v1.rb +9 -3
- data/lib/mindee/product/multi_receipts_detector/multi_receipts_detector_v1_document.rb +3 -3
- data/lib/mindee/product/multi_receipts_detector/multi_receipts_detector_v1_page.rb +9 -5
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1.rb +9 -3
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_added_sugar.rb +7 -4
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_calorie.rb +7 -4
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_cholesterol.rb +7 -4
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_dietary_fiber.rb +7 -4
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_document.rb +58 -20
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_nutrient.rb +13 -7
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_nutrients.rb +68 -0
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_page.rb +9 -5
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_protein.rb +7 -4
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_saturated_fat.rb +7 -4
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_serving_size.rb +3 -2
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_sodium.rb +7 -4
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_total_carbohydrate.rb +7 -4
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_total_fat.rb +7 -4
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_total_sugar.rb +7 -4
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_trans_fat.rb +7 -4
- data/lib/mindee/product/passport/passport_v1.rb +9 -3
- data/lib/mindee/product/passport/passport_v1_document.rb +37 -13
- data/lib/mindee/product/passport/passport_v1_page.rb +9 -5
- data/lib/mindee/product/receipt/receipt_v5.rb +9 -3
- data/lib/mindee/product/receipt/receipt_v5_document.rb +54 -24
- data/lib/mindee/product/receipt/receipt_v5_line_item.rb +13 -7
- data/lib/mindee/product/receipt/receipt_v5_line_items.rb +54 -0
- data/lib/mindee/product/receipt/receipt_v5_page.rb +9 -5
- data/lib/mindee/product/resume/resume_v1.rb +9 -3
- data/lib/mindee/product/resume/resume_v1_certificate.rb +1 -1
- data/lib/mindee/product/resume/resume_v1_certificates.rb +58 -0
- data/lib/mindee/product/resume/resume_v1_document.rb +60 -47
- data/lib/mindee/product/resume/resume_v1_education.rb +1 -1
- data/lib/mindee/product/resume/resume_v1_educations.rb +64 -0
- data/lib/mindee/product/resume/resume_v1_language.rb +1 -1
- data/lib/mindee/product/resume/resume_v1_languages.rb +54 -0
- data/lib/mindee/product/resume/resume_v1_page.rb +9 -5
- data/lib/mindee/product/resume/resume_v1_professional_experience.rb +1 -1
- data/lib/mindee/product/resume/resume_v1_professional_experiences.rb +68 -0
- data/lib/mindee/product/resume/resume_v1_social_networks_url.rb +1 -1
- data/lib/mindee/product/resume/resume_v1_social_networks_urls.rb +54 -0
- data/lib/mindee/product/universal/universal.rb +46 -0
- data/lib/mindee/product/universal/universal_document.rb +32 -0
- data/lib/mindee/product/{generated/generated_v1_page.rb → universal/universal_page.rb} +14 -14
- data/lib/mindee/product/{generated/generated_v1_prediction.rb → universal/universal_prediction.rb} +32 -24
- data/lib/mindee/product/us/bank_check/bank_check_v1.rb +9 -3
- data/lib/mindee/product/us/bank_check/bank_check_v1_document.rb +20 -8
- data/lib/mindee/product/us/bank_check/bank_check_v1_page.rb +15 -8
- data/lib/mindee/product/us/healthcare_card/healthcare_card_v1.rb +9 -3
- data/lib/mindee/product/us/healthcare_card/healthcare_card_v1_copay.rb +5 -3
- data/lib/mindee/product/us/healthcare_card/healthcare_card_v1_copays.rb +52 -0
- data/lib/mindee/product/us/healthcare_card/healthcare_card_v1_document.rb +46 -19
- data/lib/mindee/product/us/healthcare_card/healthcare_card_v1_page.rb +9 -5
- data/lib/mindee/product/us/us_mail/us_mail_v3.rb +9 -3
- data/lib/mindee/product/us/us_mail/us_mail_v3_document.rb +20 -12
- data/lib/mindee/product/us/us_mail/us_mail_v3_page.rb +9 -5
- data/lib/mindee/product/us/us_mail/us_mail_v3_recipient_address.rb +2 -2
- data/lib/mindee/product/us/us_mail/us_mail_v3_recipient_addresses.rb +65 -0
- data/lib/mindee/product/us/us_mail/us_mail_v3_sender_address.rb +1 -1
- data/lib/mindee/product/us/w9/w9_v1.rb +10 -4
- data/lib/mindee/product/us/w9/w9_v1_page.rb +49 -18
- data/lib/mindee/product.rb +2 -8
- data/lib/mindee/version.rb +2 -2
- data/lib/mindee.rb +22 -9
- data/mindee.gemspec +19 -17
- data/sig/custom/marcel.rbs +3 -0
- data/sig/custom/mini_magick.rbs +24 -0
- data/sig/custom/net_http.rbs +34 -0
- data/sig/custom/origami.rbs +54 -0
- data/sig/mindee/client.rbs +63 -0
- data/sig/mindee/errors/mindee_error.rbs +13 -0
- data/sig/mindee/errors/mindee_http_error.rbs +16 -0
- data/sig/mindee/errors/mindee_input_error.rbs +17 -0
- data/sig/mindee/extraction/multi_receipts_extractor.rbs +6 -0
- data/sig/mindee/geometry/min_max.rbs +10 -0
- data/sig/mindee/geometry/point.rbs +13 -0
- data/sig/mindee/geometry/polygon.rbs +9 -0
- data/sig/mindee/geometry/quadrilateral.rbs +18 -0
- data/sig/mindee/geometry/utils.rbs +13 -0
- data/sig/mindee/http/endpoint.rbs +26 -0
- data/sig/mindee/http/http_error_handler.rbs +10 -0
- data/sig/mindee/http/response_validation.rbs +10 -0
- data/sig/mindee/http/workflow_endpoint.rbs +14 -0
- data/sig/mindee/image/extracted_image.rbs +15 -0
- data/sig/mindee/image/image_compressor.rbs +8 -0
- data/sig/mindee/image/image_extractor.rbs +13 -0
- data/sig/mindee/image/image_utils.rbs +19 -0
- data/sig/mindee/input/local_response.rbs +13 -0
- data/sig/mindee/input/sources/base64_input_source.rbs +11 -0
- data/sig/mindee/input/sources/bytes_input_source.rbs +10 -0
- data/sig/mindee/input/sources/file_input_source.rbs +10 -0
- data/sig/mindee/input/sources/local_input_source.rbs +24 -0
- data/sig/mindee/input/sources/path_input_source.rbs +10 -0
- data/sig/mindee/input/sources/url_input_source.rbs +20 -0
- data/sig/mindee/logging/logger.rbs +9 -0
- data/sig/mindee/parsing/common/api_request.rbs +15 -0
- data/sig/mindee/parsing/common/api_response.rbs +27 -0
- data/sig/mindee/parsing/common/document.rbs +20 -0
- data/sig/mindee/parsing/common/execution.rbs +23 -0
- data/sig/mindee/parsing/common/execution_file.rbs +12 -0
- data/sig/mindee/parsing/common/execution_priority.rbs +13 -0
- data/sig/mindee/parsing/common/extras/cropper_extra.rbs +14 -0
- data/sig/mindee/parsing/common/extras/extras.rbs +18 -0
- data/sig/mindee/parsing/common/extras/full_text_ocr_extra.rbs +15 -0
- data/sig/mindee/parsing/common/inference.rbs +19 -0
- data/sig/mindee/parsing/common/job.rbs +16 -0
- data/sig/mindee/parsing/common/ocr/mvision_v1.rbs +15 -0
- data/sig/mindee/parsing/common/ocr/ocr.rbs +39 -0
- data/sig/mindee/parsing/common/orientation.rbs +12 -0
- data/sig/mindee/parsing/common/page.rbs +15 -0
- data/sig/mindee/parsing/common/prediction.rbs +11 -0
- data/sig/mindee/parsing/common/product.rbs +13 -0
- data/sig/mindee/parsing/common/workflow_response.rbs +13 -0
- data/sig/mindee/parsing/standard/abstract_field.rbs +19 -0
- data/sig/mindee/parsing/standard/amount_field.rbs +12 -0
- data/sig/mindee/parsing/standard/base_field.rbs +12 -0
- data/sig/mindee/parsing/standard/boolean_field.rbs +12 -0
- data/sig/mindee/parsing/standard/classification_field.rbs +10 -0
- data/sig/mindee/parsing/standard/company_registration_field.rbs +14 -0
- data/sig/mindee/parsing/standard/date_field.rbs +14 -0
- data/sig/mindee/parsing/standard/feature_field.rbs +10 -0
- data/sig/mindee/parsing/standard/locale_field.rbs +16 -0
- data/sig/mindee/parsing/standard/payment_details_field.rbs +15 -0
- data/sig/mindee/parsing/standard/position_field.rbs +17 -0
- data/sig/mindee/parsing/standard/string_field.rbs +12 -0
- data/sig/mindee/parsing/standard/tax_field.rbs +23 -0
- data/sig/mindee/parsing/universal/universal_list_field.rbs +17 -0
- data/sig/mindee/parsing/universal/universal_object_field.rbs +23 -0
- data/sig/mindee/pdf/extracted_pdf.rbs +15 -0
- data/sig/mindee/pdf/pdf_compressor.rbs +15 -0
- data/sig/mindee/pdf/pdf_extractor.rbs +16 -0
- data/sig/mindee/pdf/pdf_processor.rbs +12 -0
- data/sig/mindee/pdf/pdf_tools.rbs +23 -0
- data/sig/mindee/product/barcode_reader/barcode_reader_v1.rbs +11 -0
- data/sig/mindee/product/barcode_reader/barcode_reader_v1_document.rbs +14 -0
- data/sig/mindee/product/barcode_reader/barcode_reader_v1_page.rbs +15 -0
- data/sig/mindee/product/bill_of_lading/bill_of_lading_v1.rbs +11 -0
- data/sig/mindee/product/bill_of_lading/bill_of_lading_v1_carrier.rbs +14 -0
- data/sig/mindee/product/bill_of_lading/bill_of_lading_v1_carrier_item.rbs +19 -0
- data/sig/mindee/product/bill_of_lading/bill_of_lading_v1_carrier_items.rbs +13 -0
- data/sig/mindee/product/bill_of_lading/bill_of_lading_v1_consignee.rbs +15 -0
- data/sig/mindee/product/bill_of_lading/bill_of_lading_v1_document.rbs +25 -0
- data/sig/mindee/product/bill_of_lading/bill_of_lading_v1_notify_party.rbs +15 -0
- data/sig/mindee/product/bill_of_lading/bill_of_lading_v1_page.rbs +15 -0
- data/sig/mindee/product/bill_of_lading/bill_of_lading_v1_shipper.rbs +15 -0
- data/sig/mindee/product/business_card/business_card_v1.rbs +11 -0
- data/sig/mindee/product/business_card/business_card_v1_document.rbs +23 -0
- data/sig/mindee/product/business_card/business_card_v1_page.rbs +15 -0
- data/sig/mindee/product/cropper/cropper_v1.rbs +11 -0
- data/sig/mindee/product/cropper/cropper_v1_document.rbs +12 -0
- data/sig/mindee/product/cropper/cropper_v1_page.rbs +16 -0
- data/sig/mindee/product/delivery_note/delivery_note_v1.rbs +11 -0
- data/sig/mindee/product/delivery_note/delivery_note_v1_document.rbs +19 -0
- data/sig/mindee/product/delivery_note/delivery_note_v1_page.rbs +15 -0
- data/sig/mindee/product/driver_license/driver_license_v1.rbs +11 -0
- data/sig/mindee/product/driver_license/driver_license_v1_document.rbs +25 -0
- data/sig/mindee/product/driver_license/driver_license_v1_page.rbs +15 -0
- data/sig/mindee/product/eu/license_plate/license_plate_v1.rbs +13 -0
- data/sig/mindee/product/eu/license_plate/license_plate_v1_document.rbs +15 -0
- data/sig/mindee/product/eu/license_plate/license_plate_v1_page.rbs +17 -0
- data/sig/mindee/product/financial_document/financial_document_v1.rbs +11 -0
- data/sig/mindee/product/financial_document/financial_document_v1_document.rbs +46 -0
- data/sig/mindee/product/financial_document/financial_document_v1_line_item.rbs +21 -0
- data/sig/mindee/product/financial_document/financial_document_v1_line_items.rbs +13 -0
- data/sig/mindee/product/financial_document/financial_document_v1_page.rbs +15 -0
- data/sig/mindee/product/fr/bank_account_details/bank_account_details_v1.rbs +13 -0
- data/sig/mindee/product/fr/bank_account_details/bank_account_details_v1_document.rbs +17 -0
- data/sig/mindee/product/fr/bank_account_details/bank_account_details_v1_page.rbs +17 -0
- data/sig/mindee/product/fr/bank_account_details/bank_account_details_v2.rbs +13 -0
- data/sig/mindee/product/fr/bank_account_details/bank_account_details_v2_bban.rbs +17 -0
- data/sig/mindee/product/fr/bank_account_details/bank_account_details_v2_document.rbs +18 -0
- data/sig/mindee/product/fr/bank_account_details/bank_account_details_v2_page.rbs +17 -0
- data/sig/mindee/product/fr/bank_statement/bank_statement_v2.rbs +13 -0
- data/sig/mindee/product/fr/bank_statement/bank_statement_v2_document.rbs +29 -0
- data/sig/mindee/product/fr/bank_statement/bank_statement_v2_page.rbs +17 -0
- data/sig/mindee/product/fr/bank_statement/bank_statement_v2_transaction.rbs +18 -0
- data/sig/mindee/product/fr/bank_statement/bank_statement_v2_transactions.rbs +15 -0
- data/sig/mindee/product/fr/carte_grise/carte_grise_v1.rbs +13 -0
- data/sig/mindee/product/fr/carte_grise/carte_grise_v1_document.rbs +55 -0
- data/sig/mindee/product/fr/carte_grise/carte_grise_v1_page.rbs +17 -0
- data/sig/mindee/product/fr/energy_bill/energy_bill_v1.rbs +13 -0
- data/sig/mindee/product/fr/energy_bill/energy_bill_v1_document.rbs +34 -0
- data/sig/mindee/product/fr/energy_bill/energy_bill_v1_energy_consumer.rbs +15 -0
- data/sig/mindee/product/fr/energy_bill/energy_bill_v1_energy_supplier.rbs +15 -0
- data/sig/mindee/product/fr/energy_bill/energy_bill_v1_energy_usage.rbs +21 -0
- data/sig/mindee/product/fr/energy_bill/energy_bill_v1_energy_usages.rbs +15 -0
- data/sig/mindee/product/fr/energy_bill/energy_bill_v1_meter_detail.rbs +16 -0
- data/sig/mindee/product/fr/energy_bill/energy_bill_v1_page.rbs +17 -0
- data/sig/mindee/product/fr/energy_bill/energy_bill_v1_subscription.rbs +21 -0
- data/sig/mindee/product/fr/energy_bill/energy_bill_v1_subscriptions.rbs +15 -0
- data/sig/mindee/product/fr/energy_bill/energy_bill_v1_taxes_and_contribution.rbs +21 -0
- data/sig/mindee/product/fr/energy_bill/energy_bill_v1_taxes_and_contributions.rbs +15 -0
- data/sig/mindee/product/fr/health_card/health_card_v1.rbs +13 -0
- data/sig/mindee/product/fr/health_card/health_card_v1_document.rbs +18 -0
- data/sig/mindee/product/fr/health_card/health_card_v1_page.rbs +17 -0
- data/sig/mindee/product/fr/id_card/id_card_v1.rbs +13 -0
- data/sig/mindee/product/fr/id_card/id_card_v1_document.rbs +24 -0
- data/sig/mindee/product/fr/id_card/id_card_v1_page.rbs +18 -0
- data/sig/mindee/product/fr/id_card/id_card_v2.rbs +13 -0
- data/sig/mindee/product/fr/id_card/id_card_v2_document.rbs +29 -0
- data/sig/mindee/product/fr/id_card/id_card_v2_page.rbs +19 -0
- data/sig/mindee/product/fr/payslip/payslip_v2.rbs +13 -0
- data/sig/mindee/product/fr/payslip/payslip_v2_bank_account_detail.rbs +16 -0
- data/sig/mindee/product/fr/payslip/payslip_v2_document.rbs +24 -0
- data/sig/mindee/product/fr/payslip/payslip_v2_employee.rbs +20 -0
- data/sig/mindee/product/fr/payslip/payslip_v2_employer.rbs +20 -0
- data/sig/mindee/product/fr/payslip/payslip_v2_employment.rbs +19 -0
- data/sig/mindee/product/fr/payslip/payslip_v2_page.rbs +17 -0
- data/sig/mindee/product/fr/payslip/payslip_v2_pay_detail.rbs +23 -0
- data/sig/mindee/product/fr/payslip/payslip_v2_pay_period.rbs +18 -0
- data/sig/mindee/product/fr/payslip/payslip_v2_pto.rbs +16 -0
- data/sig/mindee/product/fr/payslip/payslip_v2_salary_detail.rbs +19 -0
- data/sig/mindee/product/fr/payslip/payslip_v2_salary_details.rbs +15 -0
- data/sig/mindee/product/fr/payslip/payslip_v3.rbs +13 -0
- data/sig/mindee/product/fr/payslip/payslip_v3_bank_account_detail.rbs +16 -0
- data/sig/mindee/product/fr/payslip/payslip_v3_document.rbs +26 -0
- data/sig/mindee/product/fr/payslip/payslip_v3_employee.rbs +20 -0
- data/sig/mindee/product/fr/payslip/payslip_v3_employer.rbs +20 -0
- data/sig/mindee/product/fr/payslip/payslip_v3_employment.rbs +20 -0
- data/sig/mindee/product/fr/payslip/payslip_v3_page.rbs +17 -0
- data/sig/mindee/product/fr/payslip/payslip_v3_paid_time_off.rbs +20 -0
- data/sig/mindee/product/fr/payslip/payslip_v3_paid_time_offs.rbs +15 -0
- data/sig/mindee/product/fr/payslip/payslip_v3_pay_detail.rbs +23 -0
- data/sig/mindee/product/fr/payslip/payslip_v3_pay_period.rbs +18 -0
- data/sig/mindee/product/fr/payslip/payslip_v3_salary_detail.rbs +20 -0
- data/sig/mindee/product/fr/payslip/payslip_v3_salary_details.rbs +15 -0
- data/sig/mindee/product/ind/indian_passport/indian_passport_v1.rbs +13 -0
- data/sig/mindee/product/ind/indian_passport/indian_passport_v1_document.rbs +37 -0
- data/sig/mindee/product/ind/indian_passport/indian_passport_v1_page.rbs +17 -0
- data/sig/mindee/product/international_id/international_id_v2.rbs +11 -0
- data/sig/mindee/product/international_id/international_id_v2_document.rbs +29 -0
- data/sig/mindee/product/international_id/international_id_v2_page.rbs +15 -0
- data/sig/mindee/product/invoice/invoice_v4.rbs +11 -0
- data/sig/mindee/product/invoice/invoice_v4_document.rbs +40 -0
- data/sig/mindee/product/invoice/invoice_v4_line_item.rbs +21 -0
- data/sig/mindee/product/invoice/invoice_v4_line_items.rbs +13 -0
- data/sig/mindee/product/invoice/invoice_v4_page.rbs +15 -0
- data/sig/mindee/product/invoice_splitter/invoice_splitter_v1.rbs +14 -0
- data/sig/mindee/product/invoice_splitter/invoice_splitter_v1_document.rbs +19 -0
- data/sig/mindee/product/invoice_splitter/invoice_splitter_v1_page.rbs +13 -0
- data/sig/mindee/product/multi_receipts_detector/multi_receipts_detector_v1.rbs +11 -0
- data/sig/mindee/product/multi_receipts_detector/multi_receipts_detector_v1_document.rbs +13 -0
- data/sig/mindee/product/multi_receipts_detector/multi_receipts_detector_v1_page.rbs +15 -0
- data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1.rbs +11 -0
- data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_added_sugar.rbs +14 -0
- data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_calorie.rbs +14 -0
- data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_cholesterol.rbs +14 -0
- data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_dietary_fiber.rbs +14 -0
- data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_document.rbs +28 -0
- data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_nutrient.rbs +18 -0
- data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_nutrients.rbs +13 -0
- data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_page.rbs +15 -0
- data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_protein.rbs +14 -0
- data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_saturated_fat.rbs +14 -0
- data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_serving_size.rbs +13 -0
- data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_sodium.rbs +15 -0
- data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_total_carbohydrate.rbs +14 -0
- data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_total_fat.rbs +14 -0
- data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_total_sugar.rbs +14 -0
- data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_trans_fat.rbs +14 -0
- data/sig/mindee/product/passport/passport_v1.rbs +11 -0
- data/sig/mindee/product/passport/passport_v1_document.rbs +23 -0
- data/sig/mindee/product/passport/passport_v1_page.rbs +15 -0
- data/sig/mindee/product/receipt/receipt_v5.rbs +11 -0
- data/sig/mindee/product/receipt/receipt_v5_document.rbs +31 -0
- data/sig/mindee/product/receipt/receipt_v5_line_item.rbs +17 -0
- data/sig/mindee/product/receipt/receipt_v5_line_items.rbs +13 -0
- data/sig/mindee/product/receipt/receipt_v5_page.rbs +15 -0
- data/sig/mindee/product/resume/resume_v1.rbs +11 -0
- data/sig/mindee/product/resume/resume_v1_certificate.rbs +17 -0
- data/sig/mindee/product/resume/resume_v1_certificates.rbs +13 -0
- data/sig/mindee/product/resume/resume_v1_document.rbs +39 -0
- data/sig/mindee/product/resume/resume_v1_education.rbs +20 -0
- data/sig/mindee/product/resume/resume_v1_educations.rbs +13 -0
- data/sig/mindee/product/resume/resume_v1_language.rbs +15 -0
- data/sig/mindee/product/resume/resume_v1_languages.rbs +13 -0
- data/sig/mindee/product/resume/resume_v1_page.rbs +15 -0
- data/sig/mindee/product/resume/resume_v1_professional_experience.rbs +22 -0
- data/sig/mindee/product/resume/resume_v1_professional_experiences.rbs +13 -0
- data/sig/mindee/product/resume/resume_v1_social_networks_url.rbs +15 -0
- data/sig/mindee/product/resume/resume_v1_social_networks_urls.rbs +13 -0
- data/sig/mindee/product/universal/universal.rbs +14 -0
- data/sig/mindee/product/universal/universal_document.rbs +10 -0
- data/sig/mindee/product/universal/universal_page.rbs +14 -0
- data/sig/mindee/product/universal/universal_prediction.rbs +19 -0
- data/sig/mindee/product/us/bank_check/bank_check_v1.rbs +13 -0
- data/sig/mindee/product/us/bank_check/bank_check_v1_document.rbs +20 -0
- data/sig/mindee/product/us/bank_check/bank_check_v1_page.rbs +19 -0
- data/sig/mindee/product/us/healthcare_card/healthcare_card_v1.rbs +13 -0
- data/sig/mindee/product/us/healthcare_card/healthcare_card_v1_copay.rbs +17 -0
- data/sig/mindee/product/us/healthcare_card/healthcare_card_v1_copays.rbs +15 -0
- data/sig/mindee/product/us/healthcare_card/healthcare_card_v1_document.rbs +28 -0
- data/sig/mindee/product/us/healthcare_card/healthcare_card_v1_page.rbs +17 -0
- data/sig/mindee/product/us/us_mail/us_mail_v3.rbs +13 -0
- data/sig/mindee/product/us/us_mail/us_mail_v3_document.rbs +21 -0
- data/sig/mindee/product/us/us_mail/us_mail_v3_page.rbs +17 -0
- data/sig/mindee/product/us/us_mail/us_mail_v3_recipient_address.rbs +23 -0
- data/sig/mindee/product/us/us_mail/us_mail_v3_recipient_addresses.rbs +15 -0
- data/sig/mindee/product/us/us_mail/us_mail_v3_sender_address.rbs +18 -0
- data/sig/mindee/product/us/w9/w9_v1.rbs +13 -0
- data/sig/mindee/product/us/w9/w9_v1_document.rbs +14 -0
- data/sig/mindee/product/us/w9/w9_v1_page.rbs +29 -0
- data/sig/mindee/version.rbs +6 -0
- data/sig/mindee.rbs +59 -0
- metadata +395 -103
- data/docs/bank_statement_fr_v1.md +0 -178
- data/docs/code_samples/bank_statement_fr_v1_async.txt +0 -19
- data/docs/code_samples/custom_v1.txt +0 -33
- data/docs/code_samples/eu_driver_license_v1.txt +0 -19
- data/docs/code_samples/expense_receipts_v4.txt +0 -19
- data/docs/code_samples/proof_of_address_v1.txt +0 -19
- data/docs/code_samples/us_mail_v2_async.txt +0 -19
- data/docs/code_samples/workflow_execution.txt +0 -29
- data/docs/custom_v1.md +0 -111
- data/docs/payslip_fra_v2.md +0 -294
- data/lib/mindee/extraction/common.rb +0 -4
- data/lib/mindee/extraction/multi_receipts_extractor/multi_receipts_extractor.rb +0 -32
- data/lib/mindee/extraction/pdf_extractor.rb +0 -4
- data/lib/mindee/extraction/tax_extractor/ocr_extractor.rb +0 -110
- data/lib/mindee/extraction/tax_extractor/tax_extractor.rb +0 -338
- data/lib/mindee/extraction/tax_extractor.rb +0 -3
- data/lib/mindee/parsing/custom/classification_field.rb +0 -28
- data/lib/mindee/parsing/custom/list_field.rb +0 -78
- data/lib/mindee/parsing/custom.rb +0 -4
- data/lib/mindee/parsing/generated.rb +0 -4
- data/lib/mindee/product/custom/custom_v1.rb +0 -36
- data/lib/mindee/product/custom/custom_v1_document.rb +0 -60
- data/lib/mindee/product/custom/custom_v1_page.rb +0 -32
- data/lib/mindee/product/eu/driver_license/driver_license_v1.rb +0 -41
- data/lib/mindee/product/eu/driver_license/driver_license_v1_document.rb +0 -88
- data/lib/mindee/product/eu/driver_license/driver_license_v1_page.rb +0 -53
- data/lib/mindee/product/fr/bank_statement/bank_statement_v1.rb +0 -41
- data/lib/mindee/product/fr/bank_statement/bank_statement_v1_page.rb +0 -34
- data/lib/mindee/product/generated/generated_v1.rb +0 -38
- data/lib/mindee/product/generated/generated_v1_document.rb +0 -35
- data/lib/mindee/product/proof_of_address/proof_of_address_v1.rb +0 -39
- data/lib/mindee/product/proof_of_address/proof_of_address_v1_document.rb +0 -83
- data/lib/mindee/product/proof_of_address/proof_of_address_v1_page.rb +0 -32
- data/lib/mindee/product/receipt/receipt_v4.rb +0 -36
- data/lib/mindee/product/receipt/receipt_v4_document.rb +0 -86
- data/lib/mindee/product/receipt/receipt_v4_page.rb +0 -32
- data/lib/mindee/product/us/driver_license/driver_license_v1.rb +0 -41
- data/lib/mindee/product/us/driver_license/driver_license_v1_document.rb +0 -113
- data/lib/mindee/product/us/driver_license/driver_license_v1_page.rb +0 -53
- data/lib/mindee/product/us/us_mail/us_mail_v2.rb +0 -41
- data/lib/mindee/product/us/us_mail/us_mail_v2_document.rb +0 -100
- data/lib/mindee/product/us/us_mail/us_mail_v2_page.rb +0 -34
- data/lib/mindee/product/us/us_mail/us_mail_v2_recipient_address.rb +0 -105
- data/lib/mindee/product/us/us_mail/us_mail_v2_sender_address.rb +0 -66
data/lib/mindee/client.rb
CHANGED
@@ -4,8 +4,103 @@ require_relative 'input'
|
|
4
4
|
require_relative 'http'
|
5
5
|
require_relative 'product'
|
6
6
|
require_relative 'parsing/common/api_response'
|
7
|
+
require_relative 'parsing/common/job'
|
8
|
+
require_relative 'parsing/common/workflow_response'
|
9
|
+
require_relative 'logging'
|
10
|
+
|
11
|
+
# Default owner for products.
|
12
|
+
OTS_OWNER = 'mindee'
|
7
13
|
|
8
14
|
module Mindee
|
15
|
+
# Class for page options in parse calls.
|
16
|
+
#
|
17
|
+
# @!attribute page_indexes [Array[Integer]] Zero-based list of page indexes.
|
18
|
+
# @!attribute operation [:KEEP_ONLY, :REMOVE] Operation to apply on the document, given the specified page indexes:
|
19
|
+
# * `:KEEP_ONLY` - keep only the specified pages, and remove all others.
|
20
|
+
# * `:REMOVE` - remove the specified pages, and keep all others.
|
21
|
+
# @!attribute on_min_pages [Integer, nil] Apply the operation only if the document has at least this many pages.
|
22
|
+
class PageOptions
|
23
|
+
attr_accessor :page_indexes, :operation, :on_min_pages
|
24
|
+
|
25
|
+
def initialize(params: {})
|
26
|
+
params ||= {}
|
27
|
+
params = params.transform_keys(&:to_sym)
|
28
|
+
@page_indexes = params.fetch(
|
29
|
+
:page_indexes,
|
30
|
+
[] # : Array[Integer]
|
31
|
+
)
|
32
|
+
@operation = params.fetch(:operation, :KEEP_ONLY)
|
33
|
+
@on_min_pages = params.fetch(:on_min_pages, nil)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# Class for configuration options in parse calls.
|
38
|
+
#
|
39
|
+
# @!attribute all_words [bool] Whether to include the full text for each page.
|
40
|
+
# This performs a full OCR operation on the server and will increase response time.
|
41
|
+
# @!attribute full_text [bool] Whether to include the full OCR text response in compatible APIs.
|
42
|
+
# This performs a full OCR operation on the server and may increase response time.
|
43
|
+
# @!attribute close_file [bool] Whether to `close()` the file after parsing it.
|
44
|
+
# Set to false if you need to access the file after this operation.
|
45
|
+
# @!attribute page_options [PageOptions, Hash, nil] Page cutting/merge options:
|
46
|
+
# * `:page_indexes` Zero-based list of page indexes.
|
47
|
+
# * `:operation` Operation to apply on the document, given the specified page indexes:
|
48
|
+
# * `:KEEP_ONLY` - keep only the specified pages, and remove all others.
|
49
|
+
# * `:REMOVE` - remove the specified pages, and keep all others.
|
50
|
+
# * `:on_min_pages` Apply the operation only if the document has at least this many pages.
|
51
|
+
# @!attribute cropper [bool] Whether to include cropper results for each page.
|
52
|
+
# This performs a cropping operation on the server and will increase response time.
|
53
|
+
# @!attribute initial_delay_sec [Numeric] Initial delay before polling. Defaults to 2.
|
54
|
+
# @!attribute delay_sec [Numeric] Delay between polling attempts. Defaults to 1.5.
|
55
|
+
# @!attribute max_retries [Integer] Maximum number of retries. Defaults to 80.
|
56
|
+
class ParseOptions
|
57
|
+
attr_accessor :all_words, :full_text, :close_file, :page_options, :cropper,
|
58
|
+
:initial_delay_sec, :delay_sec, :max_retries
|
59
|
+
|
60
|
+
def initialize(params: {})
|
61
|
+
params = params.transform_keys(&:to_sym)
|
62
|
+
@all_words = params.fetch(:all_words, false)
|
63
|
+
@full_text = params.fetch(:full_text, false)
|
64
|
+
@close_file = params.fetch(:close_file, true)
|
65
|
+
raw_page_options = params.fetch(:page_options, nil)
|
66
|
+
raw_page_options = PageOptions.new(params: raw_page_options) unless raw_page_options.is_a?(PageOptions)
|
67
|
+
@page_options = raw_page_options
|
68
|
+
@cropper = params.fetch(:cropper, false)
|
69
|
+
@initial_delay_sec = params.fetch(:initial_delay_sec, 2)
|
70
|
+
@delay_sec = params.fetch(:delay_sec, 1.5)
|
71
|
+
@max_retries = params.fetch(:max_retries, 80)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# Class for configuration options in workflow executions.
|
76
|
+
#
|
77
|
+
# @!attribute document_alias [String, nil] Alias to give to the document.
|
78
|
+
# @!attribute priority [Symbol, nil] Priority to give to the document.
|
79
|
+
# @!attribute full_text [bool] Whether to include the full OCR text response in compatible APIs.
|
80
|
+
# This performs a full OCR operation on the server and may increase response time.
|
81
|
+
# @!attribute public_url [String, nil] A unique, encrypted URL for accessing the document validation interface without
|
82
|
+
# requiring authentication.
|
83
|
+
# @!attribute page_options [PageOptions, Hash, nil] Page cutting/merge options:
|
84
|
+
# * `:page_indexes` Zero-based list of page indexes.
|
85
|
+
# * `:operation` Operation to apply on the document, given the specified page indexes:
|
86
|
+
# * `:KEEP_ONLY` - keep only the specified pages, and remove all others.
|
87
|
+
# * `:REMOVE` - remove the specified pages, and keep all others.
|
88
|
+
# * `:on_min_pages` Apply the operation only if the document has at least this many pages.
|
89
|
+
class WorkflowOptions
|
90
|
+
attr_accessor :document_alias, :priority, :full_text, :public_url, :page_options
|
91
|
+
|
92
|
+
def initialize(params: {})
|
93
|
+
params = params.transform_keys(&:to_sym)
|
94
|
+
@document_alias = params.fetch(:document_alias, nil)
|
95
|
+
@priority = params.fetch(:priority, nil)
|
96
|
+
@full_text = params.fetch(:full_text, false)
|
97
|
+
@public_url = params.fetch(:public_url, nil)
|
98
|
+
raw_page_options = params.fetch(:page_options, nil)
|
99
|
+
raw_page_options = PageOptions.new(params: raw_page_options) unless raw_page_options.is_a?(PageOptions)
|
100
|
+
@page_options = raw_page_options
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
9
104
|
# Mindee API Client.
|
10
105
|
# See: https://developers.mindee.com/docs
|
11
106
|
class Client
|
@@ -14,225 +109,235 @@ module Mindee
|
|
14
109
|
@api_key = api_key
|
15
110
|
end
|
16
111
|
|
17
|
-
#
|
18
|
-
#
|
19
|
-
# @param input_source [Mindee::Input::Source::LocalInputSource, Mindee::Input::Source::UrlInputSource]
|
20
|
-
# @param product_class [Mindee::Inference] class of the product
|
21
|
-
# @param endpoint [HTTP::Endpoint] Endpoint of the API
|
22
|
-
# Doesn't need to be set in the case of OTS APIs.
|
23
|
-
#
|
24
|
-
# @param all_words [Boolean] Whether to include the full text for each page.
|
25
|
-
# This performs a full OCR operation on the server and will increase response time.
|
26
|
-
#
|
27
|
-
# @param full_text [Boolean] Whether to include the full OCR text response in compatible APIs.
|
28
|
-
# This performs a full OCR operation on the server and may increase response time.
|
29
|
-
#
|
30
|
-
# @param close_file [Boolean] Whether to `close()` the file after parsing it.
|
31
|
-
# Set to false if you need to access the file after this operation.
|
32
|
-
#
|
33
|
-
# @param page_options [Hash, nil] Page cutting/merge options:
|
34
|
-
#
|
35
|
-
# * `:page_indexes` Zero-based list of page indexes.
|
36
|
-
# * `:operation` Operation to apply on the document, given the `page_indexes specified:
|
37
|
-
# * `:KEEP_ONLY` - keep only the specified pages, and remove all others.
|
38
|
-
# * `:REMOVE` - remove the specified pages, and keep all others.
|
39
|
-
# * `:on_min_pages` Apply the operation only if document has at least this many pages.
|
40
|
-
#
|
41
|
-
# @param cropper [Boolean] Whether to include cropper results for each page.
|
42
|
-
# This performs a cropping operation on the server and will increase response time.
|
112
|
+
# Enqueue a document for parsing and automatically try to retrieve it if needed.
|
43
113
|
#
|
114
|
+
# Accepts options either as a Hash or as a ParseOptions struct.
|
44
115
|
#
|
116
|
+
# @param input_source [Mindee::Input::Source::LocalInputSource, Mindee::Input::Source::URLInputSource]
|
117
|
+
# @param product_class [Mindee::Inference] The class of the product.
|
118
|
+
# @param endpoint [Mindee::HTTP::Endpoint, nil] Endpoint of the API.
|
119
|
+
# @param options [Hash] A hash of options to configure the parsing behavior. Possible keys:
|
120
|
+
# * `:all_words` [bool] Whether to extract all the words on each page.
|
121
|
+
# This performs a full OCR operation on the server and will increase response time.
|
122
|
+
# * `:full_text` [bool] Whether to include the full OCR text response in compatible APIs.
|
123
|
+
# This performs a full OCR operation on the server and may increase response time.
|
124
|
+
# * `:close_file` [bool] Whether to `close()` the file after parsing it.
|
125
|
+
# Set to false if you need to access the file after this operation.
|
126
|
+
# * `:page_options` [Hash, nil] Page cutting/merge options:
|
127
|
+
# - `:page_indexes` [Array<Integer>] Zero-based list of page indexes.
|
128
|
+
# - `:operation` [Symbol] Operation to apply on the document, given the `page_indexes` specified:
|
129
|
+
# - `:KEEP_ONLY` - keep only the specified pages, and remove all others.
|
130
|
+
# - `:REMOVE` - remove the specified pages, and keep all others.
|
131
|
+
# - `:on_min_pages` [Integer] Apply the operation only if the document has at least this many pages.
|
132
|
+
# * `:cropper` [bool, nil] Whether to include cropper results for each page.
|
133
|
+
# This performs a cropping operation on the server and will increase response time.
|
134
|
+
# * `:initial_delay_sec` [Numeric] Initial delay before polling. Defaults to 2.
|
135
|
+
# * `:delay_sec` [Numeric] Delay between polling attempts. Defaults to 1.5.
|
136
|
+
# * `:max_retries` [Integer] Maximum number of retries. Defaults to 80.
|
137
|
+
# @param enqueue [bool] Whether to enqueue the file.
|
45
138
|
# @return [Mindee::Parsing::Common::ApiResponse]
|
46
|
-
def parse(
|
47
|
-
|
48
|
-
|
49
|
-
endpoint
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
)
|
56
|
-
if input_source.is_a?(Mindee::Input::Source::LocalInputSource) && !page_options.nil? && input_source.pdf?
|
57
|
-
input_source.process_pdf(page_options)
|
139
|
+
def parse(input_source, product_class, endpoint: nil, options: {}, enqueue: true)
|
140
|
+
opts = normalize_parse_options(options)
|
141
|
+
process_pdf_if_required(input_source, opts) if input_source.is_a?(Input::Source::LocalInputSource)
|
142
|
+
endpoint ||= initialize_endpoint(product_class)
|
143
|
+
|
144
|
+
if enqueue && product_class.has_async
|
145
|
+
enqueue_and_parse(input_source, product_class, endpoint, opts)
|
146
|
+
else
|
147
|
+
parse_sync(input_source, product_class, endpoint, opts)
|
58
148
|
end
|
59
|
-
endpoint = initialize_endpoint(product_class) if endpoint.nil?
|
60
|
-
prediction, raw_http = endpoint.predict(input_source, all_words, full_text, close_file, cropper)
|
61
|
-
Mindee::Parsing::Common::ApiResponse.new(product_class, prediction, raw_http)
|
62
149
|
end
|
63
150
|
|
64
|
-
#
|
151
|
+
# Call prediction API on a document and parse the results.
|
65
152
|
#
|
153
|
+
# @param input_source [Mindee::Input::Source::LocalInputSource, Mindee::Input::Source::URLInputSource]
|
66
154
|
# @param product_class [Mindee::Inference] class of the product
|
67
|
-
# @param
|
68
|
-
# @param
|
69
|
-
#
|
70
|
-
#
|
71
|
-
#
|
72
|
-
#
|
73
|
-
#
|
74
|
-
#
|
75
|
-
#
|
76
|
-
#
|
77
|
-
#
|
78
|
-
#
|
79
|
-
#
|
80
|
-
#
|
81
|
-
#
|
82
|
-
#
|
83
|
-
#
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
155
|
+
# @param endpoint [Mindee::HTTP::Endpoint, nil] Endpoint of the API.
|
156
|
+
# @param options [Hash] A hash of options to configure the parsing behavior. Possible keys:
|
157
|
+
# * `:all_words` [bool] Whether to extract all the words on each page.
|
158
|
+
# This performs a full OCR operation on the server and will increase response time.
|
159
|
+
# * `:full_text` [bool] Whether to include the full OCR text response in compatible APIs.
|
160
|
+
# This performs a full OCR operation on the server and may increase response time.
|
161
|
+
# * `:close_file` [bool] Whether to `close()` the file after parsing it.
|
162
|
+
# Set to false if you need to access the file after this operation.
|
163
|
+
# * `:page_options` [Hash, nil] Page cutting/merge options:
|
164
|
+
# - `:page_indexes` [Array<Integer>] Zero-based list of page indexes.
|
165
|
+
# - `:operation` [Symbol] Operation to apply on the document, given the `page_indexes` specified:
|
166
|
+
# - `:KEEP_ONLY` - keep only the specified pages, and remove all others.
|
167
|
+
# - `:REMOVE` - remove the specified pages, and keep all others.
|
168
|
+
# - `:on_min_pages` [Integer] Apply the operation only if the document has at least this many pages.
|
169
|
+
# * `:cropper` [bool, nil] Whether to include cropper results for each page.
|
170
|
+
# This performs a cropping operation on the server and will increase response time.
|
171
|
+
# @return [Mindee::Parsing::Common::ApiResponse]
|
172
|
+
def parse_sync(input_source, product_class, endpoint, options)
|
173
|
+
logger.debug("Parsing document as '#{endpoint.url_root}'")
|
174
|
+
|
175
|
+
prediction, raw_http = endpoint.predict(
|
176
|
+
input_source,
|
177
|
+
options.all_words,
|
178
|
+
options.full_text,
|
179
|
+
options.close_file,
|
180
|
+
options.cropper
|
181
|
+
)
|
182
|
+
|
183
|
+
Mindee::Parsing::Common::ApiResponse.new(product_class, prediction, raw_http)
|
184
|
+
end
|
185
|
+
|
186
|
+
# Enqueue a document for async parsing
|
91
187
|
#
|
188
|
+
# @param input_source [Mindee::Input::Source::LocalInputSource, Mindee::Input::Source::URLInputSource]
|
189
|
+
# The source of the input document (local file or URL).
|
190
|
+
# @param product_class [Mindee::Inference] The class of the product.
|
191
|
+
# @param options [Hash] A hash of options to configure the enqueue behavior. Possible keys:
|
192
|
+
# * `:endpoint` [HTTP::Endpoint, nil] Endpoint of the API.
|
193
|
+
# Doesn't need to be set in the case of OTS APIs.
|
194
|
+
# * `:all_words` [bool] Whether to extract all the words on each page.
|
195
|
+
# This performs a full OCR operation on the server and will increase response time.
|
196
|
+
# * `:full_text` [bool] Whether to include the full OCR text response in compatible APIs.
|
197
|
+
# This performs a full OCR operation on the server and may increase response time.
|
198
|
+
# * `:close_file` [bool] Whether to `close()` the file after parsing it.
|
199
|
+
# Set to false if you need to access the file after this operation.
|
200
|
+
# * `:page_options` [Hash, nil] Page cutting/merge options:
|
201
|
+
# - `:page_indexes` [Array<Integer>] Zero-based list of page indexes.
|
202
|
+
# - `:operation` [Symbol] Operation to apply on the document, given the `page_indexes` specified:
|
203
|
+
# - `:KEEP_ONLY` - keep only the specified pages, and remove all others.
|
204
|
+
# - `:REMOVE` - remove the specified pages, and keep all others.
|
205
|
+
# - `:on_min_pages` [Integer] Apply the operation only if the document has at least this many pages.
|
206
|
+
# * `:cropper` [bool] Whether to include cropper results for each page.
|
207
|
+
# This performs a cropping operation on the server and will increase response time.
|
208
|
+
# @param endpoint [Mindee::HTTP::Endpoint] Endpoint of the API.
|
92
209
|
# @return [Mindee::Parsing::Common::ApiResponse]
|
93
|
-
def enqueue(
|
94
|
-
|
95
|
-
product_class
|
96
|
-
endpoint
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
endpoint = initialize_endpoint(product_class) if endpoint.nil?
|
107
|
-
prediction, raw_http = endpoint.predict_async(input_source, all_words, full_text, close_file, cropper)
|
108
|
-
Mindee::Parsing::Common::ApiResponse.new(product_class,
|
109
|
-
prediction, raw_http)
|
210
|
+
def enqueue(input_source, product_class, endpoint: nil, options: {})
|
211
|
+
opts = normalize_parse_options(options)
|
212
|
+
endpoint ||= initialize_endpoint(product_class)
|
213
|
+
logger.debug("Enqueueing document as '#{endpoint.url_root}'")
|
214
|
+
|
215
|
+
prediction, raw_http = endpoint.predict_async(
|
216
|
+
input_source,
|
217
|
+
opts.all_words,
|
218
|
+
opts.full_text,
|
219
|
+
opts.close_file,
|
220
|
+
opts.cropper
|
221
|
+
)
|
222
|
+
Mindee::Parsing::Common::ApiResponse.new(product_class, prediction, raw_http)
|
110
223
|
end
|
111
224
|
|
112
225
|
# Parses a queued document
|
113
226
|
#
|
114
|
-
# @param job_id [String]
|
227
|
+
# @param job_id [String] ID of the job (queue) to poll from
|
115
228
|
# @param product_class [Mindee::Inference] class of the product
|
116
229
|
# @param endpoint [HTTP::Endpoint, nil] Endpoint of the API
|
117
230
|
# Doesn't need to be set in the case of OTS APIs.
|
118
231
|
#
|
119
232
|
# @return [Mindee::Parsing::Common::ApiResponse]
|
120
|
-
def parse_queued(
|
121
|
-
job_id,
|
122
|
-
product_class,
|
123
|
-
endpoint: nil
|
124
|
-
)
|
233
|
+
def parse_queued(job_id, product_class, endpoint: nil)
|
125
234
|
endpoint = initialize_endpoint(product_class) if endpoint.nil?
|
235
|
+
logger.debug("Fetching queued document as '#{endpoint.url_root}'")
|
126
236
|
prediction, raw_http = endpoint.parse_async(job_id)
|
127
237
|
Mindee::Parsing::Common::ApiResponse.new(product_class, prediction, raw_http)
|
128
238
|
end
|
129
239
|
|
130
|
-
# rubocop:disable Metrics/ParameterLists
|
131
|
-
|
132
240
|
# Enqueue a document for async parsing and automatically try to retrieve it
|
133
241
|
#
|
134
|
-
# @param input_source [Mindee::Input::Source::LocalInputSource, Mindee::Input::Source::
|
135
|
-
#
|
136
|
-
# @param
|
137
|
-
#
|
138
|
-
#
|
139
|
-
#
|
140
|
-
#
|
141
|
-
#
|
142
|
-
#
|
143
|
-
#
|
144
|
-
#
|
145
|
-
#
|
146
|
-
#
|
147
|
-
#
|
148
|
-
#
|
149
|
-
#
|
150
|
-
#
|
151
|
-
#
|
152
|
-
#
|
153
|
-
#
|
154
|
-
#
|
242
|
+
# @param input_source [Mindee::Input::Source::LocalInputSource, Mindee::Input::Source::URLInputSource]
|
243
|
+
# The source of the input document (local file or URL).
|
244
|
+
# @param product_class [Mindee::Inference] The class of the product.
|
245
|
+
# @param options [Hash] A hash of options to configure the parsing behavior. Possible keys:
|
246
|
+
# * `:endpoint` [HTTP::Endpoint, nil] Endpoint of the API.
|
247
|
+
# Doesn't need to be set in the case of OTS APIs.
|
248
|
+
# * `:all_words` [bool] Whether to extract all the words on each page.
|
249
|
+
# This performs a full OCR operation on the server and will increase response time.
|
250
|
+
# * `:full_text` [bool] Whether to include the full OCR text response in compatible APIs.
|
251
|
+
# This performs a full OCR operation on the server and may increase response time.
|
252
|
+
# * `:close_file` [bool] Whether to `close()` the file after parsing it.
|
253
|
+
# Set to false if you need to access the file after this operation.
|
254
|
+
# * `:page_options` [Hash, nil] Page cutting/merge options:
|
255
|
+
# - `:page_indexes` [Array<Integer>] Zero-based list of page indexes.
|
256
|
+
# - `:operation` [Symbol] Operation to apply on the document, given the `page_indexes` specified:
|
257
|
+
# - `:KEEP_ONLY` - keep only the specified pages, and remove all others.
|
258
|
+
# - `:REMOVE` - remove the specified pages, and keep all others.
|
259
|
+
# - `:on_min_pages` [Integer] Apply the operation only if the document has at least this many pages.
|
260
|
+
# * `:cropper` [bool, nil] Whether to include cropper results for each page.
|
261
|
+
# This performs a cropping operation on the server and will increase response time.
|
262
|
+
# * `:initial_delay_sec` [Numeric] Initial delay before polling. Defaults to 2.
|
263
|
+
# * `:delay_sec` [Numeric] Delay between polling attempts. Defaults to 1.5.
|
264
|
+
# * `:max_retries` [Integer] Maximum number of retries. Defaults to 80.
|
265
|
+
# @param endpoint [Mindee::HTTP::Endpoint] Endpoint of the API.
|
155
266
|
# @return [Mindee::Parsing::Common::ApiResponse]
|
156
|
-
def enqueue_and_parse(
|
157
|
-
|
158
|
-
product_class,
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
page_options: nil,
|
164
|
-
cropper: false,
|
165
|
-
initial_delay_sec: 2,
|
166
|
-
delay_sec: 1.5,
|
167
|
-
max_retries: 80
|
168
|
-
)
|
169
|
-
enqueue_res = enqueue(
|
170
|
-
input_source,
|
171
|
-
product_class,
|
172
|
-
endpoint: endpoint,
|
173
|
-
all_words: all_words,
|
174
|
-
full_text: full_text,
|
175
|
-
close_file: close_file,
|
176
|
-
page_options: page_options,
|
177
|
-
cropper: cropper
|
178
|
-
)
|
179
|
-
sleep(initial_delay_sec)
|
267
|
+
def enqueue_and_parse(input_source, product_class, endpoint, options)
|
268
|
+
validate_async_params(options.initial_delay_sec, options.delay_sec, options.max_retries)
|
269
|
+
enqueue_res = enqueue(input_source, product_class, endpoint: endpoint, options: options)
|
270
|
+
job = enqueue_res.job or raise Errors::MindeeAPIError, 'Expected job to be present'
|
271
|
+
job_id = job.id
|
272
|
+
|
273
|
+
sleep(options.initial_delay_sec)
|
180
274
|
polling_attempts = 1
|
181
|
-
|
275
|
+
logger.debug("Successfully enqueued document with job id: '#{job_id}'")
|
182
276
|
queue_res = parse_queued(job_id, product_class, endpoint: endpoint)
|
183
|
-
|
184
|
-
|
277
|
+
queue_res_job = queue_res.job or raise Errors::MindeeAPIError, 'Expected job to be present'
|
278
|
+
valid_statuses = [
|
279
|
+
Mindee::Parsing::Common::JobStatus::WAITING,
|
280
|
+
Mindee::Parsing::Common::JobStatus::PROCESSING,
|
281
|
+
]
|
282
|
+
# @type var valid_statuses: Array[(:waiting | :processing | :completed | :failed)]
|
283
|
+
while valid_statuses.include?(queue_res_job.status) && polling_attempts < options.max_retries
|
284
|
+
logger.debug("Polling server for parsing result with job id: '#{job_id}'. Attempt #{polling_attempts}")
|
285
|
+
sleep(options.delay_sec)
|
185
286
|
queue_res = parse_queued(job_id, product_class, endpoint: endpoint)
|
287
|
+
queue_res_job = queue_res.job or raise Errors::MindeeAPIError, 'Expected job to be present'
|
186
288
|
polling_attempts += 1
|
187
289
|
end
|
188
|
-
|
189
|
-
|
190
|
-
|
290
|
+
|
291
|
+
if queue_res_job.status != Mindee::Parsing::Common::JobStatus::COMPLETED
|
292
|
+
elapsed = options.initial_delay_sec + (polling_attempts * options.delay_sec.to_f)
|
293
|
+
raise Errors::MindeeAPIError,
|
294
|
+
"Asynchronous parsing request timed out after #{elapsed} seconds (#{polling_attempts} tries)"
|
191
295
|
end
|
192
296
|
|
193
297
|
queue_res
|
194
298
|
end
|
195
299
|
|
196
|
-
#
|
197
|
-
|
198
|
-
# Sends a document to a workflow.
|
300
|
+
# Same idea applies to execute_workflow:
|
199
301
|
#
|
200
|
-
#
|
201
|
-
# @param document_alias [String, nil] Alias to give to the document.
|
202
|
-
# @param priority [Symbol, nil] Priority to give to the document.
|
203
|
-
# @param full_text [Boolean] Whether to include the full OCR text response in compatible APIs.
|
204
|
-
# This performs a full OCR operation on the server and may increase response time.
|
205
|
-
#
|
206
|
-
# @param public_url [String, nil] A unique, encrypted URL for accessing the document validation interface without
|
207
|
-
# requiring authentication.
|
208
|
-
# @param page_options [Hash, nil] Page cutting/merge options:
|
302
|
+
# Sends a document to a workflow.
|
209
303
|
#
|
210
|
-
#
|
211
|
-
# * `:operation` Operation to apply on the document, given the `page_indexes specified:
|
212
|
-
# * `:KEEP_ONLY` - keep only the specified pages, and remove all others.
|
213
|
-
# * `:REMOVE` - remove the specified pages, and keep all others.
|
214
|
-
# * `:on_min_pages` Apply the operation only if document has at least this many pages.
|
304
|
+
# Accepts options either as a Hash or as a WorkflowOptions struct.
|
215
305
|
#
|
306
|
+
# @param input_source [Mindee::Input::Source::LocalInputSource, Mindee::Input::Source::URLInputSource]
|
307
|
+
# @param workflow_id [String]
|
308
|
+
# @param options [Hash, WorkflowOptions] Options to configure workflow behavior. Possible keys:
|
309
|
+
# * `document_alias` [String, nil] Alias to give to the document.
|
310
|
+
# * `priority` [Symbol, nil] Priority to give to the document.
|
311
|
+
# * `full_text` [bool] Whether to include the full OCR text response in compatible APIs.
|
216
312
|
#
|
313
|
+
# * `public_url` [String, nil] A unique, encrypted URL for accessing the document validation interface without
|
314
|
+
# requiring authentication.
|
315
|
+
# * `page_options` [Hash, nil] Page cutting/merge options:
|
316
|
+
# * `:page_indexes` Zero-based list of page indexes.
|
317
|
+
# * `:operation` Operation to apply on the document, given the `page_indexes specified:
|
318
|
+
# * `:KEEP_ONLY` - keep only the specified pages, and remove all others.
|
319
|
+
# * `:REMOVE` - remove the specified pages, and keep all others.
|
320
|
+
# * `:on_min_pages` Apply the operation only if document has at least this many pa
|
217
321
|
# @return [Mindee::Parsing::Common::WorkflowResponse]
|
218
|
-
def execute_workflow(
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
full_text: false,
|
224
|
-
public_url: nil,
|
225
|
-
page_options: nil
|
226
|
-
)
|
227
|
-
if input_source.is_a?(Mindee::Input::Source::LocalInputSource) && !page_options.nil? && input_source.pdf?
|
228
|
-
input_source.process_pdf(page_options)
|
322
|
+
def execute_workflow(input_source, workflow_id, options: {})
|
323
|
+
opts = options.is_a?(WorkflowOptions) ? options : WorkflowOptions.new(params: options)
|
324
|
+
if opts.respond_to?(:page_options) && input_source.is_a?(Input::Source::LocalInputSource)
|
325
|
+
process_pdf_if_required(input_source,
|
326
|
+
opts)
|
229
327
|
end
|
230
328
|
|
231
329
|
workflow_endpoint = Mindee::HTTP::WorkflowEndpoint.new(workflow_id, api_key: @api_key)
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
330
|
+
logger.debug("Sending document to workflow '#{workflow_id}'")
|
331
|
+
|
332
|
+
prediction, raw_http = workflow_endpoint.execute_workflow(
|
333
|
+
input_source,
|
334
|
+
opts.full_text,
|
335
|
+
opts.document_alias,
|
336
|
+
opts.priority,
|
337
|
+
opts.public_url
|
338
|
+
)
|
339
|
+
|
340
|
+
Mindee::Parsing::Common::WorkflowResponse.new(Product::Universal::Universal, prediction, raw_http)
|
236
341
|
end
|
237
342
|
|
238
343
|
# Load a prediction.
|
@@ -241,51 +346,56 @@ module Mindee
|
|
241
346
|
# @param local_response [Mindee::Input::LocalResponse]
|
242
347
|
# @return [Mindee::Parsing::Common::ApiResponse]
|
243
348
|
def load_prediction(product_class, local_response)
|
244
|
-
|
245
|
-
|
246
|
-
|
349
|
+
raise Errors::MindeeAPIError, 'Expected LocalResponse to not be nil.' if local_response.nil?
|
350
|
+
|
351
|
+
response_hash = local_response.as_hash || {}
|
352
|
+
raise Errors::MindeeAPIError, 'Expected LocalResponse#as_hash to return a hash.' if response_hash.nil?
|
353
|
+
|
354
|
+
Mindee::Parsing::Common::ApiResponse.new(product_class, response_hash, response_hash.to_json)
|
355
|
+
rescue KeyError, Errors::MindeeAPIError
|
356
|
+
raise Errors::MindeeInputError, 'No prediction found in local response.'
|
247
357
|
end
|
248
358
|
|
249
359
|
# Load a document from an absolute path, as a string.
|
250
360
|
# @param input_path [String] Path of file to open
|
251
|
-
# @param
|
361
|
+
# @param repair_pdf [bool] Attempts to fix broken pdf if true
|
252
362
|
# @return [Mindee::Input::Source::PathInputSource]
|
253
|
-
def source_from_path(input_path,
|
254
|
-
Input::Source::PathInputSource.new(input_path,
|
363
|
+
def source_from_path(input_path, repair_pdf: false)
|
364
|
+
Input::Source::PathInputSource.new(input_path, repair_pdf: repair_pdf)
|
255
365
|
end
|
256
366
|
|
257
367
|
# Load a document from raw bytes.
|
258
368
|
# @param input_bytes [String] Encoding::BINARY byte input
|
259
369
|
# @param filename [String] The name of the file (without the path)
|
260
|
-
# @param
|
370
|
+
# @param repair_pdf [bool] Attempts to fix broken pdf if true
|
261
371
|
# @return [Mindee::Input::Source::BytesInputSource]
|
262
|
-
def source_from_bytes(input_bytes, filename,
|
263
|
-
Input::Source::BytesInputSource.new(input_bytes, filename,
|
372
|
+
def source_from_bytes(input_bytes, filename, repair_pdf: false)
|
373
|
+
Input::Source::BytesInputSource.new(input_bytes, filename, repair_pdf: repair_pdf)
|
264
374
|
end
|
265
375
|
|
266
376
|
# Load a document from a base64 encoded string.
|
267
377
|
# @param base64_string [String] Input to parse as base64 string
|
268
378
|
# @param filename [String] The name of the file (without the path)
|
269
|
-
# @param
|
379
|
+
# @param repair_pdf [bool] Attempts to fix broken pdf if true
|
270
380
|
# @return [Mindee::Input::Source::Base64InputSource]
|
271
|
-
def source_from_b64string(base64_string, filename,
|
272
|
-
Input::Source::Base64InputSource.new(base64_string, filename,
|
381
|
+
def source_from_b64string(base64_string, filename, repair_pdf: false)
|
382
|
+
Input::Source::Base64InputSource.new(base64_string, filename, repair_pdf: repair_pdf)
|
273
383
|
end
|
274
384
|
|
275
385
|
# Load a document from a normal Ruby `File`.
|
276
386
|
# @param input_file [File] Input file handle
|
277
387
|
# @param filename [String] The name of the file (without the path)
|
278
|
-
# @param
|
388
|
+
# @param repair_pdf [bool] Attempts to fix broken pdf if true
|
279
389
|
# @return [Mindee::Input::Source::FileInputSource]
|
280
|
-
def source_from_file(input_file, filename,
|
281
|
-
Input::Source::FileInputSource.new(input_file, filename,
|
390
|
+
def source_from_file(input_file, filename, repair_pdf: false)
|
391
|
+
Input::Source::FileInputSource.new(input_file, filename, repair_pdf: repair_pdf)
|
282
392
|
end
|
283
393
|
|
284
394
|
# Load a document from a secure remote source (HTTPS).
|
285
|
-
# @param url [String]
|
286
|
-
# @return [Mindee::Input::Source::
|
395
|
+
# @param url [String] URL of the file
|
396
|
+
# @return [Mindee::Input::Source::URLInputSource]
|
287
397
|
def source_from_url(url)
|
288
|
-
Input::Source::
|
398
|
+
Input::Source::URLInputSource.new(url)
|
289
399
|
end
|
290
400
|
|
291
401
|
# Creates a custom endpoint with the given values.
|
@@ -300,29 +410,36 @@ module Mindee
|
|
300
410
|
# @param version [String] For custom endpoints, version of the product
|
301
411
|
# @return [Mindee::HTTP::Endpoint]
|
302
412
|
def create_endpoint(endpoint_name: '', account_name: '', version: '')
|
303
|
-
initialize_endpoint(
|
304
|
-
|
413
|
+
initialize_endpoint(
|
414
|
+
Mindee::Product::Universal::Universal,
|
415
|
+
endpoint_name: endpoint_name,
|
416
|
+
account_name: account_name,
|
417
|
+
version: version
|
418
|
+
)
|
305
419
|
end
|
306
420
|
|
307
|
-
private
|
308
|
-
|
309
421
|
# Validates the parameters for async auto-polling
|
310
|
-
# @param initial_delay_sec [
|
311
|
-
# @param delay_sec [
|
422
|
+
# @param initial_delay_sec [Numeric] initial delay before polling
|
423
|
+
# @param delay_sec [Numeric] delay between polling attempts
|
312
424
|
# @param max_retries [Integer, nil] maximum amount of retries.
|
313
425
|
def validate_async_params(initial_delay_sec, delay_sec, max_retries)
|
314
426
|
min_delay_sec = 1
|
315
427
|
min_initial_delay_sec = 1
|
316
428
|
min_retries = 2
|
317
|
-
|
429
|
+
|
430
|
+
if delay_sec < min_delay_sec
|
431
|
+
raise ArgumentError,
|
432
|
+
"Cannot set auto-poll delay to less than #{min_delay_sec} second(s)"
|
433
|
+
end
|
318
434
|
if initial_delay_sec < min_initial_delay_sec
|
319
|
-
raise
|
435
|
+
raise ArgumentError,
|
436
|
+
"Cannot set initial parsing delay to less than #{min_initial_delay_sec} second(s)"
|
320
437
|
end
|
321
|
-
raise "Cannot set auto-poll retries to less than #{min_retries}" if max_retries < min_retries
|
438
|
+
raise ArgumentError, "Cannot set auto-poll retries to less than #{min_retries}" if max_retries < min_retries
|
322
439
|
end
|
323
440
|
|
324
441
|
# Creates an endpoint with the given values. Raises an error if the endpoint is invalid.
|
325
|
-
# @param product_class [Mindee::Inference] class of the product
|
442
|
+
# @param product_class [Mindee::Parsing::Common::Inference] class of the product
|
326
443
|
#
|
327
444
|
# @param endpoint_name [String] For custom endpoints, the "API name" field in the "Settings" page of the
|
328
445
|
# API Builder. Do not set for standard (off the shelf) endpoints.
|
@@ -333,33 +450,61 @@ module Mindee
|
|
333
450
|
# @param version [String] For custom endpoints, version of the product.
|
334
451
|
# @return [Mindee::HTTP::Endpoint]
|
335
452
|
def initialize_endpoint(product_class, endpoint_name: '', account_name: '', version: '')
|
336
|
-
if (endpoint_name.nil? || endpoint_name.empty?) && product_class == Mindee::Product::
|
337
|
-
raise 'Missing argument endpoint_name when using custom class'
|
453
|
+
if (endpoint_name.nil? || endpoint_name.empty?) && product_class == Mindee::Product::Universal::Universal
|
454
|
+
raise Mindee::Errors::MindeeConfigurationError, 'Missing argument endpoint_name when using custom class'
|
338
455
|
end
|
339
456
|
|
340
457
|
endpoint_name = fix_endpoint_name(product_class, endpoint_name)
|
341
458
|
account_name = fix_account_name(account_name)
|
342
459
|
version = fix_version(product_class, version)
|
460
|
+
|
343
461
|
HTTP::Endpoint.new(account_name, endpoint_name, version, api_key: @api_key)
|
344
462
|
end
|
345
463
|
|
346
464
|
def fix_endpoint_name(product_class, endpoint_name)
|
347
|
-
|
348
|
-
|
349
|
-
endpoint_name
|
465
|
+
endpoint_name.nil? || endpoint_name.empty? ? product_class.endpoint_name : endpoint_name
|
350
466
|
end
|
351
467
|
|
352
468
|
def fix_account_name(account_name)
|
353
|
-
|
469
|
+
if account_name.nil? || account_name.empty?
|
470
|
+
logger.info("No account name provided, #{OTS_OWNER} will be used by default.")
|
471
|
+
return OTS_OWNER
|
472
|
+
end
|
354
473
|
|
355
474
|
account_name
|
356
475
|
end
|
357
476
|
|
358
477
|
def fix_version(product_class, version)
|
359
478
|
return version unless version.nil? || version.empty?
|
360
|
-
return '1' if product_class.endpoint_version.nil? || product_class.endpoint_version.empty?
|
361
479
|
|
480
|
+
if product_class.endpoint_version.nil? || product_class.endpoint_version.empty?
|
481
|
+
logger.debug('No version provided for a custom build, will attempt to poll version 1 by default.')
|
482
|
+
return '1'
|
483
|
+
end
|
362
484
|
product_class.endpoint_version
|
363
485
|
end
|
486
|
+
|
487
|
+
# If needed, converts the parsing options provided as a hash into a proper ParseOptions object.
|
488
|
+
# @param options [Hash, ParseOptions] Options.
|
489
|
+
# @return [ParseOptions]
|
490
|
+
def normalize_parse_options(options)
|
491
|
+
return options if options.is_a?(ParseOptions)
|
492
|
+
|
493
|
+
ParseOptions.new(params: options)
|
494
|
+
end
|
495
|
+
|
496
|
+
# Processes a PDF if parameters were provided.
|
497
|
+
# @param input_source [Mindee::Input::Source::LocalInputSource, Mindee::Input::Source::URLInputSource]
|
498
|
+
# @param opts [ParseOptions]
|
499
|
+
def process_pdf_if_required(input_source, opts)
|
500
|
+
return unless input_source.is_a?(Mindee::Input::Source::LocalInputSource) &&
|
501
|
+
opts.page_options &&
|
502
|
+
input_source.pdf?
|
503
|
+
|
504
|
+
input_source.process_pdf(opts.page_options)
|
505
|
+
end
|
506
|
+
|
507
|
+
private :parse_sync, :validate_async_params, :initialize_endpoint, :fix_endpoint_name, :fix_version,
|
508
|
+
:fix_account_name, :process_pdf_if_required, :normalize_parse_options
|
364
509
|
end
|
365
510
|
end
|