mindee 4.6.0 → 4.7.0.pre.rc1
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/CHANGELOG.md +12 -0
- data/README.md +21 -222
- data/docs/code_samples/default_v2.txt +28 -0
- data/lib/mindee/client.rb +11 -30
- data/lib/mindee/client_v2.rb +109 -0
- data/lib/mindee/errors/mindee_http_error_v2.rb +26 -0
- data/lib/mindee/errors.rb +1 -0
- data/lib/mindee/geometry/point.rb +2 -2
- data/lib/mindee/geometry/quadrilateral.rb +4 -4
- data/lib/mindee/geometry/utils.rb +1 -0
- data/lib/mindee/http/api_settings_v2.rb +61 -0
- data/lib/mindee/http/endpoint.rb +12 -6
- data/lib/mindee/http/http_error_handler.rb +17 -4
- data/lib/mindee/http/mindee_api_v2.rb +148 -0
- data/lib/mindee/http/response_validation.rb +20 -1
- data/lib/mindee/http/workflow_endpoint.rb +2 -2
- data/lib/mindee/http.rb +2 -0
- data/lib/mindee/image/extracted_image.rb +1 -1
- data/lib/mindee/image/image_extractor.rb +10 -10
- data/lib/mindee/input/inference_parameters.rb +116 -0
- data/lib/mindee/input/local_response.rb +10 -1
- data/lib/mindee/input/polling_options.rb +26 -0
- data/lib/mindee/input/sources/base64_input_source.rb +2 -2
- data/lib/mindee/input/sources/local_input_source.rb +19 -12
- data/lib/mindee/input.rb +2 -0
- data/lib/mindee/page_options.rb +24 -0
- data/lib/mindee/parsing/common/api_request.rb +2 -2
- data/lib/mindee/parsing/common/api_response.rb +4 -0
- data/lib/mindee/parsing/common/execution.rb +1 -1
- data/lib/mindee/parsing/common/extras/extras.rb +2 -2
- data/lib/mindee/parsing/common/extras/rag_extra.rb +2 -0
- data/lib/mindee/parsing/common/ocr/ocr.rb +4 -6
- data/lib/mindee/parsing/common/orientation.rb +2 -2
- data/lib/mindee/parsing/common/product.rb +6 -1
- data/lib/mindee/parsing/standard/amount_field.rb +2 -2
- data/lib/mindee/parsing/standard/feature_field.rb +1 -1
- data/lib/mindee/parsing/standard/tax_field.rb +1 -1
- data/lib/mindee/parsing/universal/universal_list_field.rb +2 -2
- data/lib/mindee/parsing/universal/universal_object_field.rb +6 -3
- data/lib/mindee/parsing/v2/common_response.rb +18 -0
- data/lib/mindee/parsing/v2/error_response.rb +36 -0
- data/lib/mindee/parsing/v2/field/base_field.rb +60 -0
- data/lib/mindee/parsing/v2/field/field_confidence.rb +91 -0
- data/lib/mindee/parsing/v2/field/field_location.rb +36 -0
- data/lib/mindee/parsing/v2/field/inference_fields.rb +96 -0
- data/lib/mindee/parsing/v2/field/list_field.rb +88 -0
- data/lib/mindee/parsing/v2/field/object_field.rb +102 -0
- data/lib/mindee/parsing/v2/field/simple_field.rb +56 -0
- data/lib/mindee/parsing/v2/field.rb +9 -0
- data/lib/mindee/parsing/v2/inference.rb +50 -0
- data/lib/mindee/parsing/v2/inference_file.rb +38 -0
- data/lib/mindee/parsing/v2/inference_model.rb +18 -0
- data/lib/mindee/parsing/v2/inference_response.rb +30 -0
- data/lib/mindee/parsing/v2/inference_result.rb +49 -0
- data/lib/mindee/parsing/v2/inference_result_options.rb +21 -0
- data/lib/mindee/parsing/v2/job.rb +86 -0
- data/lib/mindee/parsing/v2/job_response.rb +30 -0
- data/lib/mindee/parsing/v2/job_webhook.rb +60 -0
- data/lib/mindee/parsing/v2/raw_text.rb +21 -0
- data/lib/mindee/parsing/v2.rb +15 -0
- data/lib/mindee/pdf/extracted_pdf.rb +5 -3
- data/lib/mindee/pdf/pdf_extractor.rb +11 -7
- data/lib/mindee/pdf/pdf_processor.rb +6 -6
- data/lib/mindee/pdf/pdf_tools.rb +4 -2
- data/lib/mindee/product/universal/universal_prediction.rb +4 -4
- data/lib/mindee/version.rb +2 -2
- data/lib/mindee.rb +6 -0
- data/mindee.gemspec +1 -1
- data/sig/custom/mini_magick.rbs +14 -7
- data/sig/custom/net_http.rbs +4 -4
- data/sig/custom/origami.rbs +9 -4
- data/sig/mindee/client.rbs +14 -19
- data/sig/mindee/client_v2.rbs +17 -0
- data/sig/mindee/errors/mindee_http_error.rbs +6 -5
- data/sig/mindee/errors/mindee_http_error_v2.rbs +12 -0
- data/sig/mindee/errors/mindee_input_error.rbs +3 -2
- data/sig/mindee/geometry/min_max.rbs +4 -3
- data/sig/mindee/geometry/point.rbs +5 -6
- data/sig/mindee/geometry/polygon.rbs +3 -3
- data/sig/mindee/geometry/quadrilateral.rbs +5 -8
- data/sig/mindee/geometry/utils.rbs +8 -8
- data/sig/mindee/http/api_settings_v2.rbs +23 -0
- data/sig/mindee/http/endpoint.rbs +12 -11
- data/sig/mindee/http/http_error_handler.rbs +8 -3
- data/sig/mindee/http/mindee_api_v2.rbs +18 -0
- data/sig/mindee/http/response_validation.rbs +1 -0
- data/sig/mindee/http/workflow_endpoint.rbs +1 -1
- data/sig/mindee/image/extracted_image.rbs +2 -2
- data/sig/mindee/image/image_compressor.rbs +1 -1
- data/sig/mindee/image/image_extractor.rbs +5 -5
- data/sig/mindee/image/image_utils.rbs +10 -10
- data/sig/mindee/input/inference_parameters.rbs +30 -0
- data/sig/mindee/input/local_response.rbs +6 -5
- data/sig/mindee/input/polling_options.rbs +12 -0
- data/sig/mindee/input/sources/base64_input_source.rbs +1 -1
- data/sig/mindee/input/sources/local_input_source.rbs +10 -7
- data/sig/mindee/input/sources/url_input_source.rbs +1 -1
- data/sig/mindee/logging/logger.rbs +2 -0
- data/sig/mindee/page_options.rbs +11 -0
- data/sig/mindee/parsing/common/api_request.rbs +6 -6
- data/sig/mindee/parsing/common/api_response.rbs +2 -2
- data/sig/mindee/parsing/common/document.rbs +10 -10
- data/sig/mindee/parsing/common/execution.rbs +15 -14
- data/sig/mindee/parsing/common/execution_file.rbs +3 -3
- data/sig/mindee/parsing/common/extras/cropper_extra.rbs +3 -2
- data/sig/mindee/parsing/common/extras/extras.rbs +6 -5
- data/sig/mindee/parsing/common/extras/full_text_ocr_extra.rbs +2 -1
- data/sig/mindee/parsing/common/inference.rbs +16 -9
- data/sig/mindee/parsing/common/job.rbs +2 -2
- data/sig/mindee/parsing/common/ocr/mvision_v1.rbs +2 -2
- data/sig/mindee/parsing/common/ocr/ocr.rbs +22 -20
- data/sig/mindee/parsing/common/orientation.rbs +4 -3
- data/sig/mindee/parsing/common/page.rbs +6 -5
- data/sig/mindee/parsing/common/product.rbs +4 -4
- data/sig/mindee/parsing/common/workflow_response.rbs +8 -4
- data/sig/mindee/parsing/standard/abstract_field.rbs +1 -1
- data/sig/mindee/parsing/standard/address_field.rbs +1 -1
- data/sig/mindee/parsing/standard/amount_field.rbs +6 -4
- data/sig/mindee/parsing/standard/base_field.rbs +1 -1
- data/sig/mindee/parsing/standard/boolean_field.rbs +1 -1
- data/sig/mindee/parsing/standard/company_registration_field.rbs +3 -2
- data/sig/mindee/parsing/standard/date_field.rbs +6 -6
- data/sig/mindee/parsing/standard/locale_field.rbs +1 -1
- data/sig/mindee/parsing/standard/payment_details_field.rbs +7 -6
- data/sig/mindee/parsing/standard/position_field.rbs +2 -2
- data/sig/mindee/parsing/standard/string_field.rbs +1 -1
- data/sig/mindee/parsing/standard/tax_field.rbs +8 -7
- data/sig/mindee/parsing/universal/universal_list_field.rbs +4 -5
- data/sig/mindee/parsing/universal/universal_object_field.rbs +17 -11
- data/sig/mindee/parsing/v2/common_response.rbs +11 -0
- data/sig/mindee/parsing/v2/error_response.rbs +16 -0
- data/sig/mindee/parsing/v2/field/base_field.rbs +17 -0
- data/sig/mindee/parsing/v2/field/field_confidence.rbs +27 -0
- data/sig/mindee/parsing/v2/field/field_location.rbs +16 -0
- data/sig/mindee/parsing/v2/field/inference_fields.rbs +19 -0
- data/sig/mindee/parsing/v2/field/list_field.rbs +22 -0
- data/sig/mindee/parsing/v2/field/object_field.rbs +21 -0
- data/sig/mindee/parsing/v2/field/simple_field.rbs +16 -0
- data/sig/mindee/parsing/v2/inference.rbs +16 -0
- data/sig/mindee/parsing/v2/inference_file.rbs +15 -0
- data/sig/mindee/parsing/v2/inference_model.rbs +11 -0
- data/sig/mindee/parsing/v2/inference_response.rbs +12 -0
- data/sig/mindee/parsing/v2/inference_result.rbs +13 -0
- data/sig/mindee/parsing/v2/inference_result_options.rbs +11 -0
- data/sig/mindee/parsing/v2/job.rbs +22 -0
- data/sig/mindee/parsing/v2/job_response.rbs +12 -0
- data/sig/mindee/parsing/v2/job_webhook.rbs +17 -0
- data/sig/mindee/parsing/v2/raw_text.rbs +12 -0
- data/sig/mindee/pdf/extracted_pdf.rbs +6 -6
- data/sig/mindee/pdf/pdf_compressor.rbs +4 -4
- data/sig/mindee/pdf/pdf_extractor.rbs +8 -7
- data/sig/mindee/pdf/pdf_processor.rbs +4 -4
- data/sig/mindee/pdf/pdf_tools.rbs +22 -16
- data/sig/mindee/product/barcode_reader/barcode_reader_v1.rbs +1 -1
- data/sig/mindee/product/barcode_reader/barcode_reader_v1_document.rbs +1 -1
- data/sig/mindee/product/barcode_reader/barcode_reader_v1_page.rbs +2 -2
- data/sig/mindee/product/bill_of_lading/bill_of_lading_v1.rbs +1 -1
- data/sig/mindee/product/bill_of_lading/bill_of_lading_v1_carrier.rbs +2 -2
- data/sig/mindee/product/bill_of_lading/bill_of_lading_v1_carrier_item.rbs +3 -3
- data/sig/mindee/product/bill_of_lading/bill_of_lading_v1_consignee.rbs +2 -2
- data/sig/mindee/product/bill_of_lading/bill_of_lading_v1_document.rbs +1 -1
- data/sig/mindee/product/bill_of_lading/bill_of_lading_v1_notify_party.rbs +2 -2
- data/sig/mindee/product/bill_of_lading/bill_of_lading_v1_page.rbs +2 -2
- data/sig/mindee/product/bill_of_lading/bill_of_lading_v1_shipper.rbs +2 -2
- data/sig/mindee/product/business_card/business_card_v1.rbs +1 -1
- data/sig/mindee/product/business_card/business_card_v1_document.rbs +1 -1
- data/sig/mindee/product/business_card/business_card_v1_page.rbs +2 -2
- data/sig/mindee/product/cropper/cropper_v1.rbs +1 -1
- data/sig/mindee/product/cropper/cropper_v1_document.rbs +1 -1
- data/sig/mindee/product/cropper/cropper_v1_page.rbs +2 -2
- data/sig/mindee/product/delivery_note/delivery_note_v1.rbs +1 -1
- data/sig/mindee/product/delivery_note/delivery_note_v1_document.rbs +1 -1
- data/sig/mindee/product/delivery_note/delivery_note_v1_page.rbs +2 -2
- data/sig/mindee/product/driver_license/driver_license_v1.rbs +1 -1
- data/sig/mindee/product/driver_license/driver_license_v1_document.rbs +1 -1
- data/sig/mindee/product/driver_license/driver_license_v1_page.rbs +2 -2
- data/sig/mindee/product/financial_document/financial_document_v1.rbs +1 -1
- data/sig/mindee/product/financial_document/financial_document_v1_document.rbs +1 -1
- data/sig/mindee/product/financial_document/financial_document_v1_line_item.rbs +3 -3
- data/sig/mindee/product/financial_document/financial_document_v1_page.rbs +2 -2
- data/sig/mindee/product/fr/bank_account_details/bank_account_details_v1.rbs +1 -1
- data/sig/mindee/product/fr/bank_account_details/bank_account_details_v1_document.rbs +1 -1
- data/sig/mindee/product/fr/bank_account_details/bank_account_details_v1_page.rbs +2 -2
- data/sig/mindee/product/fr/bank_account_details/bank_account_details_v2.rbs +1 -1
- data/sig/mindee/product/fr/bank_account_details/bank_account_details_v2_bban.rbs +2 -2
- data/sig/mindee/product/fr/bank_account_details/bank_account_details_v2_document.rbs +1 -1
- data/sig/mindee/product/fr/bank_account_details/bank_account_details_v2_page.rbs +2 -2
- data/sig/mindee/product/fr/bank_statement/bank_statement_v2.rbs +1 -1
- data/sig/mindee/product/fr/bank_statement/bank_statement_v2_document.rbs +1 -1
- data/sig/mindee/product/fr/bank_statement/bank_statement_v2_page.rbs +2 -2
- data/sig/mindee/product/fr/bank_statement/bank_statement_v2_transaction.rbs +3 -3
- data/sig/mindee/product/fr/carte_grise/carte_grise_v1.rbs +1 -1
- data/sig/mindee/product/fr/carte_grise/carte_grise_v1_document.rbs +1 -1
- data/sig/mindee/product/fr/carte_grise/carte_grise_v1_page.rbs +2 -2
- data/sig/mindee/product/fr/energy_bill/energy_bill_v1.rbs +1 -1
- data/sig/mindee/product/fr/energy_bill/energy_bill_v1_document.rbs +1 -1
- data/sig/mindee/product/fr/energy_bill/energy_bill_v1_energy_consumer.rbs +2 -2
- data/sig/mindee/product/fr/energy_bill/energy_bill_v1_energy_supplier.rbs +2 -2
- data/sig/mindee/product/fr/energy_bill/energy_bill_v1_energy_usage.rbs +3 -3
- data/sig/mindee/product/fr/energy_bill/energy_bill_v1_meter_detail.rbs +2 -2
- data/sig/mindee/product/fr/energy_bill/energy_bill_v1_page.rbs +2 -2
- data/sig/mindee/product/fr/energy_bill/energy_bill_v1_subscription.rbs +3 -3
- data/sig/mindee/product/fr/energy_bill/energy_bill_v1_taxes_and_contribution.rbs +3 -3
- data/sig/mindee/product/fr/health_card/health_card_v1.rbs +1 -1
- data/sig/mindee/product/fr/health_card/health_card_v1_document.rbs +1 -1
- data/sig/mindee/product/fr/health_card/health_card_v1_page.rbs +2 -2
- data/sig/mindee/product/fr/id_card/id_card_v1.rbs +1 -1
- data/sig/mindee/product/fr/id_card/id_card_v1_document.rbs +1 -1
- data/sig/mindee/product/fr/id_card/id_card_v1_page.rbs +2 -2
- data/sig/mindee/product/fr/id_card/id_card_v2.rbs +1 -1
- data/sig/mindee/product/fr/id_card/id_card_v2_document.rbs +1 -1
- data/sig/mindee/product/fr/id_card/id_card_v2_page.rbs +2 -2
- data/sig/mindee/product/fr/payslip/payslip_v2.rbs +1 -1
- data/sig/mindee/product/fr/payslip/payslip_v2_bank_account_detail.rbs +2 -2
- data/sig/mindee/product/fr/payslip/payslip_v2_document.rbs +1 -1
- data/sig/mindee/product/fr/payslip/payslip_v2_employee.rbs +2 -2
- data/sig/mindee/product/fr/payslip/payslip_v2_employer.rbs +2 -2
- data/sig/mindee/product/fr/payslip/payslip_v2_employment.rbs +2 -2
- data/sig/mindee/product/fr/payslip/payslip_v2_page.rbs +2 -2
- data/sig/mindee/product/fr/payslip/payslip_v2_pay_detail.rbs +2 -2
- data/sig/mindee/product/fr/payslip/payslip_v2_pay_period.rbs +2 -2
- data/sig/mindee/product/fr/payslip/payslip_v2_pto.rbs +2 -2
- data/sig/mindee/product/fr/payslip/payslip_v2_salary_detail.rbs +3 -3
- data/sig/mindee/product/fr/payslip/payslip_v3.rbs +1 -1
- data/sig/mindee/product/fr/payslip/payslip_v3_bank_account_detail.rbs +2 -2
- data/sig/mindee/product/fr/payslip/payslip_v3_document.rbs +1 -1
- data/sig/mindee/product/fr/payslip/payslip_v3_employee.rbs +2 -2
- data/sig/mindee/product/fr/payslip/payslip_v3_employer.rbs +2 -2
- data/sig/mindee/product/fr/payslip/payslip_v3_employment.rbs +2 -2
- data/sig/mindee/product/fr/payslip/payslip_v3_page.rbs +2 -2
- data/sig/mindee/product/fr/payslip/payslip_v3_paid_time_off.rbs +3 -3
- data/sig/mindee/product/fr/payslip/payslip_v3_pay_detail.rbs +2 -2
- data/sig/mindee/product/fr/payslip/payslip_v3_pay_period.rbs +2 -2
- data/sig/mindee/product/fr/payslip/payslip_v3_salary_detail.rbs +3 -3
- data/sig/mindee/product/ind/indian_passport/indian_passport_v1.rbs +1 -1
- data/sig/mindee/product/ind/indian_passport/indian_passport_v1_document.rbs +1 -1
- data/sig/mindee/product/ind/indian_passport/indian_passport_v1_page.rbs +2 -2
- data/sig/mindee/product/international_id/international_id_v2.rbs +1 -1
- data/sig/mindee/product/international_id/international_id_v2_document.rbs +1 -1
- data/sig/mindee/product/international_id/international_id_v2_page.rbs +2 -2
- data/sig/mindee/product/invoice/invoice_v4.rbs +1 -1
- data/sig/mindee/product/invoice/invoice_v4_document.rbs +1 -1
- data/sig/mindee/product/invoice/invoice_v4_line_item.rbs +3 -3
- data/sig/mindee/product/invoice/invoice_v4_page.rbs +2 -2
- data/sig/mindee/product/invoice_splitter/invoice_splitter_v1.rbs +1 -1
- data/sig/mindee/product/invoice_splitter/invoice_splitter_v1_document.rbs +1 -1
- data/sig/mindee/product/invoice_splitter/invoice_splitter_v1_invoice_page_group.rbs +3 -3
- data/sig/mindee/product/invoice_splitter/invoice_splitter_v1_page.rbs +2 -2
- data/sig/mindee/product/multi_receipts_detector/multi_receipts_detector_v1.rbs +1 -1
- data/sig/mindee/product/multi_receipts_detector/multi_receipts_detector_v1_document.rbs +1 -1
- data/sig/mindee/product/multi_receipts_detector/multi_receipts_detector_v1_page.rbs +2 -2
- data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1.rbs +1 -1
- data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_added_sugar.rbs +2 -2
- data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_calorie.rbs +2 -2
- data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_cholesterol.rbs +2 -2
- data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_dietary_fiber.rbs +2 -2
- data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_document.rbs +1 -1
- data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_nutrient.rbs +3 -3
- data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_page.rbs +2 -2
- data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_protein.rbs +2 -2
- data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_saturated_fat.rbs +2 -2
- data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_serving_size.rbs +2 -2
- data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_sodium.rbs +2 -2
- data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_total_carbohydrate.rbs +2 -2
- data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_total_fat.rbs +2 -2
- data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_total_sugar.rbs +2 -2
- data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_trans_fat.rbs +2 -2
- data/sig/mindee/product/passport/passport_v1.rbs +1 -1
- data/sig/mindee/product/passport/passport_v1_document.rbs +1 -1
- data/sig/mindee/product/passport/passport_v1_page.rbs +2 -2
- data/sig/mindee/product/receipt/receipt_v5.rbs +1 -1
- data/sig/mindee/product/receipt/receipt_v5_document.rbs +1 -1
- data/sig/mindee/product/receipt/receipt_v5_line_item.rbs +3 -3
- data/sig/mindee/product/receipt/receipt_v5_page.rbs +2 -2
- data/sig/mindee/product/resume/resume_v1.rbs +1 -1
- data/sig/mindee/product/resume/resume_v1_certificate.rbs +3 -3
- data/sig/mindee/product/resume/resume_v1_document.rbs +1 -1
- data/sig/mindee/product/resume/resume_v1_education.rbs +3 -3
- data/sig/mindee/product/resume/resume_v1_language.rbs +3 -3
- data/sig/mindee/product/resume/resume_v1_page.rbs +2 -2
- data/sig/mindee/product/resume/resume_v1_professional_experience.rbs +3 -3
- data/sig/mindee/product/resume/resume_v1_social_networks_url.rbs +3 -3
- data/sig/mindee/product/universal/universal.rbs +5 -5
- data/sig/mindee/product/universal/universal_document.rbs +1 -1
- data/sig/mindee/product/universal/universal_page.rbs +2 -2
- data/sig/mindee/product/universal/universal_prediction.rbs +5 -5
- data/sig/mindee/product/us/bank_check/bank_check_v1.rbs +1 -1
- data/sig/mindee/product/us/bank_check/bank_check_v1_document.rbs +1 -1
- data/sig/mindee/product/us/bank_check/bank_check_v1_page.rbs +2 -2
- data/sig/mindee/product/us/healthcare_card/healthcare_card_v1.rbs +1 -1
- data/sig/mindee/product/us/healthcare_card/healthcare_card_v1_copay.rbs +3 -3
- data/sig/mindee/product/us/healthcare_card/healthcare_card_v1_document.rbs +1 -1
- data/sig/mindee/product/us/healthcare_card/healthcare_card_v1_page.rbs +2 -2
- data/sig/mindee/product/us/us_mail/us_mail_v2.rbs +1 -1
- data/sig/mindee/product/us/us_mail/us_mail_v2_document.rbs +1 -1
- data/sig/mindee/product/us/us_mail/us_mail_v2_page.rbs +2 -2
- data/sig/mindee/product/us/us_mail/us_mail_v2_recipient_address.rbs +3 -3
- data/sig/mindee/product/us/us_mail/us_mail_v2_sender_address.rbs +2 -2
- data/sig/mindee/product/us/us_mail/us_mail_v3.rbs +1 -1
- data/sig/mindee/product/us/us_mail/us_mail_v3_document.rbs +1 -1
- data/sig/mindee/product/us/us_mail/us_mail_v3_page.rbs +2 -2
- data/sig/mindee/product/us/us_mail/us_mail_v3_recipient_address.rbs +3 -3
- data/sig/mindee/product/us/us_mail/us_mail_v3_sender_address.rbs +2 -2
- data/sig/mindee/product/us/w9/w9_v1.rbs +1 -1
- data/sig/mindee/product/us/w9/w9_v1_document.rbs +1 -1
- data/sig/mindee/product/us/w9/w9_v1_page.rbs +2 -2
- data/sig/mindee/version.rbs +2 -2
- metadata +61 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c88f4c2b47bf3a97cd519d1c658f12a874ed930c8e86d5ff208c0c44d4174cca
|
4
|
+
data.tar.gz: 191850ef611da7ca60fac4827f6c530348adf2d07d4a7790dd46a6abb335e906
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cbf412b01eb4c6a324f6548232ce24e7ed0bd6f20b12d3803a47218e971805b77c32989e644077809aaf3ec404946461deaf4e440385812228ece7d8d839d6b6
|
7
|
+
data.tar.gz: 381aebed32ebee1cbd763f361c46bf76eff8fd6592f1d9652ccb79ca5515a804e20c8a36459c56af189e5af883ec9b02c2f69a921dde46d15ad6bb1b7224267d
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# Mindee Ruby API Library Changelog
|
2
2
|
|
3
|
+
## v4.7.0-rc1 - 2025-08-13
|
4
|
+
### Changes
|
5
|
+
* :sparkles: add support for client V2 & associated features
|
6
|
+
|
7
|
+
### Fixes
|
8
|
+
* :recycle: add many missing internal types
|
9
|
+
* :bug: fix invalid types for many V1 features
|
10
|
+
* :bug: fix V1 errors sometimes having the wrong code
|
11
|
+
* :bug: fix many presumably immutable fields having non-readonly parameters
|
12
|
+
* :bug: fix broken `resources` accessor in `ApiRequest` object
|
13
|
+
|
14
|
+
|
3
15
|
## v4.6.0 - 2025-06-03
|
4
16
|
### Changes
|
5
17
|
* :sparkles: add support for address fields
|
data/README.md
CHANGED
@@ -4,240 +4,39 @@
|
|
4
4
|
|
5
5
|
Quickly and easily connect to Mindee's API services using Ruby.
|
6
6
|
|
7
|
-
##
|
7
|
+
## Mindee API Versions
|
8
|
+
This client library has support for both Mindee platform versions.
|
8
9
|
|
9
|
-
|
10
|
+
### Latest - V2
|
11
|
+
This is the new platform located here:
|
10
12
|
|
11
|
-
|
13
|
+
https://app.mindee.com
|
12
14
|
|
13
|
-
|
15
|
+
It uses **API version 2**.
|
14
16
|
|
15
|
-
|
17
|
+
Consult the
|
18
|
+
**[Latest Documentation](https://docs.mindee.com/integrations/client-libraries-sdk)**
|
16
19
|
|
17
|
-
Install by adding this line to your application's Gemfile:
|
18
20
|
|
19
|
-
|
20
|
-
|
21
|
-
```
|
21
|
+
### Legacy - V1
|
22
|
+
This is the legacy platform located here:
|
22
23
|
|
23
|
-
|
24
|
+
https://platform.mindee.com/
|
24
25
|
|
25
|
-
|
26
|
-
bundle install
|
27
|
-
```
|
26
|
+
It uses **API version 1**.
|
28
27
|
|
29
|
-
|
28
|
+
Consult the
|
29
|
+
**[Legacy Documentation](https://developers.mindee.com/docs/ruby-getting-started)**
|
30
30
|
|
31
|
-
|
31
|
+
## Additional Information
|
32
32
|
|
33
|
-
|
34
|
-
rely on them, it's crucial to exercise caution when modifying them to avoid unintended consequences.
|
33
|
+
**[Source Code](https://github.com/mindee/mindee-api-ruby)**
|
35
34
|
|
36
|
-
|
37
|
-
specific reason. Accidentally overwriting them can lead to unexpected behavior.
|
35
|
+
**[Reference Documentation](https://mindee.github.io/mindee-api-ruby/)**
|
38
36
|
|
39
|
-
|
40
|
-
impact of each environment variable:
|
37
|
+
**[Feedback](https://feedback.mindee.com/)**
|
41
38
|
|
42
|
-
|
43
|
-
|
44
|
-
* **Default Value**: `nil`
|
45
|
-
* `MINDEE_BASE_URL`:
|
46
|
-
* **Description**: The default base URL of the API endpoint. Use this variable to specify the root URL for API requests. Modify as needed for proxy configurations or changes in API endpoint location.
|
47
|
-
* **Default Value**: `https://api.mindee.net/v1`
|
48
|
-
* `MINDEE_REQUEST_TIMEOUT`:
|
49
|
-
* **Description**: The default timeout for HTTP requests (in seconds).
|
50
|
-
* **Default Value**: `120`
|
51
|
-
* `MINDEE_LOG_LEVEL`:
|
52
|
-
* **Description**: The default logging level for the mindee logger.
|
53
|
-
* **Default Value**: `WARN`
|
39
|
+
### License
|
40
|
+
Copyright © Mindee
|
54
41
|
|
55
|
-
|
56
|
-
|
57
|
-
#### Global Documents
|
58
|
-
|
59
|
-
```ruby
|
60
|
-
require 'mindee'
|
61
|
-
|
62
|
-
# Init a new client
|
63
|
-
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
|
64
|
-
|
65
|
-
# Load a file from disk
|
66
|
-
input_source = mindee_client.source_from_path('/path/to/the/file.ext')
|
67
|
-
result = mindee_client.parse(
|
68
|
-
input_source,
|
69
|
-
Mindee::Product::Invoice::InvoiceV4
|
70
|
-
)
|
71
|
-
|
72
|
-
# Print a full summary of the parsed data in RST format
|
73
|
-
puts result.document
|
74
|
-
```
|
75
|
-
|
76
|
-
**Note:** Files can also be loaded from:
|
77
|
-
|
78
|
-
A URL (`https`):
|
79
|
-
|
80
|
-
```rb
|
81
|
-
input_source = mindee_client.source_from_url("https://my-url")
|
82
|
-
```
|
83
|
-
|
84
|
-
A bytes input stream:
|
85
|
-
|
86
|
-
```rb
|
87
|
-
input_source = mindee_client.source_from_bytes('/path/to/the/file.ext', "name-of-my-file.ext")
|
88
|
-
```
|
89
|
-
|
90
|
-
A base64 encoded string:
|
91
|
-
|
92
|
-
```rb
|
93
|
-
input_source = mindee_client.source_from_b64string('/path/to/the/file.ext', "name-of-my-file.ext")
|
94
|
-
```
|
95
|
-
|
96
|
-
A ruby `file` object:
|
97
|
-
|
98
|
-
```rb
|
99
|
-
input_source = mindee_client.source_from_file(input_file, "name-of-my-file.ext")
|
100
|
-
```
|
101
|
-
|
102
|
-
#### Region-Specific Documents
|
103
|
-
|
104
|
-
```ruby
|
105
|
-
require 'mindee'
|
106
|
-
|
107
|
-
# Init a new client
|
108
|
-
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
|
109
|
-
|
110
|
-
# Load a file from disk
|
111
|
-
input_source = mindee_client.source_from_path('/path/to/the/file.ext')
|
112
|
-
|
113
|
-
result = mindee_client.parse(
|
114
|
-
input_source,
|
115
|
-
Mindee::Product::EU::LicensePlate::LicensePlateV1
|
116
|
-
)
|
117
|
-
|
118
|
-
# Print a full summary of the parsed data in RST format
|
119
|
-
puts result.document
|
120
|
-
```
|
121
|
-
|
122
|
-
### Universal - All Other Documents
|
123
|
-
|
124
|
-
The Universal product acts as a catch-all for every and any API if it doesn't have an assigned product name.
|
125
|
-
|
126
|
-
```ruby
|
127
|
-
require 'mindee'
|
128
|
-
|
129
|
-
# Init a new client and configure your custom document
|
130
|
-
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
|
131
|
-
endpoint = mindee_client.create_endpoint(
|
132
|
-
endpoint_name: 'my-endpoint',
|
133
|
-
account_name: 'my-account'
|
134
|
-
)
|
135
|
-
|
136
|
-
# Load a file from disk
|
137
|
-
input_source = mindee_client.source_from_path('/path/to/the/file.ext')
|
138
|
-
|
139
|
-
result = mindee_client.parse(
|
140
|
-
input_source,
|
141
|
-
Mindee::Product::Universal::Universal,
|
142
|
-
endpoint: endpoint
|
143
|
-
)
|
144
|
-
|
145
|
-
# Print a full summary of the parsed data in RST format
|
146
|
-
puts result.document
|
147
|
-
|
148
|
-
# Looping over all prediction values
|
149
|
-
result.document.inference.prediction.fields.each do |field_name, field_data|
|
150
|
-
puts field_name
|
151
|
-
puts field_data.values
|
152
|
-
puts field_data.to_s
|
153
|
-
end
|
154
|
-
```
|
155
|
-
|
156
|
-
|
157
|
-
## Enqueueing and Parse a Webhook Response
|
158
|
-
|
159
|
-
This is an optional way of handling asynchronous APIs.
|
160
|
-
|
161
|
-
```rb
|
162
|
-
require 'mindee'
|
163
|
-
|
164
|
-
# Init a new client
|
165
|
-
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
|
166
|
-
|
167
|
-
# Load a file from disk
|
168
|
-
input_source = mindee_client.source_from_path('/path/to/the/file.ext')
|
169
|
-
|
170
|
-
|
171
|
-
# Send the file to the server
|
172
|
-
enqueue_response = mindee_client.enqueue(
|
173
|
-
input_source,
|
174
|
-
Mindee::Product::InternationalId::InternationalIdV2
|
175
|
-
)
|
176
|
-
|
177
|
-
job_id = enqueue_response.job.id
|
178
|
-
|
179
|
-
# Load the JSON string sent by the Mindee webhook POST callback.
|
180
|
-
# Reading the callback data will vary greatly depending on your HTTP server.
|
181
|
-
# This is therefore beyond the scope of this example.
|
182
|
-
|
183
|
-
local_response = Mindee::Input::LocalResponse.new(request.body.string)
|
184
|
-
|
185
|
-
# You can also use a File object as the input.
|
186
|
-
# FILE_PATH = File.join('path', 'to', 'file.json').freeze
|
187
|
-
# local_response = Mindee::Input::LocalResponse.new(FILE_PATH);
|
188
|
-
|
189
|
-
# Optional: verify the HMAC signature.
|
190
|
-
unless local_response.valid_hmac_signature?(my_secret_key, 'invalid signature')
|
191
|
-
raise "Invalid HMAC signature!"
|
192
|
-
end
|
193
|
-
|
194
|
-
|
195
|
-
# Deserialize the response:
|
196
|
-
result = mindee_client.load_prediction(
|
197
|
-
Mindee::Product::InternationalId::InternationalIdV2,
|
198
|
-
local_response
|
199
|
-
)
|
200
|
-
|
201
|
-
# Print a full summary of the parsed data in RST format
|
202
|
-
puts result.document
|
203
|
-
```
|
204
|
-
|
205
|
-
|
206
|
-
## CLI Tool
|
207
|
-
|
208
|
-
A command-line interface tool is available to quickly test documents:
|
209
|
-
|
210
|
-
```sh
|
211
|
-
ruby ./bin/mindee.rb <product_name> path/to/your/file.ext
|
212
|
-
```
|
213
|
-
|
214
|
-
Using the ruby bundler:
|
215
|
-
|
216
|
-
```sh
|
217
|
-
bundle exec ruby ./bin/mindee.rb <product_name> path/to/your/file.ext
|
218
|
-
```
|
219
|
-
|
220
|
-
Where possible values for `<product_name>` can be displayed by running the command with no arguments.
|
221
|
-
|
222
|
-
## Further Reading
|
223
|
-
|
224
|
-
There's more to it than that for those that need more features, or want to
|
225
|
-
customize the experience.
|
226
|
-
|
227
|
-
* [Ruby Overview](https://developers.mindee.com/docs/ruby-getting-started)
|
228
|
-
* [Common file operations](https://developers.mindee.com/docs/ruby-common-file-operations)
|
229
|
-
* [Global products](https://developers.mindee.com/docs/ruby-global-products)
|
230
|
-
* [Localized products](https://developers.mindee.com/docs/ruby-localized-products)
|
231
|
-
|
232
|
-
You can also take a look at the
|
233
|
-
[Reference Documentation](https://mindee.github.io/mindee-api-ruby/).
|
234
|
-
|
235
|
-
## License
|
236
|
-
|
237
|
-
Copyright © Mindee, SA
|
238
|
-
|
239
|
-
Available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
240
|
-
|
241
|
-
## Questions?
|
242
|
-
|
243
|
-
[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g)
|
42
|
+
Available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'mindee'
|
2
|
+
|
3
|
+
input_path = '/path/to/the/file.ext'
|
4
|
+
api_key = 'MY_API_KEY'
|
5
|
+
model_id = 'MY_MODEL_ID'
|
6
|
+
|
7
|
+
# Init a new client
|
8
|
+
mindee_client = Mindee::ClientV2.new(api_key: api_key)
|
9
|
+
|
10
|
+
# Set inference parameters
|
11
|
+
params = Mindee::Input::InferenceParameters.new(
|
12
|
+
# ID of the model, required.
|
13
|
+
model_id,
|
14
|
+
# If set to `True`, will enable Retrieval-Augmented Generation.
|
15
|
+
rag: false,
|
16
|
+
)
|
17
|
+
|
18
|
+
# Load a file from disk
|
19
|
+
input_source = Mindee::Input::Source::PathInputSource.new(input_path)
|
20
|
+
|
21
|
+
# Send for processing
|
22
|
+
response = mindee_client.enqueue_and_get_inference(
|
23
|
+
input_source,
|
24
|
+
params # Note: this parameter can also be provided as a Hash.
|
25
|
+
)
|
26
|
+
|
27
|
+
# Print a brief summary of the parsed data
|
28
|
+
puts response.inference
|
data/lib/mindee/client.rb
CHANGED
@@ -2,38 +2,17 @@
|
|
2
2
|
|
3
3
|
require_relative 'input'
|
4
4
|
require_relative 'http'
|
5
|
-
require_relative '
|
5
|
+
require_relative 'logging'
|
6
|
+
require_relative 'page_options'
|
6
7
|
require_relative 'parsing/common/api_response'
|
7
8
|
require_relative 'parsing/common/job'
|
8
9
|
require_relative 'parsing/common/workflow_response'
|
9
|
-
require_relative '
|
10
|
+
require_relative 'product'
|
10
11
|
|
11
12
|
# Default owner for products.
|
12
13
|
OTS_OWNER = 'mindee'
|
13
14
|
|
14
15
|
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
16
|
# Class for configuration options in parse calls.
|
38
17
|
#
|
39
18
|
# @!attribute all_words [bool] Whether to include the full text for each page.
|
@@ -89,8 +68,9 @@ module Mindee
|
|
89
68
|
# * `:KEEP_ONLY` - keep only the specified pages, and remove all others.
|
90
69
|
# * `:REMOVE` - remove the specified pages, and keep all others.
|
91
70
|
# * `:on_min_pages` Apply the operation only if the document has at least this many pages.
|
71
|
+
# @!attribute close_file [bool, nil] Whether to close the file after sending it. Defaults to true.
|
92
72
|
class WorkflowOptions
|
93
|
-
attr_accessor :document_alias, :priority, :full_text, :public_url, :page_options, :rag
|
73
|
+
attr_accessor :document_alias, :priority, :full_text, :public_url, :page_options, :rag, :close_file
|
94
74
|
|
95
75
|
def initialize(params: {})
|
96
76
|
params = params.transform_keys(&:to_sym)
|
@@ -102,6 +82,7 @@ module Mindee
|
|
102
82
|
raw_page_options = params.fetch(:page_options, nil)
|
103
83
|
raw_page_options = PageOptions.new(params: raw_page_options) unless raw_page_options.is_a?(PageOptions)
|
104
84
|
@page_options = raw_page_options
|
85
|
+
@close_file = params.fetch(:close_file, true)
|
105
86
|
end
|
106
87
|
end
|
107
88
|
|
@@ -326,7 +307,7 @@ module Mindee
|
|
326
307
|
process_pdf_if_required(input_source, opts)
|
327
308
|
end
|
328
309
|
|
329
|
-
workflow_endpoint = Mindee::HTTP::WorkflowEndpoint.new(workflow_id, api_key: @api_key)
|
310
|
+
workflow_endpoint = Mindee::HTTP::WorkflowEndpoint.new(workflow_id, api_key: @api_key.to_s)
|
330
311
|
logger.debug("Sending document to workflow '#{workflow_id}'")
|
331
312
|
|
332
313
|
prediction, raw_http = workflow_endpoint.execute_workflow(
|
@@ -455,11 +436,11 @@ module Mindee
|
|
455
436
|
account_name = fix_account_name(account_name)
|
456
437
|
version = fix_version(product_class, version)
|
457
438
|
|
458
|
-
HTTP::Endpoint.new(account_name, endpoint_name, version, api_key: @api_key)
|
439
|
+
HTTP::Endpoint.new(account_name, endpoint_name, version, api_key: @api_key.to_s)
|
459
440
|
end
|
460
441
|
|
461
442
|
def fix_endpoint_name(product_class, endpoint_name)
|
462
|
-
endpoint_name.nil? || endpoint_name.empty? ? product_class.endpoint_name : endpoint_name
|
443
|
+
endpoint_name.nil? || endpoint_name.empty? ? product_class.endpoint_name.to_s : endpoint_name.to_s
|
463
444
|
end
|
464
445
|
|
465
446
|
def fix_account_name(account_name)
|
@@ -474,11 +455,11 @@ module Mindee
|
|
474
455
|
def fix_version(product_class, version)
|
475
456
|
return version unless version.nil? || version.empty?
|
476
457
|
|
477
|
-
if product_class.endpoint_version.nil? || product_class.endpoint_version.empty?
|
458
|
+
if product_class.endpoint_version.nil? || product_class.endpoint_version.to_s.empty?
|
478
459
|
logger.debug('No version provided for a custom build, will attempt to poll version 1 by default.')
|
479
460
|
return '1'
|
480
461
|
end
|
481
|
-
product_class.endpoint_version
|
462
|
+
product_class.endpoint_version || ''
|
482
463
|
end
|
483
464
|
|
484
465
|
# If needed, converts the parsing options provided as a hash into a proper ParseOptions object.
|
@@ -0,0 +1,109 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'input'
|
4
|
+
require_relative 'http'
|
5
|
+
require_relative 'product'
|
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
|
+
module Mindee
|
12
|
+
# Mindee V2 API Client.
|
13
|
+
class ClientV2
|
14
|
+
# @return [HTTP::MindeeApiV2]
|
15
|
+
private attr_reader :mindee_api
|
16
|
+
|
17
|
+
# @param api_key [String]
|
18
|
+
def initialize(api_key: '')
|
19
|
+
@mindee_api = Mindee::HTTP::MindeeApiV2.new(api_key: api_key)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Retrieves an inference.
|
23
|
+
# @param inference_id [String]
|
24
|
+
# @return [Mindee::Parsing::V2::InferenceResponse]
|
25
|
+
def get_inference(inference_id)
|
26
|
+
@mindee_api.req_get_inference(inference_id)
|
27
|
+
end
|
28
|
+
|
29
|
+
# Retrieves an inference.
|
30
|
+
# @param job_id [String]
|
31
|
+
# @return [Mindee::Parsing::V2::JobResponse]
|
32
|
+
def get_job(job_id)
|
33
|
+
@mindee_api.req_get_job(job_id)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Enqueue a document for async parsing.
|
37
|
+
# @param input_source [Mindee::Input::Source::LocalInputSource, Mindee::Input::Source::URLInputSource]
|
38
|
+
# The source of the input document (local file or URL).
|
39
|
+
# @param params [Hash, InferenceParameters]
|
40
|
+
# @return [Mindee::Parsing::V2::JobResponse]
|
41
|
+
def enqueue_inference(input_source, params)
|
42
|
+
normalized_params = normalize_inference_parameters(params)
|
43
|
+
logger.debug("Enqueueing document to model '#{normalized_params.model_id}'.")
|
44
|
+
|
45
|
+
@mindee_api.req_post_inference_enqueue(input_source, normalized_params)
|
46
|
+
end
|
47
|
+
|
48
|
+
# Enqueue a document for async parsing and automatically try to retrieve it.
|
49
|
+
# @param input_source [Mindee::Input::Source::LocalInputSource, Mindee::Input::Source::URLInputSource]
|
50
|
+
# The source of the input document (local file or URL).
|
51
|
+
# @param params [Hash, InferenceParameters] Parameters for the inference.
|
52
|
+
# @return [Mindee::Parsing::V2::InferenceResponse]
|
53
|
+
def enqueue_and_get_inference(input_source, params)
|
54
|
+
normalized_params = normalize_inference_parameters(params)
|
55
|
+
normalized_params.validate_async_params
|
56
|
+
enqueue_response = enqueue_inference(input_source, normalized_params)
|
57
|
+
|
58
|
+
if enqueue_response.job.id.nil? || enqueue_response.job.id.empty?
|
59
|
+
logger.error("Failed enqueueing:\n#{enqueue_response.raw_http}")
|
60
|
+
raise Mindee::Errors::MindeeError, 'Enqueueing of the document failed.'
|
61
|
+
end
|
62
|
+
|
63
|
+
job_id = enqueue_response.job.id
|
64
|
+
logger.debug("Successfully enqueued document with job id: #{job_id}.")
|
65
|
+
|
66
|
+
sleep(normalized_params.polling_options.initial_delay_sec)
|
67
|
+
retry_counter = 1
|
68
|
+
poll_results = get_job(job_id)
|
69
|
+
|
70
|
+
while retry_counter < normalized_params.polling_options.max_retries
|
71
|
+
if poll_results.job.status == 'Failed'
|
72
|
+
break
|
73
|
+
elsif poll_results.job.status == 'Processed'
|
74
|
+
return get_inference(poll_results.job.id)
|
75
|
+
end
|
76
|
+
|
77
|
+
logger.debug(
|
78
|
+
"Successfully enqueued inference with job id: #{job_id}.\n" \
|
79
|
+
"Attempt n°#{retry_counter}/#{normalized_params.polling_options.max_retries}.\n" \
|
80
|
+
"Job status: #{poll_results.job.status}."
|
81
|
+
)
|
82
|
+
|
83
|
+
sleep(normalized_params.polling_options.delay_sec)
|
84
|
+
poll_results = get_job(job_id)
|
85
|
+
retry_counter += 1
|
86
|
+
end
|
87
|
+
|
88
|
+
error = poll_results.job.error
|
89
|
+
unless error.nil?
|
90
|
+
err_to_raise = Mindee::Errors::MindeeHTTPErrorV2.new(error)
|
91
|
+
# NOTE: purposefully decoupled from the line above, otherwise rubocop thinks `error` is a `message` param.
|
92
|
+
raise err_to_raise
|
93
|
+
end
|
94
|
+
|
95
|
+
sec_count = normalized_params.polling_options.delay_sec * retry_counter
|
96
|
+
raise Mindee::Errors::MindeeError,
|
97
|
+
"Asynchronous parsing request timed out after #{sec_count} seconds"
|
98
|
+
end
|
99
|
+
|
100
|
+
# If needed, converts the parsing options provided as a hash into a proper InferenceParameters object.
|
101
|
+
# @param params [Hash, InferenceParameters] Params.
|
102
|
+
# @return [InferenceParameters]
|
103
|
+
def normalize_inference_parameters(params)
|
104
|
+
return params if params.is_a?(Input::InferenceParameters)
|
105
|
+
|
106
|
+
Input::InferenceParameters.from_hash(params: params)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'mindee_error'
|
4
|
+
|
5
|
+
module Mindee
|
6
|
+
module Errors
|
7
|
+
# API V2 HttpError
|
8
|
+
class MindeeHTTPErrorV2 < MindeeError
|
9
|
+
# @return [Integer]
|
10
|
+
attr_reader :status
|
11
|
+
# @return [String]
|
12
|
+
attr_reader :detail
|
13
|
+
|
14
|
+
# @param http_error [Hash, Parsing::V2::ErrorResponse]
|
15
|
+
def initialize(http_error)
|
16
|
+
if http_error.is_a?(Parsing::V2::ErrorResponse)
|
17
|
+
http_error = { 'detail' => http_error.detail,
|
18
|
+
'status' => http_error.status }
|
19
|
+
end
|
20
|
+
@status = http_error['status']
|
21
|
+
@detail = http_error['detail']
|
22
|
+
super("HTTP error: #{@status} - #{@detail}")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/mindee/errors.rb
CHANGED
@@ -6,13 +6,13 @@ module Mindee
|
|
6
6
|
# Contains exactly 4 relative vertices coordinates (Points).
|
7
7
|
class Quadrilateral
|
8
8
|
# @return [Mindee::Geometry::Point]
|
9
|
-
|
9
|
+
attr_reader :top_left
|
10
10
|
# @return [Mindee::Geometry::Point]
|
11
|
-
|
11
|
+
attr_reader :top_right
|
12
12
|
# @return [Mindee::Geometry::Point]
|
13
|
-
|
13
|
+
attr_reader :bottom_right
|
14
14
|
# @return [Mindee::Geometry::Point]
|
15
|
-
|
15
|
+
attr_reader :bottom_left
|
16
16
|
|
17
17
|
# @param top_left [Mindee::Geometry::Point]
|
18
18
|
# @param top_right [Mindee::Geometry::Point]
|
@@ -83,6 +83,7 @@ module Mindee
|
|
83
83
|
# @param anchor [Array<Mindee::Geometry::Point] Reference polygon
|
84
84
|
# @param margin_left [Float] Margin tolerance on the left of the anchor
|
85
85
|
# @param margin_right [Float] Margin tolerance on the right of the anchor
|
86
|
+
# @return bool
|
86
87
|
def self.below?(candidate, anchor, margin_left, margin_right)
|
87
88
|
return false if Geometry.get_min_max_y(candidate).min < Geometry.get_min_max_y(anchor).min
|
88
89
|
if Geometry.get_min_max_x(candidate).min <
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Mindee
|
4
|
+
module HTTP
|
5
|
+
# API client for version 2.
|
6
|
+
class ApiSettingsV2
|
7
|
+
# V2 API key's default environment key name.
|
8
|
+
MINDEE_V2_API_KEY_ENV_NAME = 'MINDEE_V2_API_KEY'
|
9
|
+
# V2 API key's default value.
|
10
|
+
MINDEE_V2_API_KEY_DEFAULT = nil
|
11
|
+
|
12
|
+
# V2 base URL default environment key name.
|
13
|
+
MINDEE_V2_BASE_URL_ENV_NAME = 'MINDEE_V2_BASE_URL'
|
14
|
+
# V2 base URL default value.
|
15
|
+
MINDEE_V2_BASE_URL_DEFAULT = 'https://api-v2.mindee.net/v2'
|
16
|
+
|
17
|
+
# HTTP request timeout default environment key name.
|
18
|
+
MINDEE_V2_REQUEST_TIMEOUT_ENV_NAME = 'MINDEE_V2_REQUEST_TIMEOUT'
|
19
|
+
# HTTP request timeout default value.
|
20
|
+
MINDEE_V2_TIMEOUT_DEFAULT = 120
|
21
|
+
|
22
|
+
# Default value for the user agent (same as V1).
|
23
|
+
USER_AGENT = "mindee-api-ruby@v#{Mindee::VERSION} ruby-v#{RUBY_VERSION} #{Mindee::PLATFORM}".freeze
|
24
|
+
|
25
|
+
# @return [String]
|
26
|
+
attr_reader :api_key
|
27
|
+
# @return [Integer]
|
28
|
+
attr_reader :request_timeout
|
29
|
+
# @return [String]
|
30
|
+
attr_reader :base_url
|
31
|
+
# @return [String]
|
32
|
+
attr_reader :user_agent
|
33
|
+
|
34
|
+
def initialize(api_key: nil)
|
35
|
+
@request_timeout = ENV.fetch(MINDEE_V2_REQUEST_TIMEOUT_ENV_NAME, MINDEE_V2_TIMEOUT_DEFAULT).to_i
|
36
|
+
if api_key.nil? && !ENV.fetch(MINDEE_V2_API_KEY_ENV_NAME, MINDEE_V2_API_KEY_DEFAULT).to_s.empty?
|
37
|
+
logger.debug('API key set from environment')
|
38
|
+
end
|
39
|
+
@api_key = if api_key.nil? || api_key.empty?
|
40
|
+
ENV.fetch(MINDEE_V2_API_KEY_ENV_NAME,
|
41
|
+
MINDEE_V2_API_KEY_DEFAULT)
|
42
|
+
else
|
43
|
+
api_key
|
44
|
+
end
|
45
|
+
@base_url = ENV.fetch(MINDEE_V2_BASE_URL_ENV_NAME, MINDEE_V2_BASE_URL_DEFAULT).chomp('/')
|
46
|
+
@user_agent = USER_AGENT
|
47
|
+
end
|
48
|
+
|
49
|
+
# Checks API key for a value.
|
50
|
+
# @return
|
51
|
+
# @raise [Errors::MindeeAPIError] Raises if the api key is empty or nil.
|
52
|
+
def check_api_key
|
53
|
+
return unless @api_key.nil? || @api_key.to_s.empty?
|
54
|
+
|
55
|
+
raise Errors::MindeeAPIError,
|
56
|
+
"Missing API key. check your Client Configuration.\nYou can set this using the " \
|
57
|
+
"'#{MINDEE_V2_API_KEY_ENV_NAME}' environment variable."
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|